Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/org.eclipse.cdt.core.tests')
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/cdescriptor/tests/CDescriptorOldTests.java73
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/cdescriptor/tests/CDescriptorTests.java75
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/envvar/IEnvironmentVariableManagerTests.java142
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/efsextension/tests/EFSExtensionProviderTestsProvider.java4
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/efsextension/tests/EFSExtensionTests.java132
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserEfsFileMatchingTest.java127
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserFileMatchingTest.java605
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserManagerTest.java71
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserTests.java25
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/FileBasedErrorParserTests.java4
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GCCErrorParserTests.java237
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GLDErrorParserTests.java102
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GenericErrorParserTests.java44
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/MakeErrorParserTests.java78
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/RegexErrorParserTests.java163
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/index/provider/test/AbstractDummyProvider.java7
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/index/provider/test/DummyProviderTraces.java29
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/index/provider/test/Providers.java24
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/PositionTrackerTests.java662
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/ResourceLookupTests.java151
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/StringBuilderTest.java67
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryEFSExtensionProvider.java4
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryFileStore.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryFileSystem.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryTree.java7
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/Policy.java7
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/preferences/tests/TestScopeOfBuildConfigResourceChangesPreference.java6
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java320
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/TestExclusion.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/TestExclusionFactory.java4
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/winreg/tests/WinRegTests.java5
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/ByteUtilsTest.java272
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/CdtVariableResolverTest.java136
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/CommandLineUtilTest.java36
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/FindProgramLocationTest.java10
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/StorableCdtVariablesTest.java26
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/UNCPathConverterTest.java7
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/WeakHashSetTest.java9
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/elf/ElfParserTest.java6
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/AllLanguageTests.java4
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/LanguageInheritanceTests.java66
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsExtensionsTests.java83
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsListenersTests.java346
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManagerTests.java209
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java405
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java78
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java110
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProviderTests.java236
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockLanguageSettingsEditableProvider.java4
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockLanguageSettingsProvider.java3
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockListenerRegisterer.java11
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ASTCacheTests.java113
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllCoreTests.java40
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllLanguageInterfaceTests.java12
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ArchiveTests.java330
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AsmModelBuilderTest.java75
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/BinaryTests.java728
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/Bug311189.java7
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderBugsTest.java32
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderInactiveCodeTest.java24
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java282
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelExceptionTest.java128
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelIdentifierTests.java47
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java1018
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CPathEntryTest.java68
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/DeclaratorsTests.java153
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ElementDeltaTests.java160
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/FlagTests.java359
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IIncludeTests.java37
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IMacroTests.java59
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IStructureTests.java189
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ITemplateTests.java353
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IntegratedCModelTest.java20
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/MacroTests.java60
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralCModelElementsTests.java272
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralMacroTests.java11
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralStructureTests.java59
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralTemplateTests.java195
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitBaseTest.java240
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitTests.java79
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/WorkingCopyTests.java66
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/AllCProjectDescriptionTests.java18
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/BackwardCompatibilityTests.java209
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionExportSettings.java141
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionReferenceTests.java141
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionBasicTests.java126
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java148
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionStorageTests.java40
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CfgSettingsTests.java42
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java154
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/PathSettingsContainerTests.java52
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ProjectCreationStateTests.java113
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestCfgDataProvider.java32
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestExtSettingsProvider.java131
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestUserAndDiscoveredEntriesCfgDataProvider.java19
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ASTComparer.java105
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ArrayUtilTest.java162
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/AutomatedFramework.java153
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CharArrayObjectMapTest.java11
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CharArrayUtilsTest.java17
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ContentAssistMatcherFactoryTest.java9
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FileBasePluginTestCase.java124
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ObjectMapTest.java154
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserTestSuite.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/SegmentMatcherTest.java35
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/XMLDumper.java61
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java12
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPImplicitNameTests.java50
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java367
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTestBase.java6
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java1937
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java184
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTestCase.java126
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java1204
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java1606
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTestBase.java130
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecTestBase.java167
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java1072
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java426
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java3129
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilOldTests.java671
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java242
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTCPPSpecDefectTests.java22
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTInactiveCodeTests.java155
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTNodeSelectorTest.java428
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AccessControlTests.java24
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CharArrayMapTest.java139
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java76
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java2595
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMFileBasePluginTest.java191
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCParserExtensionTestSuite.java12
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCSelectionParseExtensionsTest.java13
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationMacroTests.java872
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java1374
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java117
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSearchUtil.java217
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTest.java892
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTestBase.java25
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/FaultToleranceTests.java412
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java468
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCTests.java1557
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ImageLocationTests.java98
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/LanguageExtensionsTest.java276
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java2929
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticTestBase.java566
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticsTests.java39
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TaskParserTest.java48
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TestLexerLog.java12
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TypeTraitsTests.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/VariableReadWriteFlagsTest.java11
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/GenericLambdaIndexTests.java16
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/GenericLambdaTests.java6
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/InitCaptureTests.java26
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/ReturnTypeDeductionIndexTests.java8
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/ReturnTypeDeductionTests.java62
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/VariableTemplateTests.java22
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/AllConstexprEvalTests.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ArrayTests.java78
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryExpressionTests.java32
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryOperatorOverloadingTests.java52
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/CStringValueTests.java46
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ClassTemplateTests.java48
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ConstructorTests.java175
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/DoWhileStatementTests.java42
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FloatingPointValueTests.java56
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ForStatementTests.java74
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTemplateTests.java114
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTests.java100
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IfStatementTests.java92
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IntegralValueTests.java122
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberFunctionTests.java66
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberVariableTests.java88
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/PointerTests.java136
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/RangeBasedForStatementTests.java96
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ReferenceTests.java38
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/SwitchStatementTests.java71
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TestBase.java10
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TypeAliasTests.java30
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryExpressionTests.java94
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryOperatorOverloadingTests.java38
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UserDefinedLiteralTests.java100
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/WhileStatementTests.java46
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx17/LambdaExpressionTests.java6
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java144
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java108
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestSuite.java4
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteBaseTest.java23
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTester.java65
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTests.java16
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/TestHelper.java14
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/TestSourceFile.java30
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTest.java90
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTestSourceFile.java18
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/AstWriterTestSuite.java42
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ExpressionWriterTest.java314
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/SourceRewriteTester.java35
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/AppendTests.java29
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTest.java15
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTestSuite.java14
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/CopyReplaceVisitor.java3
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/InsertBeforeTests.java32
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/RemoveTests.java14
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ReplaceTests.java79
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTest.java54
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTestSuite.java19
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/NodeCommentMapTest.java56
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/ExpansionExplorerTests.java436
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/FileCharArrayTests.java34
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/FileCodeReaderFactory.java11
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/InactiveCodeTests.java24
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/InclusionTests.java474
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LexerTests.java347
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LocationMapTests.java284
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PortedScannerTests.java1742
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorBugsTests.java68
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorSpeedTest.java103
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTests.java239
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTestsBase.java77
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/ScannerTestSuite.java6
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/StreamHasherTests.java52
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/TestMacro.java12
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/Bug246129.java15
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/EmptyIndexFragment.java55
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java216
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java1043
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionBugs.java285
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionTest.java129
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugs.java665
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugsSingleProjectFirstAST.java24
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java470
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java1130
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPVariableTemplateResolutionTest.java48
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCompositeTests.java79
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexGPPBindingResolutionTest.java20
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexIncludeTest.java234
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexListenerTest.java37
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexLocationTest.java227
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiFileTest.java17
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiVariantHeaderTest.java8
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexNamesTests.java130
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java411
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexSearchTest.java128
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexTestBase.java19
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexUpdateTests.java272
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/ProjectBuilder.java11
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TeamSharedIndexTest.java76
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TrilogyPerformanceTest.java16
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeExpensiveTests.java10
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeTests.java12
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CCompositeTypeTests.java75
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CFunctionTests.java17
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPClassTemplateTests.java315
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPCompositeTypeTests.java42
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFieldTests.java29
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTemplateTests.java20
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTests.java30
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPVariableTests.java5
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CVariableTests.java7
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ChangeConfigurationTests.java55
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ClassTests.java44
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DBPropertiesTests.java69
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DatabaseTest.java76
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DefDeclTests.java53
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/EnumerationTests.java24
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/FilesOnReindexTests.java15
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/GeneratePDOMApplicationTest.java293
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/IncludesTests.java10
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/MethodTests.java44
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/NamespaceTests.java14
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/OverloadsWithinCommonHeaderTests.java116
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/OverloadsWithinSingleTUTests.java33
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCBugsTest.java34
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCPPBugsTest.java82
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMInlineCodeTestBase.java15
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMLocationTests.java32
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMNameTests.java19
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMPrettyPrinter.java16
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMProviderTests.java213
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMSearchTest.java9
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTagIndexTests.java16
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTestBase.java42
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/RaceCondition157992Test.java23
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/TypesTests.java29
-rw-r--r--core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/BaseTestFramework.java134
-rw-r--r--core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/FailingTest.java84
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/ProjectCreator.java14
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java45
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CProjectHelper.java75
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CTestPlugin.java16
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CTestSetup.java11
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/FileManager.java26
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/Main.java90
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/NewMain.java43
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java76
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestPluginLauncher.java42
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestProject.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestScannerInfo.java18
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestScannerProvider.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/AccessibilityTestPass.java12
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java193
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/ExpectedStrings.java82
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/ExpectedStringsTests.java98
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/FailureDialog.java27
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/FocusTestPass.java8
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/IDialogTestPass.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/OneSourceMultipleHeadersTestCase.java24
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java204
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/VerifyDialog.java98
310 files changed, 27396 insertions, 26408 deletions
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/cdescriptor/tests/CDescriptorOldTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/cdescriptor/tests/CDescriptorOldTests.java
index 98d46ebf787..06c5f2130d7 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/cdescriptor/tests/CDescriptorOldTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/cdescriptor/tests/CDescriptorOldTests.java
@@ -46,7 +46,7 @@ import org.w3c.dom.NodeList;
/**
* This class exists because the tests in CDescriptorTests
* are not fixed.
- * This class corresponds to the version of
+ * This class corresponds to the version of
* CDescrptorTests before the changes made in cdt.core 5.1
* (CVS version 1.12)
*/
@@ -59,7 +59,7 @@ public class CDescriptorOldTests extends TestCase {
/**
* Constructor for CDescriptorTest.
- *
+ *
* @param name
*/
public CDescriptorOldTests(String name) {
@@ -81,7 +81,7 @@ public class CDescriptorOldTests extends TestCase {
suite.addTest(new CDescriptorOldTests("testConcurrentDescriptorCreation2"));
suite.addTest(new CDescriptorOldTests("testDeadlockDuringProjectCreation"));
suite.addTest(new CDescriptorOldTests("testProjectStorageDelete"));
-
+
TestSetup wrapper = new TestSetup(suite) {
@Override
@@ -98,7 +98,8 @@ public class CDescriptorOldTests extends TestCase {
return wrapper;
}
- private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
+ private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor)
+ throws CoreException {
IProjectDescription description = proj.getDescription();
String[] prevNatures = description.getNatureIds();
String[] newNatures = new String[prevNatures.length + 1];
@@ -168,7 +169,7 @@ public class CDescriptorOldTests extends TestCase {
public void testConcurrentDescriptorCreation() throws Exception {
fProject.close(null);
fProject.open(null);
- Thread t= new Thread() {
+ Thread t = new Thread() {
@Override
public void run() {
try {
@@ -180,57 +181,61 @@ public class CDescriptorOldTests extends TestCase {
t.start();
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
t.join();
-
+
Element data = desc.getProjectData("testElement0");
data.appendChild(data.getOwnerDocument().createElement("test"));
desc.saveProjectData();
fLastEvent = null;
- }
+ }
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185930
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=193503
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=196118
public void testConcurrentDescriptorCreation2() throws Exception {
int lastLength = 0;
- for (int i=0; i<200; ++i) {
+ for (int i = 0; i < 200; ++i) {
final int indexi = i;
- PDOMManager pdomMgr= (PDOMManager)CCorePlugin.getIndexManager();
+ PDOMManager pdomMgr = (PDOMManager) CCorePlugin.getIndexManager();
pdomMgr.shutdown();
fProject.close(null);
fProject.open(null);
pdomMgr.startup().schedule();
- ICDescriptor desc= CCorePlugin.getDefault().getCProjectDescription(fProject, true);
+ ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
if (lastLength == 0)
lastLength = countChildElements(desc.getProjectData("testElement"));
- final Throwable[] exception= new Throwable[10];
- Thread[] threads= new Thread[10];
+ final Throwable[] exception = new Throwable[10];
+ Thread[] threads = new Thread[10];
for (int j = 0; j < 10; j++) {
final int indexj = j;
- Thread t= new Thread() {
+ Thread t = new Thread() {
@Override
public void run() {
try {
- ICDescriptorOperation operation= new ICDescriptorOperation() {
+ ICDescriptorOperation operation = new ICDescriptorOperation() {
@Override
- public void execute(ICDescriptor descriptor, IProgressMonitor monitor) throws CoreException {
+ public void execute(ICDescriptor descriptor, IProgressMonitor monitor)
+ throws CoreException {
assertFalse(descriptor.getConfigurationDescription().isReadOnly());
Element data = descriptor.getProjectData("testElement");
- String test = "test"+(indexi*10 + indexj);
+ String test = "test" + (indexi * 10 + indexj);
data.appendChild(data.getOwnerDocument().createElement(test));
assertFalse(descriptor.getConfigurationDescription().isReadOnly());
// BUG196118 the model cached in memory doesn't reflect the contents of .cproject
//
// descriptor.saveProjectData() doesn't actually save despite what the API says
// see CConfigBasedDescriptor.fApplyOnChange
-// ((CConfigBasedDescriptor)descriptor).apply(false);
-// System.out.println("Saved " + test);
- }};
- CCorePlugin.getDefault().getCDescriptorManager().runDescriptorOperation(fProject, operation, null);
- ICDescriptor descriptor = CCorePlugin.getDefault().getCDescriptorManager().getDescriptor(fProject);
- // perform apply outside descriptor operation to avoid deadlock - http://bugs.eclipse.org/241288
- descriptor.saveProjectData();
+ // ((CConfigBasedDescriptor)descriptor).apply(false);
+ // System.out.println("Saved " + test);
+ }
+ };
+ CCorePlugin.getDefault().getCDescriptorManager().runDescriptorOperation(fProject, operation,
+ null);
+ ICDescriptor descriptor = CCorePlugin.getDefault().getCDescriptorManager()
+ .getDescriptor(fProject);
+ // perform apply outside descriptor operation to avoid deadlock - http://bugs.eclipse.org/241288
+ descriptor.saveProjectData();
} catch (Throwable exc) {
- exception[indexj]= exc;
+ exception[indexj] = exc;
exc.printStackTrace();
}
}
@@ -242,9 +247,9 @@ public class CDescriptorOldTests extends TestCase {
if (threads[j] != null) {
threads[j].join();
}
- assertNull("Exception occurred: "+exception[j], exception[j]);
+ assertNull("Exception occurred: " + exception[j], exception[j]);
}
- desc= CCorePlugin.getDefault().getCProjectDescription(fProject, true);
+ desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
int lengthAfter = countChildElements(desc.getProjectData("testElement"));
lastLength += threads.length; // Update last lengths to what we expect
assertEquals("Iteration count: " + i, lastLength, lengthAfter);
@@ -254,7 +259,7 @@ public class CDescriptorOldTests extends TestCase {
}
/**
- * Count the number of Node.ELEMENT_NODE elements which are a
+ * Count the number of Node.ELEMENT_NODE elements which are a
* direct descendent of the parent Element.
* Other nodes (e.g. Text) are ignored
* @param parent
@@ -263,17 +268,17 @@ public class CDescriptorOldTests extends TestCase {
private int countChildElements(Element parent) {
int numElements = 0;
NodeList childNodes = parent.getChildNodes();
- for (int k = 0 ; k < childNodes.getLength() ; k++)
+ for (int k = 0; k < childNodes.getLength(); k++)
if (childNodes.item(k).getNodeType() == Node.ELEMENT_NODE)
- numElements ++;
+ numElements++;
return numElements;
}
public void testDeadlockDuringProjectCreation() throws Exception {
- for (int i=0; i < 10; ++i) {
+ for (int i = 0; i < 10; ++i) {
oneTimeTearDown();
oneTimeSetUp();
- Thread t= new Thread() {
+ Thread t = new Thread() {
@Override
public void run() {
try {
@@ -292,10 +297,10 @@ public class CDescriptorOldTests extends TestCase {
data.appendChild(data.getOwnerDocument().createElement("test"));
desc.saveProjectData();
t.join();
-
+
fLastEvent = null;
}
- }
+ }
public void testDescriptorOwner() throws Exception {
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
@@ -404,7 +409,7 @@ public class CDescriptorOldTests extends TestCase {
// 3rd check the item no longer exists
desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
data = desc.getProjectData("testElement");
- assertTrue(data.getChildNodes().getLength() == 0);
+ assertTrue(data.getChildNodes().getLength() == 0);
fLastEvent = null;
}
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/cdescriptor/tests/CDescriptorTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/cdescriptor/tests/CDescriptorTests.java
index 4d5dafbf472..93cb50ddf25 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/cdescriptor/tests/CDescriptorTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/cdescriptor/tests/CDescriptorTests.java
@@ -102,7 +102,8 @@ public class CDescriptorTests extends BaseTestCase {
fProject.delete(true, true, null);
}
- private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
+ private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor)
+ throws CoreException {
IProjectDescription description = proj.getDescription();
String[] prevNatures = description.getNatureIds();
String[] newNatures = new String[prevNatures.length + 1];
@@ -143,10 +144,10 @@ public class CDescriptorTests extends BaseTestCase {
// Disabled this test because it fails every now and then and it tests deprecated API
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=340123
public void _testConcurrentDescriptorCreation() throws Exception {
- for (int i = 0; i < 100 ; i++) {
+ for (int i = 0; i < 100; i++) {
fProject.close(null);
fProject.open(null);
- Thread t= new Thread() {
+ Thread t = new Thread() {
@Override
public void run() {
try {
@@ -168,7 +169,7 @@ public class CDescriptorTests extends BaseTestCase {
desc.saveProjectData();
fLastEvent = null;
}
- }
+ }
/*
* This tests concurrent descriptor modification inside of a ICDescriptor operation run
@@ -180,38 +181,41 @@ public class CDescriptorTests extends BaseTestCase {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=196118
public void testConcurrentDescriptorModification() throws Exception {
int lastLength = 0;
- for (int i= 0; i < 100; ++i) {
+ for (int i = 0; i < 100; ++i) {
final int indexi = i;
- PDOMManager pdomMgr= (PDOMManager)CCorePlugin.getIndexManager();
+ PDOMManager pdomMgr = (PDOMManager) CCorePlugin.getIndexManager();
pdomMgr.shutdown();
fProject.close(null);
fProject.open(null);
pdomMgr.startup().schedule();
- final ICDescriptor fdesc= CCorePlugin.getDefault().getCProjectDescription(fProject, true);
+ final ICDescriptor fdesc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
if (lastLength == 0)
lastLength = fdesc.getProjectStorageElement("testElement").getChildren().length;
- final Throwable[] exception= new Throwable[10];
- Thread[] threads= new Thread[10];
+ final Throwable[] exception = new Throwable[10];
+ Thread[] threads = new Thread[10];
for (int j = 0; j < 10; j++) {
final int indexj = j;
- Thread t= new Thread() {
+ Thread t = new Thread() {
@Override
public void run() {
try {
- ICDescriptorOperation operation= new ICDescriptorOperation() {
+ ICDescriptorOperation operation = new ICDescriptorOperation() {
@Override
- public void execute(ICDescriptor descriptor, IProgressMonitor monitor) throws CoreException {
-// assertFalse(descriptor.getConfigurationDescription().isReadOnly());
+ public void execute(ICDescriptor descriptor, IProgressMonitor monitor)
+ throws CoreException {
+ // assertFalse(descriptor.getConfigurationDescription().isReadOnly());
ICStorageElement data = fdesc.getProjectStorageElement("testElement");
- String test = "test"+(indexi*10 + indexj);
+ String test = "test" + (indexi * 10 + indexj);
data.createChild(test);
-// assertFalse(descriptor.getConfigurationDescription().isReadOnly());
+ // assertFalse(descriptor.getConfigurationDescription().isReadOnly());
descriptor.saveProjectData();
-// System.out.println("Saved " + test);
- }};
- CCorePlugin.getDefault().getCDescriptorManager().runDescriptorOperation(fProject, operation, null);
+ // System.out.println("Saved " + test);
+ }
+ };
+ CCorePlugin.getDefault().getCDescriptorManager().runDescriptorOperation(fProject, operation,
+ null);
} catch (Throwable exc) {
- exception[indexj]= exc;
+ exception[indexj] = exc;
exc.printStackTrace();
}
}
@@ -226,9 +230,9 @@ public class CDescriptorTests extends BaseTestCase {
} catch (InterruptedException e) {
}
}
- assertNull("Exception occurred: "+exception[j], exception[j]);
+ assertNull("Exception occurred: " + exception[j], exception[j]);
}
- ICDescriptor desc= CCorePlugin.getDefault().getCProjectDescription(fProject, true);
+ ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
int lengthAfter = desc.getProjectStorageElement("testElement").getChildren().length;
lastLength += threads.length; // Update last lengths to what we expect
assertEquals("Iteration count: " + i, lastLength, lengthAfter);
@@ -242,8 +246,8 @@ public class CDescriptorTests extends BaseTestCase {
* (outside of an operation) should be safe.
*/
public void testConcurrentDifferentStorageElementModification() throws Exception {
- for (int i= 0; i < 100; ++i) {
- Thread t= new Thread() {
+ for (int i = 0; i < 100; ++i) {
+ Thread t = new Thread() {
@Override
public void run() {
try {
@@ -269,16 +273,18 @@ public class CDescriptorTests extends BaseTestCase {
fLastEvent = null;
}
- Assert.assertEquals(100, CCorePlugin.getDefault().getCProjectDescription(fProject, false).getProjectStorageElement("testElement4").getChildren().length);
- Assert.assertEquals(100, CCorePlugin.getDefault().getCProjectDescription(fProject, false).getProjectStorageElement("testElement5").getChildren().length);
- }
+ Assert.assertEquals(100, CCorePlugin.getDefault().getCProjectDescription(fProject, false)
+ .getProjectStorageElement("testElement4").getChildren().length);
+ Assert.assertEquals(100, CCorePlugin.getDefault().getCProjectDescription(fProject, false)
+ .getProjectStorageElement("testElement5").getChildren().length);
+ }
/*
* Tests that (non-structural) changes to the storage element tree work as expected.
*/
public void testConcurrentSameStorageElementModification() throws Exception {
- for (int i= 0; i < 100; ++i) {
- Thread t= new Thread() {
+ for (int i = 0; i < 100; ++i) {
+ Thread t = new Thread() {
@Override
public void run() {
try {
@@ -304,17 +310,18 @@ public class CDescriptorTests extends BaseTestCase {
fLastEvent = null;
}
- Assert.assertEquals(200, CCorePlugin.getDefault().getCProjectDescription(fProject, false).getProjectStorageElement("testElement6").getChildren().length);
- }
+ Assert.assertEquals(200, CCorePlugin.getDefault().getCProjectDescription(fProject, false)
+ .getProjectStorageElement("testElement6").getChildren().length);
+ }
/*
* Tests deadlock when accessing c project description concurrently from two threads
*/
public void testDeadlockDuringProjectCreation() throws Exception {
- for (int i= 0; i < 10; ++i) {
+ for (int i = 0; i < 10; ++i) {
tearDown();
setUp();
- Thread t= new Thread() {
+ Thread t = new Thread() {
@Override
public void run() {
try {
@@ -339,7 +346,7 @@ public class CDescriptorTests extends BaseTestCase {
fLastEvent = null;
}
- }
+ }
public void testDescriptorConversion() {
}
@@ -431,7 +438,7 @@ public class CDescriptorTests extends BaseTestCase {
}
public void testCProjectDescriptionDescriptorInteraction() throws Exception {
- for (int i = 1; i < 100 ; i++) {
+ for (int i = 1; i < 100; i++) {
// Create a descriptor with some test data
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
ICStorageElement data = desc.getProjectStorageElement("descDescInteraction");
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/envvar/IEnvironmentVariableManagerTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/envvar/IEnvironmentVariableManagerTests.java
index 0bb112f2672..031650d4400 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/envvar/IEnvironmentVariableManagerTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/envvar/IEnvironmentVariableManagerTests.java
@@ -48,13 +48,16 @@ public class IEnvironmentVariableManagerTests extends TestCase {
public int getCount() {
return count;
}
+
public void resetCount() {
count = 0;
lastEvent = null;
}
+
public IEnvironmentChangeEvent getLastEvent() {
return lastEvent;
}
+
@Override
public void handleEvent(IEnvironmentChangeEvent event) {
count++;
@@ -73,8 +76,8 @@ public class IEnvironmentVariableManagerTests extends TestCase {
}
public static Test suite() {
- TestSuite suite = new TestSuite(IEnvironmentVariableManagerTests.class);
- return suite;
+ TestSuite suite = new TestSuite(IEnvironmentVariableManagerTests.class);
+ return suite;
}
/**
@@ -88,8 +91,8 @@ public class IEnvironmentVariableManagerTests extends TestCase {
// Add another, derived configuration
ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(project);
ICConfigurationDescription desc = prjDesc.getActiveConfiguration();
- final String id1 = desc.getId(); // Config 1's ID
- final String id2 = CDataUtil.genId(id1); // Config 2's ID
+ final String id1 = desc.getId(); // Config 1's ID
+ final String id2 = CDataUtil.genId(id1); // Config 2's ID
prjDesc.createConfiguration(id2, "config2", desc);
CoreModel.getDefault().setProjectDescription(project, prjDesc);
@@ -142,7 +145,7 @@ public class IEnvironmentVariableManagerTests extends TestCase {
ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(project);
ICConfigurationDescription desc = prjDesc.getActiveConfiguration();
final String id1 = desc.getId(); // Config 1's ID
- final String id2 = "712427638"; // Config 2's ID
+ final String id2 = "712427638"; // Config 2's ID
prjDesc.createConfiguration(id2, "config2", desc);
CoreModel.getDefault().setProjectDescription(project, prjDesc);
@@ -152,14 +155,14 @@ public class IEnvironmentVariableManagerTests extends TestCase {
contribEnv.addVariable(varOrig, prjDesc.getConfigurationById(id2));
CoreModel.getDefault().setProjectDescription(project, prjDesc);
- final String env = "#Mon Nov 16 21:47:46 GMT 2009\n" +
- "eclipse.preferences.version=1\n" +
- "environment/project/712427638=<?xml version\\=\"1.0\" encoding\\=\"UTF-8\" standalone\\=\"no\"?>\\n" +
- "<environment append\\=\"true\" appendContributed\\=\"true\">\\n" +
- "<variable delimiter\\=\"\\:\" name\\=\"FOO1\" operation\\=\"replace\" value\\=\"BAR1\"/>\\n" +
- "<variable delimiter\\=\"\\:\" name\\=\"FOO2\" operation\\=\"replace\" value\\=\"BAR2\"/>\\n" +
- "<variable delimiter\\=\"\\;\" name\\=\"FOO\" operation\\=\"append\" value\\=\"BAR\"/>\\n</environment>\n";
- project.getFile(".settings/org.eclipse.cdt.core.prefs").setContents(new ByteArrayInputStream(env.getBytes("UTF-8")), true, false, null);
+ final String env = "#Mon Nov 16 21:47:46 GMT 2009\n" + "eclipse.preferences.version=1\n"
+ + "environment/project/712427638=<?xml version\\=\"1.0\" encoding\\=\"UTF-8\" standalone\\=\"no\"?>\\n"
+ + "<environment append\\=\"true\" appendContributed\\=\"true\">\\n"
+ + "<variable delimiter\\=\"\\:\" name\\=\"FOO1\" operation\\=\"replace\" value\\=\"BAR1\"/>\\n"
+ + "<variable delimiter\\=\"\\:\" name\\=\"FOO2\" operation\\=\"replace\" value\\=\"BAR2\"/>\\n"
+ + "<variable delimiter\\=\"\\;\" name\\=\"FOO\" operation\\=\"append\" value\\=\"BAR\"/>\\n</environment>\n";
+ project.getFile(".settings/org.eclipse.cdt.core.prefs")
+ .setContents(new ByteArrayInputStream(env.getBytes("UTF-8")), true, false, null);
final IEnvironmentVariable var = new EnvironmentVariable("FOO", "BAR", IEnvironmentVariable.ENVVAR_APPEND, ";");
final IEnvironmentVariable var1 = new EnvironmentVariable("FOO1", "BAR1", ":");
@@ -182,7 +185,7 @@ public class IEnvironmentVariableManagerTests extends TestCase {
ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(project);
ICConfigurationDescription desc = prjDesc.getActiveConfiguration();
final String id1 = desc.getId(); // Config 1's ID
- final String id2 = "712427638"; // Config 2's ID
+ final String id2 = "712427638"; // Config 2's ID
prjDesc.createConfiguration(id2, "config2", desc);
CoreModel.getDefault().setProjectDescription(project, prjDesc);
@@ -192,20 +195,21 @@ public class IEnvironmentVariableManagerTests extends TestCase {
contribEnv.addVariable(varOrig, prjDesc.getConfigurationById(id2));
CoreModel.getDefault().setProjectDescription(project, prjDesc);
- final String env = "#Mon Nov 16 21:47:46 GMT 2009\n" +
- "eclipse.preferences.version=1\n" +
- "environment/project/712427638=<?xml version\\=\"1.0\" encoding\\=\"UTF-8\" standalone\\=\"no\"?>\\n" +
- "<environment append\\=\"true\" appendContributed\\=\"true\">\\n" +
- "<variable delimiter\\=\"\\:\" name\\=\"FOO1\" operation\\=\"replace\" value\\=\"BAR1\"/>\\n" +
- "<variable delimiter\\=\"\\:\" name\\=\"FOO2\" operation\\=\"replace\" value\\=\"BAR2\"/>\\n" +
- "<variable delimiter\\=\"\\;\" name\\=\"FOO\" operation\\=\"append\" value\\=\"BAR\"/>\\n</environment>\n";
- project.getFile(".settings/org.eclipse.cdt.core.prefs").setContents(new ByteArrayInputStream(env.getBytes("UTF-8")), true, false, null);
+ final String env = "#Mon Nov 16 21:47:46 GMT 2009\n" + "eclipse.preferences.version=1\n"
+ + "environment/project/712427638=<?xml version\\=\"1.0\" encoding\\=\"UTF-8\" standalone\\=\"no\"?>\\n"
+ + "<environment append\\=\"true\" appendContributed\\=\"true\">\\n"
+ + "<variable delimiter\\=\"\\:\" name\\=\"FOO1\" operation\\=\"replace\" value\\=\"BAR1\"/>\\n"
+ + "<variable delimiter\\=\"\\:\" name\\=\"FOO2\" operation\\=\"replace\" value\\=\"BAR2\"/>\\n"
+ + "<variable delimiter\\=\"\\;\" name\\=\"FOO\" operation\\=\"append\" value\\=\"BAR\"/>\\n</environment>\n";
+ project.getFile(".settings/org.eclipse.cdt.core.prefs")
+ .setContents(new ByteArrayInputStream(env.getBytes("UTF-8")), true, false, null);
ISchedulingRule incompatibleRule = new ISchedulingRule() {
@Override
public boolean isConflicting(ISchedulingRule rule) {
return rule == this || rule instanceof IResource;
}
+
@Override
public boolean contains(ISchedulingRule rule) {
return rule == this;
@@ -213,10 +217,11 @@ public class IEnvironmentVariableManagerTests extends TestCase {
};
try {
Job.getJobManager().beginRule(incompatibleRule, new NullProgressMonitor());
- final IEnvironmentVariable var = new EnvironmentVariable("FOO", "BAR", IEnvironmentVariable.ENVVAR_APPEND, ";");
+ final IEnvironmentVariable var = new EnvironmentVariable("FOO", "BAR", IEnvironmentVariable.ENVVAR_APPEND,
+ ";");
final IEnvironmentVariable var1 = new EnvironmentVariable("FOO1", "BAR1", ":");
final IEnvironmentVariable var2 = new EnvironmentVariable("FOO2", "BAR2", ":");
-
+
prjDesc = CoreModel.getDefault().getProjectDescription(project);
assertEquals(var, envManager.getVariable(var.getName(), prjDesc.getConfigurationById(id2), true));
assertEquals(var1, envManager.getVariable(var1.getName(), prjDesc.getConfigurationById(id2), true));
@@ -247,7 +252,7 @@ public class IEnvironmentVariableManagerTests extends TestCase {
ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(project);
ICConfigurationDescription desc = prjDesc.getActiveConfiguration();
final String id1 = desc.getId(); // Config 1's ID
- final String id2 = "712427638"; // Config 2's ID
+ final String id2 = "712427638"; // Config 2's ID
prjDesc.createConfiguration(id2, "config2", desc);
CoreModel.getDefault().setProjectDescription(project, prjDesc);
@@ -258,18 +263,17 @@ public class IEnvironmentVariableManagerTests extends TestCase {
contribEnv.addVariable(varOrig, prjDesc.getConfigurationById(id2));
CoreModel.getDefault().setProjectDescription(project, prjDesc);
- final String env = "environment/project/712427638/FOO/delimiter=;\n" +
- "environment/project/712427638/FOO/operation=append\n" +
- "environment/project/712427638/FOO/value=BAR\n" +
- "environment/project/712427638/FOO1/delimiter=\\:\n" +
- "environment/project/712427638/FOO1/operation=replace\n" +
- "environment/project/712427638/FOO1/value=BAR1\n" +
- "environment/project/712427638/FOO2/delimiter=\\:\n" +
- "environment/project/712427638/FOO2/operation=replace\n" +
- "environment/project/712427638/FOO2/value=BAR2\n" +
- "environment/project/712427638/append=true\n" +
- "environment/project/712427638/appendContributed=true\n";
- project.getFile(".settings/org.eclipse.cdt.core.prefs").setContents(new ByteArrayInputStream(env.getBytes("UTF-8")), true, false, null);
+ final String env = "environment/project/712427638/FOO/delimiter=;\n"
+ + "environment/project/712427638/FOO/operation=append\n"
+ + "environment/project/712427638/FOO/value=BAR\n" + "environment/project/712427638/FOO1/delimiter=\\:\n"
+ + "environment/project/712427638/FOO1/operation=replace\n"
+ + "environment/project/712427638/FOO1/value=BAR1\n"
+ + "environment/project/712427638/FOO2/delimiter=\\:\n"
+ + "environment/project/712427638/FOO2/operation=replace\n"
+ + "environment/project/712427638/FOO2/value=BAR2\n" + "environment/project/712427638/append=true\n"
+ + "environment/project/712427638/appendContributed=true\n";
+ project.getFile(".settings/org.eclipse.cdt.core.prefs")
+ .setContents(new ByteArrayInputStream(env.getBytes("UTF-8")), true, false, null);
final IEnvironmentVariable var = new EnvironmentVariable("FOO", "BAR", IEnvironmentVariable.ENVVAR_APPEND, ";");
final IEnvironmentVariable var1 = new EnvironmentVariable("FOO1", "BAR1", ":");
@@ -346,8 +350,8 @@ public class IEnvironmentVariableManagerTests extends TestCase {
// Add another, derived configuration
ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(project);
ICConfigurationDescription desc = prjDesc.getActiveConfiguration();
- final String id1 = desc.getId(); // Config 1's ID
- final String id2 = CDataUtil.genId(id1); // Config 2's ID
+ final String id1 = desc.getId(); // Config 1's ID
+ final String id2 = CDataUtil.genId(id1); // Config 2's ID
prjDesc.createConfiguration(id2, "config2", desc);
CoreModel.getDefault().setProjectDescription(project, prjDesc);
@@ -389,8 +393,8 @@ public class IEnvironmentVariableManagerTests extends TestCase {
// Add another, derived configuration
ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(project);
ICConfigurationDescription desc = prjDesc.getActiveConfiguration();
- final String id1 = desc.getId(); // Config 1's ID
- final String id2 = CDataUtil.genId(id1); // Config 2's ID
+ final String id1 = desc.getId(); // Config 1's ID
+ final String id2 = CDataUtil.genId(id1); // Config 2's ID
prjDesc.createConfiguration(id2, "config2", desc);
CoreModel.getDefault().setProjectDescription(project, prjDesc);
@@ -413,8 +417,8 @@ public class IEnvironmentVariableManagerTests extends TestCase {
CoreModel.getDefault().setProjectDescription(project, prjDesc);
// Backup the settings file
- project.getFile(".settings/org.eclipse.cdt.core.prefs.bak").create(
- project.getFile(".settings/org.eclipse.cdt.core.prefs").getContents(), true, null);
+ project.getFile(".settings/org.eclipse.cdt.core.prefs.bak")
+ .create(project.getFile(".settings/org.eclipse.cdt.core.prefs").getContents(), true, null);
// Change the environment variable
final IEnvironmentVariable var2 = new EnvironmentVariable("FOO", "BOO");
@@ -438,8 +442,8 @@ public class IEnvironmentVariableManagerTests extends TestCase {
// Add another, derived configuration
ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(project);
ICConfigurationDescription desc = prjDesc.getActiveConfiguration();
- final String id1 = desc.getId(); // Config 1's ID
- final String id2 = CDataUtil.genId(id1); // Config 2's ID
+ final String id1 = desc.getId(); // Config 1's ID
+ final String id2 = CDataUtil.genId(id1); // Config 2's ID
prjDesc.createConfiguration(id2, "config2", desc);
CoreModel.getDefault().setProjectDescription(project, prjDesc);
@@ -462,8 +466,8 @@ public class IEnvironmentVariableManagerTests extends TestCase {
CoreModel.getDefault().setProjectDescription(project, prjDesc);
// Backup the settings file
- project.getFile(".settings/org.eclipse.cdt.core.prefs.bak").create(
- project.getFile(".settings/org.eclipse.cdt.core.prefs").getContents(), true, null);
+ project.getFile(".settings/org.eclipse.cdt.core.prefs.bak")
+ .create(project.getFile(".settings/org.eclipse.cdt.core.prefs").getContents(), true, null);
// Change the environment variable
final IEnvironmentVariable var2 = new EnvironmentVariable("FOO", "BOO");
@@ -473,13 +477,15 @@ public class IEnvironmentVariableManagerTests extends TestCase {
// clean desc should be updated when the preference file is overwritten
final ICProjectDescription cleanDesc = CoreModel.getDefault().getProjectDescription(project);
- assertEquals(contribEnv.getVariable(var.getName(), cleanDesc.getConfigurationById(id1)).getValue(), var2.getValue());
+ assertEquals(contribEnv.getVariable(var.getName(), cleanDesc.getConfigurationById(id1)).getValue(),
+ var2.getValue());
// Replace the settings with it's backup
project.getFile(".settings/org.eclipse.cdt.core.prefs").setContents(
project.getFile(".settings/org.eclipse.cdt.core.prefs.bak").getContents(), true, false, null);
// check that cleanDesc has been updated
- assertEquals(contribEnv.getVariable(var.getName(), cleanDesc.getConfigurationById(id1)).getValue(), var.getValue());
+ assertEquals(contribEnv.getVariable(var.getName(), cleanDesc.getConfigurationById(id1)).getValue(),
+ var.getValue());
assertEquals(var, envManager.getVariable(var.getName(), cleanDesc.getConfigurationById(id1), true));
}
@@ -608,7 +614,7 @@ public class IEnvironmentVariableManagerTests extends TestCase {
/**
* This test checks if an environment variable is only processed as a list
* if it matches a certain pattern. ([^:]+:)+[^:]* (; on Windows)
- *
+ *
* If a variable is a list, it is split into a String array depending on the
* delimiter given. At some point, this array is used to build a new
* String representing the list, separated by the delimiter. This should
@@ -616,10 +622,10 @@ public class IEnvironmentVariableManagerTests extends TestCase {
* variable has a value of ':' without the quotes, it shouldn't processed as
* a list even if it contains a delimiter because if it was, it would give
* an empty string when built since there are no items in the list.
- *
+ *
* @throws Exception
*/
- public void testBug284843() throws Exception{
+ public void testBug284843() throws Exception {
final IProject project = ResourceHelper.createCDTProjectWithConfig("envProject");
ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(project);
IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager();
@@ -628,50 +634,48 @@ public class IEnvironmentVariableManagerTests extends TestCase {
String delimiter = System.getProperty("path.separator");
// Create the test variables
- IEnvironmentVariable varDelim = new EnvironmentVariable("DELIM",
- delimiter);
+ IEnvironmentVariable varDelim = new EnvironmentVariable("DELIM", delimiter);
String varListValue = "value1" + delimiter + "value2" + delimiter + "value3";
IEnvironmentVariable varList = new EnvironmentVariable("LIST", varListValue);
- IEnvironmentVariable varListDelim = new EnvironmentVariable("LISTDELIM",
- "value1" + delimiter);
- IEnvironmentVariable varListDelims = new EnvironmentVariable("LISTDELIMS",
- varListValue + delimiter);
- String varInvalidListValue = delimiter + "value1" + delimiter + "value2" + delimiter + delimiter + "value3" + delimiter;
+ IEnvironmentVariable varListDelim = new EnvironmentVariable("LISTDELIM", "value1" + delimiter);
+ IEnvironmentVariable varListDelims = new EnvironmentVariable("LISTDELIMS", varListValue + delimiter);
+ String varInvalidListValue = delimiter + "value1" + delimiter + "value2" + delimiter + delimiter + "value3"
+ + delimiter;
IEnvironmentVariable varInvalidList = new EnvironmentVariable("INVALIDLIST", varInvalidListValue);
-
+
// Add the variables to the contributed environment
contribEnv.addVariable(varDelim, confDesc);
contribEnv.addVariable(varList, confDesc);
contribEnv.addVariable(varListDelim, confDesc);
contribEnv.addVariable(varListDelims, confDesc);
contribEnv.addVariable(varInvalidList, confDesc);
-
+
// Get the processed variables
varDelim = envManager.getVariable(varDelim.getName(), confDesc, true);
varList = envManager.getVariable(varList.getName(), confDesc, true);
varListDelim = envManager.getVariable(varListDelim.getName(), confDesc, true);
varListDelims = envManager.getVariable(varListDelims.getName(), confDesc, true);
varInvalidList = envManager.getVariable(varInvalidList.getName(), confDesc, true);
-
+
// Should keep the same value, not a list
assertEquals(delimiter, varDelim.getValue());
-
+
// Should keep the same value, processed as a list
assertEquals(varListValue, varList.getValue());
-
+
// The delimiter will be trimmed, processed as a list
assertEquals("value1", varListDelim.getValue());
-
+
// The last delimiter will be trimmed, processed as a list
- assertEquals(varListValue, varListDelims.getValue());
-
+ assertEquals(varListValue, varListDelims.getValue());
+
// Should keep the same value, not a list
- assertEquals(varInvalidListValue,varInvalidList.getValue());
+ assertEquals(varInvalidListValue, varInvalidList.getValue());
}
/**
* Test case to test environment variable change notifications
- *
+ *
* @throws Exception
*/
public void testEnvironmentChangeListener() throws Exception {
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/efsextension/tests/EFSExtensionProviderTestsProvider.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/efsextension/tests/EFSExtensionProviderTestsProvider.java
index 447af854e8e..8f6a3d63910 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/efsextension/tests/EFSExtensionProviderTestsProvider.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/efsextension/tests/EFSExtensionProviderTestsProvider.java
@@ -21,7 +21,7 @@ import org.eclipse.cdt.core.EFSExtensionProvider;
* Test class that is used to make sure that extensions to the EFSExtensionProvider
* extension point are picked up. Overrrides the default behaviour for isVirtual()
* to return true.
- *
+ *
* @author crecoskie
*
*/
@@ -32,6 +32,4 @@ public class EFSExtensionProviderTestsProvider extends EFSExtensionProvider {
return true;
}
-
-
}
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/efsextension/tests/EFSExtensionTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/efsextension/tests/EFSExtensionTests.java
index 790d1a65c23..45febb88d08 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/efsextension/tests/EFSExtensionTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/efsextension/tests/EFSExtensionTests.java
@@ -27,7 +27,7 @@ import org.eclipse.core.runtime.Platform;
/**
* Tests the EFSExtensionManager and EFSExtensionProvider classes, as well as the EFSExtensionProvider extension point.
- *
+ *
* @author crecoskie
*
*/
@@ -41,16 +41,14 @@ public class EFSExtensionTests extends TestCase {
} catch (URISyntaxException e) {
fail(e.getMessage());
}
- String workingDirPath = EFSExtensionManager.getDefault()
- .getPathFromURI(originalURI);
+ String workingDirPath = EFSExtensionManager.getDefault().getPathFromURI(originalURI);
IPath path = new Path("subdirectory");
IPath newPath = new Path(workingDirPath).append(path).makeAbsolute();
- URI uri = EFSExtensionManager.getDefault()
- .createNewURIFromPath(originalURI, newPath.toString());
-
+ URI uri = EFSExtensionManager.getDefault().createNewURIFromPath(originalURI, newPath.toString());
+
assertEquals(expected, uri);
}
-
+
public void testReplaceInUNIXURI() {
URI originalURI = null;
URI expected = null;
@@ -60,16 +58,14 @@ public class EFSExtensionTests extends TestCase {
} catch (URISyntaxException e) {
fail(e.getMessage());
}
- String workingDirPath = EFSExtensionManager.getDefault()
- .getPathFromURI(originalURI);
+ String workingDirPath = EFSExtensionManager.getDefault().getPathFromURI(originalURI);
IPath path = new Path("subdirectory");
IPath newPath = new Path(workingDirPath).append(path).makeAbsolute();
- URI uri = EFSExtensionManager.getDefault()
- .createNewURIFromPath(originalURI, newPath.toString());
-
+ URI uri = EFSExtensionManager.getDefault().createNewURIFromPath(originalURI, newPath.toString());
+
assertEquals(expected, uri);
}
-
+
public void testReplaceInWindowsURI() {
URI originalURI = null;
URI expected = null;
@@ -79,16 +75,14 @@ public class EFSExtensionTests extends TestCase {
} catch (URISyntaxException e) {
fail(e.getMessage());
}
- String workingDirPath = EFSExtensionManager.getDefault()
- .getPathFromURI(originalURI);
+ String workingDirPath = EFSExtensionManager.getDefault().getPathFromURI(originalURI);
IPath path = new Path("subdirectory");
IPath newPath = new Path(workingDirPath).append(path).makeAbsolute();
- URI uri = EFSExtensionManager.getDefault()
- .createNewURIFromPath(originalURI, newPath.toString());
-
+ URI uri = EFSExtensionManager.getDefault().createNewURIFromPath(originalURI, newPath.toString());
+
assertEquals(expected, uri);
}
-
+
public void testReplaceInMadeUpURI() {
URI originalURI = null;
URI expected = null;
@@ -98,26 +92,23 @@ public class EFSExtensionTests extends TestCase {
} catch (URISyntaxException e) {
fail(e.getMessage());
}
- String workingDirPath = EFSExtensionManager.getDefault()
- .getPathFromURI(originalURI);
+ String workingDirPath = EFSExtensionManager.getDefault().getPathFromURI(originalURI);
IPath path = new Path("subdirectory");
IPath newPath = new Path(workingDirPath).append(path).makeAbsolute();
- URI uri = EFSExtensionManager.getDefault()
- .createNewURIFromPath(originalURI, newPath.toString());
-
+ URI uri = EFSExtensionManager.getDefault().createNewURIFromPath(originalURI, newPath.toString());
+
assertEquals(expected, uri);
}
-
+
public void testReplaceWithWindowsPathNoLeadingSlash() {
URI originalURI = null;
URI expected = null;
try {
originalURI = new URI("file", "/c:/foo", null);
-
- if(java.io.File.separatorChar == '\\') {
+
+ if (java.io.File.separatorChar == '\\') {
expected = new URI("file", "/c:/foo/subdirectory", null);
- }
- else {
+ } else {
// if we're not on Windows then backslash is not the path separator, and instead
// is a valid filename character. Using a backslash will result in it being escaped.
expected = new URI("file", "/c:\\foo\\subdirectory", null);
@@ -125,52 +116,49 @@ public class EFSExtensionTests extends TestCase {
} catch (URISyntaxException e) {
fail(e.getMessage());
}
-
+
String newPath = "c:\\foo\\subdirectory";
- URI uri = EFSExtensionManager.getDefault()
- .createNewURIFromPath(originalURI, newPath);
-
+ URI uri = EFSExtensionManager.getDefault().createNewURIFromPath(originalURI, newPath);
+
assertEquals(expected, uri);
}
-
+
public void testReplaceURIWithAuthority() {
URI originalURI = null;
URI expected = null;
try {
originalURI = new URI("rse", "recoskie@dbgaix3.torolab.ibm.com:1000", "/home/recoskie", null, null);
- expected = new URI("rse", "recoskie@dbgaix3.torolab.ibm.com:1000", "/home/recoskie/subdirectory", null, null);
+ expected = new URI("rse", "recoskie@dbgaix3.torolab.ibm.com:1000", "/home/recoskie/subdirectory", null,
+ null);
} catch (URISyntaxException e) {
fail(e.getMessage());
}
- String workingDirPath = EFSExtensionManager.getDefault()
- .getPathFromURI(originalURI);
+ String workingDirPath = EFSExtensionManager.getDefault().getPathFromURI(originalURI);
IPath path = new Path("subdirectory");
IPath newPath = new Path(workingDirPath).append(path).makeAbsolute();
- URI uri = EFSExtensionManager.getDefault()
- .createNewURIFromPath(originalURI, newPath.toString());
-
+ URI uri = EFSExtensionManager.getDefault().createNewURIFromPath(originalURI, newPath.toString());
+
assertEquals(expected, uri);
}
-
+
public void testReplaceURIWithAuthority2() {
URI originalURI = null;
URI expected = null;
try {
originalURI = new URI("rse", "recoskie@dbgaix3.torolab.ibm.com:1000", "/home/recoskie", null, null);
- expected = new URI("rse", "recoskie", "dbgaix3.torolab.ibm.com", 1000, "/home/recoskie/subdirectory", null, null);
+ expected = new URI("rse", "recoskie", "dbgaix3.torolab.ibm.com", 1000, "/home/recoskie/subdirectory", null,
+ null);
} catch (URISyntaxException e) {
fail(e.getMessage());
}
- String workingDirPath = EFSExtensionManager.getDefault()
- .getPathFromURI(originalURI);
+ String workingDirPath = EFSExtensionManager.getDefault().getPathFromURI(originalURI);
IPath path = new Path("subdirectory");
IPath newPath = new Path(workingDirPath).append(path).makeAbsolute();
- URI uri = EFSExtensionManager.getDefault()
- .createNewURIFromPath(originalURI, newPath.toString());
-
+ URI uri = EFSExtensionManager.getDefault().createNewURIFromPath(originalURI, newPath.toString());
+
assertEquals(expected, uri);
- }
-
+ }
+
public void testAppendinRSEURI() {
URI originalURI = null;
URI expected = null;
@@ -180,12 +168,12 @@ public class EFSExtensionTests extends TestCase {
} catch (URISyntaxException e) {
fail(e.getMessage());
}
-
+
URI uri = EFSExtensionManager.getDefault().append(originalURI, "subdirectory");
-
+
assertEquals(expected, uri);
}
-
+
public void testAppendToUNIXURI() {
URI originalURI = null;
URI expected = null;
@@ -195,12 +183,12 @@ public class EFSExtensionTests extends TestCase {
} catch (URISyntaxException e) {
fail(e.getMessage());
}
-
+
URI uri = EFSExtensionManager.getDefault().append(originalURI, "subdirectory");
-
+
assertEquals(expected, uri);
}
-
+
public void testAppendToWindowsURI() {
URI originalURI = null;
URI expected = null;
@@ -210,67 +198,67 @@ public class EFSExtensionTests extends TestCase {
} catch (URISyntaxException e) {
fail(e.getMessage());
}
-
+
URI uri = EFSExtensionManager.getDefault().append(originalURI, "subdirectory");
-
+
assertEquals(expected, uri);
}
-
+
public void testGetLinkedURI() {
URI originalURI = null;
try {
originalURI = new URI("file", "/c:/foo", null);
- } catch(URISyntaxException e) {
+ } catch (URISyntaxException e) {
fail(e.getMessage());
}
-
+
URI uri = EFSExtensionManager.getDefault().getLinkedURI(originalURI);
-
+
assertEquals(originalURI, uri);
}
-
+
public void testGetMappedPath() {
URI originalURI = null;
try {
originalURI = new URI("file", "/c:/foo", null);
- } catch(URISyntaxException e) {
+ } catch (URISyntaxException e) {
fail(e.getMessage());
}
-
+
String path = EFSExtensionManager.getDefault().getMappedPath(originalURI);
-
+
if (Platform.getOS().equals(Platform.WS_WIN32)) {
assertEquals(path, "c:/foo");
} else {
assertEquals(path, "/c:/foo");
}
}
-
+
public void testGetPathFromURI() {
URI originalURI = null;
try {
originalURI = new URI("file", "/c:/foo", null);
- } catch(URISyntaxException e) {
+ } catch (URISyntaxException e) {
fail(e.getMessage());
}
-
+
String path = EFSExtensionManager.getDefault().getMappedPath(originalURI);
-
+
if (Platform.getOS().equals(Platform.WS_WIN32)) {
assertEquals(path, "c:/foo");
} else {
assertEquals(path, "/c:/foo");
}
}
-
+
public void testExtension() {
URI originalURI = null;
try {
originalURI = new URI("EFSExtensionProviderTestsScheme", "/some/silly/path", null);
- } catch(URISyntaxException e) {
+ } catch (URISyntaxException e) {
fail(e.getMessage());
}
-
+
assertTrue(EFSExtensionManager.getDefault().isVirtual(originalURI));
}
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserEfsFileMatchingTest.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserEfsFileMatchingTest.java
index c64b0957293..2455514acc8 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserEfsFileMatchingTest.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserEfsFileMatchingTest.java
@@ -58,7 +58,8 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
private final IMarkerGenerator markerGenerator = new IMarkerGenerator() {
// deprecated
@Override
- public void addMarker(IResource file, int lineNumber, String errorDesc, int severity, String errorVar) {}
+ public void addMarker(IResource file, int lineNumber, String errorDesc, int severity, String errorVar) {
+ }
@Override
public void addMarker(ProblemMarkerInfo problemMarkerInfo) {
@@ -75,8 +76,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
*/
public MockErrorParser() {
super(new ErrorPattern[] {
- new ErrorPattern("(.*):(.*):(.*)", 1, 2, 3, 0, IMarkerGenerator.SEVERITY_ERROR_RESOURCE)
- });
+ new ErrorPattern("(.*):(.*):(.*)", 1, 2, 3, 0, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) });
}
}
@@ -91,7 +91,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
@Override
protected void setUp() throws Exception {
- if (fProject==null) {
+ if (fProject == null) {
fProject = ResourceHelper.createCDTProject(testName);
Assert.assertNotNull(fProject);
mockErrorParserId = addErrorParserExtension("MockErrorParser", MockErrorParser.class);
@@ -187,7 +187,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
* Convenience method to parse one line of output.
*/
private void parseOutput(IProject project, String buildDir, String line) throws Exception {
- parseOutput(project, new Path(buildDir), new String[] {mockErrorParserId}, line);
+ parseOutput(project, new Path(buildDir), new String[] { mockErrorParserId }, line);
}
/**
@@ -195,7 +195,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
* Search is done in project location.
*/
private void parseOutput(IProject project, String line) throws Exception {
- parseOutput(project, project.getLocation(), new String[] {mockErrorParserId}, line);
+ parseOutput(project, project.getLocation(), new String[] { mockErrorParserId }, line);
}
/**
@@ -203,7 +203,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
* Search is done for current project in default location.
*/
private void parseOutput(String line) throws Exception {
- parseOutput(fProject, fProject.getLocation(), new String[] {mockErrorParserId}, line);
+ parseOutput(fProject, fProject.getLocation(), new String[] { mockErrorParserId }, line);
}
/**
@@ -217,8 +217,8 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesEfsTest/testSingle.c",problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesEfsTest/testSingle.c", problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -233,8 +233,8 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesEfsTest/testEfsVsRegular.c",problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesEfsTest/testEfsVsRegular.c", problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -243,15 +243,14 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
*/
public void testFullPath() throws Exception {
ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder");
- ResourceHelper.createEfsFile(fProject, "Folder/testFullPath.c",
- "null:/EfsFolder/efsTestFullPath.c");
+ ResourceHelper.createEfsFile(fProject, "Folder/testFullPath.c", "null:/EfsFolder/efsTestFullPath.c");
parseOutput("EfsFolder/efsTestFullPath.c:1:error");
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesEfsTest/Folder/testFullPath.c",problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesEfsTest/Folder/testFullPath.c", problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
}
@@ -268,8 +267,8 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesEfsTest/NonEfsFolder/testInNonEfsFolder.c",problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesEfsTest/NonEfsFolder/testInNonEfsFolder.c", problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
}
@@ -279,15 +278,14 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
*/
public void testInFolder() throws Exception {
ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder");
- ResourceHelper.createEfsFile(fProject, "Folder/testInFolder.c",
- "null:/EfsFolder/efsTestInFolder.c");
+ ResourceHelper.createEfsFile(fProject, "Folder/testInFolder.c", "null:/EfsFolder/efsTestInFolder.c");
parseOutput("efsTestInFolder.c:1:error");
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesEfsTest/Folder/testInFolder.c",problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesEfsTest/Folder/testInFolder.c", problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
}
@@ -299,17 +297,16 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
ResourceHelper.createEfsFile(fProject, "testDuplicateInRoot.c", "null:/testDuplicateInRoot.c");
ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder");
- ResourceHelper.createEfsFile(fProject, "Folder/testDuplicateInRoot.c",
- "null:/Folder/testDuplicateInRoot.c");
+ ResourceHelper.createEfsFile(fProject, "Folder/testDuplicateInRoot.c", "null:/Folder/testDuplicateInRoot.c");
// Resolved to the file in root folder
parseOutput("testDuplicateInRoot.c:1:error");
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("L/FindMatchingFilesEfsTest/testDuplicateInRoot.c",problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("L/FindMatchingFilesEfsTest/testDuplicateInRoot.c", problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -325,9 +322,10 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesEfsTest/Folder/testRelativePathFromProjectRoot.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesEfsTest/Folder/testRelativePathFromProjectRoot.c",
+ problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -344,9 +342,10 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesEfsTest/Subfolder/Folder/testRelativePathFromSubfolder.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesEfsTest/Subfolder/Folder/testRelativePathFromSubfolder.c",
+ problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -363,10 +362,10 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
// No match
- assertEquals("P/FindMatchingFilesEfsTest",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
- assertEquals(new Path("NotMatchingFolder/testRelativePathNotMatchingFolder.c"),problemMarkerInfo.externalPath);
+ assertEquals("P/FindMatchingFilesEfsTest", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
+ assertEquals(new Path("NotMatchingFolder/testRelativePathNotMatchingFolder.c"), problemMarkerInfo.externalPath);
}
/**
@@ -388,10 +387,10 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
// No match found
- assertEquals("P/FindMatchingFilesEfsTest",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
- assertEquals(new Path("Folder/testRelativePathDuplicate.c"),problemMarkerInfo.externalPath);
+ assertEquals("P/FindMatchingFilesEfsTest", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
+ assertEquals(new Path("Folder/testRelativePathDuplicate.c"), problemMarkerInfo.externalPath);
}
/**
@@ -407,9 +406,10 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesEfsTest/Folder/testRelativePathUpSubfolder.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesEfsTest/Folder/testRelativePathUpSubfolder.c",
+ problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -426,9 +426,10 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesEfsTest/Subfolder/Folder/testRelativePathDotFromSubfolder.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesEfsTest/Subfolder/Folder/testRelativePathDotFromSubfolder.c",
+ problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -446,9 +447,9 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesEfsTest/BuildDir/testBuildDir.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesEfsTest/BuildDir/testBuildDir.c", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -467,8 +468,8 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/EfsProject/Folder/testEfsProject.c",problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/EfsProject/Folder/testEfsProject.c", problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -485,12 +486,12 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
ResourceHelper.createFile(efsProject, "BuildDir/" + fileName);
URI buildDirURI = new URI("mem:/EfsProject/BuildDir/");
- parseOutput(efsProject, buildDirURI, new String[] {mockErrorParserId}, fileName+":1:error");
+ parseOutput(efsProject, buildDirURI, new String[] { mockErrorParserId }, fileName + ":1:error");
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/EfsProject/BuildDir/"+fileName,problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/EfsProject/BuildDir/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -505,21 +506,19 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
ResourceHelper.createFolder(efsProject, "Folder");
ResourceHelper.createFolder(efsProject, "Folder/SubFolder");
ResourceHelper.createFile(efsProject, fileName);
- ResourceHelper.createFile(efsProject, "Folder/"+fileName);
- ResourceHelper.createFile(efsProject, "Folder/SubFolder/"+fileName);
+ ResourceHelper.createFile(efsProject, "Folder/" + fileName);
+ ResourceHelper.createFile(efsProject, "Folder/SubFolder/" + fileName);
- String lines = "make[1]: Entering directory `Folder'\n"
- + "make[2]: Entering directory `SubFolder'\n"
- + "make[2]: Leaving directory `SubFolder'\n"
- + fileName+":1:error\n";
+ String lines = "make[1]: Entering directory `Folder'\n" + "make[2]: Entering directory `SubFolder'\n"
+ + "make[2]: Leaving directory `SubFolder'\n" + fileName + ":1:error\n";
- String[] errorParsers = {MAKE_ERRORPARSER_ID, mockErrorParserId };
+ String[] errorParsers = { MAKE_ERRORPARSER_ID, mockErrorParserId };
parseOutput(efsProject, efsProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/EfsProject/Folder/"+fileName,problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/EfsProject/Folder/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserFileMatchingTest.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserFileMatchingTest.java
index 12fc14873d4..246863aa110 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserFileMatchingTest.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserFileMatchingTest.java
@@ -61,7 +61,8 @@ public class ErrorParserFileMatchingTest extends TestCase {
private final IMarkerGenerator markerGenerator = new IMarkerGenerator() {
// deprecated
@Override
- public void addMarker(IResource file, int lineNumber, String errorDesc, int severity, String errorVar) {}
+ public void addMarker(IResource file, int lineNumber, String errorDesc, int severity, String errorVar) {
+ }
@Override
public void addMarker(ProblemMarkerInfo problemMarkerInfo) {
@@ -78,12 +79,10 @@ public class ErrorParserFileMatchingTest extends TestCase {
*/
public MockErrorParser() {
super(new ErrorPattern[] {
- new ErrorPattern("(.*):(.*):(.*)", 1, 2, 3, 0, IMarkerGenerator.SEVERITY_ERROR_RESOURCE)
- });
+ new ErrorPattern("(.*):(.*):(.*)", 1, 2, 3, 0, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) });
}
}
-
/**
* Constructor.
* @param name - name of the test.
@@ -95,7 +94,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
@Override
protected void setUp() throws Exception {
- if (fProject==null) {
+ if (fProject == null) {
fProject = ResourceHelper.createCDTProject(testName);
Assert.assertNotNull(fProject);
mockErrorParserId = addErrorParserExtension("MockErrorParser", MockErrorParser.class);
@@ -172,7 +171,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Convenience method to parse one line of output.
*/
private void parseOutput(IProject project, String buildDir, String line) throws Exception {
- parseOutput(project, new Path(buildDir), new String[] {mockErrorParserId}, line);
+ parseOutput(project, new Path(buildDir), new String[] { mockErrorParserId }, line);
}
/**
@@ -180,7 +179,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Search is done in project location.
*/
private void parseOutput(IProject project, String line) throws Exception {
- parseOutput(project, project.getLocation(), new String[] {mockErrorParserId}, line);
+ parseOutput(project, project.getLocation(), new String[] { mockErrorParserId }, line);
}
/**
@@ -188,7 +187,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Search is done for current project in default location.
*/
private void parseOutput(String line) throws Exception {
- parseOutput(fProject, fProject.getLocation(), new String[] {mockErrorParserId}, line);
+ parseOutput(fProject, fProject.getLocation(), new String[] { mockErrorParserId }, line);
}
/**
@@ -202,9 +201,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/testSingle.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/testSingle.c", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -218,10 +217,10 @@ public class ErrorParserFileMatchingTest extends TestCase {
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
// No match found
- assertEquals("P/FindMatchingFilesTest",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
- assertEquals(new Path("testMissing.c"),problemMarkerInfo.externalPath);
+ assertEquals("P/FindMatchingFilesTest", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
+ assertEquals(new Path("testMissing.c"), problemMarkerInfo.externalPath);
}
/**
@@ -240,9 +239,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
// Ambiguous match
- assertEquals("P/FindMatchingFilesTest",problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
- assertEquals(new Path("testDuplicate.c"),problemMarkerInfo.externalPath);
+ assertEquals("P/FindMatchingFilesTest", problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
+ assertEquals(new Path("testDuplicate.c"), problemMarkerInfo.externalPath);
}
/**
@@ -257,8 +256,8 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/Folder/testInFolder.c",problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Folder/testInFolder.c", problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -276,9 +275,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("L/FindMatchingFilesTest/testDuplicateInRoot.c",problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("L/FindMatchingFilesTest/testDuplicateInRoot.c", problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -295,8 +294,8 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/Folder/testLinkedFile.c",problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Folder/testLinkedFile.c", problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -313,8 +312,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/Folder/testLinkedFileWithDifferentName.c",problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Folder/testLinkedFileWithDifferentName.c",
+ problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -337,9 +337,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
// Ambiguous match
- assertEquals("P/FindMatchingFilesTest",problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
- assertEquals(new Path("testDuplicateLinkedFile.c"),problemMarkerInfo.externalPath);
+ assertEquals("P/FindMatchingFilesTest", problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
+ assertEquals(new Path("testDuplicateLinkedFile.c"), problemMarkerInfo.externalPath);
}
/**
@@ -361,9 +361,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
// No match found
- assertEquals("P/FindMatchingFilesTest",problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
- assertEquals(new Path("testDuplicateLinkedFileDifferentName.c"),problemMarkerInfo.externalPath);
+ assertEquals("P/FindMatchingFilesTest", problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
+ assertEquals(new Path("testDuplicateLinkedFileDifferentName.c"), problemMarkerInfo.externalPath);
}
/**
@@ -379,8 +379,8 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/LinkedFolder/testInLinkedFolder.c",problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/LinkedFolder/testInLinkedFolder.c", problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -401,9 +401,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
// No match found
- assertEquals("P/FindMatchingFilesTest",problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
- assertEquals(new Path("testDuplicateInLinkedFolder.c"),problemMarkerInfo.externalPath);
+ assertEquals("P/FindMatchingFilesTest", problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
+ assertEquals(new Path("testDuplicateInLinkedFolder.c"), problemMarkerInfo.externalPath);
}
/**
@@ -411,19 +411,20 @@ public class ErrorParserFileMatchingTest extends TestCase {
* @throws Exception...
*/
public void testLinkedFolderInAnotherProject() throws Exception {
- ResourceHelper.createFolder(fProject,"Folder");
- ResourceHelper.createFile(fProject,"Folder/testLinkedFolderInAnotherProject.c");
+ ResourceHelper.createFolder(fProject, "Folder");
+ ResourceHelper.createFile(fProject, "Folder/testLinkedFolderInAnotherProject.c");
IProject anotherProject = ResourceHelper.createCDTProject("AnotherProjectWithLinkedFolder");
- ResourceHelper.createLinkedFolder(anotherProject, "LinkedFolder", fProject.getLocation()+"/Folder");
+ ResourceHelper.createLinkedFolder(anotherProject, "LinkedFolder", fProject.getLocation() + "/Folder");
{
parseOutput(fProject, "testLinkedFolderInAnotherProject.c:1:error");
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/Folder/testLinkedFolderInAnotherProject.c",problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Folder/testLinkedFolderInAnotherProject.c",
+ problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
}
{
@@ -431,8 +432,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(2, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(1);
- assertEquals("L/AnotherProjectWithLinkedFolder/LinkedFolder/testLinkedFolderInAnotherProject.c",problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/AnotherProjectWithLinkedFolder/LinkedFolder/testLinkedFolderInAnotherProject.c",
+ problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
}
}
@@ -448,15 +450,15 @@ public class ErrorParserFileMatchingTest extends TestCase {
ResourceHelper.createWorkspaceFolder("OutsideFolder");
IPath realFile = ResourceHelper.createWorkspaceFile("OutsideFolder/RealFile.c");
- ResourceHelper.createFolder(fProject,"Folder");
+ ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createSymbolicLink(fProject, "Folder/testSymbolicLink.c", realFile);
parseOutput("testSymbolicLink.c:1:error");
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/Folder/testSymbolicLink.c",problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Folder/testSymbolicLink.c", problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -471,10 +473,10 @@ public class ErrorParserFileMatchingTest extends TestCase {
ResourceHelper.createWorkspaceFolder("OutsideFolder");
IPath realFile = ResourceHelper.createWorkspaceFile("OutsideFolder/RealFile.c");
- ResourceHelper.createFolder(fProject,"FolderA");
+ ResourceHelper.createFolder(fProject, "FolderA");
ResourceHelper.createSymbolicLink(fProject, "FolderA/testDuplicateSymbolicLink.c", realFile);
- ResourceHelper.createFolder(fProject,"FolderB");
+ ResourceHelper.createFolder(fProject, "FolderB");
ResourceHelper.createSymbolicLink(fProject, "FolderB/testDuplicateSymbolicLink.c", realFile);
parseOutput("testDuplicateSymbolicLink.c:1:error");
@@ -482,9 +484,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
// No match found
- assertEquals("P/FindMatchingFilesTest",problemMarkerInfo.file.toString());
- assertEquals(new Path("testDuplicateSymbolicLink.c"),problemMarkerInfo.externalPath);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("P/FindMatchingFilesTest", problemMarkerInfo.file.toString());
+ assertEquals(new Path("testDuplicateSymbolicLink.c"), problemMarkerInfo.externalPath);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -505,8 +507,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/FolderSymbolicLink/testFolderSymbolicLink.c",problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/FolderSymbolicLink/testFolderSymbolicLink.c",
+ problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -529,9 +532,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
// No match found
- assertEquals("P/FindMatchingFilesTest",problemMarkerInfo.file.toString());
- assertEquals(new Path("testDuplicateFolderSymbolicLink.c"),problemMarkerInfo.externalPath);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("P/FindMatchingFilesTest", problemMarkerInfo.file.toString());
+ assertEquals(new Path("testDuplicateFolderSymbolicLink.c"), problemMarkerInfo.externalPath);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -542,13 +545,13 @@ public class ErrorParserFileMatchingTest extends TestCase {
ResourceHelper.createFile(fProject, "testAbsolutePathSingle.c");
String fullName = fProject.getLocation().append("testAbsolutePathSingle.c").toOSString();
- parseOutput(fullName+":1:error");
+ parseOutput(fullName + ":1:error");
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/testAbsolutePathSingle.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/testAbsolutePathSingle.c", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -560,13 +563,14 @@ public class ErrorParserFileMatchingTest extends TestCase {
ResourceHelper.createFile(anotherProject, "testAbsolutePathInOtherProject.c");
String fullName = anotherProject.getLocation().append("testAbsolutePathInOtherProject.c").toOSString();
- parseOutput(fullName+":1:error");
+ parseOutput(fullName + ":1:error");
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/ProjectAbsolutePathInOtherProject/testAbsolutePathInOtherProject.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/ProjectAbsolutePathInOtherProject/testAbsolutePathInOtherProject.c",
+ problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -579,15 +583,15 @@ public class ErrorParserFileMatchingTest extends TestCase {
IPath outsideFile = ResourceHelper.createWorkspaceFile("OutsideFolder/testAbsolutePathOutsideWorkspace.c");
String fullName = ResourcesPlugin.getWorkspace().getRoot().getLocation()
- .append("OutsideFolder/testAbsolutePathOutsideWorkspace.c").toOSString();
+ .append("OutsideFolder/testAbsolutePathOutsideWorkspace.c").toOSString();
- parseOutput(fullName+":1:error");
+ parseOutput(fullName + ":1:error");
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
// Can't assign marker to non-IResource
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
assertEquals(outsideFile, problemMarkerInfo.externalPath);
}
@@ -603,9 +607,10 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/Folder/testRelativePathFromProjectRoot.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Folder/testRelativePathFromProjectRoot.c",
+ problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -621,9 +626,10 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/Folder/SubFolder/testRelativePathFromSubfolder.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Folder/SubFolder/testRelativePathFromSubfolder.c",
+ problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -639,10 +645,10 @@ public class ErrorParserFileMatchingTest extends TestCase {
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
// No match
- assertEquals("P/FindMatchingFilesTest",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
- assertEquals(new Path("NotMatchingFolder/testRelativePathNotMatchingFolder.c"),problemMarkerInfo.externalPath);
+ assertEquals("P/FindMatchingFilesTest", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
+ assertEquals(new Path("NotMatchingFolder/testRelativePathNotMatchingFolder.c"), problemMarkerInfo.externalPath);
}
/**
@@ -662,10 +668,10 @@ public class ErrorParserFileMatchingTest extends TestCase {
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
// No match found
- assertEquals("P/FindMatchingFilesTest",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
- assertEquals(new Path("Folder/testRelativePathDuplicate.c"),problemMarkerInfo.externalPath);
+ assertEquals("P/FindMatchingFilesTest", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
+ assertEquals(new Path("Folder/testRelativePathDuplicate.c"), problemMarkerInfo.externalPath);
}
/**
@@ -679,9 +685,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/testRelativePathUp.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/testRelativePathUp.c", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -696,9 +702,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/Folder/testRelativePathUpSubfolder.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Folder/testRelativePathUpSubfolder.c", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -713,9 +719,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/AnotherProject/testRelativePathUpOtherProject.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/AnotherProject/testRelativePathUpOtherProject.c", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -733,10 +739,10 @@ public class ErrorParserFileMatchingTest extends TestCase {
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
// No match found
- assertEquals("P/FindMatchingFilesTest",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
- assertEquals(new Path("../SubFolder/testRelativePathUpDuplicate.c"),problemMarkerInfo.externalPath);
+ assertEquals("P/FindMatchingFilesTest", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
+ assertEquals(new Path("../SubFolder/testRelativePathUpDuplicate.c"), problemMarkerInfo.externalPath);
}
/**
@@ -751,9 +757,10 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/Folder/testRelativePathDotFromProjectRoot.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Folder/testRelativePathDotFromProjectRoot.c",
+ problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -769,9 +776,10 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/Subfolder/Folder/testRelativePathDotFromSubfolder.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Subfolder/Folder/testRelativePathDotFromSubfolder.c",
+ problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -787,10 +795,11 @@ public class ErrorParserFileMatchingTest extends TestCase {
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
// No match
- assertEquals("P/FindMatchingFilesTest",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
- assertEquals(new Path("./NotMatchingFolder/testRelativePathDotNotMatchingFolder.c"),problemMarkerInfo.externalPath);
+ assertEquals("P/FindMatchingFilesTest", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
+ assertEquals(new Path("./NotMatchingFolder/testRelativePathDotNotMatchingFolder.c"),
+ problemMarkerInfo.externalPath);
}
/**
@@ -811,13 +820,12 @@ public class ErrorParserFileMatchingTest extends TestCase {
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
// No match found
- assertEquals("P/FindMatchingFilesTest",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
- assertEquals(new Path("./Folder/testRelativePathDotDuplicate.c"),problemMarkerInfo.externalPath);
+ assertEquals("P/FindMatchingFilesTest", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
+ assertEquals(new Path("./Folder/testRelativePathDotDuplicate.c"), problemMarkerInfo.externalPath);
}
-
/**
* Checks if a file from error output can be found.
* @throws Exception...
@@ -834,9 +842,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/upcase1.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/upcase1.c", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -852,9 +860,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/Folder/UPCASE2.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Folder/UPCASE2.c", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -872,9 +880,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/FolderB/UpCase3.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/FolderB/UpCase3.c", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -893,10 +901,10 @@ public class ErrorParserFileMatchingTest extends TestCase {
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
// No match found
- assertEquals("P/FindMatchingFilesTest",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
- assertEquals(new Path("UpCase4.c"),problemMarkerInfo.externalPath);
+ assertEquals("P/FindMatchingFilesTest", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
+ assertEquals(new Path("UpCase4.c"), problemMarkerInfo.externalPath);
}
/**
@@ -913,17 +921,17 @@ public class ErrorParserFileMatchingTest extends TestCase {
// Skip the test if Cygwin is not available.
return;
}
- assertTrue("cygwinFileName=["+cygwinFileName+"]", cygwinFileName.startsWith("/cygdrive/"));
+ assertTrue("cygwinFileName=[" + cygwinFileName + "]", cygwinFileName.startsWith("/cygdrive/"));
ResourceHelper.createFile(fProject, fileName);
- parseOutput(cygwinFileName+":1:error");
+ parseOutput(cygwinFileName + ":1:error");
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/"+fileName,problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -942,21 +950,21 @@ public class ErrorParserFileMatchingTest extends TestCase {
return;
}
- assertTrue("usrIncludeWindowsPath=["+usrIncludeWindowsPath+"]",
- usrIncludeWindowsPath.charAt(1)==IPath.DEVICE_SEPARATOR);
+ assertTrue("usrIncludeWindowsPath=[" + usrIncludeWindowsPath + "]",
+ usrIncludeWindowsPath.charAt(1) == IPath.DEVICE_SEPARATOR);
java.io.File file = new java.io.File(usrIncludeWindowsPath + "\\" + fileName);
assertTrue("File " + file + " does not exist, check your cygwin installation", file.exists());
ResourceHelper.createLinkedFolder(fProject, "include", usrIncludeWindowsPath);
- parseOutput(cygwinFolder+fileName+":1:error");
+ parseOutput(cygwinFolder + fileName + ":1:error");
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/include/"+fileName,problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/include/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -975,17 +983,17 @@ public class ErrorParserFileMatchingTest extends TestCase {
// Skip the test if Cygwin is not available.
return;
}
- assertTrue("cygwinFileName=["+cygwinFileName+"]", cygwinFileName.startsWith("/cygdrive/"));
+ assertTrue("cygwinFileName=[" + cygwinFileName + "]", cygwinFileName.startsWith("/cygdrive/"));
ResourceHelper.createFile(anotherProject, fileName);
- parseOutput(cygwinFileName+":1:error");
+ parseOutput(cygwinFileName + ":1:error");
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/AnotherProject/"+fileName,problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/AnotherProject/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -995,7 +1003,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
public void testCustomProjectLocation() throws Exception {
ResourceHelper.createWorkspaceFolder("Custom");
ResourceHelper.createWorkspaceFolder("Custom/ProjectLocation");
- IProject anotherProject = ResourceHelper.createCDTProject("AnotherProject", "Custom/ProjectLocation");
+ IProject anotherProject = ResourceHelper.createCDTProject("AnotherProject", "Custom/ProjectLocation");
ResourceHelper.createFolder(anotherProject, "Folder");
ResourceHelper.createFile(anotherProject, "Folder/testCustomProjectLocation.c");
@@ -1004,9 +1012,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/AnotherProject/Folder/testCustomProjectLocation.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/AnotherProject/Folder/testCustomProjectLocation.c", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -1024,21 +1032,20 @@ public class ErrorParserFileMatchingTest extends TestCase {
// Skip the test if Cygwin is not available.
return;
}
- assertTrue("cygwinFileName=["+cygwinFileName+"]", cygwinFileName.startsWith("/cygdrive/"));
+ assertTrue("cygwinFileName=[" + cygwinFileName + "]", cygwinFileName.startsWith("/cygdrive/"));
ResourceHelper.createFile(fProject, fileName);
- String lines = "make[0]: Entering directory `dir'\n"
- + cygwinFileName+":1:error\n";
+ String lines = "make[0]: Entering directory `dir'\n" + cygwinFileName + ":1:error\n";
- String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
+ String[] errorParsers = { CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/"+fileName,problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -1047,7 +1054,8 @@ public class ErrorParserFileMatchingTest extends TestCase {
*/
public void testInNestedProject() throws Exception {
ResourceHelper.createFolder(fProject, "NestedProjectFolder");
- IProject nestedProject = ResourceHelper.createCDTProject("NestedProject", "FindMatchingFilesTest/NestedProject");
+ IProject nestedProject = ResourceHelper.createCDTProject("NestedProject",
+ "FindMatchingFilesTest/NestedProject");
ResourceHelper.createFolder(nestedProject, "Folder");
ResourceHelper.createFile(nestedProject, "Folder/testInNestedProject.c");
@@ -1057,9 +1065,10 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/NestedProject/Folder/testInNestedProject.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/NestedProject/Folder/testInNestedProject.c",
+ problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
{
@@ -1067,9 +1076,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(2, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(1);
- assertEquals("L/NestedProject/Folder/testInNestedProject.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/NestedProject/Folder/testInNestedProject.c", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
}
@@ -1088,9 +1097,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/BuildDir/testBuildDir.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/BuildDir/testBuildDir.c", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -1107,9 +1116,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/BuildDir/testBuildDirVsProjectRoot.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/BuildDir/testBuildDirVsProjectRoot.c", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -1123,13 +1132,13 @@ public class ErrorParserFileMatchingTest extends TestCase {
String fullName = file.getLocation().toOSString();
ResourceHelper.createLinkedFile(fProject, "testAbsoluteFileVsLink.c", file.getLocation());
- parseOutput(fullName+":1:error");
+ parseOutput(fullName + ":1:error");
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/Folder/testAbsoluteFileVsLink.c",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Folder/testAbsoluteFileVsLink.c", problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -1141,19 +1150,18 @@ public class ErrorParserFileMatchingTest extends TestCase {
String fileName = "testPushDirectory.c";
ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, fileName);
- ResourceHelper.createFile(fProject, "Folder/"+fileName);
+ ResourceHelper.createFile(fProject, "Folder/" + fileName);
- String lines = "make[0]: Entering directory `Folder'\n"
- + fileName+":1:error\n";
+ String lines = "make[0]: Entering directory `Folder'\n" + fileName + ":1:error\n";
- String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
+ String[] errorParsers = { CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/Folder/"+fileName,problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Folder/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -1166,19 +1174,18 @@ public class ErrorParserFileMatchingTest extends TestCase {
String fileName = "testPushDirectory.c";
ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, fileName);
- ResourceHelper.createFile(fProject, "Folder/"+fileName);
+ ResourceHelper.createFile(fProject, "Folder/" + fileName);
- String lines = "make[0]: Entering directory 'Folder'\n"
- + fileName+":1:error\n";
+ String lines = "make[0]: Entering directory 'Folder'\n" + fileName + ":1:error\n";
- String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
+ String[] errorParsers = { CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/Folder/"+fileName,problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Folder/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -1190,22 +1197,21 @@ public class ErrorParserFileMatchingTest extends TestCase {
String fileName = "testPushAbsoluteDirectory.c";
IFolder folder = ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, fileName);
- ResourceHelper.createFile(fProject, "Folder/"+fileName);
+ ResourceHelper.createFile(fProject, "Folder/" + fileName);
IPath absoluteDir = folder.getLocation();
Assert.assertTrue(absoluteDir.isAbsolute());
- String lines = "make[0]: Entering directory `" + absoluteDir + "'\n"
- + fileName+":1:error\n";
+ String lines = "make[0]: Entering directory `" + absoluteDir + "'\n" + fileName + ":1:error\n";
- String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
+ String[] errorParsers = { CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/Folder/"+fileName,problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Folder/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -1220,22 +1226,20 @@ public class ErrorParserFileMatchingTest extends TestCase {
ResourceHelper.createFolder(fProject, "Folder/SubFolder");
ResourceHelper.createFile(fProject, fileName);
- ResourceHelper.createFile(fProject, "Folder/"+fileName);
- ResourceHelper.createFile(fProject, "Folder/SubFolder/"+fileName);
+ ResourceHelper.createFile(fProject, "Folder/" + fileName);
+ ResourceHelper.createFile(fProject, "Folder/SubFolder/" + fileName);
- String lines = "make[1]: Entering directory `Folder'\n"
- + "make[2]: Entering directory `SubFolder'\n"
- + "make[2]: Leaving directory `SubFolder'\n"
- + fileName+":1:error\n";
+ String lines = "make[1]: Entering directory `Folder'\n" + "make[2]: Entering directory `SubFolder'\n"
+ + "make[2]: Leaving directory `SubFolder'\n" + fileName + ":1:error\n";
- String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
+ String[] errorParsers = { CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/Folder/"+fileName,problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Folder/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -1250,22 +1254,20 @@ public class ErrorParserFileMatchingTest extends TestCase {
ResourceHelper.createFolder(fProject, "Folder/SubFolder");
ResourceHelper.createFile(fProject, fileName);
- ResourceHelper.createFile(fProject, "Folder/"+fileName);
- ResourceHelper.createFile(fProject, "Folder/SubFolder/"+fileName);
+ ResourceHelper.createFile(fProject, "Folder/" + fileName);
+ ResourceHelper.createFile(fProject, "Folder/SubFolder/" + fileName);
- String lines = "make: Entering directory `Folder'\n"
- + "make: Entering directory `SubFolder'\n"
- + "make: Leaving directory `SubFolder'\n"
- + fileName+":1:error\n";
+ String lines = "make: Entering directory `Folder'\n" + "make: Entering directory `SubFolder'\n"
+ + "make: Leaving directory `SubFolder'\n" + fileName + ":1:error\n";
- String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
+ String[] errorParsers = { CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/Folder/"+fileName,problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Folder/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -1277,28 +1279,26 @@ public class ErrorParserFileMatchingTest extends TestCase {
String fileName = "testPushDirectoryCacheProblem.c";
ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, fileName);
- ResourceHelper.createFile(fProject, "Folder/"+fileName);
+ ResourceHelper.createFile(fProject, "Folder/" + fileName);
- String lines = fileName+":1:error\n"
- + "make[0]: Entering directory `Folder'\n"
- + fileName+":1:error\n";
+ String lines = fileName + ":1:error\n" + "make[0]: Entering directory `Folder'\n" + fileName + ":1:error\n";
- String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
+ String[] errorParsers = { CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(2, errorList.size());
{
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/"+fileName,problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
{
ProblemMarkerInfo problemMarkerInfo = errorList.get(1);
- assertEquals("L/FindMatchingFilesTest/Folder/"+fileName,problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Folder/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
}
@@ -1308,23 +1308,21 @@ public class ErrorParserFileMatchingTest extends TestCase {
* @throws Exception...
*/
public void testDisablePushDirectoryOnParallelBuild_J() throws Exception {
- String fileName = getName()+".c";
+ String fileName = getName() + ".c";
ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, fileName);
- ResourceHelper.createFile(fProject, "Folder/"+fileName);
+ ResourceHelper.createFile(fProject, "Folder/" + fileName);
- String lines = "make -j\n"
- + "make[0]: Entering directory `Folder'\n"
- + fileName+":1:error\n";
+ String lines = "make -j\n" + "make[0]: Entering directory `Folder'\n" + fileName + ":1:error\n";
- String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
+ String[] errorParsers = { CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/"+fileName,problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -1333,23 +1331,21 @@ public class ErrorParserFileMatchingTest extends TestCase {
* @throws Exception...
*/
public void testDisablePushDirectoryOnParallelBuild_J2() throws Exception {
- String fileName = getName()+".c";
+ String fileName = getName() + ".c";
ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, fileName);
- ResourceHelper.createFile(fProject, "Folder/"+fileName);
+ ResourceHelper.createFile(fProject, "Folder/" + fileName);
- String lines = "make -j2\n"
- + "make[0]: Entering directory `Folder'\n"
- + fileName+":1:error\n";
+ String lines = "make -j2\n" + "make[0]: Entering directory `Folder'\n" + fileName + ":1:error\n";
- String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
+ String[] errorParsers = { CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/"+fileName,problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -1358,23 +1354,21 @@ public class ErrorParserFileMatchingTest extends TestCase {
* @throws Exception...
*/
public void testDisablePushDirectoryOnParallelBuild_J_2() throws Exception {
- String fileName = getName()+".c";
+ String fileName = getName() + ".c";
ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, fileName);
- ResourceHelper.createFile(fProject, "Folder/"+fileName);
+ ResourceHelper.createFile(fProject, "Folder/" + fileName);
- String lines = "make -j 2\n"
- + "make[0]: Entering directory `Folder'\n"
- + fileName+":1:error\n";
+ String lines = "make -j 2\n" + "make[0]: Entering directory `Folder'\n" + fileName + ":1:error\n";
- String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
+ String[] errorParsers = { CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/"+fileName,problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -1383,23 +1377,21 @@ public class ErrorParserFileMatchingTest extends TestCase {
* @throws Exception...
*/
public void testDisablePushDirectoryOnParallelBuild_J1() throws Exception {
- String fileName = getName()+".c";
+ String fileName = getName() + ".c";
ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, fileName);
- ResourceHelper.createFile(fProject, "Folder/"+fileName);
+ ResourceHelper.createFile(fProject, "Folder/" + fileName);
- String lines = "make -j1\n"
- + "make[0]: Entering directory `Folder'\n"
- + fileName+":1:error\n";
+ String lines = "make -j1\n" + "make[0]: Entering directory `Folder'\n" + fileName + ":1:error\n";
- String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
+ String[] errorParsers = { CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/Folder/"+fileName,problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Folder/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -1408,23 +1400,21 @@ public class ErrorParserFileMatchingTest extends TestCase {
* @throws Exception...
*/
public void testDisablePushDirectoryOnParallelBuild_J_1() throws Exception {
- String fileName = getName()+".c";
+ String fileName = getName() + ".c";
ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, fileName);
- ResourceHelper.createFile(fProject, "Folder/"+fileName);
+ ResourceHelper.createFile(fProject, "Folder/" + fileName);
- String lines = "make -j 1\n"
- + "make[0]: Entering directory `Folder'\n"
- + fileName+":1:error\n";
+ String lines = "make -j 1\n" + "make[0]: Entering directory `Folder'\n" + fileName + ":1:error\n";
- String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
+ String[] errorParsers = { CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/Folder/"+fileName,problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Folder/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -1433,23 +1423,21 @@ public class ErrorParserFileMatchingTest extends TestCase {
* @throws Exception...
*/
public void testDisablePushDirectoryOnParallelBuild_Jobs() throws Exception {
- String fileName = getName()+".c";
+ String fileName = getName() + ".c";
ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, fileName);
- ResourceHelper.createFile(fProject, "Folder/"+fileName);
+ ResourceHelper.createFile(fProject, "Folder/" + fileName);
- String lines = "make --jobs=2\n"
- + "make[0]: Entering directory `Folder'\n"
- + fileName+":1:error\n";
+ String lines = "make --jobs=2\n" + "make[0]: Entering directory `Folder'\n" + fileName + ":1:error\n";
- String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
+ String[] errorParsers = { CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/"+fileName,problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -1458,23 +1446,21 @@ public class ErrorParserFileMatchingTest extends TestCase {
* @throws Exception...
*/
public void testDisablePushDirectoryOnParallelBuild_Jobs1() throws Exception {
- String fileName = getName()+".c";
+ String fileName = getName() + ".c";
ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, fileName);
- ResourceHelper.createFile(fProject, "Folder/"+fileName);
+ ResourceHelper.createFile(fProject, "Folder/" + fileName);
- String lines = "make --jobs=1\n"
- + "make[0]: Entering directory `Folder'\n"
- + fileName+":1:error\n";
+ String lines = "make --jobs=1\n" + "make[0]: Entering directory `Folder'\n" + fileName + ":1:error\n";
- String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
+ String[] errorParsers = { CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/Folder/"+fileName,problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Folder/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -1483,23 +1469,21 @@ public class ErrorParserFileMatchingTest extends TestCase {
* @throws Exception...
*/
public void testDisablePushDirectoryOnParallelBuild_gmake() throws Exception {
- String fileName = getName()+".c";
+ String fileName = getName() + ".c";
ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, fileName);
- ResourceHelper.createFile(fProject, "Folder/"+fileName);
+ ResourceHelper.createFile(fProject, "Folder/" + fileName);
- String lines = "gmake384 -k -j all\n"
- + "make[0]: Entering directory `Folder'\n"
- + fileName+":1:error\n";
+ String lines = "gmake384 -k -j all\n" + "make[0]: Entering directory `Folder'\n" + fileName + ":1:error\n";
- String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
+ String[] errorParsers = { CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/"+fileName,problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -1516,9 +1500,10 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/Folder/AbsoluteRemoteFolder/testMappedRemoteAbsolutePath.h",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/Folder/AbsoluteRemoteFolder/testMappedRemoteAbsolutePath.h",
+ problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -1532,15 +1517,18 @@ public class ErrorParserFileMatchingTest extends TestCase {
ResourceHelper.createFolder(anotherProject, "Folder");
ResourceHelper.createFolder(anotherProject, "Folder/AbsoluteRemoteFolder");
- IFile file = ResourceHelper.createFile(anotherProject, "Folder/AbsoluteRemoteFolder/testMappedRemoteAbsolutePathAnotherProject.h");
+ IFile file = ResourceHelper.createFile(anotherProject,
+ "Folder/AbsoluteRemoteFolder/testMappedRemoteAbsolutePathAnotherProject.h");
parseOutput("/AbsoluteRemoteFolder/testMappedRemoteAbsolutePathAnotherProject.h:1:error");
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/ProjectMappedRemoteAbsolutePathAnotherProject/Folder/AbsoluteRemoteFolder/testMappedRemoteAbsolutePathAnotherProject.h",problemMarkerInfo.file.toString());
- assertEquals(1,problemMarkerInfo.lineNumber);
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals(
+ "L/ProjectMappedRemoteAbsolutePathAnotherProject/Folder/AbsoluteRemoteFolder/testMappedRemoteAbsolutePathAnotherProject.h",
+ problemMarkerInfo.file.toString());
+ assertEquals(1, problemMarkerInfo.lineNumber);
+ assertEquals("error", problemMarkerInfo.description);
}
/**
@@ -1550,12 +1538,9 @@ public class ErrorParserFileMatchingTest extends TestCase {
*/
public void testWindowsPathOnLinux_Bug263977() throws Exception {
// This test is valid on Unix platforms only
- boolean isUnix = Platform.getOS().equals(Platform.OS_LINUX)
- || Platform.getOS().equals(Platform.OS_AIX)
- || Platform.getOS().equals(Platform.OS_SOLARIS)
- || Platform.getOS().equals(Platform.OS_HPUX)
- || Platform.getOS().equals(Platform.OS_QNX)
- || Platform.getOS().equals(Platform.OS_MACOSX);
+ boolean isUnix = Platform.getOS().equals(Platform.OS_LINUX) || Platform.getOS().equals(Platform.OS_AIX)
+ || Platform.getOS().equals(Platform.OS_SOLARIS) || Platform.getOS().equals(Platform.OS_HPUX)
+ || Platform.getOS().equals(Platform.OS_QNX) || Platform.getOS().equals(Platform.OS_MACOSX);
if (!isUnix) {
return;
}
@@ -1563,15 +1548,15 @@ public class ErrorParserFileMatchingTest extends TestCase {
String fileName = "testWindowsPathOnLinux_Bug263977.c";
ResourceHelper.createFolder(fProject, "w:/Folder/Subfolder");
- ResourceHelper.createFile(fProject, "w:/Folder/Subfolder/"+fileName);
+ ResourceHelper.createFile(fProject, "w:/Folder/Subfolder/" + fileName);
// Note that main intention of this test is to run on *Linux*, see bug 263977
- parseOutput("W:\\Folder\\Subfolder\\"+fileName+":1:error");
+ parseOutput("W:\\Folder\\Subfolder\\" + fileName + ":1:error");
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("L/FindMatchingFilesTest/w:/Folder/Subfolder/"+fileName,problemMarkerInfo.file.toString());
- assertEquals("error",problemMarkerInfo.description);
+ assertEquals("L/FindMatchingFilesTest/w:/Folder/Subfolder/" + fileName, problemMarkerInfo.file.toString());
+ assertEquals("error", problemMarkerInfo.description);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserManagerTest.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserManagerTest.java
index a66d1637c61..e9cc8dc7133 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserManagerTest.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserManagerTest.java
@@ -49,7 +49,7 @@ import junit.framework.TestSuite;
/**
* @author Alena Laskavaia
*
- * Tests for ErrorParser manager and different parsers
+ * Tests for ErrorParser manager and different parsers
*/
public class ErrorParserManagerTest extends TestCase {
IWorkspace workspace;
@@ -73,15 +73,15 @@ public class ErrorParserManagerTest extends TestCase {
* Sets up the test fixture.
*
* Called before every test case method.
- *
- * Example code test the packages in the project
+ *
+ * Example code test the packages in the project
* "com.qnx.tools.ide.cdt.core"
*/
@Override
protected void setUp() throws Exception {
/***
* The test of the tests assume that they have a working workspace
- * and workspace root object to use to create projects/files in,
+ * and workspace root object to use to create projects/files in,
* so we need to get them setup first.
*/
IWorkspaceDescription desc;
@@ -109,14 +109,9 @@ public class ErrorParserManagerTest extends TestCase {
errorList.add(problemMarkerInfo);
}
};
- String[] errorParsersIds = {
- "org.eclipse.cdt.core.CWDLocator",
- "org.eclipse.cdt.core.GCCErrorParser",
- "org.eclipse.cdt.core.GASErrorParser",
- "org.eclipse.cdt.core.GLDErrorParser",
- "org.eclipse.cdt.core.VCErrorParser",
- "org.eclipse.cdt.core.GmakeErrorParser",
- };
+ String[] errorParsersIds = { "org.eclipse.cdt.core.CWDLocator", "org.eclipse.cdt.core.GCCErrorParser",
+ "org.eclipse.cdt.core.GASErrorParser", "org.eclipse.cdt.core.GLDErrorParser",
+ "org.eclipse.cdt.core.VCErrorParser", "org.eclipse.cdt.core.GmakeErrorParser", };
epManager = new ErrorParserManager(cProject.getProject(), markerGenerator, errorParsersIds);
}
@@ -161,25 +156,25 @@ public class ErrorParserManagerTest extends TestCase {
output("catchpoints.cpp:12: warning: no return statement in function returning non-void\n");
end();
assertEquals(1, errorList.size());
-
+
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("no return statement in function returning non-void",problemMarkerInfo.description);
- assertEquals(new Path("catchpoints.cpp"),problemMarkerInfo.externalPath);
+ assertEquals("no return statement in function returning non-void", problemMarkerInfo.description);
+ assertEquals(new Path("catchpoints.cpp"), problemMarkerInfo.externalPath);
}
public void testParsersSanityTrimmed() throws CoreException, IOException {
output(" catchpoints.cpp:12: warning: no return statement in function returning non-void \n");
end();
assertEquals(1, errorList.size());
-
+
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("no return statement in function returning non-void",problemMarkerInfo.description);
- assertEquals(new Path("catchpoints.cpp"),problemMarkerInfo.externalPath);
+ assertEquals("no return statement in function returning non-void", problemMarkerInfo.description);
+ assertEquals(new Path("catchpoints.cpp"), problemMarkerInfo.externalPath);
}
public void testOutput() throws IOException {
- try (FileInputStream fileInputStream = new FileInputStream(CTestPlugin.getDefault().getFileInPlugin(
- new Path("resources/errortests/output-1")))) {
+ try (FileInputStream fileInputStream = new FileInputStream(
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/errortests/output-1")))) {
byte b[] = new byte[1024];
while (true) {
int k = fileInputStream.read(b);
@@ -209,6 +204,7 @@ public class ErrorParserManagerTest extends TestCase {
public static class TestParser1 implements IErrorParser2 {
String last = null;
+
@Override
public int getProcessLineBehaviour() {
return KEEP_UNTRIMMED;
@@ -216,8 +212,8 @@ public class ErrorParserManagerTest extends TestCase {
@Override
public boolean processLine(String line, ErrorParserManager eoParser) {
- if (line.startsWith(" ") && last!=null) {
- eoParser.generateExternalMarker(null, 1, last+line, 1, "", null);
+ if (line.startsWith(" ") && last != null) {
+ eoParser.generateExternalMarker(null, 1, last + line, 1, "", null);
return true;
}
if (line.startsWith("bug:")) {
@@ -230,18 +226,19 @@ public class ErrorParserManagerTest extends TestCase {
return false;
}
}
+
public void testNoTrimParser() throws IOException {
String id = addErrorParserExtension("test1", TestParser1.class);
epManager = new ErrorParserManager(cProject.getProject(), markerGenerator, new String[] { id });
-
+
output("bug: start\n");
output(" end");
end();
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
- assertEquals("bug: start end",problemMarkerInfo.description);
+ assertEquals("bug: start end", problemMarkerInfo.description);
}
-
+
public static class TestParser2 implements IErrorParser2 {
@Override
public int getProcessLineBehaviour() {
@@ -262,7 +259,7 @@ public class ErrorParserManagerTest extends TestCase {
public void testLongLinesParser() throws IOException {
String id = addErrorParserExtension("test2", TestParser2.class);
epManager = new ErrorParserManager(cProject.getProject(), markerGenerator, new String[] { id });
-
+
StringBuilder buf = new StringBuilder("errorT: ");
for (int i = 0; i < 100; i++) {
buf.append("la la la la la ").append(i).append(' ');
@@ -273,10 +270,10 @@ public class ErrorParserManagerTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
int l = problemMarkerInfo.description.length();
- assertTrue(l>1000);
- String end = problemMarkerInfo.description.substring(l-10,l);
+ assertTrue(l > 1000);
+ String end = problemMarkerInfo.description.substring(l - 10, l);
// check - line trimmed but long
- assertEquals("a la la 99",end);
+ assertEquals("a la la 99", end);
}
public static class TestParser3 implements IErrorParser2 {
@@ -299,7 +296,7 @@ public class ErrorParserManagerTest extends TestCase {
public void testLongLinesUntrimmedParser() throws IOException {
String id = addErrorParserExtension("test3", TestParser3.class);
epManager = new ErrorParserManager(cProject.getProject(), markerGenerator, new String[] { id });
-
+
StringBuilder buf = new StringBuilder("errorT: ");
for (int i = 0; i < 100; i++) {
buf.append("la la la la la ").append(i).append(' ');
@@ -310,17 +307,17 @@ public class ErrorParserManagerTest extends TestCase {
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
int l = problemMarkerInfo.description.length();
- assertTrue(l>1000);
- String end = problemMarkerInfo.description.substring(l-10,l);
+ assertTrue(l > 1000);
+ String end = problemMarkerInfo.description.substring(l - 10, l);
// check - line trimmed but long
- assertEquals(" la la 99 ",end);
+ assertEquals(" la la 99 ", end);
}
public static class TestParser4 implements IErrorParser {
@Override
public boolean processLine(String line, ErrorParserManager eoParser) {
- ProblemMarkerInfo problemMarkerInfo =
- new ProblemMarkerInfo(null, 0, "Workspace level marker", IMarker.SEVERITY_INFO, null);
+ ProblemMarkerInfo problemMarkerInfo = new ProblemMarkerInfo(null, 0, "Workspace level marker",
+ IMarker.SEVERITY_INFO, null);
eoParser.addProblemMarker(problemMarkerInfo);
return true;
}
@@ -329,9 +326,9 @@ public class ErrorParserManagerTest extends TestCase {
public void testWorkspaceLevelError() throws IOException {
String id = addErrorParserExtension("test4", TestParser4.class);
epManager = new ErrorParserManager(null, markerGenerator, new String[] { id });
-
+
StringBuilder buf = new StringBuilder("errorT: ");
- output(buf.toString()+"\n");
+ output(buf.toString() + "\n");
end();
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserTests.java
index cb8eba9d722..b2c9e0762dc 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserTests.java
@@ -16,23 +16,22 @@ package org.eclipse.cdt.core.internal.errorparsers.tests;
import junit.framework.Test;
import junit.framework.TestSuite;
-
public class ErrorParserTests {
public static Test suite() {
- TestSuite suite = new TestSuite(ErrorParserTests.class.getName());
+ TestSuite suite = new TestSuite(ErrorParserTests.class.getName());
- // Just add more test cases here as you create them for
- // each class being tested
- suite.addTest(GCCErrorParserTests.suite());
- suite.addTest(GLDErrorParserTests.suite());
- suite.addTest(MakeErrorParserTests.suite());
- suite.addTest(FileBasedErrorParserTests.suite());
- suite.addTest(ErrorParserManagerTest.suite());
- suite.addTest(ErrorParserFileMatchingTest.suite());
- suite.addTest(ErrorParserEfsFileMatchingTest.suite());
- suite.addTest(RegexErrorParserTests.suite());
- return suite;
+ // Just add more test cases here as you create them for
+ // each class being tested
+ suite.addTest(GCCErrorParserTests.suite());
+ suite.addTest(GLDErrorParserTests.suite());
+ suite.addTest(MakeErrorParserTests.suite());
+ suite.addTest(FileBasedErrorParserTests.suite());
+ suite.addTest(ErrorParserManagerTest.suite());
+ suite.addTest(ErrorParserFileMatchingTest.suite());
+ suite.addTest(ErrorParserEfsFileMatchingTest.suite());
+ suite.addTest(RegexErrorParserTests.suite());
+ return suite;
}
}
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/FileBasedErrorParserTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/FileBasedErrorParserTests.java
index 903de35238b..4d26b3c947d 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/FileBasedErrorParserTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/FileBasedErrorParserTests.java
@@ -32,7 +32,7 @@ public class FileBasedErrorParserTests extends GenericErrorParserTests {
super("testErrorsInFiles");
errorFile = file;
}
-
+
@Override
public String getName() {
return super.getName() + " " + errorFile.getName();
@@ -41,7 +41,7 @@ public class FileBasedErrorParserTests extends GenericErrorParserTests {
public void testErrorsInFiles() throws IOException {
InputStream stream = new FileInputStream(errorFile);
- runParserTest(stream, -1, -1, null, null, new String[]{GCC_ERROR_PARSER_ID});
+ runParserTest(stream, -1, -1, null, null, new String[] { GCC_ERROR_PARSER_ID });
stream.close();
}
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GCCErrorParserTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GCCErrorParserTests.java
index d20298423f5..1514d2fde78 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GCCErrorParserTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GCCErrorParserTests.java
@@ -14,13 +14,11 @@
*******************************************************************************/
package org.eclipse.cdt.core.internal.errorparsers.tests;
-
import java.io.IOException;
import junit.framework.Test;
import junit.framework.TestSuite;
-
/**
* This test is designed to exercise the error parser capabilities.
*/
@@ -29,29 +27,30 @@ public class GCCErrorParserTests extends GenericErrorParserTests {
public static final String[] GCC_ERROR_STREAM1 = {
"qcc -c -I/qnx630/target/qnx6/usr/include -I/qnx630/target/qnx6/usr/include/photon -V3.3.1,gcc_ntox86 -w5 -O2 -I. ../abmain.c abmain.o",
"In file included from ../globals.h:9,", " from ../abmain.c:36:",
- "../_combolist.h:34:24: warning: no newline at end of file",};
+ "../_combolist.h:34:24: warning: no newline at end of file", };
public static final int GCC_ERROR_STREAM1_WARNINGS = 1;
public static final int GCC_ERROR_STREAM1_ERRORS = 0;
- public static final String[] GCC_ERROR_STREAM1_FILENAMES = {"_combolist.h"};
+ public static final String[] GCC_ERROR_STREAM1_FILENAMES = { "_combolist.h" };
- public static final String[] GCC_ERROR_STREAM2 = {"C:/QNX630/workspace/System/inc/RPNEvaluator.hpp:234: warning: `",
+ public static final String[] GCC_ERROR_STREAM2 = {
+ "C:/QNX630/workspace/System/inc/RPNEvaluator.hpp:234: warning: `",
" RPNEvaluator<NumericType>::OperandConstant' is implicitly a typename",
"C:/QNX630/workspace/System/inc/RPNEvaluator.hpp:234: warning: implicit typename",
- " is deprecated, please see the documentation for details"};
+ " is deprecated, please see the documentation for details" };
public static final int GCC_ERROR_STREAM2_WARNINGS = 2;
public static final int GCC_ERROR_STREAM2_ERRORS = 0;
- public static final String[] GCC_ERROR_STREAM2_FILENAMES = {"RPNEvaluator.hpp"};
- public static final String[] GCC_ERROR_STREAM2_DESCRIPTIONS = {"please see the documentation"};
+ public static final String[] GCC_ERROR_STREAM2_FILENAMES = { "RPNEvaluator.hpp" };
+ public static final String[] GCC_ERROR_STREAM2_DESCRIPTIONS = { "please see the documentation" };
public static final String[] GCC_ERROR_STREAM3 = {
"C:/QNX630/workspace/System/inc/RPNEvaluator.hpp:370: error: ISO C++ says that `",
" char& String::operator[](unsigned int)' and `operator[]' are ambiguous even ",
- " though the worst conversion for the former is better than the worst ", " conversion for the latter"};
+ " though the worst conversion for the former is better than the worst ", " conversion for the latter" };
public static final int GCC_ERROR_STREAM3_WARNINGS = 0;
public static final int GCC_ERROR_STREAM3_ERRORS = 1;
- public static final String[] GCC_ERROR_STREAM3_FILENAMES = {"RPNEvaluator.hpp"};
- public static final String[] GCC_ERROR_STREAM3_DESCRIPTIONS = {"ISO C++", "are ambiguous", "worst conversion",
- "conversion for the latter"};
+ public static final String[] GCC_ERROR_STREAM3_FILENAMES = { "RPNEvaluator.hpp" };
+ public static final String[] GCC_ERROR_STREAM3_DESCRIPTIONS = { "ISO C++", "are ambiguous", "worst conversion",
+ "conversion for the latter" };
public static final String[] GCC_ERROR_STREAM4 = {
"C:/QNX630/workspace/System/inc/RPNEvaluator.hpp: In member function `",
@@ -60,37 +59,26 @@ public class GCCErrorParserTests extends GenericErrorParserTests {
"C:/QNX630/workspace/System/inc/RPNEvaluator.hpp:370: error: ISO C++ says that `",
" char& String::operator[](unsigned int)' and `operator[]' are ambiguous even ",
" though the worst conversion for the former is better than the worst ",
- " conversion for the latter",
- };
+ " conversion for the latter", };
public static final int GCC_ERROR_STREAM4_WARNINGS = 0;
public static final int GCC_ERROR_STREAM4_ERRORS = 1;
- public static final String[] GCC_ERROR_STREAM4_FILENAMES = {"RPNEvaluator.hpp"};
- public static final String[] GCC_ERROR_STREAM4_DESCRIPTIONS = {
- "ISO C++",
- "are ambiguous",
- "worst conversion for",
- "conversion for the latter"
- };
+ public static final String[] GCC_ERROR_STREAM4_FILENAMES = { "RPNEvaluator.hpp" };
+ public static final String[] GCC_ERROR_STREAM4_DESCRIPTIONS = { "ISO C++", "are ambiguous", "worst conversion for",
+ "conversion for the latter" };
- public static final String[] GCC_ERROR_STREAM5 = {
- "make -k all",
- "gcc -c -g -o hallo.o main.c",
- "main.c: In function `main':",
- "main.c:6: error: `wrong' undeclared (first use in this function)",
+ public static final String[] GCC_ERROR_STREAM5 = { "make -k all", "gcc -c -g -o hallo.o main.c",
+ "main.c: In function `main':", "main.c:6: error: `wrong' undeclared (first use in this function)",
"main.c:6: error: (Each undeclared identifier is reported only once",
- "main.c:6: error: for each function it appears in.)",
- "main.c:6: error: parse error before \"return\"",
- "main.c:7:2: warning: no newline at end of file",
- "make: *** [hallo.o] Error 1",
- "make: Target `all' not remade because of errors."
- };
+ "main.c:6: error: for each function it appears in.)", "main.c:6: error: parse error before \"return\"",
+ "main.c:7:2: warning: no newline at end of file", "make: *** [hallo.o] Error 1",
+ "make: Target `all' not remade because of errors." };
public static final int GCC_ERROR_STREAM5_WARNINGS = 1;
public static final int GCC_ERROR_STREAM5_ERRORS = 2;
- public static final String[] GCC_ERROR_STREAM5_FILENAMES = {"main.c"};
+ public static final String[] GCC_ERROR_STREAM5_FILENAMES = { "main.c" };
/**
* Constructor for IndexManagerTest.
- *
+ *
* @param name
*/
public GCCErrorParserTests() {
@@ -103,156 +91,119 @@ public class GCCErrorParserTests extends GenericErrorParserTests {
}
public void testMultipleIncludesError() throws IOException {
- runParserTest(GCC_ERROR_STREAM1, GCC_ERROR_STREAM1_ERRORS, GCC_ERROR_STREAM1_WARNINGS, GCC_ERROR_STREAM1_FILENAMES, null,
- new String[]{GCC_ERROR_PARSER_ID});
+ runParserTest(GCC_ERROR_STREAM1, GCC_ERROR_STREAM1_ERRORS, GCC_ERROR_STREAM1_WARNINGS,
+ GCC_ERROR_STREAM1_FILENAMES, null, new String[] { GCC_ERROR_PARSER_ID });
}
-/*
- * Norbert Ploett
- * I am commenting these tests out. The current error parser implementation
- * invariably fails to correctly process the descriptions in multiline messages.
- * My analysis indicates that these tests never were really in the automatic tests anyway.
- * This test appears in org.eclipse.cdt.core.suite.AutomatedIntegrationSuite.suite() since it's version 1.31
- * but was always commented out.
- * I brought this up in http://dev.eclipse.org/mhonarc/lists/cdt-dev/msg08668.html
- * but did not get any replies.
- *
- public void testMultiLineDescriptionError() throws IOException {
- runParserTest(GCC_ERROR_STREAM2, GCC_ERROR_STREAM2_ERRORS, GCC_ERROR_STREAM2_WARNINGS, GCC_ERROR_STREAM2_FILENAMES,
- GCC_ERROR_STREAM2_DESCRIPTIONS, new String[]{GCC_ERROR_PARSER_ID});
- }
+ /*
+ * Norbert Ploett
+ * I am commenting these tests out. The current error parser implementation
+ * invariably fails to correctly process the descriptions in multiline messages.
+ * My analysis indicates that these tests never were really in the automatic tests anyway.
+ * This test appears in org.eclipse.cdt.core.suite.AutomatedIntegrationSuite.suite() since it's version 1.31
+ * but was always commented out.
+ * I brought this up in http://dev.eclipse.org/mhonarc/lists/cdt-dev/msg08668.html
+ * but did not get any replies.
+ *
+ public void testMultiLineDescriptionError() throws IOException {
+ runParserTest(GCC_ERROR_STREAM2, GCC_ERROR_STREAM2_ERRORS, GCC_ERROR_STREAM2_WARNINGS, GCC_ERROR_STREAM2_FILENAMES,
+ GCC_ERROR_STREAM2_DESCRIPTIONS, new String[]{GCC_ERROR_PARSER_ID});
+ }
+
+ public void testLongMultiLineDescriptionError() throws IOException {
+ runParserTest(GCC_ERROR_STREAM3, GCC_ERROR_STREAM3_ERRORS, GCC_ERROR_STREAM3_WARNINGS, GCC_ERROR_STREAM3_FILENAMES,
+ GCC_ERROR_STREAM3_DESCRIPTIONS, new String[]{GCC_ERROR_PARSER_ID});
+ }
+
+ public void testMultiFileMultiLineSingleError() throws IOException {
+ runParserTest(GCC_ERROR_STREAM4, GCC_ERROR_STREAM4_ERRORS, GCC_ERROR_STREAM4_WARNINGS, GCC_ERROR_STREAM4_FILENAMES,
+ GCC_ERROR_STREAM4_DESCRIPTIONS, new String[]{GCC_ERROR_PARSER_ID});
+ }
+ */
- public void testLongMultiLineDescriptionError() throws IOException {
- runParserTest(GCC_ERROR_STREAM3, GCC_ERROR_STREAM3_ERRORS, GCC_ERROR_STREAM3_WARNINGS, GCC_ERROR_STREAM3_FILENAMES,
- GCC_ERROR_STREAM3_DESCRIPTIONS, new String[]{GCC_ERROR_PARSER_ID});
- }
-
- public void testMultiFileMultiLineSingleError() throws IOException {
- runParserTest(GCC_ERROR_STREAM4, GCC_ERROR_STREAM4_ERRORS, GCC_ERROR_STREAM4_WARNINGS, GCC_ERROR_STREAM4_FILENAMES,
- GCC_ERROR_STREAM4_DESCRIPTIONS, new String[]{GCC_ERROR_PARSER_ID});
- }
-*/
-
public void testBasicMessages() throws IOException {
- runParserTest(GCC_ERROR_STREAM5, GCC_ERROR_STREAM5_ERRORS, GCC_ERROR_STREAM5_WARNINGS, GCC_ERROR_STREAM5_FILENAMES,
- null, new String[]{GCC_ERROR_PARSER_ID});
+ runParserTest(GCC_ERROR_STREAM5, GCC_ERROR_STREAM5_ERRORS, GCC_ERROR_STREAM5_WARNINGS,
+ GCC_ERROR_STREAM5_FILENAMES, null, new String[] { GCC_ERROR_PARSER_ID });
}
-
+
public void testGccErrorMessages_Colon_bug263987() throws IOException {
- runParserTest(
- new String[] {"foo.cc:11:20: error: value with length 0 violates the length restriction: length (1 .. infinity)",},
+ runParserTest(new String[] {
+ "foo.cc:11:20: error: value with length 0 violates the length restriction: length (1 .. infinity)", },
1, // errors
0, // warnings
- new String[] {"foo.cc"},
- new String[] {"value with length 0 violates the length restriction: length (1 .. infinity)"},
- new String[] {GCC_ERROR_PARSER_ID}
- );
+ new String[] { "foo.cc" },
+ new String[] { "value with length 0 violates the length restriction: length (1 .. infinity)" },
+ new String[] { GCC_ERROR_PARSER_ID });
}
-
+
public void testGccErrorMessages_C90Comments_bug193982() throws IOException {
runParserTest(
- new String[] {
- "Myfile.c:66:3: warning: C++ style comments are not allowed in ISO C90",
- "Myfile.c:66:3: warning: (this will be reported only once per input file)",
- },
+ new String[] { "Myfile.c:66:3: warning: C++ style comments are not allowed in ISO C90",
+ "Myfile.c:66:3: warning: (this will be reported only once per input file)", },
0, // errors
1, // warnings
- new String[] {"Myfile.c"},
- new String[] {"C++ style comments are not allowed in ISO C90"},
- new String[] {GCC_ERROR_PARSER_ID}
- );
+ new String[] { "Myfile.c" }, new String[] { "C++ style comments are not allowed in ISO C90" },
+ new String[] { GCC_ERROR_PARSER_ID });
}
-
+
public void testGccErrorMessages_ConflictingTypes() throws IOException {
runParserTest(
- new String[] {
- "bar.h:42: error: conflicting types for 'jmp_buf'",
- "foo.c:12: warning: conflicting types for built-in function `memset'",
- },
+ new String[] { "bar.h:42: error: conflicting types for 'jmp_buf'",
+ "foo.c:12: warning: conflicting types for built-in function `memset'", },
1, // errors
1, // warnings
- new String[] {"bar.h", "foo.c"},
- new String[] {
- "conflicting types for 'jmp_buf'",
- "conflicting types for built-in function `memset'",
- },
- new String[] {GCC_ERROR_PARSER_ID}
- );
+ new String[] { "bar.h", "foo.c" },
+ new String[] { "conflicting types for 'jmp_buf'", "conflicting types for built-in function `memset'", },
+ new String[] { GCC_ERROR_PARSER_ID });
}
-
+
public void testGccErrorMessages_InstantiatedFromHere() throws IOException {
- runParserTest(
- new String[] {
- "/usr/include/c++/4.1.3/ext/hashtable.h:600: instantiated from 'size_t __gnu_cxx::hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>::_M_bkt_num(const _Val&, size_t) const [with _Val = std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int>, _Key = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, _HashFcn = __gnu_cxx::hash<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, _ExtractKey = std::_Select1st<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int> >, _EqualKey = std::equal_to<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, _Alloc = std::allocator<int>]'",
- "C:/QNX630/workspace/System/src/NewCommonScriptClasses.cpp:609: instantiated from here",
- },
- 0, // errors
+ runParserTest(new String[] {
+ "/usr/include/c++/4.1.3/ext/hashtable.h:600: instantiated from 'size_t __gnu_cxx::hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>::_M_bkt_num(const _Val&, size_t) const [with _Val = std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int>, _Key = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, _HashFcn = __gnu_cxx::hash<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, _ExtractKey = std::_Select1st<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int> >, _EqualKey = std::equal_to<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, _Alloc = std::allocator<int>]'",
+ "C:/QNX630/workspace/System/src/NewCommonScriptClasses.cpp:609: instantiated from here", }, 0, // errors
0, // warnings
2, // infos
- new String[] {
- "hashtable.h",
- "NewCommonScriptClasses.cpp",
- },
+ new String[] { "hashtable.h", "NewCommonScriptClasses.cpp", },
new String[] {
"instantiated from 'size_t __gnu_cxx::hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>::_M_bkt_num(const _Val&, size_t) const [with _Val = std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int>, _Key = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, _HashFcn = __gnu_cxx::hash<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, _ExtractKey = std::_Select1st<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int> >, _EqualKey = std::equal_to<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, _Alloc = std::allocator<int>]'",
- "instantiated from here",
- },
- new String[] {GCC_ERROR_PARSER_ID}
- );
+ "instantiated from here", },
+ new String[] { GCC_ERROR_PARSER_ID });
}
-
+
public void testGccErrorMessages_RequiredFromHere() throws IOException {
- runParserTest(
- new String[] {
- "utils/bar.hpp:61:7: required from 'static void OpenCVUtils::show_contours_d(std::string, cv::Mat&, const std::vector<std::vector<cv::Point_<_Tp> > >&, bool, const Scalar&, int, int, int) [with T = int; std::string = std::basic_string<char>; cv::Scalar = cv::Scalar_<double>]'",
- "utils/foo.cpp:117:96: required from here",
- },
- 0, // errors
+ runParserTest(new String[] {
+ "utils/bar.hpp:61:7: required from 'static void OpenCVUtils::show_contours_d(std::string, cv::Mat&, const std::vector<std::vector<cv::Point_<_Tp> > >&, bool, const Scalar&, int, int, int) [with T = int; std::string = std::basic_string<char>; cv::Scalar = cv::Scalar_<double>]'",
+ "utils/foo.cpp:117:96: required from here", }, 0, // errors
0, // warnings
2, // infos
- new String[] {
- "bar.hpp",
- "foo.cpp",
- },
+ new String[] { "bar.hpp", "foo.cpp", },
new String[] {
"required from 'static void OpenCVUtils::show_contours_d(std::string, cv::Mat&, const std::vector<std::vector<cv::Point_<_Tp> > >&, bool, const Scalar&, int, int, int) [with T = int; std::string = std::basic_string<char>; cv::Scalar = cv::Scalar_<double>]'",
- "required from here",
- },
- new String[] {GCC_ERROR_PARSER_ID}
- );
+ "required from here", },
+ new String[] { GCC_ERROR_PARSER_ID });
}
-
+
public void testGccErrorMessages_Infos() throws IOException {
runParserTest(
- new String[] {
- "foo.c:5: note: Offset of packed bit-field 'b' has changed in GCC 4.4",
- "bar.c:7: Info: foo undeclared, assumed to return int",
- },
+ new String[] { "foo.c:5: note: Offset of packed bit-field 'b' has changed in GCC 4.4",
+ "bar.c:7: Info: foo undeclared, assumed to return int", },
0, // errors
0, // warnings
2, // infos
- new String[] {"bar.c", "foo.c"},
- new String[] {
- "Offset of packed bit-field 'b' has changed in GCC 4.4",
- "foo undeclared, assumed to return int",
- },
- new String[] {GCC_ERROR_PARSER_ID}
- );
+ new String[] { "bar.c", "foo.c" },
+ new String[] { "Offset of packed bit-field 'b' has changed in GCC 4.4",
+ "foo undeclared, assumed to return int", },
+ new String[] { GCC_ERROR_PARSER_ID });
}
-
+
public void testGccErrorMessages_DangerousFunction_bug248669() throws IOException {
runParserTest(
- new String[] {
- "mktemp.o(.text+0x19): In function 'main':",
- "mktemp.c:15: the use of 'mktemp' is dangerous, better use 'mkstemp'",
- },
+ new String[] { "mktemp.o(.text+0x19): In function 'main':",
+ "mktemp.c:15: the use of 'mktemp' is dangerous, better use 'mkstemp'", },
0, // errors
1, // warnings
- new String[] {"mktemp.c"},
- new String[] {"the use of 'mktemp' is dangerous, better use 'mkstemp'",},
- new String[] {GCC_ERROR_PARSER_ID}
- );
+ new String[] { "mktemp.c" }, new String[] { "the use of 'mktemp' is dangerous, better use 'mkstemp'", },
+ new String[] { GCC_ERROR_PARSER_ID });
}
-
}
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GLDErrorParserTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GLDErrorParserTests.java
index d9b53c350d2..599de3c4d5c 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GLDErrorParserTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GLDErrorParserTests.java
@@ -13,13 +13,11 @@
*******************************************************************************/
package org.eclipse.cdt.core.internal.errorparsers.tests;
-
import java.io.IOException;
import junit.framework.Test;
import junit.framework.TestSuite;
-
/**
* This test is designed to exercise the error parser capabilities for GNU ld.
*/
@@ -37,107 +35,73 @@ public class GLDErrorParserTests extends GenericErrorParserTests {
public void testLinkerMessages0() throws IOException {
runParserTest(
// old style: no colons before sections
- new String[] {
- "make -k all",
- "gcc -o hallo.o main.c libfoo.a",
+ new String[] { "make -k all", "gcc -o hallo.o main.c libfoo.a",
"main.c(.text+0x14): undefined reference to `foo()'",
"main.o(.rodata+0x14): undefined reference to `something'",
- "make: Target `all' not remade because of errors.",
- },
+ "make: Target `all' not remade because of errors.", },
2, // errors
0, // warnings
0, // Infos
- new String[] {"main.c","main.o"},
- new String[] {
- "undefined reference to `foo()'",
- "undefined reference to `something'"
- },
- new String[]{GLD_ERROR_PARSER_ID}
- );
+ new String[] { "main.c", "main.o" },
+ new String[] { "undefined reference to `foo()'", "undefined reference to `something'" },
+ new String[] { GLD_ERROR_PARSER_ID });
}
-
+
public void testLinkerMessages1() throws IOException {
runParserTest(
// new style: colons before sections
- new String[] {
- "make -k all",
- "gcc -o hallo.o main.c libfoo.a",
+ new String[] { "make -k all", "gcc -o hallo.o main.c libfoo.a",
"main.c:(.text+0x14): undefined reference to `foo()'",
"main.o:(.rodata+0x14): undefined reference to `something'",
- "make: Target `all' not remade because of errors.",
- },
+ "make: Target `all' not remade because of errors.", },
2, // errors
0, // warnings
0, // Infos
- new String[] {"main.c","main.o"},
- new String[] {
- "undefined reference to `foo()'",
- "undefined reference to `something'"
- },
- new String[]{GLD_ERROR_PARSER_ID}
- );
+ new String[] { "main.c", "main.o" },
+ new String[] { "undefined reference to `foo()'", "undefined reference to `something'" },
+ new String[] { GLD_ERROR_PARSER_ID });
}
public void testLinkerMessages2() throws IOException {
runParserTest(
- new String[] {
- "make -k all",
- "gcc -o hallo.o main.c libfoo.a",
- "libfoo.a(foo.o): In function `foo':",
+ new String[] { "make -k all", "gcc -o hallo.o main.c libfoo.a", "libfoo.a(foo.o): In function `foo':",
"foo.c:(.text+0x7): undefined reference to `bar'",
- "make: Target `all' not remade because of errors.",
- },
+ "make: Target `all' not remade because of errors.", },
1, // errors
0, // warnings
0, // Infos
- new String[] {"foo.c"},
- new String[] {"undefined reference to `bar'"},
- new String[] {GLD_ERROR_PARSER_ID}
- );
+ new String[] { "foo.c" }, new String[] { "undefined reference to `bar'" },
+ new String[] { GLD_ERROR_PARSER_ID });
}
public void testLinkerMessages_DangerousFunction_bug248669() throws IOException {
- runParserTest(
- new String[] {
- "mktemp.o(.text+0x19): In function 'main':",
- "mktemp.c:15: the use of 'mktemp' is dangerous, better use 'mkstemp'",
- "1.o: In function `main':",
- "1.c:(.text+0x19): warning: the use of `mktemp' is dangerous, better use `mkstemp'",
- },
- 0, // errors
+ runParserTest(new String[] { "mktemp.o(.text+0x19): In function 'main':",
+ "mktemp.c:15: the use of 'mktemp' is dangerous, better use 'mkstemp'", "1.o: In function `main':",
+ "1.c:(.text+0x19): warning: the use of `mktemp' is dangerous, better use `mkstemp'", }, 0, // errors
2, // warnings
0, // Infos
- new String[] {"1.c", "mktemp.c"},
- new String[] {
- "the use of 'mktemp' is dangerous, better use 'mkstemp'",
- "the use of `mktemp' is dangerous, better use `mkstemp'",
- },
- new String[] {GLD_ERROR_PARSER_ID}
- );
+ new String[] { "1.c", "mktemp.c" },
+ new String[] { "the use of 'mktemp' is dangerous, better use 'mkstemp'",
+ "the use of `mktemp' is dangerous, better use `mkstemp'", },
+ new String[] { GLD_ERROR_PARSER_ID });
}
-
+
public void testLinkerMessages_PrecedingPath_bug314253() throws IOException {
- runParserTest(
- new String[] {
- "ld: warning: libstdc++.so.5, needed by testlib_1.so, may conflict with libstdc++.so.6",
- "/usr/bin/ld: warning: libstdc++.so.5, needed by testlib_2.so, may conflict with libstdc++.so.6",
- "C:\\bin\\ld.exe: warning: libstdc++.so.5, needed by testlib_3.so, may conflict with libstdc++.so.6",
- "c:/bin/ld.exe: warning: libstdc++.so.5, needed by testlib_4.so, may conflict with libstdc++.so.6",
- "D:\\mingw\\bin\\..\\lib\\gcc-lib\\mingw32\\3.2.3\\..\\..\\..\\..\\mingw32\\bin\\ld.exe: cannot find -ljpeg",
- "notld: warning: ld error parser has no business parsing this message",
- },
- 1, // errors
+ runParserTest(new String[] {
+ "ld: warning: libstdc++.so.5, needed by testlib_1.so, may conflict with libstdc++.so.6",
+ "/usr/bin/ld: warning: libstdc++.so.5, needed by testlib_2.so, may conflict with libstdc++.so.6",
+ "C:\\bin\\ld.exe: warning: libstdc++.so.5, needed by testlib_3.so, may conflict with libstdc++.so.6",
+ "c:/bin/ld.exe: warning: libstdc++.so.5, needed by testlib_4.so, may conflict with libstdc++.so.6",
+ "D:\\mingw\\bin\\..\\lib\\gcc-lib\\mingw32\\3.2.3\\..\\..\\..\\..\\mingw32\\bin\\ld.exe: cannot find -ljpeg",
+ "notld: warning: ld error parser has no business parsing this message", }, 1, // errors
4, // warnings
0, // Infos
null,
- new String[] {
- "libstdc++.so.5, needed by testlib_1.so, may conflict with libstdc++.so.6",
+ new String[] { "libstdc++.so.5, needed by testlib_1.so, may conflict with libstdc++.so.6",
"libstdc++.so.5, needed by testlib_2.so, may conflict with libstdc++.so.6",
"libstdc++.so.5, needed by testlib_3.so, may conflict with libstdc++.so.6",
"libstdc++.so.5, needed by testlib_4.so, may conflict with libstdc++.so.6",
- "cannot find -ljpeg",
- },
- new String[] {GLD_ERROR_PARSER_ID}
- );
+ "cannot find -ljpeg", },
+ new String[] { GLD_ERROR_PARSER_ID });
}
}
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GenericErrorParserTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GenericErrorParserTests.java
index e88b481fdab..1984e351158 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GenericErrorParserTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GenericErrorParserTests.java
@@ -46,7 +46,7 @@ public abstract class GenericErrorParserTests extends TestCase {
/**
* Constructor for IndexManagerTest.
- *
+ *
* @param name
*/
public GenericErrorParserTests(String name) {
@@ -93,11 +93,12 @@ public abstract class GenericErrorParserTests extends TestCase {
return buf.toString();
}
- protected void transferInputStreamToOutputStream(InputStream input, OutputStream output, int byteBlockSize) throws IOException {
+ protected void transferInputStreamToOutputStream(InputStream input, OutputStream output, int byteBlockSize)
+ throws IOException {
byte[] buffer = new byte[byteBlockSize];
int bytesRead;
- while ( (bytesRead = input.read(buffer)) >= 0) {
+ while ((bytesRead = input.read(buffer)) >= 0) {
output.write(buffer, 0, bytesRead);
}
@@ -106,12 +107,13 @@ public abstract class GenericErrorParserTests extends TestCase {
protected void runParserTest(InputStream inputStream, int expectedErrorCount, int expectedWarningCount,
String[] expectedFileNames, String[] expectedDescriptions, String[] parserID) throws IOException {
- runParserTest(inputStream, expectedErrorCount, expectedWarningCount, 0, expectedFileNames, expectedDescriptions, parserID);
+ runParserTest(inputStream, expectedErrorCount, expectedWarningCount, 0, expectedFileNames, expectedDescriptions,
+ parserID);
}
-
+
protected void runParserTest(InputStream inputStream, int expectedErrorCount, int expectedWarningCount,
- int expectedInfoCount, String[] expectedFileNames, String[] expectedDescriptions,
- String[] parserID) throws IOException {
+ int expectedInfoCount, String[] expectedFileNames, String[] expectedDescriptions, String[] parserID)
+ throws IOException {
assertNotNull(inputStream);
CountingMarkerGenerator markerGenerator = new CountingMarkerGenerator();
@@ -139,7 +141,7 @@ public abstract class GenericErrorParserTests extends TestCase {
assertEquals(expectedFileNames.length, markerGenerator.uniqFiles.size());
for (int i = 0; i < expectedFileNames.length; i++) {
// Keep in mind that uniqFiles get alphabetically sorted
- IPath path = ((IFile)markerGenerator.uniqFiles.get(i)).getLocation();
+ IPath path = ((IFile) markerGenerator.uniqFiles.get(i)).getLocation();
assertEquals(expectedFileNames[i], path.lastSegment());
}
}
@@ -147,24 +149,26 @@ public abstract class GenericErrorParserTests extends TestCase {
if (expectedDescriptions != null) {
assertNotNull(markerGenerator.descriptions);
for (int i = 0; i < expectedDescriptions.length; i++) {
- assertEquals(expectedDescriptions[i],markerGenerator.descriptions.get(i));
+ assertEquals(expectedDescriptions[i], markerGenerator.descriptions.get(i));
}
}
}
protected void runParserTest(String[] dataStream, int expectedErrorCount, int expectedWarningCount,
String[] expectedFileNames, String[] expectedDescriptions, String[] parserID) throws IOException {
- runParserTest(dataStream, expectedErrorCount, expectedWarningCount, 0, expectedFileNames, expectedDescriptions, parserID);
+ runParserTest(dataStream, expectedErrorCount, expectedWarningCount, 0, expectedFileNames, expectedDescriptions,
+ parserID);
}
-
- protected void runParserTest(String[] dataStream, int expectedErrorCount, int expectedWarningCount, int expectedInfoCount,
- String[] expectedFileNames, String[] expectedDescriptions, String[] parserID) throws IOException {
+
+ protected void runParserTest(String[] dataStream, int expectedErrorCount, int expectedWarningCount,
+ int expectedInfoCount, String[] expectedFileNames, String[] expectedDescriptions, String[] parserID)
+ throws IOException {
String errorStream = makeStringFromArray(dataStream, "\n");
ByteArrayInputStream inputStream = new ByteArrayInputStream(errorStream.getBytes());
- runParserTest(inputStream, expectedErrorCount, expectedWarningCount, expectedInfoCount,
- expectedFileNames, expectedDescriptions, parserID);
+ runParserTest(inputStream, expectedErrorCount, expectedWarningCount, expectedInfoCount, expectedFileNames,
+ expectedDescriptions, parserID);
}
private static class FileNameComparator implements Comparator<IResource> {
@@ -188,7 +192,8 @@ public abstract class GenericErrorParserTests extends TestCase {
@Override
public void addMarker(IResource file, int lineNumber, String errorDesc, int severity, String errorVar) {
- ProblemMarkerInfo problemMarkerInfo = new ProblemMarkerInfo(file, lineNumber, errorDesc, severity, errorVar, null);
+ ProblemMarkerInfo problemMarkerInfo = new ProblemMarkerInfo(file, lineNumber, errorDesc, severity, errorVar,
+ null);
addMarker(problemMarkerInfo);
}
@@ -199,7 +204,8 @@ public abstract class GenericErrorParserTests extends TestCase {
uniqFiles.add(-1 * (index + 1), problemMarkerInfo.file);
}
- if (problemMarkerInfo.severity == SEVERITY_ERROR_BUILD || problemMarkerInfo.severity == SEVERITY_ERROR_RESOURCE) {
+ if (problemMarkerInfo.severity == SEVERITY_ERROR_BUILD
+ || problemMarkerInfo.severity == SEVERITY_ERROR_RESOURCE) {
numErrors++;
} else if (problemMarkerInfo.severity == SEVERITY_WARNING) {
numWarnings++;
@@ -235,14 +241,14 @@ public abstract class GenericErrorParserTests extends TestCase {
@Override
public IFile findFileName(String fileName) {
- if (fileName==null || fileName.trim().length()==0) {
+ if (fileName == null || fileName.trim().length() == 0) {
return null;
}
if (fileName.lastIndexOf('/') != -1) {
fileName = fileName.substring(fileName.lastIndexOf('/') + 1);
}
IFile file = fProject.getFile(fileName);
- if (file!=null && !file.exists()) {
+ if (file != null && !file.exists()) {
try {
InputStream stream = new ByteArrayInputStream("TestFile".getBytes());
file.create(stream, true, new NullProgressMonitor());
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/MakeErrorParserTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/MakeErrorParserTests.java
index acf91ed9313..d5f3263231f 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/MakeErrorParserTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/MakeErrorParserTests.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.core.internal.errorparsers.tests;
-
import java.io.IOException;
import junit.framework.Test;
@@ -21,60 +20,49 @@ import junit.framework.TestSuite;
import org.eclipse.cdt.core.ErrorParserManager;
-
/**
* This test is designed to exercise the error parser capabilities for GNU make.
*/
public class MakeErrorParserTests extends GenericErrorParserTests {
private static final String[] GMAKE_ERROR_STREAM0 = {
- // Infos
- "make: [Hello.o] Error 1 (ignored)",
- "make[2]: [all] Error 2 (ignored)",
- // Warnings
- "make: [Hello.o] Error 1",
- "make: Circular .folder/file.h <- .folder/file2.h dependency dropped.",
- "make[1]: Circular folder/file.h <- Makefile dependency dropped.",
- // Errors
- "make: *** [Hello.o] Error 1",
- "make[3]: *** [Hello.o] Error 1",
- "make: *** No rule to make target `one', needed by `all'. Stop.",
- "make: *** No rule to make target `all'. Stop.",
- "make: *** missing.mk: No such file or directory. Stop.",
- "make: Target `all' not remade because of errors.",
- // Ignored
- "make[3]: Nothing to be done for `all'.",
- "make[2]: `all' is up to date.",
- };
+ // Infos
+ "make: [Hello.o] Error 1 (ignored)", "make[2]: [all] Error 2 (ignored)",
+ // Warnings
+ "make: [Hello.o] Error 1", "make: Circular .folder/file.h <- .folder/file2.h dependency dropped.",
+ "make[1]: Circular folder/file.h <- Makefile dependency dropped.",
+ // Errors
+ "make: *** [Hello.o] Error 1", "make[3]: *** [Hello.o] Error 1",
+ "make: *** No rule to make target `one', needed by `all'. Stop.",
+ "make: *** No rule to make target `all'. Stop.", "make: *** missing.mk: No such file or directory. Stop.",
+ "make: Target `all' not remade because of errors.",
+ // Ignored
+ "make[3]: Nothing to be done for `all'.", "make[2]: `all' is up to date.", };
private static final int GMAKE_ERROR_STREAM0_INFOS = 2;
private static final int GMAKE_ERROR_STREAM0_WARNINGS = 3;
private static final int GMAKE_ERROR_STREAM0_ERRORS = 6;
private static final String[] GMAKE_ERROR_STREAM1 = {
- // Warning
- "GNUmakefile:12: warning: overriding commands for target `target'",
- "Makefile1:10: include.mk: No such file or directory",
- // Errors
- "Makefile2:10: *** missing separator. Stop.",
- "Makefile3:10: *** missing separator (did you mean TAB instead of 8 spaces?). Stop.",
- "Makefile4:10: *** commands commence before first target. Stop.",
- "Makefile5:10: *** Recursive variable 'VAR' references itself (eventually). Stop.",
- "Makefile6:10: *** target pattern contains no `%'. Stop.",
- // Ignored. Do not intercept compiler warnings
- "mytest.cpp:19: warning: unused variable 'i'",
- "hello.c:14:17: error: foo.h: No such file or directory",
- };
+ // Warning
+ "GNUmakefile:12: warning: overriding commands for target `target'",
+ "Makefile1:10: include.mk: No such file or directory",
+ // Errors
+ "Makefile2:10: *** missing separator. Stop.",
+ "Makefile3:10: *** missing separator (did you mean TAB instead of 8 spaces?). Stop.",
+ "Makefile4:10: *** commands commence before first target. Stop.",
+ "Makefile5:10: *** Recursive variable 'VAR' references itself (eventually). Stop.",
+ "Makefile6:10: *** target pattern contains no `%'. Stop.",
+ // Ignored. Do not intercept compiler warnings
+ "mytest.cpp:19: warning: unused variable 'i'", "hello.c:14:17: error: foo.h: No such file or directory", };
private static final int GMAKE_ERROR_STREAM1_WARNINGS = 2;
private static final int GMAKE_ERROR_STREAM1_ERRORS = 5;
- private static final String[] GMAKE_ERROR_STREAM1_FILENAMES = {"GNUmakefile", "Makefile1",
- "Makefile2", "Makefile3", "Makefile4", "Makefile5", "Makefile6"};
+ private static final String[] GMAKE_ERROR_STREAM1_FILENAMES = { "GNUmakefile", "Makefile1", "Makefile2",
+ "Makefile3", "Makefile4", "Makefile5", "Makefile6" };
private static final String[] GMAKE_ERROR_STREAM2 = {
- // Errors
- "gmake[3]: *** [Hello.o] Error 1",
- "make-381.exe: *** [Hello.o] Error 1",
- "gmake381: Target `all' not remade because of errors.",
- };
+ // Errors
+ "gmake[3]: *** [Hello.o] Error 1", "make-381.exe: *** [Hello.o] Error 1",
+ "gmake381: Target `all' not remade because of errors.", };
private static final int GMAKE_ERROR_STREAM2_WARNINGS = 0;
private static final int GMAKE_ERROR_STREAM2_ERRORS = 3;
@@ -92,17 +80,17 @@ public class MakeErrorParserTests extends GenericErrorParserTests {
}
public void testGmakeMessages0() throws IOException {
- runParserTest(GMAKE_ERROR_STREAM0, GMAKE_ERROR_STREAM0_ERRORS, GMAKE_ERROR_STREAM0_WARNINGS, GMAKE_ERROR_STREAM0_INFOS,
- null, null, new String[]{GMAKE_ERROR_PARSER_ID});
+ runParserTest(GMAKE_ERROR_STREAM0, GMAKE_ERROR_STREAM0_ERRORS, GMAKE_ERROR_STREAM0_WARNINGS,
+ GMAKE_ERROR_STREAM0_INFOS, null, null, new String[] { GMAKE_ERROR_PARSER_ID });
}
public void testGMakeMessages1() throws IOException {
runParserTest(GMAKE_ERROR_STREAM1, GMAKE_ERROR_STREAM1_ERRORS, GMAKE_ERROR_STREAM1_WARNINGS,
- GMAKE_ERROR_STREAM1_FILENAMES, null, new String[]{GMAKE_ERROR_PARSER_ID});
+ GMAKE_ERROR_STREAM1_FILENAMES, null, new String[] { GMAKE_ERROR_PARSER_ID });
}
public void testGmakeMessages2() throws IOException {
- runParserTest(GMAKE_ERROR_STREAM2, GMAKE_ERROR_STREAM2_ERRORS, GMAKE_ERROR_STREAM2_WARNINGS,
- null, null, new String[]{GMAKE_ERROR_PARSER_ID});
+ runParserTest(GMAKE_ERROR_STREAM2, GMAKE_ERROR_STREAM2_ERRORS, GMAKE_ERROR_STREAM2_WARNINGS, null, null,
+ new String[] { GMAKE_ERROR_PARSER_ID });
}
}
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/RegexErrorParserTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/RegexErrorParserTests.java
index 0c4cb8ee827..aed5a8b40aa 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/RegexErrorParserTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/RegexErrorParserTests.java
@@ -53,7 +53,8 @@ public class RegexErrorParserTests extends TestCase {
private final IMarkerGenerator markerGenerator = new IMarkerGenerator() {
// deprecated
@Override
- public void addMarker(IResource file, int lineNumber, String errorDesc, int severity, String errorVar) {}
+ public void addMarker(IResource file, int lineNumber, String errorDesc, int severity, String errorVar) {
+ }
@Override
public void addMarker(ProblemMarkerInfo problemMarkerInfo) {
@@ -124,12 +125,12 @@ public class RegexErrorParserTests extends TestCase {
*/
public void testRegexErrorParserAddDeletePattern() throws Exception {
RegexErrorParser regexErrorParser = new RegexErrorParser();
- regexErrorParser.addPattern(new RegexErrorPattern("pattern 1",
- null, null, null, null, RegexErrorPattern.SEVERITY_SKIP, true));
- regexErrorParser.addPattern(new RegexErrorPattern("delete me",
- null, null, null, null, RegexErrorPattern.SEVERITY_SKIP, true));
- regexErrorParser.addPattern(new RegexErrorPattern("pattern 3",
- null, null, null, null, RegexErrorPattern.SEVERITY_SKIP, true));
+ regexErrorParser.addPattern(
+ new RegexErrorPattern("pattern 1", null, null, null, null, RegexErrorPattern.SEVERITY_SKIP, true));
+ regexErrorParser.addPattern(
+ new RegexErrorPattern("delete me", null, null, null, null, RegexErrorPattern.SEVERITY_SKIP, true));
+ regexErrorParser.addPattern(
+ new RegexErrorPattern("pattern 3", null, null, null, null, RegexErrorPattern.SEVERITY_SKIP, true));
// adding patterns
RegexErrorPattern[] patternsBefore = regexErrorParser.getPatterns();
@@ -151,7 +152,7 @@ public class RegexErrorParserTests extends TestCase {
* @throws Exception...
*/
public void testRegexErrorParserPatternOrder() throws Exception {
- final int ERR=IMarkerGenerator.SEVERITY_ERROR_RESOURCE;
+ final int ERR = IMarkerGenerator.SEVERITY_ERROR_RESOURCE;
RegexErrorParser regexErrorParser = new RegexErrorParser();
RegexErrorPattern removable = new RegexErrorPattern("CCC", null, null, null, null, ERR, true);
regexErrorParser.addPattern(new RegexErrorPattern("AAA", null, null, null, null, ERR, true));
@@ -187,71 +188,71 @@ public class RegexErrorParserTests extends TestCase {
*/
public void testRegexErrorParserParseOutput() throws Exception {
RegexErrorParser regexErrorParser = new RegexErrorParser();
- regexErrorParser.addPattern(new RegexErrorPattern("(.*)#(.*)#(.*)#(.*)",
- "$1", "$2", "$3 $4", "var=$4", IMarkerGenerator.SEVERITY_ERROR_RESOURCE, true));
- regexErrorParser.addPattern(new RegexErrorPattern("(.*)!(skip me)!(.*)!(.*)",
- null, null, null, null, RegexErrorPattern.SEVERITY_SKIP, true));
- regexErrorParser.addPattern(new RegexErrorPattern("(.*)!(Description)!(.*)!(.*)",
- "$4", "$3", "$2", "$1", IMarkerGenerator.SEVERITY_WARNING, /*eat-line*/ false));
+ regexErrorParser.addPattern(new RegexErrorPattern("(.*)#(.*)#(.*)#(.*)", "$1", "$2", "$3 $4", "var=$4",
+ IMarkerGenerator.SEVERITY_ERROR_RESOURCE, true));
+ regexErrorParser.addPattern(new RegexErrorPattern("(.*)!(skip me)!(.*)!(.*)", null, null, null, null,
+ RegexErrorPattern.SEVERITY_SKIP, true));
+ regexErrorParser.addPattern(new RegexErrorPattern("(.*)!(Description)!(.*)!(.*)", "$4", "$3", "$2", "$1",
+ IMarkerGenerator.SEVERITY_WARNING, /*eat-line*/ false));
// broken pattern
- regexErrorParser.addPattern(new RegexErrorPattern("(.*)!(.*)",
- "$6", "$7", "$8", "$9", IMarkerGenerator.SEVERITY_WARNING, true));
- regexErrorParser.addPattern(new RegexErrorPattern("(.*)!(.*)!(.*)!(.*)",
- null, null, null, null, IMarkerGenerator.SEVERITY_INFO, true));
+ regexErrorParser.addPattern(
+ new RegexErrorPattern("(.*)!(.*)", "$6", "$7", "$8", "$9", IMarkerGenerator.SEVERITY_WARNING, true));
+ regexErrorParser.addPattern(new RegexErrorPattern("(.*)!(.*)!(.*)!(.*)", null, null, null, null,
+ IMarkerGenerator.SEVERITY_INFO, true));
String fileName = "RegexErrorParser.c";
ResourceHelper.createFile(fProject, fileName);
errorList.clear();
ErrorParserManager epManager = new ErrorParserManager(fProject, markerGenerator, new String[0]);
-
+
ProblemMarkerInfo problemMarkerInfo;
// Regular pattern
- regexErrorParser.processLine(fileName+"#10#Description#Variable", epManager);
+ regexErrorParser.processLine(fileName + "#10#Description#Variable", epManager);
// This should get ignored
- regexErrorParser.processLine("Variable!skip me!10!"+fileName, epManager);
+ regexErrorParser.processLine("Variable!skip me!10!" + fileName, epManager);
// Eat-line=false + qualifying next pattern (nulls), i.e. generates 2 problems
- regexErrorParser.processLine("Variable!Description!10!"+fileName, epManager);
+ regexErrorParser.processLine("Variable!Description!10!" + fileName, epManager);
assertEquals(3, errorList.size());
// Regular
problemMarkerInfo = errorList.get(0);
assertEquals(IMarkerGenerator.SEVERITY_ERROR_RESOURCE, problemMarkerInfo.severity);
- assertEquals("L/"+TEST_PROJECT_NAME+"/"+fileName, problemMarkerInfo.file.toString());
+ assertEquals("L/" + TEST_PROJECT_NAME + "/" + fileName, problemMarkerInfo.file.toString());
assertEquals(fileName, problemMarkerInfo.file.getName());
assertEquals(10, problemMarkerInfo.lineNumber);
- assertEquals("Description Variable",problemMarkerInfo.description);
- assertEquals("var=Variable",problemMarkerInfo.variableName);
+ assertEquals("Description Variable", problemMarkerInfo.description);
+ assertEquals("var=Variable", problemMarkerInfo.variableName);
// Eat-line
problemMarkerInfo = errorList.get(1);
assertEquals(IMarkerGenerator.SEVERITY_WARNING, problemMarkerInfo.severity);
- assertEquals("L/"+TEST_PROJECT_NAME+"/"+fileName, problemMarkerInfo.file.toString());
+ assertEquals("L/" + TEST_PROJECT_NAME + "/" + fileName, problemMarkerInfo.file.toString());
assertEquals(fileName, problemMarkerInfo.file.getName());
assertEquals(10, problemMarkerInfo.lineNumber);
- assertEquals("Description",problemMarkerInfo.description);
- assertEquals("Variable",problemMarkerInfo.variableName);
+ assertEquals("Description", problemMarkerInfo.description);
+ assertEquals("Variable", problemMarkerInfo.variableName);
// Nulls
problemMarkerInfo = errorList.get(2);
assertEquals(IMarkerGenerator.SEVERITY_INFO, problemMarkerInfo.severity);
- assertEquals("P/"+TEST_PROJECT_NAME, problemMarkerInfo.file.toString());
+ assertEquals("P/" + TEST_PROJECT_NAME, problemMarkerInfo.file.toString());
assertEquals(0, problemMarkerInfo.lineNumber);
- assertEquals("",problemMarkerInfo.description);
- assertEquals("",problemMarkerInfo.variableName);
+ assertEquals("", problemMarkerInfo.description);
+ assertEquals("", problemMarkerInfo.variableName);
// clone & equals
- RegexErrorParser cloned = (RegexErrorParser)regexErrorParser.clone();
- assertTrue(cloned!=regexErrorParser);
+ RegexErrorParser cloned = (RegexErrorParser) regexErrorParser.clone();
+ assertTrue(cloned != regexErrorParser);
assertEquals(regexErrorParser, cloned);
- assertTrue(cloned.getPatterns()!=regexErrorParser.getPatterns());
+ assertTrue(cloned.getPatterns() != regexErrorParser.getPatterns());
assertEquals(cloned.getPatterns().length, regexErrorParser.getPatterns().length);
- for (int i=0; i<regexErrorParser.getPatterns().length; i++) {
+ for (int i = 0; i < regexErrorParser.getPatterns().length; i++) {
// Checking deep copy
- assertTrue(cloned.getPatterns()[i]!=regexErrorParser.getPatterns()[i]);
- assertEquals(cloned.getPatterns()[i],regexErrorParser.getPatterns()[i]);
+ assertTrue(cloned.getPatterns()[i] != regexErrorParser.getPatterns()[i]);
+ assertEquals(cloned.getPatterns()[i], regexErrorParser.getPatterns()[i]);
}
}
@@ -287,7 +288,7 @@ public class RegexErrorParserTests extends TestCase {
assertEquals(REGEX_ERRORPARSER_NAME, errorParser.getName());
assertTrue(errorParser instanceof RegexErrorParser);
- RegexErrorParser regexErrorParser = (RegexErrorParser)errorParser;
+ RegexErrorParser regexErrorParser = (RegexErrorParser) errorParser;
assertEquals(REGEX_ERRORPARSER_ID, regexErrorParser.getId());
assertEquals(REGEX_ERRORPARSER_NAME, regexErrorParser.getName());
@@ -309,7 +310,7 @@ public class RegexErrorParserTests extends TestCase {
IErrorParser errorParser = ErrorParserManager.getErrorParserCopy(REGEX_ERRORPARSER_ID);
assertTrue(errorParser instanceof RegexErrorParser);
- RegexErrorParser regexErrorParser = (RegexErrorParser)errorParser;
+ RegexErrorParser regexErrorParser = (RegexErrorParser) errorParser;
assertEquals(REGEX_ERRORPARSER_ID, regexErrorParser.getId());
assertEquals(REGEX_ERRORPARSER_NAME, regexErrorParser.getName());
}
@@ -334,19 +335,19 @@ public class RegexErrorParserTests extends TestCase {
String name = ErrorParserManager.getErrorParserCopy(id).getName();
boolean isDeprecated = name.contains("(Deprecated)");
boolean isTestPlugin = id.startsWith(CTestPlugin.PLUGIN_ID);
- String message = "Parser ["+lastName+"] preceeds ["+name+"]";
-
+ String message = "Parser [" + lastName + "] preceeds [" + name + "]";
+
// inside the same category sorted by names
- if (lastIsDeprecated==isDeprecated && lastIsTestPlugin==isTestPlugin) {
- assertTrue(message, lastName.compareTo(name)<=0);
+ if (lastIsDeprecated == isDeprecated && lastIsTestPlugin == isTestPlugin) {
+ assertTrue(message, lastName.compareTo(name) <= 0);
}
// deprecated follow non-deprecated (unless parsers from test plugin show up)
- if (lastIsTestPlugin==isTestPlugin) {
- assertFalse(message, lastIsDeprecated==true && isDeprecated==false);
+ if (lastIsTestPlugin == isTestPlugin) {
+ assertFalse(message, lastIsDeprecated == true && isDeprecated == false);
}
// error parsers from test plugin are the last
- assertFalse(message, lastIsTestPlugin==true && isTestPlugin==false);
-
+ assertFalse(message, lastIsTestPlugin == true && isTestPlugin == false);
+
lastName = name;
lastIsDeprecated = isDeprecated;
lastIsTestPlugin = isTestPlugin;
@@ -365,7 +366,7 @@ public class RegexErrorParserTests extends TestCase {
final String[] availableParserIds = ErrorParserManager.getErrorParserAvailableIds();
assertNotNull(availableParserIds);
- assertTrue(availableParserIds.length>0);
+ assertTrue(availableParserIds.length > 0);
final String firstId = ErrorParserManager.getErrorParserAvailableIds()[0];
final IErrorParserNamed firstErrorParser = ErrorParserManager.getErrorParserCopy(firstId);
assertNotNull(firstErrorParser);
@@ -392,8 +393,7 @@ public class RegexErrorParserTests extends TestCase {
// add brand new one
new ErrorParserNamedWrapper(TESTING_ID, TESTING_NAME, dummy1),
// override extension with another one
- new ErrorParserNamedWrapper(firstId, firstName, dummy2),
- });
+ new ErrorParserNamedWrapper(firstId, firstName, dummy2), });
String all = ErrorParserManager.toDelimitedString(ErrorParserManager.getErrorParserAvailableIds());
assertEquals(true, all.contains(TESTING_ID));
assertEquals(true, all.contains(firstId));
@@ -402,14 +402,14 @@ public class RegexErrorParserTests extends TestCase {
assertNotNull(retrieved1);
assertEquals(TESTING_NAME, retrieved1.getName());
assertTrue(retrieved1 instanceof ErrorParserNamedWrapper);
- assertEquals(dummy1, ((ErrorParserNamedWrapper)retrieved1).getErrorParser());
+ assertEquals(dummy1, ((ErrorParserNamedWrapper) retrieved1).getErrorParser());
IErrorParserNamed retrieved2 = ErrorParserManager.getErrorParserCopy(firstId);
assertNotNull(retrieved2);
assertEquals(firstName, retrieved2.getName());
assertTrue(retrieved2 instanceof ErrorParserNamedWrapper);
- assertEquals(dummy2, ((ErrorParserNamedWrapper)retrieved2).getErrorParser());
-
+ assertEquals(dummy2, ((ErrorParserNamedWrapper) retrieved2).getErrorParser());
+
IErrorParserNamed retrieved2_ext = ErrorParserManager.getErrorParserExtensionCopy(firstId);
assertNotNull(retrieved2_ext);
assertEquals(firstName, retrieved2_ext.getName());
@@ -453,9 +453,9 @@ public class RegexErrorParserTests extends TestCase {
}
{
ErrorParserManager.setUserDefinedErrorParsers(new IErrorParserNamed[] {
- new ErrorParserNamedWrapper(TESTING_ID, TESTING_NAME, new DummyErrorParser()),
- });
- String userDefinedIds = ErrorParserManager.toDelimitedString(ErrorParserManager.getUserDefinedErrorParserIds());
+ new ErrorParserNamedWrapper(TESTING_ID, TESTING_NAME, new DummyErrorParser()), });
+ String userDefinedIds = ErrorParserManager
+ .toDelimitedString(ErrorParserManager.getUserDefinedErrorParserIds());
assertEquals(TESTING_ID, userDefinedIds);
String all = ErrorParserManager.toDelimitedString(ErrorParserManager.getErrorParserAvailableIds());
@@ -483,11 +483,8 @@ public class RegexErrorParserTests extends TestCase {
}
// setDefaultErrorParserIds
{
- String[] newDefaultErrorParserIds = {
- "org.eclipse.cdt.core.test.errorparser0",
- "org.eclipse.cdt.core.test.errorparser1",
- "org.eclipse.cdt.core.test.errorparser2",
- };
+ String[] newDefaultErrorParserIds = { "org.eclipse.cdt.core.test.errorparser0",
+ "org.eclipse.cdt.core.test.errorparser1", "org.eclipse.cdt.core.test.errorparser2", };
ErrorParserManager.setDefaultErrorParserIds(newDefaultErrorParserIds);
String[] defaultErrorParserIds = ErrorParserManager.getDefaultErrorParserIds();
assertNotNull(defaultErrorParserIds);
@@ -518,7 +515,8 @@ public class RegexErrorParserTests extends TestCase {
// Create error parser
IErrorParser errorParser = new GASErrorParser();
// Add to available parsers
- ErrorParserExtensionManager.setUserDefinedErrorParsersInternal(new IErrorParserNamed[] {new ErrorParserNamedWrapper(TESTING_ID, TESTING_NAME, errorParser)});
+ ErrorParserExtensionManager.setUserDefinedErrorParsersInternal(
+ new IErrorParserNamed[] { new ErrorParserNamedWrapper(TESTING_ID, TESTING_NAME, errorParser) });
assertNotNull(ErrorParserManager.getErrorParserCopy(TESTING_ID));
assertEquals(TESTING_NAME, ErrorParserManager.getErrorParserCopy(TESTING_ID).getName());
// Serialize in persistent storage
@@ -537,7 +535,7 @@ public class RegexErrorParserTests extends TestCase {
assertNotNull(errorParser);
assertEquals(TESTING_NAME, errorParser.getName());
assertTrue(errorParser instanceof ErrorParserNamedWrapper);
- assertTrue(((ErrorParserNamedWrapper)errorParser).getErrorParser() instanceof GASErrorParser);
+ assertTrue(((ErrorParserNamedWrapper) errorParser).getErrorParser() instanceof GASErrorParser);
}
{
// Remove from available parsers as clean-up
@@ -559,11 +557,12 @@ public class RegexErrorParserTests extends TestCase {
{
// Create error parser with the same id as in eclipse registry
RegexErrorParser regexErrorParser = new RegexErrorParser(TESTING_ID, TESTING_NAME);
- regexErrorParser.addPattern(new RegexErrorPattern("Pattern-Y",
- "line-Y", "file-Y", "description-Y", null, IMarkerGenerator.SEVERITY_WARNING, false));
+ regexErrorParser.addPattern(new RegexErrorPattern("Pattern-Y", "line-Y", "file-Y", "description-Y", null,
+ IMarkerGenerator.SEVERITY_WARNING, false));
// Add to available parsers
- ErrorParserExtensionManager.setUserDefinedErrorParsersInternal(new IErrorParserNamed[] {regexErrorParser});
+ ErrorParserExtensionManager
+ .setUserDefinedErrorParsersInternal(new IErrorParserNamed[] { regexErrorParser });
assertNotNull(ErrorParserManager.getErrorParserCopy(TESTING_ID));
// And serialize in persistent storage
ErrorParserExtensionManager.serializeUserDefinedErrorParsers();
@@ -584,7 +583,7 @@ public class RegexErrorParserTests extends TestCase {
IErrorParser errorParser = ErrorParserManager.getErrorParserCopy(TESTING_ID);
assertNotNull(errorParser);
assertTrue(errorParser instanceof RegexErrorParser);
- RegexErrorParser regexErrorParser = (RegexErrorParser)errorParser;
+ RegexErrorParser regexErrorParser = (RegexErrorParser) errorParser;
assertEquals(TESTING_ID, regexErrorParser.getId());
assertEquals(TESTING_NAME, regexErrorParser.getName());
@@ -619,11 +618,12 @@ public class RegexErrorParserTests extends TestCase {
{
// Create error parser with the same id as in eclipse registry
RegexErrorParser regexErrorParser = new RegexErrorParser(TESTING_ID, TESTING_NAME);
- regexErrorParser.addPattern(new RegexErrorPattern(TESTING_REGEX,
- "line-<>\"'\\&", "file-<>\"'\\&", "description-<>\"'\\&", null, IMarkerGenerator.SEVERITY_WARNING, false));
+ regexErrorParser.addPattern(new RegexErrorPattern(TESTING_REGEX, "line-<>\"'\\&", "file-<>\"'\\&",
+ "description-<>\"'\\&", null, IMarkerGenerator.SEVERITY_WARNING, false));
// Add to available parsers
- ErrorParserExtensionManager.setUserDefinedErrorParsersInternal(new IErrorParserNamed[] {regexErrorParser});
+ ErrorParserExtensionManager
+ .setUserDefinedErrorParsersInternal(new IErrorParserNamed[] { regexErrorParser });
assertNotNull(ErrorParserManager.getErrorParserCopy(TESTING_ID));
// And serialize in persistent storage
ErrorParserExtensionManager.serializeUserDefinedErrorParsers();
@@ -638,7 +638,7 @@ public class RegexErrorParserTests extends TestCase {
IErrorParser errorParser = ErrorParserManager.getErrorParserCopy(TESTING_ID);
assertNotNull(errorParser);
assertTrue(errorParser instanceof RegexErrorParser);
- RegexErrorParser regexErrorParser = (RegexErrorParser)errorParser;
+ RegexErrorParser regexErrorParser = (RegexErrorParser) errorParser;
assertEquals(TESTING_ID, regexErrorParser.getId());
assertEquals(TESTING_NAME, regexErrorParser.getName());
@@ -654,11 +654,8 @@ public class RegexErrorParserTests extends TestCase {
* @throws Exception...
*/
public void testSerializeDefaultErrorParserIds() throws Exception {
- final String[] testingDefaultErrorParserIds = {
- "org.eclipse.cdt.core.test.errorparser0",
- "org.eclipse.cdt.core.test.errorparser1",
- "org.eclipse.cdt.core.test.errorparser2",
- };
+ final String[] testingDefaultErrorParserIds = { "org.eclipse.cdt.core.test.errorparser0",
+ "org.eclipse.cdt.core.test.errorparser1", "org.eclipse.cdt.core.test.errorparser2", };
final String TESTING_IDS = ErrorParserManager.toDelimitedString(testingDefaultErrorParserIds);
final String DEFAULT_IDS = ErrorParserManager.toDelimitedString(ErrorParserManager.getDefaultErrorParserIds());
@@ -677,7 +674,8 @@ public class RegexErrorParserTests extends TestCase {
{
// Remove from internal list
ErrorParserExtensionManager.setDefaultErrorParserIdsInternal(null);
- assertEquals(DEFAULT_IDS, ErrorParserManager.toDelimitedString(ErrorParserManager.getDefaultErrorParserIds()));
+ assertEquals(DEFAULT_IDS,
+ ErrorParserManager.toDelimitedString(ErrorParserManager.getDefaultErrorParserIds()));
}
{
@@ -722,12 +720,12 @@ public class RegexErrorParserTests extends TestCase {
assertTrue(clone1 instanceof ErrorParserNamedWrapper);
assertTrue(clone2 instanceof ErrorParserNamedWrapper);
- IErrorParser gccClone1 = ((ErrorParserNamedWrapper)clone1).getErrorParser();
- IErrorParser gccClone2 = ((ErrorParserNamedWrapper)clone2).getErrorParser();
+ IErrorParser gccClone1 = ((ErrorParserNamedWrapper) clone1).getErrorParser();
+ IErrorParser gccClone2 = ((ErrorParserNamedWrapper) clone2).getErrorParser();
assertNotSame(clone1, clone2);
}
}
-
+
/**
* Check how RegexErrorParser parses output.
*
@@ -735,8 +733,8 @@ public class RegexErrorParserTests extends TestCase {
*/
public void testRegexErrorParserExternalLocation_bug301338() throws Exception {
RegexErrorParser regexErrorParser = new RegexErrorParser();
- regexErrorParser.addPattern(new RegexErrorPattern("pattern",
- "", "", "", "$0", IMarkerGenerator.SEVERITY_ERROR_RESOURCE, true));
+ regexErrorParser.addPattern(
+ new RegexErrorPattern("pattern", "", "", "", "$0", IMarkerGenerator.SEVERITY_ERROR_RESOURCE, true));
errorList.clear();
ErrorParserManager epManager = new ErrorParserManager(fProject, markerGenerator, new String[0]);
@@ -747,5 +745,4 @@ public class RegexErrorParserTests extends TestCase {
assertEquals(0, errorList.size());
}
-
}
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/index/provider/test/AbstractDummyProvider.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/index/provider/test/AbstractDummyProvider.java
index 00279c1dc87..0603f7ff588 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/index/provider/test/AbstractDummyProvider.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/index/provider/test/AbstractDummyProvider.java
@@ -24,8 +24,9 @@ import org.eclipse.core.runtime.CoreException;
* project lifecycles.
*/
public class AbstractDummyProvider implements IReadOnlyPDOMProvider {
- public AbstractDummyProvider() {}
-
+ public AbstractDummyProvider() {
+ }
+
@Override
public IPDOMDescriptor[] getDescriptors(ICConfigurationDescription config) {
if (!DummyProviderTraces.getInstance().enabled)
@@ -33,7 +34,7 @@ public class AbstractDummyProvider implements IReadOnlyPDOMProvider {
DummyProviderTraces.getInstance().getCfgsTrace(getClass()).add(config);
return new IPDOMDescriptor[0];
}
-
+
@Override
public boolean providesFor(ICProject project) throws CoreException {
if (!DummyProviderTraces.getInstance().enabled)
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/index/provider/test/DummyProviderTraces.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/index/provider/test/DummyProviderTraces.java
index a20d46eb178..bbb59c7907c 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/index/provider/test/DummyProviderTraces.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/index/provider/test/DummyProviderTraces.java
@@ -21,33 +21,36 @@ import java.util.Map;
public class DummyProviderTraces {
static DummyProviderTraces instance = new DummyProviderTraces();
-
- public static DummyProviderTraces getInstance() { return instance; }
+
+ public static DummyProviderTraces getInstance() {
+ return instance;
+ }
/** Flag indicates if test is enabled, so we should trace projects and configs */
public volatile boolean enabled;
- private DummyProviderTraces() {}
-
- Map/*<String, List>*/ id2prjTrace= new HashMap();
- Map/*<String, List>*/ id2cfgTrace= new HashMap();
-
+ private DummyProviderTraces() {
+ }
+
+ Map/*<String, List>*/ id2prjTrace = new HashMap();
+ Map/*<String, List>*/ id2cfgTrace = new HashMap();
+
public List getProjectsTrace(Class provider) {
- String key= provider.getName();
- if(!id2prjTrace.containsKey(key)) {
+ String key = provider.getName();
+ if (!id2prjTrace.containsKey(key)) {
id2prjTrace.put(key, Collections.synchronizedList(new ArrayList()));
}
return (List) id2prjTrace.get(key);
}
-
+
public List getCfgsTrace(Class provider) {
- String key= provider.getName();
- if(!id2cfgTrace.containsKey(key)) {
+ String key = provider.getName();
+ if (!id2cfgTrace.containsKey(key)) {
id2cfgTrace.put(key, Collections.synchronizedList(new ArrayList()));
}
return (List) id2cfgTrace.get(key);
}
-
+
public void reset(Class provider) {
getProjectsTrace(provider).clear();
getCfgsTrace(provider).clear();
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/index/provider/test/Providers.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/index/provider/test/Providers.java
index 4b8df2a2135..6234a20e7cc 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/index/provider/test/Providers.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/index/provider/test/Providers.java
@@ -17,14 +17,24 @@ import org.eclipse.cdt.core.index.provider.IPDOMDescriptor;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
public class Providers {
- public static class Dummy1 extends AbstractDummyProvider {}
- public static class Dummy2 extends AbstractDummyProvider {}
- public static class Dummy3 extends AbstractDummyProvider {}
- public static class Dummy4 extends AbstractDummyProvider {}
- public static class Dummy5 extends AbstractDummyProvider {}
-
- public static class Counter extends AbstractDummyProvider{
+ public static class Dummy1 extends AbstractDummyProvider {
+ }
+
+ public static class Dummy2 extends AbstractDummyProvider {
+ }
+
+ public static class Dummy3 extends AbstractDummyProvider {
+ }
+
+ public static class Dummy4 extends AbstractDummyProvider {
+ }
+
+ public static class Dummy5 extends AbstractDummyProvider {
+ }
+
+ public static class Counter extends AbstractDummyProvider {
public static int fCounter;
+
@Override
public IPDOMDescriptor[] getDescriptors(ICConfigurationDescription config) {
fCounter++;
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/PositionTrackerTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/PositionTrackerTests.java
index b909dcabdcb..41e1523a329 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/PositionTrackerTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/PositionTrackerTests.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.core.internal.tests;
import java.util.Random;
@@ -24,337 +24,331 @@ import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
public class PositionTrackerTests extends TestCase {
- public static Test suite() {
- return new TestSuite(PositionTrackerTests.class);
- }
-
- public void testInitialFailures() {
- int[][] moves = {
- {46, -18, 95, -76, 98, -89, 10, -10, 85, -80, 16, 6, 5, -3,
- 22, -8, 29, -20, 86, -62, 34, -21, 63, -41, 9, 10, 18, -7},
- {0, 2, 1,-4},
- {4,-1, 0, 2, 0,-5},
- {0, 1, 2, 1, 0,-5},
- {0, 1, 2,-3, 1,-4},
- {4, 3, 3,-2, 0,-1},
- {4,-1, 3, 1, 2,-1},
- {0, 1, 2, 8, 1,-8, 0,-10},
- {4,-1, 2, 1, 4, 1, 0,-1, 0,-5},
- };
- int[] buffer = new int[100];
- for (int i = 0; i < moves.length; i++) {
- testMove(buffer, moves[i]);
- }
- }
-
- public void testRotations() {
- int[][] moves = { { 0, 1, 2, 1, 4, 1, 6, 1, 8, 1, 10, 1, 12, 1, 14, 1, 16, 1, 18, 1, 20, 1, 22, 1, 24, 1 }, {
- 15, 1, 14, 1, 13, 1, 12, 1, 11, 1, 10, 1, 9, 1, 8, 1, 7, 1, 6, 1, 5, 1, 4, 1, 3, 1 }, {
- 0, 1, 10, 1, 2, 1, 20, 1, 4, 1, 20, 1, 6, 1, 20, 1, 8, 1, 20, 1, 10, 1, 20, 1, 12, 1 }, };
- int[] buffer = new int[30];
- for (int i = 0; i < moves.length; i++) {
- assertTrue(testMove(buffer, moves[i]).depth() <= 5);
- }
- }
-
- public void testDepth4() {
- fullTest(5, 4);
- }
-
- public void testRandomDepth5() {
- randomTest(20, 5, 5, 1000);
- }
-
- public void testRandomDepth10() {
- randomTest(50, 10, 10, 1000);
- }
-
- public void testRandomDepth15() {
- randomTest(100, 15, 15, 1000);
- }
-
- public void testRandomDepth20() {
- randomTest(100, 15, 20, 1000);
- }
-
- public void testRetireDepth2() {
- randomRetireTest(100, 10, 25, 2, 1000);
- }
-
- public void testRetireDepth5() {
- randomRetireTest(100, 10, 10, 5, 1000);
- }
-
- public void testRetireDepth10() {
- randomRetireTest(100, 10, 5, 10, 1000);
- }
-
- public static void fullTest(int len, int depth) {
- // init buffer
- int[] buffer = new int[len];
- int[] move = new int[2 * depth];
- for (int i = 0; i < move.length; i++) {
- move[i] = -1;
- }
- while (nextMove(move, len)) {
- testMove(buffer, move);
- }
- }
-
- public static void randomTest(int buflen, int changelen, int depth, int count) {
- // init buffer
- Random rand = new Random();
-
- int[] buffer = new int[buflen];
- int[] move = new int[2 * depth];
-
- for (int j = 0; j < count; j++) {
- for (int i = 0; i < move.length; i += 2) {
- move[i] = rand.nextInt(buflen);
- move[i + 1] = rand.nextInt(2 * changelen) - changelen;
- }
- testMove(buffer, move);
- }
- }
-
- public static void randomRetireTest(int buflen, int changelen, int depth, int trackerDepth, int count) {
- // init buffer
- Random rand = new Random();
-
- int[] buffer = new int[buflen];
- int[] move = new int[2 * depth];
-
- for (int j = 0; j < count; j++) {
- for (int i = 0; i < buffer.length; i++) {
- buffer[i] = i;
- }
-
- PositionTracker t0 = null;
- PositionTracker previous = null;
- for (int t = 0; t < trackerDepth; t++) {
- for (int i = 0; i < move.length; i += 2) {
- move[i] = rand.nextInt(buflen);
- move[i + 1] = rand.nextInt(2 * changelen) - changelen;
- }
- PositionTracker tracker = new PositionTracker();
- if (previous != null) {
- previous.retire(tracker);
- }
- doMove(buffer, move, tracker);
- if (t0 == null) {
- t0 = tracker;
- }
- previous = tracker;
- }
- check(t0, buffer);
- }
- }
-
- static PositionTracker testMove(int[] buffer, int[] move) {
- try {
- return __testMove(buffer, move);
- } catch (RuntimeException e) {
- System.out.println("Error on move: "); //$NON-NLS-1$
- for (int i = 0; i < move.length; i++) {
- System.out.print(move[i] + ", "); //$NON-NLS-1$
- }
- System.out.println();
- throw e;
- } catch (Error e) {
- System.out.println("Error on move: "); //$NON-NLS-1$
- for (int i = 0; i < move.length; i++) {
- System.out.print(move[i] + ", "); //$NON-NLS-1$
- }
- System.out.println();
- throw e;
- }
- }
-
- static PositionTracker __testMove(int[] buffer, int[] move) {
- PositionTracker tracker = new PositionTracker();
- for (int i = 0; i < buffer.length; i++) {
- buffer[i] = i;
- }
- doMove(buffer, move, tracker);
- check(tracker, buffer);
- return tracker;
- }
-
- static void doMove(int[] buffer, int[] move, PositionTracker tracker) {
- for (int i = 0; i < move.length; i += 2) {
- int m1 = move[i];
- int m2 = move[i + 1];
- if (m1 == -1) {
- break;
- }
- if (m2 > 0) {
- tracker.insert(m1, m2);
- for (int j = 0; j < buffer.length; j++) {
- if (buffer[j] >= m1) {
- buffer[j] += m2;
- }
- }
- } else {
- tracker.delete(m1, -m2);
- int m3 = m1 - m2;
- for (int j = 0; j < buffer.length; j++) {
- if (buffer[j] >= m1) {
- if (buffer[j] < m3) {
- buffer[j] = -1;
- } else {
- buffer[j] += m2;
- }
- }
- }
- }
- }
- }
-
- private static void check(PositionTracker tracker, int[] buffer) {
- int lasti2 = -1;
- for (int i = 0; i < buffer.length; i++) {
- int i2 = buffer[i];
- if (i2 >= 0) {
- int i22 = tracker.currentOffset(i);
- assertEquals(i22, i2);
- assertTrue(lasti2 < i22);
- lasti2 = i22;
-
- assertEquals(i, tracker.historicOffset(i2));
- }
- }
- }
-
- private static boolean nextMove(int[] move, int bufLen) {
- for (int i = 0; i < move.length; i += 2) {
- int m1 = move[i];
- if (m1 < 0) {
- move[i] = 0;
- move[i + 1] = -bufLen;
- return true;
- }
- int m2 = ++move[i + 1];
- if (m2 <= bufLen - m1) {
- return true;
- }
- if (m1 < bufLen - 1) {
- move[i]++;
- move[i + 1] = -bufLen + m1 + 1;
- return true;
- }
- move[i] = 0;
- move[i + 1] = -bufLen;
- }
- return false;
- }
-
- public void testInsertion() {
- PositionTracker pt= new PositionTracker();
- pt.insert(1,1);
-
- checkInsert11(pt);
- }
-
- private void checkInsert11(PositionTracker pt) {
- // chars
- doubleCheck(pt, 0, 0);
- backwdCheck(pt, 1, 1);
- doubleCheck(pt, 1, 2);
- doubleCheck(pt, 2, 3);
-
- // ranges
- doubleRangeCheck(pt, new Region(0,2), new Region(0,3));
- backwdRangeCheck(pt, new Region(0,1), new Region(0,2));
- doubleRangeCheck(pt, new Region(0,1), new Region(0,1));
- backwdRangeCheck(pt, new Region(1,0), new Region(1,1));
- backwdRangeCheck(pt, new Region(1,0), new Region(1,0));
- doubleRangeCheck(pt, new Region(1,1), new Region(2,1));
- doubleRangeCheck(pt, new Region(1,0), new Region(2,0));
- }
-
- public void testDeletion() {
- PositionTracker pt= new PositionTracker();
- pt.delete(1,1);
- checkDelete11(pt);
- }
-
- private void checkDelete11(PositionTracker pt) {
- doubleCheck(pt, 0, 0);
- fwdCheck (pt, 1, 1);
- doubleCheck(pt, 2, 1);
- doubleCheck(pt, 3, 2);
-
- // ranges
- doubleRangeCheck(pt, new Region(0,3), new Region(0,2));
- fwdRangeCheck (pt, new Region(0,2), new Region(0,1));
- doubleRangeCheck(pt, new Region(0,1), new Region(0,1));
- fwdRangeCheck (pt, new Region(1,1), new Region(1,0));
- fwdRangeCheck (pt, new Region(1,0), new Region(1,0));
- doubleRangeCheck(pt, new Region(2,1), new Region(1,1));
- doubleRangeCheck(pt, new Region(2,0), new Region(1,0));
- }
-
- public void testReplace() {
- PositionTracker pt= new PositionTracker();
- pt.delete(1,1);
- pt.insert(1,1);
- doubleCheck(pt, 0, 0);
- doubleCheck(pt, 1, 1);
- doubleCheck(pt, 2, 2);
- doubleCheck(pt, 3, 3);
-
- pt.clear();
- pt.insert(1,1);
- pt.delete(1,1);
- doubleCheck(pt, 0, 0);
- doubleCheck(pt, 1, 1);
- doubleCheck(pt, 2, 2);
- doubleCheck(pt, 3, 3);
-
- pt.clear();
- pt.delete(0,2);
- pt.insert(0,1);
- checkDelete11(pt);
-
- pt.clear();
- pt.insert(1,1);
- pt.delete(1,2);
- checkDelete11(pt);
-
- pt.clear();
- pt.insert(1,2);
- pt.delete(1,1);
- checkInsert11(pt);
-
- pt.clear();
- pt.delete(1,1);
- pt.insert(1,2);
- checkInsert11(pt);
- }
-
- private void doubleCheck(PositionTracker pt, int orig, int mapped) {
- fwdCheck(pt, orig, mapped);
- backwdCheck(pt, orig, mapped);
- }
-
- private void fwdCheck(PositionTracker pt, int orig, int mapped) {
- assertEquals(mapped, pt.currentOffset(orig));
- }
-
- private void backwdCheck(PositionTracker pt, int orig, int mapped) {
- assertEquals(orig, pt.historicOffset(mapped));
- }
-
- private void doubleRangeCheck(PositionTracker pt, IRegion orig, IRegion mapped) {
- fwdRangeCheck(pt, orig, mapped);
- backwdRangeCheck(pt, orig, mapped);
- }
-
- private void fwdRangeCheck(PositionTracker pt, IRegion orig, IRegion mapped) {
- assertEquals(mapped, pt.historicToActual(orig));
- }
-
- private void backwdRangeCheck(PositionTracker pt, IRegion orig, IRegion mapped) {
- assertEquals(orig, pt.actualToHistoric(mapped));
- }
+ public static Test suite() {
+ return new TestSuite(PositionTrackerTests.class);
+ }
+
+ public void testInitialFailures() {
+ int[][] moves = {
+ { 46, -18, 95, -76, 98, -89, 10, -10, 85, -80, 16, 6, 5, -3, 22, -8, 29, -20, 86, -62, 34, -21, 63, -41,
+ 9, 10, 18, -7 },
+ { 0, 2, 1, -4 }, { 4, -1, 0, 2, 0, -5 }, { 0, 1, 2, 1, 0, -5 }, { 0, 1, 2, -3, 1, -4 },
+ { 4, 3, 3, -2, 0, -1 }, { 4, -1, 3, 1, 2, -1 }, { 0, 1, 2, 8, 1, -8, 0, -10 },
+ { 4, -1, 2, 1, 4, 1, 0, -1, 0, -5 }, };
+ int[] buffer = new int[100];
+ for (int i = 0; i < moves.length; i++) {
+ testMove(buffer, moves[i]);
+ }
+ }
+
+ public void testRotations() {
+ int[][] moves = { { 0, 1, 2, 1, 4, 1, 6, 1, 8, 1, 10, 1, 12, 1, 14, 1, 16, 1, 18, 1, 20, 1, 22, 1, 24, 1 },
+ { 15, 1, 14, 1, 13, 1, 12, 1, 11, 1, 10, 1, 9, 1, 8, 1, 7, 1, 6, 1, 5, 1, 4, 1, 3, 1 },
+ { 0, 1, 10, 1, 2, 1, 20, 1, 4, 1, 20, 1, 6, 1, 20, 1, 8, 1, 20, 1, 10, 1, 20, 1, 12, 1 }, };
+ int[] buffer = new int[30];
+ for (int i = 0; i < moves.length; i++) {
+ assertTrue(testMove(buffer, moves[i]).depth() <= 5);
+ }
+ }
+
+ public void testDepth4() {
+ fullTest(5, 4);
+ }
+
+ public void testRandomDepth5() {
+ randomTest(20, 5, 5, 1000);
+ }
+
+ public void testRandomDepth10() {
+ randomTest(50, 10, 10, 1000);
+ }
+
+ public void testRandomDepth15() {
+ randomTest(100, 15, 15, 1000);
+ }
+
+ public void testRandomDepth20() {
+ randomTest(100, 15, 20, 1000);
+ }
+
+ public void testRetireDepth2() {
+ randomRetireTest(100, 10, 25, 2, 1000);
+ }
+
+ public void testRetireDepth5() {
+ randomRetireTest(100, 10, 10, 5, 1000);
+ }
+
+ public void testRetireDepth10() {
+ randomRetireTest(100, 10, 5, 10, 1000);
+ }
+
+ public static void fullTest(int len, int depth) {
+ // init buffer
+ int[] buffer = new int[len];
+ int[] move = new int[2 * depth];
+ for (int i = 0; i < move.length; i++) {
+ move[i] = -1;
+ }
+ while (nextMove(move, len)) {
+ testMove(buffer, move);
+ }
+ }
+
+ public static void randomTest(int buflen, int changelen, int depth, int count) {
+ // init buffer
+ Random rand = new Random();
+
+ int[] buffer = new int[buflen];
+ int[] move = new int[2 * depth];
+
+ for (int j = 0; j < count; j++) {
+ for (int i = 0; i < move.length; i += 2) {
+ move[i] = rand.nextInt(buflen);
+ move[i + 1] = rand.nextInt(2 * changelen) - changelen;
+ }
+ testMove(buffer, move);
+ }
+ }
+
+ public static void randomRetireTest(int buflen, int changelen, int depth, int trackerDepth, int count) {
+ // init buffer
+ Random rand = new Random();
+
+ int[] buffer = new int[buflen];
+ int[] move = new int[2 * depth];
+
+ for (int j = 0; j < count; j++) {
+ for (int i = 0; i < buffer.length; i++) {
+ buffer[i] = i;
+ }
+
+ PositionTracker t0 = null;
+ PositionTracker previous = null;
+ for (int t = 0; t < trackerDepth; t++) {
+ for (int i = 0; i < move.length; i += 2) {
+ move[i] = rand.nextInt(buflen);
+ move[i + 1] = rand.nextInt(2 * changelen) - changelen;
+ }
+ PositionTracker tracker = new PositionTracker();
+ if (previous != null) {
+ previous.retire(tracker);
+ }
+ doMove(buffer, move, tracker);
+ if (t0 == null) {
+ t0 = tracker;
+ }
+ previous = tracker;
+ }
+ check(t0, buffer);
+ }
+ }
+
+ static PositionTracker testMove(int[] buffer, int[] move) {
+ try {
+ return __testMove(buffer, move);
+ } catch (RuntimeException e) {
+ System.out.println("Error on move: "); //$NON-NLS-1$
+ for (int i = 0; i < move.length; i++) {
+ System.out.print(move[i] + ", "); //$NON-NLS-1$
+ }
+ System.out.println();
+ throw e;
+ } catch (Error e) {
+ System.out.println("Error on move: "); //$NON-NLS-1$
+ for (int i = 0; i < move.length; i++) {
+ System.out.print(move[i] + ", "); //$NON-NLS-1$
+ }
+ System.out.println();
+ throw e;
+ }
+ }
+
+ static PositionTracker __testMove(int[] buffer, int[] move) {
+ PositionTracker tracker = new PositionTracker();
+ for (int i = 0; i < buffer.length; i++) {
+ buffer[i] = i;
+ }
+ doMove(buffer, move, tracker);
+ check(tracker, buffer);
+ return tracker;
+ }
+
+ static void doMove(int[] buffer, int[] move, PositionTracker tracker) {
+ for (int i = 0; i < move.length; i += 2) {
+ int m1 = move[i];
+ int m2 = move[i + 1];
+ if (m1 == -1) {
+ break;
+ }
+ if (m2 > 0) {
+ tracker.insert(m1, m2);
+ for (int j = 0; j < buffer.length; j++) {
+ if (buffer[j] >= m1) {
+ buffer[j] += m2;
+ }
+ }
+ } else {
+ tracker.delete(m1, -m2);
+ int m3 = m1 - m2;
+ for (int j = 0; j < buffer.length; j++) {
+ if (buffer[j] >= m1) {
+ if (buffer[j] < m3) {
+ buffer[j] = -1;
+ } else {
+ buffer[j] += m2;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private static void check(PositionTracker tracker, int[] buffer) {
+ int lasti2 = -1;
+ for (int i = 0; i < buffer.length; i++) {
+ int i2 = buffer[i];
+ if (i2 >= 0) {
+ int i22 = tracker.currentOffset(i);
+ assertEquals(i22, i2);
+ assertTrue(lasti2 < i22);
+ lasti2 = i22;
+
+ assertEquals(i, tracker.historicOffset(i2));
+ }
+ }
+ }
+
+ private static boolean nextMove(int[] move, int bufLen) {
+ for (int i = 0; i < move.length; i += 2) {
+ int m1 = move[i];
+ if (m1 < 0) {
+ move[i] = 0;
+ move[i + 1] = -bufLen;
+ return true;
+ }
+ int m2 = ++move[i + 1];
+ if (m2 <= bufLen - m1) {
+ return true;
+ }
+ if (m1 < bufLen - 1) {
+ move[i]++;
+ move[i + 1] = -bufLen + m1 + 1;
+ return true;
+ }
+ move[i] = 0;
+ move[i + 1] = -bufLen;
+ }
+ return false;
+ }
+
+ public void testInsertion() {
+ PositionTracker pt = new PositionTracker();
+ pt.insert(1, 1);
+
+ checkInsert11(pt);
+ }
+
+ private void checkInsert11(PositionTracker pt) {
+ // chars
+ doubleCheck(pt, 0, 0);
+ backwdCheck(pt, 1, 1);
+ doubleCheck(pt, 1, 2);
+ doubleCheck(pt, 2, 3);
+
+ // ranges
+ doubleRangeCheck(pt, new Region(0, 2), new Region(0, 3));
+ backwdRangeCheck(pt, new Region(0, 1), new Region(0, 2));
+ doubleRangeCheck(pt, new Region(0, 1), new Region(0, 1));
+ backwdRangeCheck(pt, new Region(1, 0), new Region(1, 1));
+ backwdRangeCheck(pt, new Region(1, 0), new Region(1, 0));
+ doubleRangeCheck(pt, new Region(1, 1), new Region(2, 1));
+ doubleRangeCheck(pt, new Region(1, 0), new Region(2, 0));
+ }
+
+ public void testDeletion() {
+ PositionTracker pt = new PositionTracker();
+ pt.delete(1, 1);
+ checkDelete11(pt);
+ }
+
+ private void checkDelete11(PositionTracker pt) {
+ doubleCheck(pt, 0, 0);
+ fwdCheck(pt, 1, 1);
+ doubleCheck(pt, 2, 1);
+ doubleCheck(pt, 3, 2);
+
+ // ranges
+ doubleRangeCheck(pt, new Region(0, 3), new Region(0, 2));
+ fwdRangeCheck(pt, new Region(0, 2), new Region(0, 1));
+ doubleRangeCheck(pt, new Region(0, 1), new Region(0, 1));
+ fwdRangeCheck(pt, new Region(1, 1), new Region(1, 0));
+ fwdRangeCheck(pt, new Region(1, 0), new Region(1, 0));
+ doubleRangeCheck(pt, new Region(2, 1), new Region(1, 1));
+ doubleRangeCheck(pt, new Region(2, 0), new Region(1, 0));
+ }
+
+ public void testReplace() {
+ PositionTracker pt = new PositionTracker();
+ pt.delete(1, 1);
+ pt.insert(1, 1);
+ doubleCheck(pt, 0, 0);
+ doubleCheck(pt, 1, 1);
+ doubleCheck(pt, 2, 2);
+ doubleCheck(pt, 3, 3);
+
+ pt.clear();
+ pt.insert(1, 1);
+ pt.delete(1, 1);
+ doubleCheck(pt, 0, 0);
+ doubleCheck(pt, 1, 1);
+ doubleCheck(pt, 2, 2);
+ doubleCheck(pt, 3, 3);
+
+ pt.clear();
+ pt.delete(0, 2);
+ pt.insert(0, 1);
+ checkDelete11(pt);
+
+ pt.clear();
+ pt.insert(1, 1);
+ pt.delete(1, 2);
+ checkDelete11(pt);
+
+ pt.clear();
+ pt.insert(1, 2);
+ pt.delete(1, 1);
+ checkInsert11(pt);
+
+ pt.clear();
+ pt.delete(1, 1);
+ pt.insert(1, 2);
+ checkInsert11(pt);
+ }
+
+ private void doubleCheck(PositionTracker pt, int orig, int mapped) {
+ fwdCheck(pt, orig, mapped);
+ backwdCheck(pt, orig, mapped);
+ }
+
+ private void fwdCheck(PositionTracker pt, int orig, int mapped) {
+ assertEquals(mapped, pt.currentOffset(orig));
+ }
+
+ private void backwdCheck(PositionTracker pt, int orig, int mapped) {
+ assertEquals(orig, pt.historicOffset(mapped));
+ }
+
+ private void doubleRangeCheck(PositionTracker pt, IRegion orig, IRegion mapped) {
+ fwdRangeCheck(pt, orig, mapped);
+ backwdRangeCheck(pt, orig, mapped);
+ }
+
+ private void fwdRangeCheck(PositionTracker pt, IRegion orig, IRegion mapped) {
+ assertEquals(mapped, pt.historicToActual(orig));
+ }
+
+ private void backwdRangeCheck(PositionTracker pt, IRegion orig, IRegion mapped) {
+ assertEquals(orig, pt.actualToHistoric(mapped));
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/ResourceLookupTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/ResourceLookupTests.java
index 52eeb714ef1..cdf539f90c8 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/ResourceLookupTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/ResourceLookupTests.java
@@ -11,7 +11,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.core.internal.tests;
import java.io.File;
@@ -35,43 +35,44 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
public class ResourceLookupTests extends BaseTestCase {
- public static Test suite() {
- return new TestSuite(ResourceLookupTests.class);
- }
+ public static Test suite() {
+ return new TestSuite(ResourceLookupTests.class);
+ }
private IProject fProject;
- @Override
+ @Override
protected void setUp() throws Exception {
- super.setUp();
+ super.setUp();
final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- fProject= root.getProject("reslookup_" + getName());
- }
-
- @Override
+ fProject = root.getProject("reslookup_" + getName());
+ }
+
+ @Override
protected void tearDown() throws Exception {
fProject.delete(true, new NullProgressMonitor());
super.tearDown();
- }
-
+ }
+
protected IFolder createFolder(IProject project, String filename) throws CoreException {
- IFolder folder= project.getFolder(filename);
+ IFolder folder = project.getFolder(filename);
folder.create(true, false, new NullProgressMonitor());
return folder;
}
protected IFile createFile(IProject project, String filename) throws CoreException {
- IFile file= project.getFile(filename);
+ IFile file = project.getFile(filename);
file.create(new InputStream() {
@Override
public int read() throws IOException {
return -1;
- }}, true, new NullProgressMonitor());
+ }
+ }, true, new NullProgressMonitor());
return file;
}
-
+
public void testNameLookup() throws CoreException {
- IProject[] prjs= new IProject[] { fProject };
+ IProject[] prjs = new IProject[] { fProject };
fProject.create(new NullProgressMonitor());
fProject.open(new NullProgressMonitor());
@@ -81,159 +82,159 @@ public class ResourceLookupTests extends BaseTestCase {
createFile(fProject, "folder1/abc.h");
createFile(fProject, "folder2/abC.h");
- IFile[] files= ResourceLookup.findFilesByName(new Path("abc.h"), prjs, false);
+ IFile[] files = ResourceLookup.findFilesByName(new Path("abc.h"), prjs, false);
assertEquals(2, files.length);
- files= ResourceLookup.findFilesByName(new Path("bla/../abc.h"), prjs, false);
+ files = ResourceLookup.findFilesByName(new Path("bla/../abc.h"), prjs, false);
assertEquals(2, files.length);
- files= ResourceLookup.findFilesByName(new Path("../abc.h"), prjs, false);
+ files = ResourceLookup.findFilesByName(new Path("../abc.h"), prjs, false);
assertEquals(2, files.length);
- files= ResourceLookup.findFilesByName(new Path("../../abc.h"), prjs, false);
+ files = ResourceLookup.findFilesByName(new Path("../../abc.h"), prjs, false);
assertEquals(2, files.length);
- files= ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
+ files = ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
assertEquals(3, files.length);
- files= ResourceLookup.findFilesByName(new Path("folder1/abc.h"), prjs, false);
+ files = ResourceLookup.findFilesByName(new Path("folder1/abc.h"), prjs, false);
assertEquals(1, files.length);
- files= ResourceLookup.findFilesByName(new Path("folder1/abC.h"), prjs, false);
+ files = ResourceLookup.findFilesByName(new Path("folder1/abC.h"), prjs, false);
assertEquals(0, files.length);
- files= ResourceLookup.findFilesByName(new Path("fOlder1/abc.h"), prjs, false);
+ files = ResourceLookup.findFilesByName(new Path("fOlder1/abc.h"), prjs, false);
assertEquals(0, files.length);
- files= ResourceLookup.findFilesByName(new Path("folder1/abc.h"), prjs, true);
+ files = ResourceLookup.findFilesByName(new Path("folder1/abc.h"), prjs, true);
assertEquals(1, files.length);
- files= ResourceLookup.findFilesByName(new Path("folder1/abC.h"), prjs, true);
+ files = ResourceLookup.findFilesByName(new Path("folder1/abC.h"), prjs, true);
assertEquals(1, files.length);
- files= ResourceLookup.findFilesByName(new Path("fOlder1/abc.h"), prjs, true);
+ files = ResourceLookup.findFilesByName(new Path("fOlder1/abc.h"), prjs, true);
assertEquals(1, files.length);
- files= ResourceLookup.findFilesByName(new Path("bla/../abc.h"), prjs, true);
+ files = ResourceLookup.findFilesByName(new Path("bla/../abc.h"), prjs, true);
assertEquals(3, files.length);
}
public void testResourceDelta() throws CoreException {
- IProject[] prjs= new IProject[]{fProject};
+ IProject[] prjs = new IProject[] { fProject };
fProject.create(new NullProgressMonitor());
fProject.open(new NullProgressMonitor());
- IFile[] files= ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
+ IFile[] files = ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
assertEquals(0, files.length);
- IFolder f1= createFolder(fProject, "folder1");
+ IFolder f1 = createFolder(fProject, "folder1");
createFolder(fProject, "folder2");
- IFile f2= createFile(fProject, "abc.h");
- files= ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
+ IFile f2 = createFile(fProject, "abc.h");
+ files = ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
assertEquals(1, files.length);
createFile(fProject, "folder1/abc.h");
- files= ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
+ files = ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
assertEquals(2, files.length);
createFile(fProject, "folder2/abC.h");
- files= ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
+ files = ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
assertEquals(3, files.length);
-
+
f1.delete(true, new NullProgressMonitor());
- files= ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
+ files = ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
assertEquals(2, files.length);
-
+
f2.delete(true, new NullProgressMonitor());
- files= ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
+ files = ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
assertEquals(1, files.length);
}
public void testDeref() throws CoreException {
- IProject[] prjs= new IProject[]{fProject};
+ IProject[] prjs = new IProject[] { fProject };
fProject.create(new NullProgressMonitor());
fProject.open(new NullProgressMonitor());
createFolder(fProject, "folder1");
createFolder(fProject, "folder2");
createFile(fProject, "abc.h");
- IFile[] files= ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
+ IFile[] files = ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
assertEquals(1, files.length);
-
+
ResourceLookup.unrefNodeMap();
createFile(fProject, "folder1/abc.h");
createFile(fProject, "folder2/abC.h");
- files= ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
+ files = ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
assertEquals(3, files.length);
-
+
ResourceLookup.unrefNodeMap();
- files= ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
- assertEquals(3, files.length);
+ files = ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
+ assertEquals(3, files.length);
}
-
+
public void testCollected() throws CoreException {
- IProject[] prjs= new IProject[]{fProject};
+ IProject[] prjs = new IProject[] { fProject };
fProject.create(new NullProgressMonitor());
fProject.open(new NullProgressMonitor());
createFolder(fProject, "folder1");
createFolder(fProject, "folder2");
createFile(fProject, "abc.h");
- IFile[] files= ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
+ IFile[] files = ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
assertEquals(1, files.length);
-
+
ResourceLookup.simulateNodeMapCollection();
createFile(fProject, "folder1/abc.h");
createFile(fProject, "folder2/abC.h");
- files= ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
+ files = ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
assertEquals(3, files.length);
-
+
ResourceLookup.simulateNodeMapCollection();
- files= ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
- assertEquals(3, files.length);
+ files = ResourceLookup.findFilesByName(new Path("abc.h"), prjs, true);
+ assertEquals(3, files.length);
}
-
+
public void testFindFilesByLocation() throws Exception {
fProject.create(new NullProgressMonitor());
fProject.open(new NullProgressMonitor());
createFolder(fProject, "folder1");
createFolder(fProject, "folder2");
- IFile file= createFile(fProject, "abc.h");
+ IFile file = createFile(fProject, "abc.h");
createFile(fProject, "folder1/abc.h");
createFile(fProject, "folder2/abC.h");
- URI uri= file.getLocationURI();
- IPath path= file.getLocation();
- IFile[] files= ResourceLookup.findFilesForLocationURI(uri);
+ URI uri = file.getLocationURI();
+ IPath path = file.getLocation();
+ IFile[] files = ResourceLookup.findFilesForLocationURI(uri);
assertEquals(1, files.length);
- files= ResourceLookup.findFilesForLocation(path);
+ files = ResourceLookup.findFilesForLocation(path);
assertEquals(1, files.length);
if (new File("a").equals(new File("A"))) {
- URI upperCase= new URI(uri.getScheme(), uri.getSchemeSpecificPart().toUpperCase(), uri.getFragment());
- IPath upperCasePath= new Path(path.toString().toUpperCase());
- files= ResourceLookup.findFilesForLocationURI(upperCase);
+ URI upperCase = new URI(uri.getScheme(), uri.getSchemeSpecificPart().toUpperCase(), uri.getFragment());
+ IPath upperCasePath = new Path(path.toString().toUpperCase());
+ files = ResourceLookup.findFilesForLocationURI(upperCase);
assertEquals(1, files.length);
- files= ResourceLookup.findFilesForLocation(upperCasePath);
+ files = ResourceLookup.findFilesForLocation(upperCasePath);
assertEquals(1, files.length);
- }
+ }
}
-
+
public void testLinkedResourceFiles() throws Exception {
- IProject[] prjs= new IProject[]{fProject};
+ IProject[] prjs = new IProject[] { fProject };
fProject.create(new NullProgressMonitor());
fProject.open(new NullProgressMonitor());
createFolder(fProject, "folder1");
- File f= createTempFile("extern", ".h");
- IPath location= Path.fromOSString(f.getAbsolutePath());
- IFile file1= fProject.getFile("linked1");
- IFile file2= fProject.getFile("linked2.h");
+ File f = createTempFile("extern", ".h");
+ IPath location = Path.fromOSString(f.getAbsolutePath());
+ IFile file1 = fProject.getFile("linked1");
+ IFile file2 = fProject.getFile("linked2.h");
file1.createLink(location, 0, new NullProgressMonitor());
file2.createLink(location, 0, new NullProgressMonitor());
IFile[] files = ResourceLookup.findFilesForLocation(location);
assertEquals(2, files.length);
-
- files= ResourceLookup.findFilesByName(new Path(location.lastSegment()), prjs, false);
+
+ files = ResourceLookup.findFilesByName(new Path(location.lastSegment()), prjs, false);
assertEquals(2, files.length);
- files= ResourceLookup.findFilesByName(new Path("linked2.h"), prjs, false);
+ files = ResourceLookup.findFilesByName(new Path("linked2.h"), prjs, false);
assertEquals(0, files.length);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/StringBuilderTest.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/StringBuilderTest.java
index 70146edc266..012ae0b2d5d 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/StringBuilderTest.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/StringBuilderTest.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.core.internal.tests;
@@ -21,39 +21,38 @@ import junit.framework.TestCase;
import junit.framework.TestSuite;
public class StringBuilderTest extends TestCase {
- public static Test suite() {
- return new TestSuite(StringBuilderTest.class);
- }
+ public static Test suite() {
+ return new TestSuite(StringBuilderTest.class);
+ }
- public void testSafe() {
- StringBuilder b1= new StringBuilder();
- StringBuilder b2= new StringBuilder();
- b1.append("a");
- b2.append("b");
- CharSequence cs= b2;
- b1.append(cs);
- assertEquals("ab", b1.toString());
- }
-
- public void testBug220158() {
- StringBuilder b1= new StringBuilder();
- StringBuilder b2= new StringBuilder();
- b1.append("a");
- b2.append("b");
- b1.append(b2);
- assertEquals("ab", b1.toString());
- }
-
- public void testStringBuilderMethods() throws Exception {
- Class clazz= StringBuilder.class;
- Method method= clazz.getMethod("append", CharSequence.class);
+ public void testSafe() {
+ StringBuilder b1 = new StringBuilder();
+ StringBuilder b2 = new StringBuilder();
+ b1.append("a");
+ b2.append("b");
+ CharSequence cs = b2;
+ b1.append(cs);
+ assertEquals("ab", b1.toString());
+ }
+
+ public void testBug220158() {
+ StringBuilder b1 = new StringBuilder();
+ StringBuilder b2 = new StringBuilder();
+ b1.append("a");
+ b2.append("b");
+ b1.append(b2);
+ assertEquals("ab", b1.toString());
+ }
+
+ public void testStringBuilderMethods() throws Exception {
+ Class clazz = StringBuilder.class;
+ Method method = clazz.getMethod("append", CharSequence.class);
assertNotNull(method);
- try {
- method= clazz.getMethod("append", StringBuilder.class);
- fail();
- }
- catch (NoSuchMethodException m) {
- // ok
- }
- }
+ try {
+ method = clazz.getMethod("append", StringBuilder.class);
+ fail();
+ } catch (NoSuchMethodException m) {
+ // ok
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryEFSExtensionProvider.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryEFSExtensionProvider.java
index bf72a753c69..069bd36670b 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryEFSExtensionProvider.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryEFSExtensionProvider.java
@@ -24,12 +24,12 @@ import org.eclipse.cdt.core.EFSExtensionProvider;
public class MemoryEFSExtensionProvider extends EFSExtensionProvider {
public String getMappedPath(URI locationURI) {
-
+
String path = locationURI.getPath();
if (path.contains("/BeingMappedFrom/Folder")) {
return path.replaceFirst("/BeingMappedFrom/Folder", "/LocallyMappedTo/Folder");
}
-
+
return super.getMappedPath(locationURI);
}
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryFileStore.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryFileStore.java
index b6a97a74c7d..bbe8c1112dd 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryFileStore.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryFileStore.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Andrew Gvozdev (Quoin Inc.) - contributed to CDT from org.eclipse.core.tests.resources v20090320
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryFileSystem.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryFileSystem.java
index 35967e30dbf..7b2e4b56e19 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryFileSystem.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryFileSystem.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Andrew Gvozdev (Quoin Inc.) - contributed to CDT from org.eclipse.core.tests.resources v20090320
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryTree.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryTree.java
index 62eb70d91ab..39a3904e97e 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryTree.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryTree.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Andrew Gvozdev (Quoin Inc.) - contributed to CDT from org.eclipse.core.tests.resources v20090320
@@ -165,7 +165,8 @@ public class MemoryTree {
}
}
- static final int[] ALL_ATTRIBUTES = new int[] {EFS.ATTRIBUTE_ARCHIVE, EFS.ATTRIBUTE_EXECUTABLE, EFS.ATTRIBUTE_HIDDEN, EFS.ATTRIBUTE_READ_ONLY,};
+ static final int[] ALL_ATTRIBUTES = new int[] { EFS.ATTRIBUTE_ARCHIVE, EFS.ATTRIBUTE_EXECUTABLE,
+ EFS.ATTRIBUTE_HIDDEN, EFS.ATTRIBUTE_READ_ONLY, };
public static final MemoryTree TREE = new MemoryTree();
@@ -218,7 +219,7 @@ public class MemoryTree {
/**
* Returns the node at the given path, or null if not found.
- *
+ *
* @param path
* @return
*/
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/Policy.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/Policy.java
index 72e2d2eddbc..341f4d33f05 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/Policy.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/Policy.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Andrew Gvozdev (Quoin Inc.) - contributed to CDT from org.eclipse.core.tests.resources v20090320
@@ -17,12 +17,13 @@ package org.eclipse.cdt.core.internal.tests.filesystem.ram;
import org.eclipse.core.runtime.*;
/**
- *
+ *
*/
public class Policy {
public static void error(String message) throws CoreException {
- throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.cdt.core.tests.internal.filesystem.ram", 1, message, null));
+ throw new CoreException(
+ new Status(IStatus.ERROR, "org.eclipse.cdt.core.tests.internal.filesystem.ram", 1, message, null));
}
private Policy() {
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/preferences/tests/TestScopeOfBuildConfigResourceChangesPreference.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/preferences/tests/TestScopeOfBuildConfigResourceChangesPreference.java
index 1f7679c77e4..8d681ce381d 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/preferences/tests/TestScopeOfBuildConfigResourceChangesPreference.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/preferences/tests/TestScopeOfBuildConfigResourceChangesPreference.java
@@ -36,9 +36,9 @@ public class TestScopeOfBuildConfigResourceChangesPreference extends TestCase {
private boolean oldInstanceScopeValue;
private boolean oldDefaultScopeValue;
- public static Test suite() {
- return new TestSuite(TestScopeOfBuildConfigResourceChangesPreference.class);
- }
+ public static Test suite() {
+ return new TestSuite(TestScopeOfBuildConfigResourceChangesPreference.class);
+ }
@Override
protected void setUp() throws Exception {
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java
index abfa6f3a9fa..a0e4d6e28c0 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -54,7 +54,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
*
*/
public class RefreshScopeTests extends TestCase {
-
+
private IProject fProject;
private IProject fGeneralProject;
private IFolder fFolder1;
@@ -63,44 +63,44 @@ public class RefreshScopeTests extends TestCase {
private IFolder fFolder4;
private IFolder fFolder5;
private IFolder fFolder6;
- private String config1,config2;
+ private String config1, config2;
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
-
+
// create project
CTestPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
- ICProject cProject = CProjectHelper.createNewStyleCProject("testRefreshScope", IPDOMManager.ID_NO_INDEXER, false);
+ ICProject cProject = CProjectHelper.createNewStyleCProject("testRefreshScope",
+ IPDOMManager.ID_NO_INDEXER, false);
fProject = cProject.getProject();
-
+
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
fGeneralProject = root.getProject("testRefreshScopeGeneral");
assertNotNull(fGeneralProject);
-
+
if (!fGeneralProject.exists()) {
fGeneralProject.create(null);
} else {
fGeneralProject.refreshLocal(IResource.DEPTH_INFINITE, null);
}
-
+
if (!fGeneralProject.isOpen()) {
fGeneralProject.open(null);
}
}
}, null);
-
-
+
IWorkspaceRoot root = CTestPlugin.getWorkspace().getRoot();
IProject project = root.getProject("testRefreshScope");
-
+
config1 = "Debug";
config2 = "Release";
-
+
// create some folders
// structure is:
/*
@@ -111,12 +111,12 @@ public class RefreshScopeTests extends TestCase {
* folder 4
* folder 5
* folder 6
- *
+ *
*/
final IFolder folder1 = project.getFolder("folder1");
fFolder1 = folder1;
final IFolder folder2 = project.getFolder("folder2");
- fFolder2 = folder2;
+ fFolder2 = folder2;
final IFolder folder3 = folder2.getFolder("folder3");
fFolder3 = folder3;
final IFolder folder4 = folder3.getFolder("folder4");
@@ -125,11 +125,11 @@ public class RefreshScopeTests extends TestCase {
fFolder5 = folder5;
final IFolder folder6 = folder2.getFolder("folder6");
fFolder6 = folder6;
-
+
CTestPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
-
+
folder1.create(true, true, monitor);
folder2.create(true, true, monitor);
folder3.create(true, true, monitor);
@@ -138,7 +138,7 @@ public class RefreshScopeTests extends TestCase {
folder6.create(true, true, monitor);
}
}, null);
-
+
}
/* (non-Javadoc)
@@ -148,13 +148,13 @@ public class RefreshScopeTests extends TestCase {
protected void tearDown() throws Exception {
fProject.delete(true, true, null);
}
-
+
public void testAddDeleteResource() throws CoreException {
-
+
RefreshScopeManager manager = RefreshScopeManager.getInstance();
manager.clearAllData();
-
- // TEST 1:
+
+ // TEST 1:
// add resource "folder1" under config1.
manager.addResourceToRefresh(fProject, config1, fFolder1);
// now, check that it was added.
@@ -162,7 +162,7 @@ public class RefreshScopeTests extends TestCase {
assertEquals(config1_resources.size(), 2);
assertEquals(config1_resources.contains(fProject), true);
assertEquals(config1_resources.contains(fFolder1), true);
-
+
// TEST 2:
// add resource "folder2" under config1
manager.addResourceToRefresh(fProject, config1, fFolder2);
@@ -172,19 +172,19 @@ public class RefreshScopeTests extends TestCase {
assertEquals(config1_resources.contains(fProject), true);
assertEquals(config1_resources.contains(fFolder1), true);
assertEquals(config1_resources.contains(fFolder2), true);
-
+
// make sure it wasn't added under "Release", which should be empty now, excpet for the default project resource.
List<IResource> config2_resources = manager.getResourcesToRefresh(fProject, config2);
- assertEquals(config2_resources.size(),1);
+ assertEquals(config2_resources.size(), 1);
assertEquals(config2_resources.contains(fProject), true);
-
+
// and add one under config 2.
manager.addResourceToRefresh(fProject, config2, fFolder1);
config2_resources = manager.getResourcesToRefresh(fProject, config2);
- assertEquals(config2_resources.size(),2);
+ assertEquals(config2_resources.size(), 2);
assertEquals(config2_resources.contains(fProject), true);
assertEquals(config2_resources.contains(fFolder1), true);
-
+
// TEST 3:
// first try deleting a resource that was never added... folder5
manager.deleteResourceToRefresh(fProject, config1, fFolder5);
@@ -192,16 +192,15 @@ public class RefreshScopeTests extends TestCase {
assertEquals(config1_resourcesAfterDelete.size(), 3);
assertEquals(config1_resources.contains(fProject), true);
assertEquals(config1_resources.contains(fFolder1), true);
- assertEquals( config1_resources.contains(fFolder2), true);
-
+ assertEquals(config1_resources.contains(fFolder2), true);
+
// ditto for config2, but this time we did add the resource, to make sure fFolder1 wasn't added.
manager.deleteResourceToRefresh(fProject, config2, fFolder5);
List<IResource> config2_resourcesAfterDelete = manager.getResourcesToRefresh(fProject, config2);
assertEquals(config2_resourcesAfterDelete.size(), 2);
assertEquals(config2_resources.contains(fProject), true);
assertEquals(config2_resources.contains(fFolder1), true);
-
-
+
// TEST 4:
// now delete the resources from the manager one by one
manager.deleteResourceToRefresh(fProject, config1, config1_resources.get(config1_resources.indexOf(fFolder2)));
@@ -209,90 +208,88 @@ public class RefreshScopeTests extends TestCase {
assertEquals(config1_resourcesAfterDelete.size(), 2);
assertEquals(config1_resourcesAfterDelete.contains(fProject), true);
assertEquals(config1_resourcesAfterDelete.contains(fFolder1), true);
-
- manager.deleteResourceToRefresh(fProject, config1, config1_resources.get(config1_resources.indexOf(fFolder1)));
+
+ manager.deleteResourceToRefresh(fProject, config1, config1_resources.get(config1_resources.indexOf(fFolder1)));
config1_resourcesAfterDelete = manager.getResourcesToRefresh(fProject, config1);
assertEquals(config1_resourcesAfterDelete.size(), 1);
assertEquals(config1_resourcesAfterDelete.contains(fProject), true);
-
+
// and ditto for config2
manager.deleteResourceToRefresh(fProject, config2, config2_resources.get(config2_resources.indexOf(fFolder1)));
config2_resourcesAfterDelete = manager.getResourcesToRefresh(fProject, config2);
- assertEquals(config2_resourcesAfterDelete.size(), 1);
+ assertEquals(config2_resourcesAfterDelete.size(), 1);
assertEquals(config2_resourcesAfterDelete.contains(fProject), true);
}
-
public void testSetResourcesToExclusionsMapRefresh() {
RefreshScopeManager manager = RefreshScopeManager.getInstance();
manager.clearAllData();
-
+
HashMap<IResource, List<RefreshExclusion>> config1_resourceMap = new HashMap<IResource, List<RefreshExclusion>>();
- config1_resourceMap.put(fFolder1,new LinkedList<RefreshExclusion>());
- config1_resourceMap.put(fFolder2,new LinkedList<RefreshExclusion>());
+ config1_resourceMap.put(fFolder1, new LinkedList<RefreshExclusion>());
+ config1_resourceMap.put(fFolder2, new LinkedList<RefreshExclusion>());
manager.setResourcesToExclusionsMap(fProject, config1, config1_resourceMap);
-
+
List<IResource> config1_resourcesAfterSet = manager.getResourcesToRefresh(fProject, config1);
assertEquals(config1_resourcesAfterSet.size(), 2);
assertEquals(config1_resourcesAfterSet.contains(fFolder1), true);
assertEquals(config1_resourcesAfterSet.contains(fFolder2), true);
-
+
manager.clearResourcesToRefresh(fProject);
-
+
}
-
+
public void testAddRemoveExclusion() {
RefreshScopeManager manager = RefreshScopeManager.getInstance();
manager.clearAllData();
-
+
IResource config1_resource = fProject;
-
-
+
manager.addResourceToRefresh(fProject, config1, config1_resource);
RefreshExclusion config1_exclusion1 = new TestExclusion();
manager.addExclusion(fProject, config1, config1_resource, config1_exclusion1);
RefreshExclusion config1_exclusion2 = new TestExclusion();
manager.addExclusion(fProject, config1, config1_resource, config1_exclusion2);
-
+
// make sure the exclusions are there
List<RefreshExclusion> exclusionsList = manager.getExclusions(fProject, config1, config1_resource);
RefreshExclusion[] exclusionsArray = exclusionsList.toArray(new RefreshExclusion[0]);
assertEquals(exclusionsArray.length, 2);
assertEquals(exclusionsArray[0], config1_exclusion1);
assertEquals(exclusionsArray[1], config1_exclusion2);
-
+
// remove the exclusions one by one
manager.removeExclusion(fProject, config1, config1_resource, config1_exclusion2);
- exclusionsList = manager.getExclusions(fProject,config1,config1_resource);
+ exclusionsList = manager.getExclusions(fProject, config1, config1_resource);
exclusionsArray = exclusionsList.toArray(new RefreshExclusion[0]);
assertEquals(exclusionsArray.length, 1);
assertEquals(exclusionsArray[0], config1_exclusion1);
-
+
manager.removeExclusion(fProject, config1, config1_resource, config1_exclusion1);
- exclusionsList = manager.getExclusions(fProject, config1,config1_resource);
+ exclusionsList = manager.getExclusions(fProject, config1, config1_resource);
exclusionsArray = exclusionsList.toArray(new RefreshExclusion[0]);
assertEquals(exclusionsArray.length, 0);
-
+
}
-
+
public void testPersistAndLoad() {
RefreshScopeManager manager = RefreshScopeManager.getInstance();
manager.clearAllData();
-
+
IResource config1_resource = fProject;
IResource config2_resource = fFolder1;
-
+
//add a resource and two exclusions for config1.
- manager.addResourceToRefresh(fProject, config1, config1_resource);
+ manager.addResourceToRefresh(fProject, config1, config1_resource);
RefreshExclusion config1_exclusion1 = new TestExclusion();
manager.addExclusion(fProject, config1, config1_resource, config1_exclusion1);
RefreshExclusion config1_exclusion2 = new TestExclusion();
manager.addExclusion(fProject, config1, config1_resource, config1_exclusion2);
-
+
// add a nested exclusion to the first exclusion
RefreshExclusion config1_exclusion3 = new TestExclusion();
config1_exclusion1.addNestedExclusion(config1_exclusion3);
-
+
// add an instance to the second exclusion
ExclusionInstance config1_instance = new ExclusionInstance();
config1_instance.setDisplayString("foo");
@@ -300,18 +297,18 @@ public class RefreshScopeTests extends TestCase {
config1_instance.setExclusionType(ExclusionType.RESOURCE);
config1_instance.setParentExclusion(config1_exclusion2);
config1_exclusion2.addExclusionInstance(config1_instance);
-
+
//add a resource and two exclusions for config2.
- manager.addResourceToRefresh(fProject, config2, config2_resource);
+ manager.addResourceToRefresh(fProject, config2, config2_resource);
RefreshExclusion config2_exclusion1 = new TestExclusion();
manager.addExclusion(fProject, config2, config2_resource, config2_exclusion1);
RefreshExclusion config2_exclusion2 = new TestExclusion();
manager.addExclusion(fProject, config2, config2_resource, config2_exclusion2);
-
+
// add a nested exclusion to the first exclusion
RefreshExclusion config2_exclusion3 = new TestExclusion();
config2_exclusion1.addNestedExclusion(config2_exclusion3);
-
+
// add an instance to the second exclusion
ExclusionInstance config2_instance = new ExclusionInstance();
config2_instance.setDisplayString("foo");
@@ -319,120 +316,118 @@ public class RefreshScopeTests extends TestCase {
config2_instance.setExclusionType(ExclusionType.RESOURCE);
config2_instance.setParentExclusion(config2_exclusion2);
config2_exclusion2.addExclusionInstance(config1_instance);
-
+
ICProjectDescription projectDescription = CCorePlugin.getDefault().getProjectDescription(fProject, true);
-
+
try {
manager.persistSettings(projectDescription);
CCorePlugin.getDefault().setProjectDescription(fProject, projectDescription);
} catch (CoreException e) {
fail();
}
-
+
// now clear all the settings out of the manager
manager.clearAllData();
-
+
// now load the settings
try {
manager.loadSettings();
} catch (CoreException e) {
fail();
}
-
+
// make sure we got the same stuff we saved for config1
-
+
// the project should be set to refresh its root
- List<IResource> config1_resources = manager.getResourcesToRefresh(fProject,config1);
+ List<IResource> config1_resources = manager.getResourcesToRefresh(fProject, config1);
assertEquals(config1_resources.size(), 1);
assertEquals(config1_resources.toArray(new IResource[0])[0], config1_resource);
-
+
// there should be 2 top-level exclusions
- List<RefreshExclusion> config1_exclusions = manager.getExclusions(fProject, config1,config1_resource);
+ List<RefreshExclusion> config1_exclusions = manager.getExclusions(fProject, config1, config1_resource);
assertEquals(2, config1_exclusions.size());
RefreshExclusion[] config1_exclusionsArray = config1_exclusions.toArray(new RefreshExclusion[0]);
-
+
// both exclusions should have parent resource set to the project
assertEquals(config1_resource, config1_exclusionsArray[0].getParentResource());
assertEquals(config1_resource, config1_exclusionsArray[1].getParentResource());
-
+
// the first exclusion should have one nested exclusion
List<RefreshExclusion> config1_nestedExclusions1 = config1_exclusionsArray[0].getNestedExclusions();
assertEquals(config1_nestedExclusions1.size(), 1);
- RefreshExclusion[] config1_nestedExclusionsArray = config1_nestedExclusions1.toArray(new RefreshExclusion[0]);
+ RefreshExclusion[] config1_nestedExclusionsArray = config1_nestedExclusions1.toArray(new RefreshExclusion[0]);
// the nested exclusion should have its parent exclusion set properly
assertEquals(config1_nestedExclusionsArray[0].getParentExclusion(), config1_exclusionsArray[0]);
-
+
// the second exclusion should have no nested exclusions
List<RefreshExclusion> config1_nestedExclusions2 = config1_exclusionsArray[1].getNestedExclusions();
assertEquals(config1_nestedExclusions2.size(), 0);
-
+
// the second exclusion should have an instance
List<ExclusionInstance> config1_instances = config1_exclusionsArray[1].getExclusionInstances();
assertEquals(1, config1_instances.size());
ExclusionInstance[] config1_instancesArray = config1_instances.toArray(new ExclusionInstance[0]);
ExclusionInstance config1_loadedInstance = config1_instancesArray[0];
-
+
// check the contents of the instance
assertEquals("foo", config1_loadedInstance.getDisplayString());
assertEquals(fFolder2, config1_loadedInstance.getResource());
assertEquals(ExclusionType.RESOURCE, config1_loadedInstance.getExclusionType());
-
+
// clear data for config1
manager.deleteResourceToRefresh(fProject, config1, config1_resource);
-
+
// make sure we got the same stuff we saved for config2
// the project should be set to refresh its root
- List<IResource> config2_resources = manager.getResourcesToRefresh(fProject,config2);
+ List<IResource> config2_resources = manager.getResourcesToRefresh(fProject, config2);
assertEquals(config2_resources.size(), 2);
assertEquals(config2_resources.contains(config2_resource), true);
-
+
// there should be 2 top-level exclusions
- List<RefreshExclusion> config2_exclusions = manager.getExclusions(fProject,config2,config2_resource);
+ List<RefreshExclusion> config2_exclusions = manager.getExclusions(fProject, config2, config2_resource);
assertEquals(2, config2_exclusions.size());
RefreshExclusion[] config2_exclusionsArray = config2_exclusions.toArray(new RefreshExclusion[0]);
-
+
// both exclusions should have parent resource set to the project
assertEquals(config2_resource, config2_exclusionsArray[0].getParentResource());
assertEquals(config2_resource, config2_exclusionsArray[1].getParentResource());
-
+
// the first exclusion should have one nested exclusion
List<RefreshExclusion> config2_nestedExclusions1 = config2_exclusionsArray[0].getNestedExclusions();
assertEquals(config2_nestedExclusions1.size(), 1);
- RefreshExclusion[] config2_nestedExclusionsArray = config2_nestedExclusions1.toArray(new RefreshExclusion[0]);
+ RefreshExclusion[] config2_nestedExclusionsArray = config2_nestedExclusions1.toArray(new RefreshExclusion[0]);
// the nested exclusion should have its parent exclusion set properly
assertEquals(config2_nestedExclusionsArray[0].getParentExclusion(), config2_exclusionsArray[0]);
-
+
// the second exclusion should have no nested exclusions
List<RefreshExclusion> config2_nestedExclusions2 = config2_exclusionsArray[1].getNestedExclusions();
assertEquals(config2_nestedExclusions2.size(), 0);
-
+
// the second exclusion should have an instance
List<ExclusionInstance> config2_instances = config2_exclusionsArray[1].getExclusionInstances();
assertEquals(1, config2_instances.size());
ExclusionInstance[] config2_instancesArray = config2_instances.toArray(new ExclusionInstance[0]);
ExclusionInstance config2_loadedInstance = config2_instancesArray[0];
-
+
// check the contents of the instance
assertEquals("foo", config2_loadedInstance.getDisplayString());
assertEquals(fFolder2, config2_loadedInstance.getResource());
assertEquals(ExclusionType.RESOURCE, config2_loadedInstance.getExclusionType());
-
+
// cleanup
manager.clearAllData();
}
-
public void testResourceExclusion() {
RefreshScopeManager manager = RefreshScopeManager.getInstance();
manager.clearAllData();
-
+
IResource config1_resource = fProject;
-
-
+
String conf_name = getCurrentConfigName();
-
+
manager.addResourceToRefresh(fProject, conf_name, config1_resource);
-
+
// create a series of nested exclusions that include/exclude certain folders
// will be included/excluded as follows
/*
@@ -443,9 +438,9 @@ public class RefreshScopeTests extends TestCase {
* folder 4 - exclude
* folder 5 - include
* folder 6 - exclude
- *
+ *
*/
-
+
ResourceExclusion exclusion1 = new ResourceExclusion();
ExclusionInstance instance1 = new ExclusionInstance();
instance1.setResource(fFolder1);
@@ -454,21 +449,19 @@ public class RefreshScopeTests extends TestCase {
instance2.setResource(fFolder2);
exclusion1.addExclusionInstance(instance2);
manager.addExclusion(fProject, conf_name, config1_resource, exclusion1);
-
-
+
ResourceExclusion exclusion2 = new ResourceExclusion();
ExclusionInstance instance3 = new ExclusionInstance();
instance3.setResource(fFolder3);
exclusion2.addExclusionInstance(instance3);
exclusion1.addNestedExclusion(exclusion2);
-
+
ResourceExclusion exclusion3 = new ResourceExclusion();
ExclusionInstance instance4 = new ExclusionInstance();
instance4.setResource(fFolder4);
exclusion3.addExclusionInstance(instance4);
exclusion2.addNestedExclusion(exclusion3);
-
-
+
// now check and see if the right folders are included/excluded
assertEquals(true, manager.shouldResourceBeRefreshed(conf_name, config1_resource));
assertEquals(false, manager.shouldResourceBeRefreshed(conf_name, fFolder1));
@@ -477,32 +470,31 @@ public class RefreshScopeTests extends TestCase {
assertEquals(false, manager.shouldResourceBeRefreshed(conf_name, fFolder4));
assertEquals(true, manager.shouldResourceBeRefreshed(conf_name, fFolder5));
assertEquals(false, manager.shouldResourceBeRefreshed(conf_name, fFolder6));
-
-
+
// now let's create a bunch of files in these directories using java.io.File (so that we don't get
// resource deltas happening), and refresh the project according to the policy. We should only see the files
// in the same folders above when consulting the resource system
IPath path = fProject.getLocation();
createTestFile(path);
-
+
path = fFolder1.getLocation();
createTestFile(path);
-
+
path = fFolder2.getLocation();
createTestFile(path);
-
+
path = fFolder3.getLocation();
createTestFile(path);
-
+
path = fFolder4.getLocation();
createTestFile(path);
-
+
path = fFolder5.getLocation();
createTestFile(path);
-
+
path = fFolder6.getLocation();
createTestFile(path);
-
+
// now refresh
IWorkspaceRunnable runnable = manager.getRefreshRunnable(fProject, conf_name);
try {
@@ -510,7 +502,7 @@ public class RefreshScopeTests extends TestCase {
} catch (CoreException e) {
fail();
}
-
+
// check if the proper resources exist in the workspace
IResource resource = fProject.getFile("foo.cpp");
assertEquals(true, resource.exists());
@@ -526,7 +518,7 @@ public class RefreshScopeTests extends TestCase {
assertEquals(true, resource.exists());
resource = fFolder6.getFile("foo.cpp");
assertEquals(false, resource.exists());
-
+
manager.clearAllData();
}
@@ -539,54 +531,53 @@ public class RefreshScopeTests extends TestCase {
} catch (IOException e) {
fail();
}
-
}
-
+
public void testDefaults() {
RefreshScopeManager manager = RefreshScopeManager.getInstance();
manager.clearAllData();
-
+
// by default, a project should refresh its root
List<IResource> resourcesToRefresh = manager.getResourcesToRefresh(fProject, config1);
assertEquals(1, resourcesToRefresh.size());
assertEquals(resourcesToRefresh.contains(fProject), true);
-
+
// there should be no exclusions
List<RefreshExclusion> exclusions = manager.getExclusions(fProject, config1, fProject);
assertEquals(0, exclusions.size());
-
+
ICProjectDescription projectDescription = CCorePlugin.getDefault().getProjectDescription(fProject);
-
+
// now try persisting the data and loading it
try {
manager.persistSettings(projectDescription);
} catch (CoreException e) {
fail();
}
-
+
manager.clearAllData();
-
+
try {
manager.loadSettings();
} catch (CoreException e) {
fail();
}
-
+
// test the defaults again
// by default, a project should refresh its root
resourcesToRefresh = manager.getResourcesToRefresh(fProject, config1);
assertEquals(1, resourcesToRefresh.size());
assertEquals(resourcesToRefresh.contains(fProject), true);
-
+
// there should be no exclusions
exclusions = manager.getExclusions(fProject, config1, fProject);
assertEquals(0, exclusions.size());
-
+
}
public void closeProject(ICProjectDescription projDesc) {
-
+
try {
// save the project description
CCorePlugin.getDefault().setProjectDescription(fProject, projDesc);
@@ -595,41 +586,41 @@ public class RefreshScopeTests extends TestCase {
fail();
}
}
-
+
public void openProject() {
- try {
- fProject.open(null);
+ try {
+ fProject.open(null);
} catch (CoreException e) {
fail();
}
}
-
+
public String getCurrentConfigName() {
CProjectDescriptionManager descriptionManager = CProjectDescriptionManager.getInstance();
ICProjectDescription projectDescription = descriptionManager.getProjectDescription(fProject, false);
ICConfigurationDescription conf = projectDescription.getActiveConfiguration();
return conf.getName();
}
-
+
public void testEmptyRefreshScopeCloseAndReopen() {
-
+
RefreshScopeManager manager = RefreshScopeManager.getInstance();
manager.clearAllData();
-
+
String config_name = getCurrentConfigName();
-
+
// get the resources. since we are not loading ... the project should auto-magically be added by default.
List<IResource> config_resources = manager.getResourcesToRefresh(fProject, config_name);
- assertEquals(1,config_resources.size());
+ assertEquals(1, config_resources.size());
assertEquals(true, config_resources.contains(fProject));
-
+
// now delete it.
manager.deleteResourceToRefresh(fProject, config_name, fProject);
-
+
// and make sure it is empty.
config_resources = manager.getResourcesToRefresh(fProject, config_name);
- assertEquals(0,config_resources.size());
-
+ assertEquals(0, config_resources.size());
+
// write the persistent data.
ICProjectDescription projectDescription = CCorePlugin.getDefault().getProjectDescription(fProject);
try {
@@ -637,34 +628,37 @@ public class RefreshScopeTests extends TestCase {
} catch (CoreException e) {
fail();
}
-
+
// close and reopen
- closeProject(projectDescription);
+ closeProject(projectDescription);
openProject();
-
+
// now verify that there are no resources.
- HashMap<String, HashMap<IResource, List<RefreshExclusion>>> config_map = manager.getConfigurationToResourcesMap(fProject);
- assertEquals(1,config_map.size());
+ HashMap<String, HashMap<IResource, List<RefreshExclusion>>> config_map = manager
+ .getConfigurationToResourcesMap(fProject);
+ assertEquals(1, config_map.size());
config_resources = manager.getResourcesToRefresh(fProject, config_name);
- assertEquals(0,config_resources.size());
+ assertEquals(0, config_resources.size());
}
-
+
public void testAddEmptyConfiguration() {
- final String CFG_NAME="empty_config";
-
+ final String CFG_NAME = "empty_config";
+
CoreModel model = CoreModel.getDefault();
RefreshScopeManager manager = RefreshScopeManager.getInstance();
manager.clearAllData();
-
+
CProjectDescriptionManager descriptionManager = CProjectDescriptionManager.getInstance();
ICProjectDescription projectDescription = descriptionManager.getProjectDescription(fProject, false);
ICConfigurationDescription base = projectDescription.getActiveConfiguration();
-
+
ICProjectDescription propertyProjectDescription = CoreModel.getDefault().getProjectDescription(fProject);
- ICConfigurationDescription propertyDefaultConfigurationDescription = propertyProjectDescription.getConfigurations()[0];
+ ICConfigurationDescription propertyDefaultConfigurationDescription = propertyProjectDescription
+ .getConfigurations()[0];
try {
projectDescription.setReadOnly(false, true);
- ICConfigurationDescription newCfg = projectDescription.createConfiguration(CFG_NAME + ".id", CFG_NAME, propertyDefaultConfigurationDescription);
+ ICConfigurationDescription newCfg = projectDescription.createConfiguration(CFG_NAME + ".id", CFG_NAME,
+ propertyDefaultConfigurationDescription);
} catch (WriteAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -673,31 +667,29 @@ public class RefreshScopeTests extends TestCase {
e.printStackTrace();
}
-
List<IResource> empty_config_resources = manager.getResourcesToRefresh(fProject, CFG_NAME);
- assertEquals(1,empty_config_resources.size());
- assertEquals(true,empty_config_resources.contains(fProject));
-
+ assertEquals(1, empty_config_resources.size());
+ assertEquals(true, empty_config_resources.contains(fProject));
+
}
-
+
public void testNullProjectDescription_bug387428() {
- final String CFG_NAME="empty_config";
-
+ final String CFG_NAME = "empty_config";
+
CProjectDescriptionManager descriptionManager = CProjectDescriptionManager.getInstance();
ICProjectDescription projectDescription = descriptionManager.getProjectDescription(fGeneralProject, false);
assertNull(projectDescription);
-
+
RefreshScopeManager manager = RefreshScopeManager.getInstance();
manager.clearAllData();
-
+
List<IResource> empty_config_resources = manager.getResourcesToRefresh(fGeneralProject, CFG_NAME);
- assertEquals(1,empty_config_resources.size());
- assertEquals(true,empty_config_resources.contains(fGeneralProject));
+ assertEquals(1, empty_config_resources.size());
+ assertEquals(true, empty_config_resources.contains(fGeneralProject));
}
-
+
public static Test suite() {
return new TestSuite(RefreshScopeTests.class);
}
-
}
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/TestExclusion.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/TestExclusion.java
index d1393e5b21e..0402bb68387 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/TestExclusion.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/TestExclusion.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/TestExclusionFactory.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/TestExclusionFactory.java
index b00b53b78bf..7fc5dd75307 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/TestExclusionFactory.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/TestExclusionFactory.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -24,7 +24,7 @@ import org.eclipse.cdt.core.resources.RefreshExclusionFactory;
public class TestExclusionFactory extends RefreshExclusionFactory {
/**
- *
+ *
*/
public TestExclusionFactory() {
// TODO Auto-generated constructor stub
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/winreg/tests/WinRegTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/winreg/tests/WinRegTests.java
index 3caefcf8ce9..b0c3d005b5c 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/winreg/tests/WinRegTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/winreg/tests/WinRegTests.java
@@ -24,7 +24,8 @@ public class WinRegTests extends TestCase {
WindowsRegistry registry = WindowsRegistry.getRegistry();
if (Platform.getOS().equals(Platform.OS_WIN32)) {
assertNotNull(registry);
- String value = registry.getLocalMachineValue("SOFTWARE\\Microsoft\\Windows\\CurrentVersion", "ProgramFilesDir");
+ String value = registry.getLocalMachineValue("SOFTWARE\\Microsoft\\Windows\\CurrentVersion",
+ "ProgramFilesDir");
// Not sure how you set this to anything else so it seems safe.
assertEquals("C:\\Program Files", value);
} else {
@@ -32,7 +33,7 @@ public class WinRegTests extends TestCase {
assertNotNull(registry);
}
}
-
+
public void test2() {
WindowsRegistry registry = WindowsRegistry.getRegistry();
if (Platform.getOS().equals(Platform.OS_WIN32)) {
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/ByteUtilsTest.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/ByteUtilsTest.java
index 88ab4c421f3..2d735c6685f 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/ByteUtilsTest.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/ByteUtilsTest.java
@@ -29,123 +29,177 @@ public class ByteUtilsTest extends TestCase {
}
// Allows us to avoid ugly misalignment in the source
- private static byte Ox80 = (byte)0x80;
- private static byte Oxff = (byte)0xff;
-
+ private static byte Ox80 = (byte) 0x80;
+ private static byte Oxff = (byte) 0xff;
+
public void testMakeShort() throws Exception {
- Assert.assertEquals((short)0x0000, makeShort(new byte[]{0x00,0x00}, 0, false));
- Assert.assertEquals((short)0x7f00, makeShort(new byte[]{0x7f,0x00}, 0, false));
- Assert.assertEquals((short)0x007f, makeShort(new byte[]{0x00,0x7f}, 0, false));
- Assert.assertEquals((short)0x8000, makeShort(new byte[]{Ox80,0x00}, 0, false));
- Assert.assertEquals((short)0x0080, makeShort(new byte[]{0x00,Ox80}, 0, false));
- Assert.assertEquals((short)0xff00, makeShort(new byte[]{Oxff,0x00}, 0, false));
- Assert.assertEquals((short)0x00ff, makeShort(new byte[]{0x00,Oxff}, 0, false));
- Assert.assertEquals((short)0xffff, makeShort(new byte[]{Oxff,Oxff}, 0, false));
-
- Assert.assertEquals((short)0x0000, makeShort(new byte[]{0x00,0x00}, 0, true));
- Assert.assertEquals((short)0x007f, makeShort(new byte[]{0x7f,0x00}, 0, true));
- Assert.assertEquals((short)0x7f00, makeShort(new byte[]{0x00,0x7f}, 0, true));
- Assert.assertEquals((short)0x0080, makeShort(new byte[]{Ox80,0x00}, 0, true));
- Assert.assertEquals((short)0x8000, makeShort(new byte[]{0x00,Ox80}, 0, true));
- Assert.assertEquals((short)0x00ff, makeShort(new byte[]{Oxff,0x00}, 0, true));
- Assert.assertEquals((short)0xff00, makeShort(new byte[]{0x00,Oxff}, 0, true));
- Assert.assertEquals((short)0xffff, makeShort(new byte[]{Oxff,Oxff}, 0, true));
-
- Assert.assertEquals(0x0102, makeShort(new byte[]{0,0,0,0x01,0x02}, 3, false));
- Assert.assertEquals(0x0201, makeShort(new byte[]{0,0,0,0x01,0x02}, 3, true));
+ Assert.assertEquals((short) 0x0000, makeShort(new byte[] { 0x00, 0x00 }, 0, false));
+ Assert.assertEquals((short) 0x7f00, makeShort(new byte[] { 0x7f, 0x00 }, 0, false));
+ Assert.assertEquals((short) 0x007f, makeShort(new byte[] { 0x00, 0x7f }, 0, false));
+ Assert.assertEquals((short) 0x8000, makeShort(new byte[] { Ox80, 0x00 }, 0, false));
+ Assert.assertEquals((short) 0x0080, makeShort(new byte[] { 0x00, Ox80 }, 0, false));
+ Assert.assertEquals((short) 0xff00, makeShort(new byte[] { Oxff, 0x00 }, 0, false));
+ Assert.assertEquals((short) 0x00ff, makeShort(new byte[] { 0x00, Oxff }, 0, false));
+ Assert.assertEquals((short) 0xffff, makeShort(new byte[] { Oxff, Oxff }, 0, false));
+
+ Assert.assertEquals((short) 0x0000, makeShort(new byte[] { 0x00, 0x00 }, 0, true));
+ Assert.assertEquals((short) 0x007f, makeShort(new byte[] { 0x7f, 0x00 }, 0, true));
+ Assert.assertEquals((short) 0x7f00, makeShort(new byte[] { 0x00, 0x7f }, 0, true));
+ Assert.assertEquals((short) 0x0080, makeShort(new byte[] { Ox80, 0x00 }, 0, true));
+ Assert.assertEquals((short) 0x8000, makeShort(new byte[] { 0x00, Ox80 }, 0, true));
+ Assert.assertEquals((short) 0x00ff, makeShort(new byte[] { Oxff, 0x00 }, 0, true));
+ Assert.assertEquals((short) 0xff00, makeShort(new byte[] { 0x00, Oxff }, 0, true));
+ Assert.assertEquals((short) 0xffff, makeShort(new byte[] { Oxff, Oxff }, 0, true));
+
+ Assert.assertEquals(0x0102, makeShort(new byte[] { 0, 0, 0, 0x01, 0x02 }, 3, false));
+ Assert.assertEquals(0x0201, makeShort(new byte[] { 0, 0, 0, 0x01, 0x02 }, 3, true));
}
-
+
public void testMakeInt() throws Exception {
- Assert.assertEquals(0x00000000, makeInt(new byte[]{0x00,0x00,0x00,0x00}, 0, false));
- Assert.assertEquals(0x7f000000, makeInt(new byte[]{0x7f,0x00,0x00,0x00}, 0, false));
- Assert.assertEquals(0x007f0000, makeInt(new byte[]{0x00,0x7f,0x00,0x00}, 0, false));
- Assert.assertEquals(0x00007f00, makeInt(new byte[]{0x00,0x00,0x7f,0x00}, 0, false));
- Assert.assertEquals(0x0000007f, makeInt(new byte[]{0x00,0x00,0x00,0x7f}, 0, false));
- Assert.assertEquals(0x80000000, makeInt(new byte[]{Ox80,0x00,0x00,0x00}, 0, false));
- Assert.assertEquals(0x00800000, makeInt(new byte[]{0x00,Ox80,0x00,0x00}, 0, false));
- Assert.assertEquals(0x00008000, makeInt(new byte[]{0x00,0x00,Ox80,0x00}, 0, false));
- Assert.assertEquals(0x00000080, makeInt(new byte[]{0x00,0x00,0x00,Ox80}, 0, false));
- Assert.assertEquals(0xff000000, makeInt(new byte[]{Oxff,0x00,0x00,0x00}, 0, false));
- Assert.assertEquals(0x00ff0000, makeInt(new byte[]{0x00,Oxff,0x00,0x00}, 0, false));
- Assert.assertEquals(0x0000ff00, makeInt(new byte[]{0x00,0x00,Oxff,0x00}, 0, false));
- Assert.assertEquals(0x000000ff, makeInt(new byte[]{0x00,0x00,0x00,Oxff}, 0, false));
- Assert.assertEquals(0xffffffff, makeInt(new byte[]{Oxff,Oxff,Oxff,Oxff}, 0, false));
+ Assert.assertEquals(0x00000000, makeInt(new byte[] { 0x00, 0x00, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x7f000000, makeInt(new byte[] { 0x7f, 0x00, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x007f0000, makeInt(new byte[] { 0x00, 0x7f, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x00007f00, makeInt(new byte[] { 0x00, 0x00, 0x7f, 0x00 }, 0, false));
+ Assert.assertEquals(0x0000007f, makeInt(new byte[] { 0x00, 0x00, 0x00, 0x7f }, 0, false));
+ Assert.assertEquals(0x80000000, makeInt(new byte[] { Ox80, 0x00, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x00800000, makeInt(new byte[] { 0x00, Ox80, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x00008000, makeInt(new byte[] { 0x00, 0x00, Ox80, 0x00 }, 0, false));
+ Assert.assertEquals(0x00000080, makeInt(new byte[] { 0x00, 0x00, 0x00, Ox80 }, 0, false));
+ Assert.assertEquals(0xff000000, makeInt(new byte[] { Oxff, 0x00, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x00ff0000, makeInt(new byte[] { 0x00, Oxff, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x0000ff00, makeInt(new byte[] { 0x00, 0x00, Oxff, 0x00 }, 0, false));
+ Assert.assertEquals(0x000000ff, makeInt(new byte[] { 0x00, 0x00, 0x00, Oxff }, 0, false));
+ Assert.assertEquals(0xffffffff, makeInt(new byte[] { Oxff, Oxff, Oxff, Oxff }, 0, false));
- Assert.assertEquals(0x00000000, makeInt(new byte[]{0x00,0x00,0x00,0x00}, 0, true));
- Assert.assertEquals(0x0000007f, makeInt(new byte[]{0x7f,0x00,0x00,0x00}, 0, true));
- Assert.assertEquals(0x00007f00, makeInt(new byte[]{0x00,0x7f,0x00,0x00}, 0, true));
- Assert.assertEquals(0x007f0000, makeInt(new byte[]{0x00,0x00,0x7f,0x00}, 0, true));
- Assert.assertEquals(0x7f000000, makeInt(new byte[]{0x00,0x00,0x00,0x7f}, 0, true));
- Assert.assertEquals(0x00000080, makeInt(new byte[]{Ox80,0x00,0x00,0x00}, 0, true));
- Assert.assertEquals(0x00008000, makeInt(new byte[]{0x00,Ox80,0x00,0x00}, 0, true));
- Assert.assertEquals(0x00800000, makeInt(new byte[]{0x00,0x00,Ox80,0x00}, 0, true));
- Assert.assertEquals(0x80000000, makeInt(new byte[]{0x00,0x00,0x00,Ox80}, 0, true));
- Assert.assertEquals(0x000000ff, makeInt(new byte[]{Oxff,0x00,0x00,0x00}, 0, true));
- Assert.assertEquals(0x0000ff00, makeInt(new byte[]{0x00,Oxff,0x00,0x00}, 0, true));
- Assert.assertEquals(0x00ff0000, makeInt(new byte[]{0x00,0x00,Oxff,0x00}, 0, true));
- Assert.assertEquals(0xff000000, makeInt(new byte[]{0x00,0x00,0x00,Oxff}, 0, true));
- Assert.assertEquals(0xffffffff, makeInt(new byte[]{Oxff,Oxff,Oxff,Oxff}, 0, true));
+ Assert.assertEquals(0x00000000, makeInt(new byte[] { 0x00, 0x00, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x0000007f, makeInt(new byte[] { 0x7f, 0x00, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x00007f00, makeInt(new byte[] { 0x00, 0x7f, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x007f0000, makeInt(new byte[] { 0x00, 0x00, 0x7f, 0x00 }, 0, true));
+ Assert.assertEquals(0x7f000000, makeInt(new byte[] { 0x00, 0x00, 0x00, 0x7f }, 0, true));
+ Assert.assertEquals(0x00000080, makeInt(new byte[] { Ox80, 0x00, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x00008000, makeInt(new byte[] { 0x00, Ox80, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x00800000, makeInt(new byte[] { 0x00, 0x00, Ox80, 0x00 }, 0, true));
+ Assert.assertEquals(0x80000000, makeInt(new byte[] { 0x00, 0x00, 0x00, Ox80 }, 0, true));
+ Assert.assertEquals(0x000000ff, makeInt(new byte[] { Oxff, 0x00, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x0000ff00, makeInt(new byte[] { 0x00, Oxff, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x00ff0000, makeInt(new byte[] { 0x00, 0x00, Oxff, 0x00 }, 0, true));
+ Assert.assertEquals(0xff000000, makeInt(new byte[] { 0x00, 0x00, 0x00, Oxff }, 0, true));
+ Assert.assertEquals(0xffffffff, makeInt(new byte[] { Oxff, Oxff, Oxff, Oxff }, 0, true));
- Assert.assertEquals(0x01020304, makeInt(new byte[]{0,0,0,0x01,0x02,0x03,0x04}, 3, false));
- Assert.assertEquals(0x04030201, makeInt(new byte[]{0,0,0,0x01,0x02,0x03,0x04}, 3, true));
+ Assert.assertEquals(0x01020304, makeInt(new byte[] { 0, 0, 0, 0x01, 0x02, 0x03, 0x04 }, 3, false));
+ Assert.assertEquals(0x04030201, makeInt(new byte[] { 0, 0, 0, 0x01, 0x02, 0x03, 0x04 }, 3, true));
}
public void testMakeLong() throws Exception {
- Assert.assertEquals(0x0000000000000000L, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 0, false));
- Assert.assertEquals(0x7f00000000000000L, makeLong(new byte[]{0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 0, false));
- Assert.assertEquals(0x007f000000000000L, makeLong(new byte[]{0x00,0x7f,0x00,0x00,0x00,0x00,0x00,0x00}, 0, false));
- Assert.assertEquals(0x00007f0000000000L, makeLong(new byte[]{0x00,0x00,0x7f,0x00,0x00,0x00,0x00,0x00}, 0, false));
- Assert.assertEquals(0x0000007f00000000L, makeLong(new byte[]{0x00,0x00,0x00,0x7f,0x00,0x00,0x00,0x00}, 0, false));
- Assert.assertEquals(0x000000007f000000L, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x7f,0x00,0x00,0x00}, 0, false));
- Assert.assertEquals(0x00000000007f0000L, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x00,0x7f,0x00,0x00}, 0, false));
- Assert.assertEquals(0x0000000000007f00L, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x00}, 0, false));
- Assert.assertEquals(0x000000000000007fL, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f}, 0, false));
- Assert.assertEquals(0x8000000000000000L, makeLong(new byte[]{Ox80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 0, false));
- Assert.assertEquals(0x0080000000000000L, makeLong(new byte[]{0x00,Ox80,0x00,0x00,0x00,0x00,0x00,0x00}, 0, false));
- Assert.assertEquals(0x0000800000000000L, makeLong(new byte[]{0x00,0x00,Ox80,0x00,0x00,0x00,0x00,0x00}, 0, false));
- Assert.assertEquals(0x0000008000000000L, makeLong(new byte[]{0x00,0x00,0x00,Ox80,0x00,0x00,0x00,0x00}, 0, false));
- Assert.assertEquals(0x0000000080000000L, makeLong(new byte[]{0x00,0x00,0x00,0x00,Ox80,0x00,0x00,0x00}, 0, false));
- Assert.assertEquals(0x0000000000800000L, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x00,Ox80,0x00,0x00}, 0, false));
- Assert.assertEquals(0x0000000000008000L, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,Ox80,0x00}, 0, false));
- Assert.assertEquals(0x0000000000000080L, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,Ox80}, 0, false));
- Assert.assertEquals(0xff00000000000000L, makeLong(new byte[]{Oxff,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 0, false));
- Assert.assertEquals(0x00ff000000000000L, makeLong(new byte[]{0x00,Oxff,0x00,0x00,0x00,0x00,0x00,0x00}, 0, false));
- Assert.assertEquals(0x0000ff0000000000L, makeLong(new byte[]{0x00,0x00,Oxff,0x00,0x00,0x00,0x00,0x00}, 0, false));
- Assert.assertEquals(0x000000ff00000000L, makeLong(new byte[]{0x00,0x00,0x00,Oxff,0x00,0x00,0x00,0x00}, 0, false));
- Assert.assertEquals(0x00000000ff000000L, makeLong(new byte[]{0x00,0x00,0x00,0x00,Oxff,0x00,0x00,0x00}, 0, false));
- Assert.assertEquals(0x0000000000ff0000L, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x00,Oxff,0x00,0x00}, 0, false));
- Assert.assertEquals(0x000000000000ff00L, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,Oxff,0x00}, 0, false));
- Assert.assertEquals(0x00000000000000ffL, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,Oxff}, 0, false));
- Assert.assertEquals(0xffffffffffffffffL, makeLong(new byte[]{Oxff,Oxff,Oxff,Oxff,Oxff,Oxff,Oxff,Oxff}, 0, false));
+ Assert.assertEquals(0x0000000000000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x7f00000000000000L,
+ makeLong(new byte[] { 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x007f000000000000L,
+ makeLong(new byte[] { 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x00007f0000000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x0000007f00000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x000000007f000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x00000000007f0000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x0000000000007f00L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00 }, 0, false));
+ Assert.assertEquals(0x000000000000007fL,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f }, 0, false));
+ Assert.assertEquals(0x8000000000000000L,
+ makeLong(new byte[] { Ox80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x0080000000000000L,
+ makeLong(new byte[] { 0x00, Ox80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x0000800000000000L,
+ makeLong(new byte[] { 0x00, 0x00, Ox80, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x0000008000000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, Ox80, 0x00, 0x00, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x0000000080000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, Ox80, 0x00, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x0000000000800000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, Ox80, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x0000000000008000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, Ox80, 0x00 }, 0, false));
+ Assert.assertEquals(0x0000000000000080L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, Ox80 }, 0, false));
+ Assert.assertEquals(0xff00000000000000L,
+ makeLong(new byte[] { Oxff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x00ff000000000000L,
+ makeLong(new byte[] { 0x00, Oxff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x0000ff0000000000L,
+ makeLong(new byte[] { 0x00, 0x00, Oxff, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x000000ff00000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, Oxff, 0x00, 0x00, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x00000000ff000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, Oxff, 0x00, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x0000000000ff0000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, Oxff, 0x00, 0x00 }, 0, false));
+ Assert.assertEquals(0x000000000000ff00L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, Oxff, 0x00 }, 0, false));
+ Assert.assertEquals(0x00000000000000ffL,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, Oxff }, 0, false));
+ Assert.assertEquals(0xffffffffffffffffL,
+ makeLong(new byte[] { Oxff, Oxff, Oxff, Oxff, Oxff, Oxff, Oxff, Oxff }, 0, false));
+
+ Assert.assertEquals(0x0000000000000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x000000000000007fL,
+ makeLong(new byte[] { 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x0000000000007f00L,
+ makeLong(new byte[] { 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x00000000007f0000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x000000007f000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x0000007f00000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x00007f0000000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x007f000000000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00 }, 0, true));
+ Assert.assertEquals(0x7f00000000000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f }, 0, true));
+ Assert.assertEquals(0x0000000000000080L,
+ makeLong(new byte[] { Ox80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x0000000000008000L,
+ makeLong(new byte[] { 0x00, Ox80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x0000000000800000L,
+ makeLong(new byte[] { 0x00, 0x00, Ox80, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x0000000080000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, Ox80, 0x00, 0x00, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x0000008000000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, Ox80, 0x00, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x0000800000000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, Ox80, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x0080000000000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, Ox80, 0x00 }, 0, true));
+ Assert.assertEquals(0x8000000000000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, Ox80 }, 0, true));
+ Assert.assertEquals(0x00000000000000ffL,
+ makeLong(new byte[] { Oxff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x000000000000ff00L,
+ makeLong(new byte[] { 0x00, Oxff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x0000000000ff0000L,
+ makeLong(new byte[] { 0x00, 0x00, Oxff, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x00000000ff000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, Oxff, 0x00, 0x00, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x000000ff00000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, Oxff, 0x00, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x0000ff0000000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, Oxff, 0x00, 0x00 }, 0, true));
+ Assert.assertEquals(0x00ff000000000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, Oxff, 0x00 }, 0, true));
+ Assert.assertEquals(0xff00000000000000L,
+ makeLong(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, Oxff }, 0, true));
+ Assert.assertEquals(0xffffffffffffffffL,
+ makeLong(new byte[] { Oxff, Oxff, Oxff, Oxff, Oxff, Oxff, Oxff, Oxff }, 0, true));
- Assert.assertEquals(0x0000000000000000L, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 0, true));
- Assert.assertEquals(0x000000000000007fL, makeLong(new byte[]{0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 0, true));
- Assert.assertEquals(0x0000000000007f00L, makeLong(new byte[]{0x00,0x7f,0x00,0x00,0x00,0x00,0x00,0x00}, 0, true));
- Assert.assertEquals(0x00000000007f0000L, makeLong(new byte[]{0x00,0x00,0x7f,0x00,0x00,0x00,0x00,0x00}, 0, true));
- Assert.assertEquals(0x000000007f000000L, makeLong(new byte[]{0x00,0x00,0x00,0x7f,0x00,0x00,0x00,0x00}, 0, true));
- Assert.assertEquals(0x0000007f00000000L, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x7f,0x00,0x00,0x00}, 0, true));
- Assert.assertEquals(0x00007f0000000000L, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x00,0x7f,0x00,0x00}, 0, true));
- Assert.assertEquals(0x007f000000000000L, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x00}, 0, true));
- Assert.assertEquals(0x7f00000000000000L, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f}, 0, true));
- Assert.assertEquals(0x0000000000000080L, makeLong(new byte[]{Ox80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 0, true));
- Assert.assertEquals(0x0000000000008000L, makeLong(new byte[]{0x00,Ox80,0x00,0x00,0x00,0x00,0x00,0x00}, 0, true));
- Assert.assertEquals(0x0000000000800000L, makeLong(new byte[]{0x00,0x00,Ox80,0x00,0x00,0x00,0x00,0x00}, 0, true));
- Assert.assertEquals(0x0000000080000000L, makeLong(new byte[]{0x00,0x00,0x00,Ox80,0x00,0x00,0x00,0x00}, 0, true));
- Assert.assertEquals(0x0000008000000000L, makeLong(new byte[]{0x00,0x00,0x00,0x00,Ox80,0x00,0x00,0x00}, 0, true));
- Assert.assertEquals(0x0000800000000000L, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x00,Ox80,0x00,0x00}, 0, true));
- Assert.assertEquals(0x0080000000000000L, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,Ox80,0x00}, 0, true));
- Assert.assertEquals(0x8000000000000000L, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,Ox80}, 0, true));
- Assert.assertEquals(0x00000000000000ffL, makeLong(new byte[]{Oxff,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 0, true));
- Assert.assertEquals(0x000000000000ff00L, makeLong(new byte[]{0x00,Oxff,0x00,0x00,0x00,0x00,0x00,0x00}, 0, true));
- Assert.assertEquals(0x0000000000ff0000L, makeLong(new byte[]{0x00,0x00,Oxff,0x00,0x00,0x00,0x00,0x00}, 0, true));
- Assert.assertEquals(0x00000000ff000000L, makeLong(new byte[]{0x00,0x00,0x00,Oxff,0x00,0x00,0x00,0x00}, 0, true));
- Assert.assertEquals(0x000000ff00000000L, makeLong(new byte[]{0x00,0x00,0x00,0x00,Oxff,0x00,0x00,0x00}, 0, true));
- Assert.assertEquals(0x0000ff0000000000L, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x00,Oxff,0x00,0x00}, 0, true));
- Assert.assertEquals(0x00ff000000000000L, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,Oxff,0x00}, 0, true));
- Assert.assertEquals(0xff00000000000000L, makeLong(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,Oxff}, 0, true));
- Assert.assertEquals(0xffffffffffffffffL, makeLong(new byte[]{Oxff,Oxff,Oxff,Oxff,Oxff,Oxff,Oxff,Oxff}, 0, true));
-
- Assert.assertEquals(0x0102030405060708L, makeLong(new byte[]{0,0,0,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08}, 3, false));
- Assert.assertEquals(0x0807060504030201L, makeLong(new byte[]{0,0,0,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08}, 3, true));
+ Assert.assertEquals(0x0102030405060708L,
+ makeLong(new byte[] { 0, 0, 0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }, 3, false));
+ Assert.assertEquals(0x0807060504030201L,
+ makeLong(new byte[] { 0, 0, 0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }, 3, true));
}
}
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/CdtVariableResolverTest.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/CdtVariableResolverTest.java
index b2403421b16..362336f1c6a 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/CdtVariableResolverTest.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/CdtVariableResolverTest.java
@@ -31,8 +31,7 @@ public class CdtVariableResolverTest extends TestCase {
private class MockSubstitutor implements IVariableSubstitutor {
@Override
- public String resolveToString(String macroName)
- throws CdtVariableException {
+ public String resolveToString(String macroName) throws CdtVariableException {
if (macroName.equals("null")) {
return null;
}
@@ -43,122 +42,121 @@ public class CdtVariableResolverTest extends TestCase {
return "${loop}";
}
if (macroName.equals("throw")) {
- throw new CdtVariableException(ICdtVariableStatus.TYPE_MACRO_UNDEFINED,null,null,null);
+ throw new CdtVariableException(ICdtVariableStatus.TYPE_MACRO_UNDEFINED, null, null, null);
}
- return "#"+macroName+"#";
+ return "#" + macroName + "#";
}
@Override
- public String[] resolveToStringList(String macroName)
- throws CdtVariableException {
-
+ public String[] resolveToStringList(String macroName) throws CdtVariableException {
+
if (macroName.equals("null-to-list")) {
return null;
}
if (macroName.equals("PATH")) {
- return new String[] {
- "path0",
- "path1",
- "path2",
- };
+ return new String[] { "path0", "path1", "path2", };
}
- return new String[] {"@"+macroName+"@"};
+ return new String[] { "@" + macroName + "@" };
}
-
+
}
+
private MockSubstitutor mockSubstitutor = new MockSubstitutor();
-
+
public void testResolveToString() throws CdtVariableException {
-
- assertEquals("",CdtVariableResolver.resolveToString(null, mockSubstitutor));
- assertEquals("",CdtVariableResolver.resolveToString("", mockSubstitutor));
- assertEquals("Text",CdtVariableResolver.resolveToString("Text", mockSubstitutor));
- assertEquals("#Macro#",CdtVariableResolver.resolveToString("${Macro}", mockSubstitutor));
- assertEquals("",CdtVariableResolver.resolveToString("${}", mockSubstitutor));
- assertEquals("${Nomacro",CdtVariableResolver.resolveToString("${Nomacro", mockSubstitutor));
- assertEquals("Nomacro}",CdtVariableResolver.resolveToString("Nomacro}", mockSubstitutor));
- assertEquals("Text/#Macro#",CdtVariableResolver.resolveToString("Text/${Macro}", mockSubstitutor));
- assertEquals("#Macro#/Text",CdtVariableResolver.resolveToString("${Macro}/Text", mockSubstitutor));
- assertEquals("#Macro1#/#Macro2#",CdtVariableResolver.resolveToString("${Macro1}/${Macro2}", mockSubstitutor));
- assertEquals("${Macro}",CdtVariableResolver.resolveToString("\\${Macro}", mockSubstitutor));
- assertEquals("${Macro}:#Macro#",CdtVariableResolver.resolveToString("\\${Macro}:${Macro}", mockSubstitutor));
- assertEquals("\\#Macro#",CdtVariableResolver.resolveToString("\\\\${Macro}", mockSubstitutor));
- assertEquals("\\${Macro}",CdtVariableResolver.resolveToString("\\\\\\${Macro}", mockSubstitutor));
- assertEquals("C:\\tmp\\",CdtVariableResolver.resolveToString("C:\\tmp\\", mockSubstitutor));
-
- assertEquals("#workspace_loc:#Macro##",CdtVariableResolver.resolveToString("${workspace_loc:${Macro}}", mockSubstitutor));
- assertEquals("#workspace_loc:#Macro1#/#Macro2##",CdtVariableResolver.resolveToString("${workspace_loc:${Macro1}/${Macro2}}", mockSubstitutor));
- assertEquals("#workspace_loc:#project_loc:/#Macro###",CdtVariableResolver.resolveToString("${workspace_loc:${project_loc:/${Macro}}}", mockSubstitutor));
+
+ assertEquals("", CdtVariableResolver.resolveToString(null, mockSubstitutor));
+ assertEquals("", CdtVariableResolver.resolveToString("", mockSubstitutor));
+ assertEquals("Text", CdtVariableResolver.resolveToString("Text", mockSubstitutor));
+ assertEquals("#Macro#", CdtVariableResolver.resolveToString("${Macro}", mockSubstitutor));
+ assertEquals("", CdtVariableResolver.resolveToString("${}", mockSubstitutor));
+ assertEquals("${Nomacro", CdtVariableResolver.resolveToString("${Nomacro", mockSubstitutor));
+ assertEquals("Nomacro}", CdtVariableResolver.resolveToString("Nomacro}", mockSubstitutor));
+ assertEquals("Text/#Macro#", CdtVariableResolver.resolveToString("Text/${Macro}", mockSubstitutor));
+ assertEquals("#Macro#/Text", CdtVariableResolver.resolveToString("${Macro}/Text", mockSubstitutor));
+ assertEquals("#Macro1#/#Macro2#", CdtVariableResolver.resolveToString("${Macro1}/${Macro2}", mockSubstitutor));
+ assertEquals("${Macro}", CdtVariableResolver.resolveToString("\\${Macro}", mockSubstitutor));
+ assertEquals("${Macro}:#Macro#", CdtVariableResolver.resolveToString("\\${Macro}:${Macro}", mockSubstitutor));
+ assertEquals("\\#Macro#", CdtVariableResolver.resolveToString("\\\\${Macro}", mockSubstitutor));
+ assertEquals("\\${Macro}", CdtVariableResolver.resolveToString("\\\\\\${Macro}", mockSubstitutor));
+ assertEquals("C:\\tmp\\", CdtVariableResolver.resolveToString("C:\\tmp\\", mockSubstitutor));
+
+ assertEquals("#workspace_loc:#Macro##",
+ CdtVariableResolver.resolveToString("${workspace_loc:${Macro}}", mockSubstitutor));
+ assertEquals("#workspace_loc:#Macro1#/#Macro2##",
+ CdtVariableResolver.resolveToString("${workspace_loc:${Macro1}/${Macro2}}", mockSubstitutor));
+ assertEquals("#workspace_loc:#project_loc:/#Macro###",
+ CdtVariableResolver.resolveToString("${workspace_loc:${project_loc:/${Macro}}}", mockSubstitutor));
}
public void testExceptions() throws CdtVariableException {
// test exceptions
try {
- assertEquals("Unreacheable",CdtVariableResolver.resolveToString("${null}", mockSubstitutor));
+ assertEquals("Unreacheable", CdtVariableResolver.resolveToString("${null}", mockSubstitutor));
fail("Exception expected");
} catch (CdtVariableException e) {
// expected behavior
}
try {
- assertEquals("Unreacheable",CdtVariableResolver.resolveToString("${throw}", mockSubstitutor));
+ assertEquals("Unreacheable", CdtVariableResolver.resolveToString("${throw}", mockSubstitutor));
fail("Exception expected");
} catch (CdtVariableException e) {
// expected behavior
}
-
+
// make sure there is no infinite loop
- assertEquals("${LOOP}",CdtVariableResolver.resolveToString("${loop}", mockSubstitutor));
+ assertEquals("${LOOP}", CdtVariableResolver.resolveToString("${loop}", mockSubstitutor));
}
public void testAsList() throws CdtVariableException {
// Syntax ${var} implies using substitutor.resolveToStringList(...)
{
String[] list = CdtVariableResolver.resolveToStringList("${PATH}", mockSubstitutor);
-
+
assertNotNull(list);
- assertEquals(3,list.length);
- assertEquals("path0",list[0]);
- assertEquals("path1",list[1]);
- assertEquals("path2",list[2]);
+ assertEquals(3, list.length);
+ assertEquals("path0", list[0]);
+ assertEquals("path1", list[1]);
+ assertEquals("path2", list[2]);
}
-
+
// uses substitutor.resolveToString(...)
{
String[] list = CdtVariableResolver.resolveToStringList("Text", mockSubstitutor);
-
+
assertNotNull(list);
- assertEquals(1,list.length);
- assertEquals("Text",list[0]);
+ assertEquals(1, list.length);
+ assertEquals("Text", list[0]);
}
-
+
// uses substitutor.resolveToString(...)
{
String[] list = CdtVariableResolver.resolveToStringList("Text${PATH}", mockSubstitutor);
-
+
assertNotNull(list);
- assertEquals(1,list.length);
- assertEquals("Text#PATH#",list[0]);
+ assertEquals(1, list.length);
+ assertEquals("Text#PATH#", list[0]);
}
-
+
// uses substitutor.resolveToString(...)
{
String[] list = CdtVariableResolver.resolveToStringList("${PATH}${PATH}", mockSubstitutor);
-
+
assertNotNull(list);
- assertEquals(1,list.length);
- assertEquals("#PATH##PATH#",list[0]);
+ assertEquals(1, list.length);
+ assertEquals("#PATH##PATH#", list[0]);
}
-
+
// empty var delivers zero-length array
{
String[] list = CdtVariableResolver.resolveToStringList("${}", mockSubstitutor);
-
+
assertNotNull(list);
- assertEquals(0,list.length);
+ assertEquals(0, list.length);
}
-
+
// test exceptions
try {
CdtVariableResolver.resolveToStringList("${null-to-list}", mockSubstitutor);
@@ -167,24 +165,24 @@ public class CdtVariableResolverTest extends TestCase {
// expected behavior
}
}
-
+
// These tests are very basic not intended to be comprehensive
public void testOtherBasic() throws CdtVariableException {
- assertEquals("${Macro}",CdtVariableResolver.createVariableReference("Macro"));
+ assertEquals("${Macro}", CdtVariableResolver.createVariableReference("Macro"));
{
- String[] list = { "1","2","3" };
- assertEquals("1;2;3",CdtVariableResolver.convertStringListToString(list,";"));
+ String[] list = { "1", "2", "3" };
+ assertEquals("1;2;3", CdtVariableResolver.convertStringListToString(list, ";"));
}
{
String[] list = { "${PATH}", "${Macro}" };
String[] result = CdtVariableResolver.resolveStringListValues(list, mockSubstitutor, true);
- assertEquals(4,result.length);
- assertEquals("path0",result[0]);
- assertEquals("path1",result[1]);
- assertEquals("path2",result[2]);
- assertEquals("@Macro@",result[3]);
+ assertEquals(4, result.length);
+ assertEquals("path0", result[0]);
+ assertEquals("path1", result[1]);
+ assertEquals("path2", result[2]);
+ assertEquals("@Macro@", result[3]);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/CommandLineUtilTest.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/CommandLineUtilTest.java
index bc02ed466b0..062df03642f 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/CommandLineUtilTest.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/CommandLineUtilTest.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* QNX Software Systems - initial API and implementation
*******************************************************************************/
@@ -19,20 +19,22 @@ import junit.framework.TestSuite;
public class CommandLineUtilTest extends TestCase {
- public static Test suite() {
- return new TestSuite(CommandLineUtilTest.class);
- }
-
- private String[] parse(String line) {
+ public static Test suite() {
+ return new TestSuite(CommandLineUtilTest.class);
+ }
+
+ private String[] parse(String line) {
return CommandLineUtil.argumentsToArrayUnixStyle(line);
}
- private String[] parseWin(String line) {
+
+ private String[] parseWin(String line) {
return CommandLineUtil.argumentsToArrayWindowsStyle(line);
}
- private String[] parseU(String line) {
+
+ private String[] parseU(String line) {
return CommandLineUtil.argumentsToArray(line);
}
-
+
public void testArgumentsToArraySimple() {
String[] args = parse("A=B C");
assertEquals(2, args.length);
@@ -40,7 +42,6 @@ public class CommandLineUtilTest extends TestCase {
assertEquals("C", args[1]);
}
-
public void testArgumentsToArraySpaces() {
// [A=B C]
String[] args = parse("A=B C");
@@ -163,60 +164,65 @@ public class CommandLineUtilTest extends TestCase {
String[] args = parse(null);
assertEquals(0, args.length);
}
+
public void testArgumentsToArrayEmpty() {
// []
String[] args = parse("");
assertEquals(0, args.length);
}
+
public void testArgumentsToArrayEmptySpaces() {
// [ ]
String[] args = parse(" ");
assertEquals(0, args.length);
}
+
public void testArgumentsToArrayTabs() {
// [a b]
String[] args = parse("a \tb");
assertEquals(2, args.length);
assertEquals("a", args[0]);
}
+
public void testArgumentsToArrayNL() {
// ["a\nb"]
String[] args = parse("\"a\\nb\"");
assertEquals(1, args.length);
assertEquals("a\nb", args[0]);
}
-
+
public void testArgumentsToArraySimpleWin() {
String[] args = parseWin("A=B C");
assertEquals(2, args.length);
assertEquals("A=B", args[0]);
assertEquals("C", args[1]);
}
-
+
public void testArgumentsToArrayWindowsFiles() {
String[] args = parseWin("my\\file\\path");
assertEquals(1, args.length);
assertEquals("my\\file\\path", args[0]);
}
-
+
public void testArgumentsToArrayWindowsSpaces() {
String[] args = parseWin("\"my\\file\\path space\"");
assertEquals(1, args.length);
assertEquals("my\\file\\path space", args[0]);
}
-
+
public void testArgumentsToArrayWindowsEmpty() {
String[] args = parseWin("\"\"");
assertEquals(1, args.length);
assertEquals("", args[0]);
}
+
public void testArgumentsToArrayWindowsQuotes() {
String[] args = parseWin("\\\"a b\\\"");
assertEquals(2, args.length);
assertEquals("\"a", args[0]);
assertEquals("b\"", args[1]);
}
-
+
public void testArgumentsToArraySimpleUniversal() {
String[] args = parseU("A=B C D");
assertEquals(3, args.length);
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/FindProgramLocationTest.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/FindProgramLocationTest.java
index c197d5ebce8..8aa457cf7dc 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/FindProgramLocationTest.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/FindProgramLocationTest.java
@@ -43,10 +43,10 @@ public class FindProgramLocationTest extends TestCase {
assertNull(PathUtil.findProgramLocation("", ""));
assertNull(PathUtil.findProgramLocation("prog", ""));
assertNull(PathUtil.findProgramLocation("prog", PATH_SEPARATOR));
- assertNull(PathUtil.findProgramLocation("prog", "x"+PATH_SEPARATOR));
- assertNull(PathUtil.findProgramLocation("prog", PATH_SEPARATOR+"x"));
- assertNull(PathUtil.findProgramLocation("prog", PATH_SEPARATOR+PATH_SEPARATOR));
- assertNull(PathUtil.findProgramLocation("prog", PATH_SEPARATOR+"x"+PATH_SEPARATOR));
+ assertNull(PathUtil.findProgramLocation("prog", "x" + PATH_SEPARATOR));
+ assertNull(PathUtil.findProgramLocation("prog", PATH_SEPARATOR + "x"));
+ assertNull(PathUtil.findProgramLocation("prog", PATH_SEPARATOR + PATH_SEPARATOR));
+ assertNull(PathUtil.findProgramLocation("prog", PATH_SEPARATOR + "x" + PATH_SEPARATOR));
}
public void testFind() throws CoreException, IOException {
@@ -174,7 +174,7 @@ public class FindProgramLocationTest extends TestCase {
IPath actual = PathUtil.findProgramLocation(name2, path1);
assertEquals(filePath2_exe, actual);
}
-
+
String path12 = dir1.toOSString() + PATH_SEPARATOR + dir2.toOSString();
{
// dir2/file.exe is preferred to dir1/file
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/StorableCdtVariablesTest.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/StorableCdtVariablesTest.java
index 425d5d00016..b8c1b2d295a 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/StorableCdtVariablesTest.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/StorableCdtVariablesTest.java
@@ -10,8 +10,8 @@
*
* Contributors:
* Veaceslav Bacu (Freescale Semiconductor Inc.) - initial API and implementation (bug 348884)
- *
- *******************************************************************************/
+ *
+ *******************************************************************************/
package org.eclipse.cdt.utils;
@@ -37,12 +37,12 @@ public class StorableCdtVariablesTest extends TestCase {
public static Test suite() {
return new TestSuite(StorableCdtVariablesTest.class);
}
-
+
@Override
protected void tearDown() throws Exception {
ResourceHelper.cleanUp(getName());
}
-
+
/**
* Unit test for bug 348884
*/
@@ -57,12 +57,12 @@ public class StorableCdtVariablesTest extends TestCase {
StorableCdtVariable varA3 = new StorableCdtVariable("A3", ICdtVariable.VALUE_TEXT, "a3"); //$NON-NLS-1$ //$NON-NLS-2$
StorableCdtVariable varA4 = new StorableCdtVariable("A4", ICdtVariable.VALUE_TEXT, "a4"); //$NON-NLS-1$ //$NON-NLS-2$
StorableCdtVariable varA5 = new StorableCdtVariable("A5", ICdtVariable.VALUE_TEXT, "a5"); //$NON-NLS-1$ //$NON-NLS-2$
-
+
IUserVarSupplier supplier = CCorePlugin.getUserVarSupplier();
-
- try{
- supplier.setMacros(new ICdtVariable[]{varA1, varA2, varA3, varA4}, desc);
- }catch(Throwable e){
+
+ try {
+ supplier.setMacros(new ICdtVariable[] { varA1, varA2, varA3, varA4 }, desc);
+ } catch (Throwable e) {
fail(e.toString());
}
{
@@ -77,10 +77,10 @@ public class StorableCdtVariablesTest extends TestCase {
assertTrue(macroStrings.contains(varA4.getName() + '=' + varA4.getStringValue()));
assertEquals(4, macroStrings.size());
}
-
- try{
- supplier.setMacros(new ICdtVariable[]{varA1, varA2, varA5}, desc);
- }catch(Exception e){
+
+ try {
+ supplier.setMacros(new ICdtVariable[] { varA1, varA2, varA5 }, desc);
+ } catch (Exception e) {
fail(e.toString());
}
{
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/UNCPathConverterTest.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/UNCPathConverterTest.java
index edccefe9913..34aec5a1e58 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/UNCPathConverterTest.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/UNCPathConverterTest.java
@@ -53,10 +53,11 @@ public class UNCPathConverterTest {
// With scheme and host
{ new URI("http", "example.com", "/foo/bar", null), Path.fromOSString("//example.com/foo/bar") },
// With server-based authority
- { new URI("ssh", "user:password", "example.com", 8080, "/foo/bar", null, null), Path.fromOSString("//example.com/foo/bar") },
+ { new URI("ssh", "user:password", "example.com", 8080, "/foo/bar", null, null),
+ Path.fromOSString("//example.com/foo/bar") },
// With Registry-based authority
- { new URI("remotetools", "My Connection", "/foo/bar", null, null), Path.fromOSString("//My Connection/foo/bar") }
- });
+ { new URI("remotetools", "My Connection", "/foo/bar", null, null),
+ Path.fromOSString("//My Connection/foo/bar") } });
}
@Test
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/WeakHashSetTest.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/WeakHashSetTest.java
index 99b05dec56b..f55d76183ff 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/WeakHashSetTest.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/WeakHashSetTest.java
@@ -29,17 +29,20 @@ public class WeakHashSetTest extends TestCase {
*/
private class MockClass {
private String str;
+
private MockClass(String str) {
super();
this.str = str;
}
+
@Override
public int hashCode() {
// for test purpose make hashcodes equal for all "str" stating with the same letter
// note that "equals()" still reports difference
- String s = str.substring(0,1);
+ String s = str.substring(0, 1);
return s.hashCode();
}
+
@Override
public boolean equals(Object obj) {
MockClass other = (MockClass) obj;
@@ -102,10 +105,10 @@ public class WeakHashSetTest extends TestCase {
public void testHashSetSyncronization() throws Exception {
final WeakHashSet<Integer> weakSet = new WeakHashSetSynchronized<Integer>(1);
- Thread[] threads= new Thread[5000];
+ Thread[] threads = new Thread[5000];
for (int i = 0; i < threads.length; i++) {
final Integer n = i;
- Thread t= new Thread() {
+ Thread t = new Thread() {
@Override
public void run() {
weakSet.add(n);
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/elf/ElfParserTest.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/elf/ElfParserTest.java
index 4be76d88264..785ae7db74d 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/elf/ElfParserTest.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/elf/ElfParserTest.java
@@ -54,13 +54,13 @@ public class ElfParserTest extends TestCase {
/*
* The most probable cause for failing one of the following tests
- *
+ *
* testLE64DYNwithInterpELFoutsideHintsError_Bug512822
* testLE32DYNwithInterpELFoutsideHintsError_Bug512822
- *
+ *
* is that the hint buffer size has been changed and the test binaries
* are too small and need to be updated to reflect this change as well.
- *
+ *
* The original files have been manually created using nasm. See the
* *.asm files inside resources/elf/{inside_hints,outside_hints}/ for
* further details.
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/AllLanguageTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/AllLanguageTests.java
index 40ebacaf02f..79c5dc7fe4d 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/AllLanguageTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/AllLanguageTests.java
@@ -23,9 +23,9 @@ import junit.framework.TestSuite;
public class AllLanguageTests extends TestSuite {
public static Test suite() {
TestSuite suite = new AllLanguageTests();
-
+
suite.addTest(LanguageInheritanceTests.suite());
-
+
return suite;
}
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/LanguageInheritanceTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/LanguageInheritanceTests.java
index bf3d3a03609..393c8fcf923 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/LanguageInheritanceTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/LanguageInheritanceTests.java
@@ -37,38 +37,38 @@ import org.eclipse.core.runtime.content.IContentType;
* Tests for language inheritance computations.
*/
public class LanguageInheritanceTests extends BaseTestCase {
-
+
private static final String BIN_FOLDER = "bin";
private static final String FILE_NAME = "test.c";
private static final IContentType[] EMPTY_CONTENT_TYPES = new IContentType[0];
-
+
private ICProject fCProject;
private IFile fFile;
private LanguageManager fManager;
private ILanguage fLanguage1;
private ILanguage fLanguage2;
-
+
private IProject fProject;
private ICConfigurationDescription fConfiguration;
-
+
public static Test suite() {
return suite(LanguageInheritanceTests.class);
}
-
+
@Override
protected void setUp() throws Exception {
String name = getClass().getName() + "_" + getName();
- fCProject = CProjectHelper.createCCProject(name , BIN_FOLDER, IPDOMManager.ID_NO_INDEXER);
+ fCProject = CProjectHelper.createCCProject(name, BIN_FOLDER, IPDOMManager.ID_NO_INDEXER);
fProject = fCProject.getProject();
fFile = fProject.getFile(FILE_NAME);
-
+
ICProjectDescription projectDescription = CoreModel.getDefault().getProjectDescription(fProject, false);
fConfiguration = projectDescription.getActiveConfiguration();
-
+
fManager = LanguageManager.getInstance();
fLanguage1 = fManager.getLanguage(GPPLanguage.ID);
fLanguage2 = fManager.getLanguage(GCCLanguage.ID);
-
+
// Ensure global language mappings are cleared.
WorkspaceLanguageConfiguration config = fManager.getWorkspaceLanguageConfiguration();
config.setWorkspaceMappings(Collections.EMPTY_MAP);
@@ -79,27 +79,27 @@ public class LanguageInheritanceTests extends BaseTestCase {
protected void tearDown() throws Exception {
CProjectHelper.delete(fCProject);
}
-
+
public void testDirectFileMapping() throws Exception {
ILanguage originalLanguage = fManager.getLanguageForFile(fFile, fConfiguration);
assertDifferentLanguages(originalLanguage, fLanguage1);
-
+
ProjectLanguageConfiguration config = fManager.getLanguageConfiguration(fCProject.getProject());
config.addFileMapping(fConfiguration, fFile, GPPLanguage.ID);
fManager.storeLanguageMappingConfiguration(fFile);
-
+
assertSameLanguage(fLanguage1, fManager.getLanguageForFile(fFile, fConfiguration));
-
+
config.removeFileMapping(fConfiguration, fFile);
fManager.storeLanguageMappingConfiguration(fFile);
-
+
assertSameLanguage(originalLanguage, fManager.getLanguageForFile(fFile, fConfiguration));
}
-
+
public void testDirectProjectContentTypeMapping() throws Exception {
ILanguage originalLanguage = fManager.getLanguageForFile(fFile, fConfiguration);
assertDifferentLanguages(originalLanguage, fLanguage1);
-
+
String filename = fFile.getLocation().toString();
IContentType contentType = CContentTypes.getContentType(fProject, filename);
ProjectLanguageConfiguration config = fManager.getLanguageConfiguration(fCProject.getProject());
@@ -110,32 +110,32 @@ public class LanguageInheritanceTests extends BaseTestCase {
config.removeContentTypeMapping(fConfiguration, contentType.getId());
fManager.storeLanguageMappingConfiguration(fFile);
-
+
assertSameLanguage(originalLanguage, fManager.getLanguageForFile(fFile, fConfiguration));
}
public void testDirectWorkspaceContentTypeMapping() throws Exception {
ILanguage originalLanguage = fManager.getLanguageForFile(fFile, fConfiguration);
assertDifferentLanguages(originalLanguage, fLanguage1);
-
+
String filename = fFile.getLocation().toString();
IContentType contentType = CContentTypes.getContentType(fProject, filename);
WorkspaceLanguageConfiguration config = fManager.getWorkspaceLanguageConfiguration();
config.addWorkspaceMapping(contentType.getId(), GPPLanguage.ID);
fManager.storeWorkspaceLanguageConfiguration(EMPTY_CONTENT_TYPES);
-
+
assertEquals(fLanguage1, fManager.getLanguageForFile(fFile, fConfiguration));
-
+
config.removeWorkspaceMapping(contentType.getId());
fManager.storeLanguageMappingConfiguration(fFile);
-
+
assertEquals(originalLanguage, fManager.getLanguageForFile(fFile, fConfiguration));
}
public void testOverriddenWorkspaceContentTypeMapping1() throws Exception {
ILanguage originalLanguage = fManager.getLanguageForFile(fFile, fConfiguration);
assertDifferentLanguages(originalLanguage, fLanguage1);
-
+
String filename = fFile.getLocation().toString();
IContentType contentType = CContentTypes.getContentType(fProject, filename);
@@ -143,19 +143,19 @@ public class LanguageInheritanceTests extends BaseTestCase {
WorkspaceLanguageConfiguration config = fManager.getWorkspaceLanguageConfiguration();
config.addWorkspaceMapping(contentType.getId(), GPPLanguage.ID);
fManager.storeWorkspaceLanguageConfiguration(EMPTY_CONTENT_TYPES);
-
+
// Override with project mapping
ProjectLanguageConfiguration config2 = fManager.getLanguageConfiguration(fCProject.getProject());
config2.addContentTypeMapping(fConfiguration, contentType.getId(), GCCLanguage.ID);
fManager.storeLanguageMappingConfiguration(fProject, EMPTY_CONTENT_TYPES);
-
+
assertSameLanguage(fLanguage2, fManager.getLanguageForFile(fFile, fConfiguration));
}
public void testOverriddenWorkspaceContentTypeMapping2() throws Exception {
ILanguage originalLanguage = fManager.getLanguageForFile(fFile, fConfiguration);
assertDifferentLanguages(originalLanguage, fLanguage1);
-
+
String filename = fFile.getLocation().toString();
IContentType contentType = CContentTypes.getContentType(fProject, filename);
@@ -163,19 +163,19 @@ public class LanguageInheritanceTests extends BaseTestCase {
WorkspaceLanguageConfiguration config = fManager.getWorkspaceLanguageConfiguration();
config.addWorkspaceMapping(contentType.getId(), GPPLanguage.ID);
fManager.storeWorkspaceLanguageConfiguration(EMPTY_CONTENT_TYPES);
-
+
// Override with file mapping
ProjectLanguageConfiguration config2 = fManager.getLanguageConfiguration(fCProject.getProject());
config2.addFileMapping(fConfiguration, fFile, GCCLanguage.ID);
fManager.storeLanguageMappingConfiguration(fFile);
-
+
assertSameLanguage(fLanguage2, fManager.getLanguageForFile(fFile, fConfiguration));
}
-
+
public void testOverriddenProjectContentTypeMapping() throws Exception {
ILanguage originalLanguage = fManager.getLanguageForFile(fFile, fConfiguration);
assertDifferentLanguages(originalLanguage, fLanguage1);
-
+
String filename = fFile.getLocation().toString();
IContentType contentType = CContentTypes.getContentType(fProject, filename);
@@ -183,15 +183,15 @@ public class LanguageInheritanceTests extends BaseTestCase {
ProjectLanguageConfiguration config = fManager.getLanguageConfiguration(fCProject.getProject());
config.addContentTypeMapping(fConfiguration, contentType.getId(), GPPLanguage.ID);
fManager.storeLanguageMappingConfiguration(fProject, EMPTY_CONTENT_TYPES);
-
+
// Override with file mapping
ProjectLanguageConfiguration config2 = fManager.getLanguageConfiguration(fCProject.getProject());
config2.addFileMapping(fConfiguration, fFile, GCCLanguage.ID);
fManager.storeLanguageMappingConfiguration(fFile);
-
+
assertSameLanguage(fLanguage2, fManager.getLanguageForFile(fFile, fConfiguration));
}
-
+
protected void assertSameLanguage(ILanguage expected, ILanguage actual) {
if (expected != null) {
assertNotNull(actual);
@@ -200,7 +200,7 @@ public class LanguageInheritanceTests extends BaseTestCase {
assertNull(actual);
}
}
-
+
protected void assertDifferentLanguages(ILanguage language1, ILanguage language2) {
assertNotNull(language1);
assertNotNull(language2);
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsExtensionsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsExtensionsTests.java
index 0d859ae7e8f..5b197a63ee6 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsExtensionsTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsExtensionsTests.java
@@ -55,8 +55,10 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
/*package*/ static final String EXTENSION_SERIALIZABLE_PROVIDER_MISSING_PARAMETER = "parameter";
/*package*/ static final String EXTENSION_EDITABLE_PROVIDER_ID = "org.eclipse.cdt.core.tests.custom.editable.language.settings.provider";
/*package*/ static final String EXTENSION_EDITABLE_PROVIDER_NAME = "Test Plugin Mock Editable Language Settings Provider";
- /*package*/ static final ICLanguageSettingEntry EXTENSION_SERIALIZABLE_PROVIDER_ENTRY = new CMacroEntry("MACRO", "value", 0);
- /*package*/ static final ICLanguageSettingEntry EXTENSION_EDITABLE_PROVIDER_ENTRY = new CMacroEntry("MACRO", "value", 0);
+ /*package*/ static final ICLanguageSettingEntry EXTENSION_SERIALIZABLE_PROVIDER_ENTRY = new CMacroEntry("MACRO",
+ "value", 0);
+ /*package*/ static final ICLanguageSettingEntry EXTENSION_EDITABLE_PROVIDER_ENTRY = new CMacroEntry("MACRO",
+ "value", 0);
/*package*/ static final String EXTENSION_REGISTERER_PROVIDER_ID = "org.eclipse.cdt.core.tests.language.settings.listener.registerer.provider";
// Arbitrary sample parameters used by the test
@@ -116,25 +118,29 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
for (ILanguageSettingsProvider provider : providers) {
ids.add(provider.getId());
}
- assertTrue("extension " + EXTENSION_BASE_PROVIDER_ID + " not found", ids.contains(EXTENSION_BASE_PROVIDER_ID));
+ assertTrue("extension " + EXTENSION_BASE_PROVIDER_ID + " not found",
+ ids.contains(EXTENSION_BASE_PROVIDER_ID));
}
{
// test provider that is not in the list
- ILanguageSettingsProvider providerExt = LanguageSettingsManager.getExtensionProviderCopy("missing.povider", true);
+ ILanguageSettingsProvider providerExt = LanguageSettingsManager.getExtensionProviderCopy("missing.povider",
+ true);
assertNull(providerExt);
}
// this extension provider is not copyable
- ILanguageSettingsProvider providerExtCopy = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_BASE_PROVIDER_ID, true);
+ ILanguageSettingsProvider providerExtCopy = LanguageSettingsManager
+ .getExtensionProviderCopy(EXTENSION_BASE_PROVIDER_ID, true);
assertNull(providerExtCopy);
// test raw workspace provider defined as an extension
- ILanguageSettingsProvider providerExt = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
+ ILanguageSettingsProvider providerExt = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
assertTrue(LanguageSettingsManager.isWorkspaceProvider(providerExt));
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(providerExt);
assertTrue(rawProvider instanceof LanguageSettingsBaseProvider);
- LanguageSettingsBaseProvider provider = (LanguageSettingsBaseProvider)rawProvider;
+ LanguageSettingsBaseProvider provider = (LanguageSettingsBaseProvider) rawProvider;
assertEquals(EXTENSION_BASE_PROVIDER_ID, provider.getId());
assertEquals(EXTENSION_BASE_PROVIDER_NAME, provider.getName());
assertEquals(EXTENSION_BASE_PROVIDER_PARAMETER, provider.getProperty(EXTENSION_BASE_PROVIDER_ATTR_PARAMETER));
@@ -148,13 +154,8 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
// benchmarks matching extension point definition
List<ICLanguageSettingEntry> entriesExt = new ArrayList<ICLanguageSettingEntry>();
- entriesExt.add(new CIncludePathEntry("/usr/include/",
- ICSettingEntry.BUILTIN
- | ICSettingEntry.LOCAL
- | ICSettingEntry.RESOLVED
- | ICSettingEntry.VALUE_WORKSPACE_PATH
- | ICSettingEntry.UNDEFINED
- ));
+ entriesExt.add(new CIncludePathEntry("/usr/include/", ICSettingEntry.BUILTIN | ICSettingEntry.LOCAL
+ | ICSettingEntry.RESOLVED | ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.UNDEFINED));
entriesExt.add(new CMacroEntry("TEST_DEFINE", "100", 0));
entriesExt.add(new CIncludeFileEntry("/include/file.inc", 0));
entriesExt.add(new CLibraryPathEntry("/usr/lib/", 0));
@@ -163,8 +164,8 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
// retrieve entries from extension point
List<ICLanguageSettingEntry> actual = provider.getSettingEntries(null, FILE_0, EXTENSION_BASE_PROVIDER_LANG_ID);
- for (int i=0;i<entriesExt.size();i++) {
- assertEquals("i="+i, entriesExt.get(i), actual.get(i));
+ for (int i = 0; i < entriesExt.size(); i++) {
+ assertEquals("i=" + i, entriesExt.get(i), actual.get(i));
}
assertEquals(entriesExt.size(), actual.size());
}
@@ -174,15 +175,17 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
*/
public void testExtensionBaseProviderSubclass() throws Exception {
// get test plugin extension provider
- ILanguageSettingsProvider providerExtCopy = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_BASE_SUBCLASS_PROVIDER_ID, true);
+ ILanguageSettingsProvider providerExtCopy = LanguageSettingsManager
+ .getExtensionProviderCopy(EXTENSION_BASE_SUBCLASS_PROVIDER_ID, true);
assertNull(providerExtCopy);
- ILanguageSettingsProvider providerExt = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_SUBCLASS_PROVIDER_ID);
+ ILanguageSettingsProvider providerExt = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_BASE_SUBCLASS_PROVIDER_ID);
assertTrue(LanguageSettingsManager.isWorkspaceProvider(providerExt));
// get raw extension provider
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(providerExt);
assertTrue(rawProvider instanceof MockLanguageSettingsBaseProvider);
- MockLanguageSettingsBaseProvider provider = (MockLanguageSettingsBaseProvider)rawProvider;
+ MockLanguageSettingsBaseProvider provider = (MockLanguageSettingsBaseProvider) rawProvider;
assertEquals(EXTENSION_BASE_SUBCLASS_PROVIDER_ID, provider.getId());
assertEquals(EXTENSION_BASE_SUBCLASS_PROVIDER_PARAMETER, provider.getCustomParameter());
@@ -195,8 +198,8 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
// retrieve entries from extension point
List<ICLanguageSettingEntry> actual = provider.getSettingEntries(null, FILE_0, LANG_ID);
- for (int i=0;i<entriesExt.size();i++) {
- assertEquals("i="+i, entriesExt.get(i), actual.get(i));
+ for (int i = 0; i < entriesExt.size(); i++) {
+ assertEquals("i=" + i, entriesExt.get(i), actual.get(i));
}
assertEquals(entriesExt.size(), actual.size());
}
@@ -206,9 +209,11 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
*/
public void testExtensionCustomProvider() throws Exception {
// get test plugin extension non-default provider
- ILanguageSettingsProvider providerExtCopy = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_CUSTOM_PROVIDER_ID, true);
+ ILanguageSettingsProvider providerExtCopy = LanguageSettingsManager
+ .getExtensionProviderCopy(EXTENSION_CUSTOM_PROVIDER_ID, true);
assertNull(providerExtCopy);
- ILanguageSettingsProvider providerExt = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_CUSTOM_PROVIDER_ID);
+ ILanguageSettingsProvider providerExt = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_CUSTOM_PROVIDER_ID);
assertTrue(LanguageSettingsManager.isWorkspaceProvider(providerExt));
// get raw extension provider
@@ -231,7 +236,8 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
languages.add(LANG_ID);
// create base provider
- LanguageSettingsBaseProvider provider = new LanguageSettingsBaseProvider(PROVIDER_0, PROVIDER_NAME_0, languages, entries);
+ LanguageSettingsBaseProvider provider = new LanguageSettingsBaseProvider(PROVIDER_0, PROVIDER_NAME_0, languages,
+ entries);
{
// attempt to get entries for wrong language
@@ -246,7 +252,7 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
assertNotSame(entries, actual);
// retrieve languages
List<String> actualLanguageIds = provider.getLanguageScope();
- for (String languageId: languages) {
+ for (String languageId : languages) {
assertTrue(actualLanguageIds.contains(languageId));
}
assertEquals(languages.size(), actualLanguageIds.size());
@@ -326,9 +332,11 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
*/
public void testSerializableProvider() throws Exception {
// get test plugin extension for serializable provider
- ILanguageSettingsProvider providerExtCopy = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_SERIALIZABLE_PROVIDER_ID, true);
+ ILanguageSettingsProvider providerExtCopy = LanguageSettingsManager
+ .getExtensionProviderCopy(EXTENSION_SERIALIZABLE_PROVIDER_ID, true);
assertNull(providerExtCopy);
- ILanguageSettingsProvider providerExt = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
+ ILanguageSettingsProvider providerExt = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
assertTrue(LanguageSettingsManager.isWorkspaceProvider(providerExt));
// get raw extension provider
@@ -351,9 +359,11 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
// Non-editable providers cannot be copied so they are singletons
{
// get test plugin extension for serializable provider
- ILanguageSettingsProvider providerExtCopy = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_SERIALIZABLE_PROVIDER_ID, true);
+ ILanguageSettingsProvider providerExtCopy = LanguageSettingsManager
+ .getExtensionProviderCopy(EXTENSION_SERIALIZABLE_PROVIDER_ID, true);
assertNull(providerExtCopy);
- ILanguageSettingsProvider providerExt = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
+ ILanguageSettingsProvider providerExt = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
assertTrue(LanguageSettingsManager.isWorkspaceProvider(providerExt));
// get raw extension provider
@@ -366,19 +376,22 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
// Editable providers are retrieved by copy
{
// get extension provider
- ILanguageSettingsProvider providerExt = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, true);
+ ILanguageSettingsProvider providerExt = LanguageSettingsManager
+ .getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, true);
assertFalse(LanguageSettingsManager.isWorkspaceProvider(providerExt));
assertTrue(providerExt instanceof ILanguageSettingsEditableProvider);
assertTrue(LanguageSettingsManager.isEqualExtensionProvider(providerExt, true));
assertEquals(LanguageSettingsExtensionManager.isPreferShared(EXTENSION_EDITABLE_PROVIDER_ID), false);
// test that different copies are not same
- ILanguageSettingsProvider providerExt2 = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, true);
+ ILanguageSettingsProvider providerExt2 = LanguageSettingsManager
+ .getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, true);
assertNotSame(providerExt, providerExt2);
assertEquals(providerExt, providerExt2);
// test that workspace provider is not the same as extension provider
- ILanguageSettingsProvider providerWsp = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID);
+ ILanguageSettingsProvider providerWsp = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID);
ILanguageSettingsProvider providerWspRaw = LanguageSettingsManager.getRawProvider(providerWsp);
assertNotSame(providerExt, providerWspRaw);
assertEquals(providerExt, providerWspRaw);
@@ -387,11 +400,13 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
// Test shallow copy
{
- ILanguageSettingsProvider provider = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, true);
+ ILanguageSettingsProvider provider = LanguageSettingsManager
+ .getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, true);
assertNotNull(provider);
assertTrue(provider instanceof ILanguageSettingsEditableProvider);
- ILanguageSettingsProvider providerShallow = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, false);
+ ILanguageSettingsProvider providerShallow = LanguageSettingsManager
+ .getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, false);
assertNotNull(providerShallow);
assertTrue(providerShallow instanceof ILanguageSettingsEditableProvider);
assertFalse(provider.equals(providerShallow));
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsListenersTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsListenersTests.java
index 313ae79229b..e3a1883368f 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsListenersTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsListenersTests.java
@@ -48,7 +48,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
private static final String PROVIDER_CUSTOM_GLOBAL = "test.provider.custom.global.id";
private static final String PROVIDER_CUSTOM_GLOBAL_NAME = "test.provider.custom.global.name";
- private static final CMacroEntry SAMPLE_LSE = new CMacroEntry("MACRO", "value",0);
+ private static final CMacroEntry SAMPLE_LSE = new CMacroEntry("MACRO", "value", 0);
/**
* Mock {@link ILanguageSettingsChangeListener}.
@@ -56,22 +56,27 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
private class MockLanguageSettingsChangeListener implements ILanguageSettingsChangeListener {
private int count = 0;
private ILanguageSettingsChangeEvent lastEvent = null;
+
@Override
public void handleEvent(ILanguageSettingsChangeEvent event) {
count++;
lastEvent = event;
}
+
public int getCount() {
return count;
}
+
public void resetCount() {
count = 0;
lastEvent = null;
}
+
public ILanguageSettingsChangeEvent getLastEvent() {
return lastEvent;
}
}
+
private MockLanguageSettingsChangeListener mockLseListener = new MockLanguageSettingsChangeListener();
/**
@@ -93,8 +98,10 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
LanguageSettingsManager.unregisterLanguageSettingsChangeListener(mockLseListener);
LanguageSettingsManager.setWorkspaceProviders(null);
try {
- Job.getJobManager().join(LanguageSettingsProvidersSerializer.JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_PROJECT, null);
- Job.getJobManager().join(LanguageSettingsProvidersSerializer.JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE, null);
+ Job.getJobManager().join(LanguageSettingsProvidersSerializer.JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_PROJECT,
+ null);
+ Job.getJobManager()
+ .join(LanguageSettingsProvidersSerializer.JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE, null);
} catch (Exception e) {
// ignore
}
@@ -122,7 +129,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
*/
public void testListenerRegisterer_CheckExtensionProvider() throws Exception {
// check if extension provider exists
- ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID);
+ ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID);
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(workspaceProvider);
assertNotNull(rawProvider);
// global listeners providers get registered only lazily
@@ -139,7 +147,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -151,7 +160,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
@@ -182,14 +192,13 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
public void testListenerRegisterer_TwoOwnedByCfgs() throws Exception {
// create project
IProject project = ResourceHelper.createCDTProject(this.getName(), null, new String[] {
- "org.eclipse.cdt.core.tests.configuration.id.1",
- "org.eclipse.cdt.core.tests.configuration.id.2",
- });
+ "org.eclipse.cdt.core.tests.configuration.id.1", "org.eclipse.cdt.core.tests.configuration.id.2", });
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, true);
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(2, cfgDescriptions.length);
@@ -204,7 +213,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription1).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription1).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription1)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
}
{
@@ -213,7 +223,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription2).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription2).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription2)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
}
@@ -249,7 +260,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -257,11 +269,13 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// add global provider
- ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID);
+ ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(workspaceProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
@@ -292,16 +306,16 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
public void testListenerRegisterer_TwoGlobal() throws Exception {
// create project
IProject project = ResourceHelper.createCDTProject(this.getName(), null, new String[] {
- "org.eclipse.cdt.core.tests.configuration.id.1",
- "org.eclipse.cdt.core.tests.configuration.id.2",
- });
+ "org.eclipse.cdt.core.tests.configuration.id.1", "org.eclipse.cdt.core.tests.configuration.id.2", });
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, true);
{
// retrieve global provider
- ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID);
+ ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID);
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(2, cfgDescriptions.length);
@@ -315,7 +329,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(workspaceProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription1).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription1).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription1)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
}
{
@@ -323,7 +338,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(workspaceProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription2).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription2).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription2)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
}
// write to project description
@@ -353,16 +369,16 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
public void testListenerRegisterer_TwoGlobalMinusOne() throws Exception {
// create project
IProject project = ResourceHelper.createCDTProject(this.getName(), null, new String[] {
- "org.eclipse.cdt.core.tests.configuration.id.1",
- "org.eclipse.cdt.core.tests.configuration.id.2",
- });
+ "org.eclipse.cdt.core.tests.configuration.id.1", "org.eclipse.cdt.core.tests.configuration.id.2", });
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, true);
{
// retrieve workspace provider
- ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID);
+ ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID);
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(2, cfgDescriptions.length);
@@ -376,7 +392,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(workspaceProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription1).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription1).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription1)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
}
{
@@ -384,7 +401,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(workspaceProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription2).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription2).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription2)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
}
// write to project description
@@ -393,9 +411,11 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
}
{
// retrieve workspace provider
- ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID);
+ ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID);
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(2, cfgDescriptions.length);
@@ -408,7 +428,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// remove global provider from configuration 1
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
((ILanguageSettingsProvidersKeeper) cfgDescription1).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription1).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription1)
+ .getLanguageSettingProviders();
assertEquals(0, storedProviders.size());
}
// write to project description
@@ -431,7 +452,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project_1, true);
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project_1, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project_1, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -439,11 +461,13 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// add global provider
- ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID);
+ ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(workspaceProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
@@ -456,7 +480,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project_2, true);
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project_2, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project_2, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -464,11 +489,13 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// add global provider
- ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID);
+ ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(workspaceProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
@@ -494,7 +521,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
*/
public void testListenerRegisterer_GlobalProviderNotInUse() throws Exception {
// create project
- ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(PROVIDER_CUSTOM_GLOBAL);
+ ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager
+ .getWorkspaceProvider(PROVIDER_CUSTOM_GLOBAL);
// the global custom provider has not been added yet
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(workspaceProvider);
@@ -504,15 +532,18 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
List<ILanguageSettingsProvider> workspaceProvidersOriginal = LanguageSettingsManager.getWorkspaceProviders();
{
// add global provider which is not engaged
- ILanguageSettingsProvider provider = new MockListenerRegisterer(PROVIDER_CUSTOM_GLOBAL, PROVIDER_CUSTOM_GLOBAL_NAME);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(workspaceProvidersOriginal);
+ ILanguageSettingsProvider provider = new MockListenerRegisterer(PROVIDER_CUSTOM_GLOBAL,
+ PROVIDER_CUSTOM_GLOBAL_NAME);
+ List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(
+ workspaceProvidersOriginal);
providers.add(provider);
LanguageSettingsManager.setWorkspaceProviders(providers);
assertEquals(0, MockListenerRegisterer.getCount(PROVIDER_CUSTOM_GLOBAL));
}
{
// remove global provider and restore original list
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(workspaceProvidersOriginal);
+ List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(
+ workspaceProvidersOriginal);
LanguageSettingsManager.setWorkspaceProviders(providers);
assertEquals(0, MockListenerRegisterer.getCount(PROVIDER_CUSTOM_GLOBAL));
}
@@ -523,7 +554,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
*/
public void testListenerRegisterer_GlobalProviderAddRemoveOutsideTheProject() throws Exception {
// create project
- ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(PROVIDER_CUSTOM_GLOBAL);
+ ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager
+ .getWorkspaceProvider(PROVIDER_CUSTOM_GLOBAL);
// the global custom provider has not been added yet
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(workspaceProvider);
@@ -536,7 +568,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, true);
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -547,7 +580,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(workspaceProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
@@ -558,7 +592,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
{
// add global provider
- ILanguageSettingsProvider provider = new MockListenerRegisterer(PROVIDER_CUSTOM_GLOBAL, PROVIDER_CUSTOM_GLOBAL_NAME);
+ ILanguageSettingsProvider provider = new MockListenerRegisterer(PROVIDER_CUSTOM_GLOBAL,
+ PROVIDER_CUSTOM_GLOBAL_NAME);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(provider);
LanguageSettingsManager.setWorkspaceProviders(providers);
@@ -566,14 +601,16 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
}
{
// remove global provider
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(workspaceProvidersOriginal);
+ List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(
+ workspaceProvidersOriginal);
LanguageSettingsManager.setWorkspaceProviders(providers);
assertEquals(0, MockListenerRegisterer.getCount(PROVIDER_CUSTOM_GLOBAL));
}
{
// wait until serializing has finished
- Job.getJobManager().join(LanguageSettingsProvidersSerializer.JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE, null);
+ Job.getJobManager()
+ .join(LanguageSettingsProvidersSerializer.JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE, null);
// close project
project.close(null);
assertEquals(0, MockListenerRegisterer.getCount(PROVIDER_CUSTOM_GLOBAL));
@@ -590,7 +627,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// First clear default providers
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -600,7 +638,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// clear providers
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(0, storedProviders.size());
// write to project description
@@ -615,7 +654,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// Add empty provider
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -623,11 +663,13 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// create a provider and add to cfgDescription
- ILanguageSettingsProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ ILanguageSettingsProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
@@ -649,7 +691,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// First clear default providers
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -659,7 +702,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// clear providers
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(0, storedProviders.size());
// write to project description
@@ -674,7 +718,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// Add non-empty provider
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -683,14 +728,16 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// create a provider and add entries
- MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(SAMPLE_LSE);
mockProvider.setSettingEntries(cfgDescription, project, null, entries);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
@@ -718,7 +765,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// add the mock provider
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -729,7 +777,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1));
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
@@ -744,7 +793,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// Change the provider's entries
{
// get project descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, false);
assertNotNull(prjDescription);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -756,7 +806,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// Add entries
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(SAMPLE_LSE);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, providers.size());
assertTrue(providers.get(0) instanceof MockLanguageSettingsEditableProvider);
MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0);
@@ -788,7 +839,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// add the mock provider
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -799,7 +851,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1));
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
@@ -814,9 +867,11 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// Change the provider's entries concurrently
// get project descriptions
- ICProjectDescription prjDescription_1 = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
+ ICProjectDescription prjDescription_1 = CProjectDescriptionManager.getInstance().getProjectDescription(project,
+ false);
assertNotNull(prjDescription_1);
- ICProjectDescription prjDescription_2 = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
+ ICProjectDescription prjDescription_2 = CProjectDescriptionManager.getInstance().getProjectDescription(project,
+ false);
assertNotNull(prjDescription_2);
{
ICConfigurationDescription[] cfgDescriptions = prjDescription_1.getConfigurations();
@@ -829,7 +884,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// Add entries
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(SAMPLE_LSE);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, providers.size());
assertTrue(providers.get(0) instanceof MockLanguageSettingsEditableProvider);
MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0);
@@ -861,7 +917,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// Add same entries
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(SAMPLE_LSE);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, providers.size());
assertTrue(providers.get(0) instanceof MockLanguageSettingsEditableProvider);
MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0);
@@ -891,7 +948,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// First clear default providers
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -901,7 +959,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// clear providers
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(0, storedProviders.size());
// write to project description
@@ -916,7 +975,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// Add empty global provider
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -924,7 +984,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// retrieve a global provider
- ILanguageSettingsProvider wspProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID);
+ ILanguageSettingsProvider wspProvider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID);
assertNotNull(wspProvider);
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(wspProvider);
assertTrue(rawProvider instanceof MockLanguageSettingsEditableProvider);
@@ -935,7 +996,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(wspProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
@@ -957,7 +1019,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// First clear default providers
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -967,7 +1030,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// clear providers
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(0, storedProviders.size());
// write to project description
@@ -982,7 +1046,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// Add non-empty provider
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -992,7 +1057,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
String cfgDescriptionId = cfgDescription.getId();
// retrieve a global provider
- ILanguageSettingsProvider wspProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID);
+ ILanguageSettingsProvider wspProvider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID);
assertNotNull(wspProvider);
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(wspProvider);
assertTrue(rawProvider instanceof MockLanguageSettingsEditableProvider);
@@ -1000,13 +1066,15 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// add entries
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(SAMPLE_LSE);
- ((MockLanguageSettingsEditableProvider) rawProvider).setSettingEntries(cfgDescription, project, null, entries);
+ ((MockLanguageSettingsEditableProvider) rawProvider).setSettingEntries(cfgDescription, project, null,
+ entries);
assertEquals(SAMPLE_LSE, wspProvider.getSettingEntries(cfgDescription, project, null).get(0));
// add the provider to cfgDescription
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(wspProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
@@ -1037,7 +1105,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// Add empty global provider
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -1045,7 +1114,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// retrieve a global provider
- ILanguageSettingsProvider wspProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID);
+ ILanguageSettingsProvider wspProvider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID);
assertNotNull(wspProvider);
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(wspProvider);
assertTrue(rawProvider instanceof MockLanguageSettingsEditableProvider);
@@ -1056,7 +1126,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(wspProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
@@ -1066,7 +1137,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// Change the provider's entries
{
// retrieve a global provider
- ILanguageSettingsProvider wspProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID);
+ ILanguageSettingsProvider wspProvider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID);
assertNotNull(wspProvider);
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(wspProvider);
assertTrue(rawProvider instanceof MockLanguageSettingsEditableProvider);
@@ -1086,7 +1158,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
LanguageSettingsManager.serializeLanguageSettingsWorkspace();
// get cfgDescriptionId
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, false);
assertNotNull(prjDescription);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -1106,7 +1179,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// Clear the provider's entries
{
// retrieve a global provider
- ILanguageSettingsProvider wspProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID);
+ ILanguageSettingsProvider wspProvider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID);
assertNotNull(wspProvider);
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(wspProvider);
assertTrue(rawProvider instanceof MockLanguageSettingsEditableProvider);
@@ -1122,7 +1196,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
LanguageSettingsManager.serializeLanguageSettingsWorkspace();
// get cfgDescriptionId
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, false);
assertNotNull(prjDescription);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -1141,40 +1216,43 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// Change the provider's entries back to original state from extension point
{
-
- ILanguageSettingsProvider extensionProviderCopy = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, true);
+
+ ILanguageSettingsProvider extensionProviderCopy = LanguageSettingsManager
+ .getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, true);
List<ICLanguageSettingEntry> extEntries = extensionProviderCopy.getSettingEntries(null, null, null);
-
+
// retrieve a global provider
- ILanguageSettingsProvider wspProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID);
+ ILanguageSettingsProvider wspProvider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID);
assertNotNull(wspProvider);
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(wspProvider);
assertTrue(rawProvider instanceof MockLanguageSettingsEditableProvider);
// reset the provider to match extension
((MockLanguageSettingsEditableProvider) rawProvider).setSettingEntries(null, null, null, extEntries);
assertTrue(LanguageSettingsManager.isEqualExtensionProvider(rawProvider, true));
-
+
// reset count
mockLseListener.resetCount();
assertEquals(0, mockLseListener.getCount());
assertEquals(null, mockLseListener.getLastEvent());
-
+
// Serialize settings
LanguageSettingsManager.serializeLanguageSettingsWorkspace();
-
+
// get cfgDescriptionId
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, false);
assertNotNull(prjDescription);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
String cfgDescriptionId = cfgDescription.getId();
-
+
// inspect event
assertEquals(1, mockLseListener.getCount());
ILanguageSettingsChangeEvent event = mockLseListener.getLastEvent();
assertNotNull(event);
-
+
assertEquals(project.getName(), event.getProjectName());
assertEquals(1, event.getConfigurationDescriptionIds().length);
assertEquals(cfgDescriptionId, event.getConfigurationDescriptionIds()[0]);
@@ -1192,7 +1270,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// create a mock provider and add to cfgDescription
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -1201,10 +1280,12 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// add mock provider to cfgDescription
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
@@ -1222,13 +1303,15 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
ICConfigurationDescription cfgDescription;
{
// get project descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, false);
assertNotNull(prjDescription);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
assertEquals(1, cfgDescriptions.length);
cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper)cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, providers.size());
MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0);
@@ -1263,7 +1346,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// create a mock provider and add to cfgDescription
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -1272,10 +1356,12 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// add mock provider to cfgDescription
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
@@ -1293,13 +1379,15 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
ICConfigurationDescription cfgDescription;
{
// get project descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, false);
assertNotNull(prjDescription);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
assertEquals(1, cfgDescriptions.length);
cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper)cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, providers.size());
MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0);
@@ -1335,7 +1423,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// create a mock provider and add to cfgDescription
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -1344,10 +1433,12 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// add mock provider to cfgDescription
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
@@ -1365,13 +1456,15 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
ICConfigurationDescription cfgDescription;
{
// get project descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, false);
assertNotNull(prjDescription);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
assertEquals(1, cfgDescriptions.length);
cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper)cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, providers.size());
MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0);
@@ -1407,7 +1500,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// create a mock provider and add to cfgDescription
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -1416,10 +1510,12 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// add mock provider to cfgDescription
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
@@ -1437,13 +1533,15 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
ICConfigurationDescription cfgDescription;
{
// get project descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, false);
assertNotNull(prjDescription);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
assertEquals(1, cfgDescriptions.length);
cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper)cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, providers.size());
MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0);
@@ -1482,7 +1580,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// create a mock provider and add to cfgDescription
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -1491,10 +1590,12 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
// add mock provider to cfgDescription
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
@@ -1512,13 +1613,15 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
ICConfigurationDescription cfgDescription;
{
// get project descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, false);
assertNotNull(prjDescription);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
assertEquals(1, cfgDescriptions.length);
cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper)cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, providers.size());
MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0);
@@ -1547,4 +1650,3 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
}
}
}
-
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManagerTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManagerTests.java
index 0da38bb7818..3a0a89a5db8 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManagerTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManagerTests.java
@@ -65,24 +65,30 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
/**
* Mock configuration description.
*/
- class MockConfigurationDescription extends CModelMock.DummyCConfigurationDescription implements ILanguageSettingsProvidersKeeper {
+ class MockConfigurationDescription extends CModelMock.DummyCConfigurationDescription
+ implements ILanguageSettingsProvidersKeeper {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
String[] defaultProvidersIds = null;
+
public MockConfigurationDescription(String id) {
super(id);
}
+
@Override
public void setLanguageSettingProviders(List<? extends ILanguageSettingsProvider> providers) {
this.providers = new ArrayList<ILanguageSettingsProvider>(providers);
}
+
@Override
public List<ILanguageSettingsProvider> getLanguageSettingProviders() {
return providers;
}
+
@Override
public void setDefaultLanguageSettingsProvidersIds(String[] ids) {
defaultProvidersIds = ids;
}
+
@Override
public String[] getDefaultLanguageSettingsProvidersIds() {
return defaultProvidersIds;
@@ -94,12 +100,15 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
*/
private class MockProvider extends AbstractExecutableExtensionBase implements ILanguageSettingsProvider {
private List<ICLanguageSettingEntry> entries;
+
public MockProvider(String id, String name, List<ICLanguageSettingEntry> entries) {
super(id, name);
this.entries = entries;
}
+
@Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
+ public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc,
+ String languageId) {
return entries;
}
}
@@ -177,7 +186,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
// Create model project and accompanied descriptions
String projectName = getName();
IProject project = ResourceHelper.createCDTProjectWithConfig(projectName);
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
@@ -215,25 +225,25 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
// use provider returning null, no exception should be recorded
{
- List<ICLanguageSettingEntry> actual = LanguageSettingsManager
- .getSettingEntriesUpResourceTree(providerNull, cfgDescription, FILE_0, LANG_ID);
+ List<ICLanguageSettingEntry> actual = LanguageSettingsManager.getSettingEntriesUpResourceTree(providerNull,
+ cfgDescription, FILE_0, LANG_ID);
assertNotNull(actual);
assertEquals(0, actual.size());
}
{
List<ICLanguageSettingEntry> actual = LanguageSettingsProvidersSerializer
- .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, 0);
+ .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, 0);
assertNotNull(actual);
assertEquals(0, actual.size());
}
// set impolite provider returning null in getSettingEntries() array
ILanguageSettingsProvider providerNull_2 = new MockProvider(PROVIDER_2, PROVIDER_NAME_2,
- new ArrayList<ICLanguageSettingEntry>() {
- { // init via static initializer
- add(null);
- }
- });
+ new ArrayList<ICLanguageSettingEntry>() {
+ { // init via static initializer
+ add(null);
+ }
+ });
{
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(providerNull);
@@ -243,13 +253,13 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
// use provider returning null as item in array
{
List<ICLanguageSettingEntry> actual = LanguageSettingsManager
- .getSettingEntriesUpResourceTree(providerNull_2, cfgDescription, FILE_0, LANG_ID);
+ .getSettingEntriesUpResourceTree(providerNull_2, cfgDescription, FILE_0, LANG_ID);
assertNotNull(actual);
assertEquals(1, actual.size());
}
{
List<ICLanguageSettingEntry> actual = LanguageSettingsProvidersSerializer
- .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, 0);
+ .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, 0);
assertNotNull(actual);
assertEquals(0, actual.size());
}
@@ -260,7 +270,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
ILanguageSettingsProvider providerNPE = new MockProvider(PROVIDER_1, PROVIDER_NAME_1, null) {
@Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
+ public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription,
+ IResource rc, String languageId) {
throw new NullPointerException("Can you handle me?");
}
};
@@ -286,9 +297,10 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
// define provider returning entries when configuration id matches and null otherwise
- ILanguageSettingsProvider providerYes = new MockProvider(PROVIDER_0, PROVIDER_NAME_0, null) {
+ ILanguageSettingsProvider providerYes = new MockProvider(PROVIDER_0, PROVIDER_NAME_0, null) {
@Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
+ public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription,
+ IResource rc, String languageId) {
if (cfgDescription.getId().equals(modelCfgDescription.getId())) {
return entries;
}
@@ -298,10 +310,11 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
};
providers.add(providerYes);
// define provider returning entries when configuration id does NOT match and null otherwise
- ILanguageSettingsProvider providerNo = new MockProvider(PROVIDER_1, PROVIDER_NAME_1, null) {
+ ILanguageSettingsProvider providerNo = new MockProvider(PROVIDER_1, PROVIDER_NAME_1, null) {
@Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
- if (cfgDescription!= null && !cfgDescription.getId().equals(modelCfgDescription.getId())) {
+ public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription,
+ IResource rc, String languageId) {
+ if (cfgDescription != null && !cfgDescription.getId().equals(modelCfgDescription.getId())) {
return entries;
}
return null;
@@ -313,16 +326,16 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
{
// retrieve the entries with provider returning the given list
- List<ICLanguageSettingEntry> actual = LanguageSettingsManager
- .getSettingEntriesUpResourceTree(providerYes, modelCfgDescription, FILE_0, LANG_ID);
+ List<ICLanguageSettingEntry> actual = LanguageSettingsManager.getSettingEntriesUpResourceTree(providerYes,
+ modelCfgDescription, FILE_0, LANG_ID);
assertEquals(entries.get(0), actual.get(0));
assertEquals(entries.size(), actual.size());
}
{
// retrieve the entries with provider returning empty list
- List<ICLanguageSettingEntry> actual = LanguageSettingsManager
- .getSettingEntriesUpResourceTree(providerNo, modelCfgDescription, FILE_0, LANG_ID);
+ List<ICLanguageSettingEntry> actual = LanguageSettingsManager.getSettingEntriesUpResourceTree(providerNo,
+ modelCfgDescription, FILE_0, LANG_ID);
assertEquals(0, actual.size());
}
}
@@ -352,28 +365,28 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
{
// retrieve the entries for provider-1
- List<ICLanguageSettingEntry> actual = LanguageSettingsManager
- .getSettingEntriesUpResourceTree(provider1, cfgDescription, FILE_0, LANG_ID);
+ List<ICLanguageSettingEntry> actual = LanguageSettingsManager.getSettingEntriesUpResourceTree(provider1,
+ cfgDescription, FILE_0, LANG_ID);
assertNotSame(entries1, actual);
ICLanguageSettingEntry[] entriesArray = entries1.toArray(new ICLanguageSettingEntry[0]);
ICLanguageSettingEntry[] actualArray = actual.toArray(new ICLanguageSettingEntry[0]);
- for (int i=0;i<entries1.size();i++) {
- assertEquals("i="+i, entriesArray[i], actualArray[i]);
+ for (int i = 0; i < entries1.size(); i++) {
+ assertEquals("i=" + i, entriesArray[i], actualArray[i]);
}
assertEquals(entries1.size(), actual.size());
}
{
// retrieve the entries for provider-2
- List<ICLanguageSettingEntry> actual = LanguageSettingsManager
- .getSettingEntriesUpResourceTree(provider2, cfgDescription, FILE_0, LANG_ID);
+ List<ICLanguageSettingEntry> actual = LanguageSettingsManager.getSettingEntriesUpResourceTree(provider2,
+ cfgDescription, FILE_0, LANG_ID);
assertNotSame(entries2, actual);
ICLanguageSettingEntry[] entriesArray = entries2.toArray(new ICLanguageSettingEntry[0]);
ICLanguageSettingEntry[] actualArray = actual.toArray(new ICLanguageSettingEntry[0]);
- for (int i=0;i<entries2.size();i++) {
- assertEquals("i="+i, entriesArray[i], actualArray[i]);
+ for (int i = 0; i < entries2.size(); i++) {
+ assertEquals("i=" + i, entriesArray[i], actualArray[i]);
}
assertEquals(entries2.size(), actual.size());
}
@@ -386,7 +399,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
// Create model project and accompanied descriptions
String projectName = getName();
IProject project = ResourceHelper.createCDTProjectWithConfig(projectName);
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
@@ -401,13 +415,14 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
final List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(new CIncludePathEntry("path0", 0));
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_0, PROVIDER_NAME_0, null) {
+ ILanguageSettingsProvider provider = new MockProvider(PROVIDER_0, PROVIDER_NAME_0, null) {
@Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
- if (rc!=null && rc.equals(parentFolder)) {
+ public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription,
+ IResource rc, String languageId) {
+ if (rc != null && rc.equals(parentFolder)) {
return entries;
}
- if (rc!=null && rc.equals(emptySettingsPath)) {
+ if (rc != null && rc.equals(emptySettingsPath)) {
return new ArrayList<ICLanguageSettingEntry>(0);
}
return null;
@@ -420,25 +435,26 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
{
// retrieve entries for a derived resource (in a subfolder)
IFile derived = ResourceHelper.createFile(project, "/ParentFolder/Subfolder/resource");
- List<ICLanguageSettingEntry> actual = LanguageSettingsManager
- .getSettingEntriesUpResourceTree(provider, cfgDescriptionWritable, derived, LANG_ID);
+ List<ICLanguageSettingEntry> actual = LanguageSettingsManager.getSettingEntriesUpResourceTree(provider,
+ cfgDescriptionWritable, derived, LANG_ID);
// taken from parent folder
- assertEquals(entries.get(0),actual.get(0));
+ assertEquals(entries.get(0), actual.get(0));
assertEquals(entries.size(), actual.size());
}
{
// retrieve entries for not related resource
- IFile notRelated = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/AnotherFolder/Subfolder/resource"));
- List<ICLanguageSettingEntry> actual = LanguageSettingsManager
- .getSettingEntriesUpResourceTree(provider, cfgDescriptionWritable, notRelated, LANG_ID);
+ IFile notRelated = ResourcesPlugin.getWorkspace().getRoot()
+ .getFile(new Path("/AnotherFolder/Subfolder/resource"));
+ List<ICLanguageSettingEntry> actual = LanguageSettingsManager.getSettingEntriesUpResourceTree(provider,
+ cfgDescriptionWritable, notRelated, LANG_ID);
assertEquals(0, actual.size());
}
{
// test distinction between no settings and empty settings
- List<ICLanguageSettingEntry> actual = LanguageSettingsManager
- .getSettingEntriesUpResourceTree(provider, cfgDescriptionWritable, emptySettingsPath, LANG_ID);
+ List<ICLanguageSettingEntry> actual = LanguageSettingsManager.getSettingEntriesUpResourceTree(provider,
+ cfgDescriptionWritable, emptySettingsPath, LANG_ID);
// NOT taken from parent folder
assertEquals(0, actual.size());
}
@@ -451,7 +467,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
// Create model project and accompanied descriptions
String projectName = getName();
IProject project = ResourceHelper.createCDTProjectWithConfig(projectName);
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
@@ -466,10 +483,11 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
final List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(new CIncludePathEntry("path0", 0));
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_0, PROVIDER_NAME_0, null) {
+ ILanguageSettingsProvider provider = new MockProvider(PROVIDER_0, PROVIDER_NAME_0, null) {
@Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
- if (cfgDescription==null && rc==null) {
+ public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription,
+ IResource rc, String languageId) {
+ if (cfgDescription == null && rc == null) {
return entries;
}
return null;
@@ -482,10 +500,10 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
{
// retrieve entries for a resource
IFile derived = ResourceHelper.createFile(project, "/ParentFolder/Subfolder/resource");
- List<ICLanguageSettingEntry> actual = LanguageSettingsManager
- .getSettingEntriesUpResourceTree(provider, cfgDescriptionWritable, derived, LANG_ID);
+ List<ICLanguageSettingEntry> actual = LanguageSettingsManager.getSettingEntriesUpResourceTree(provider,
+ cfgDescriptionWritable, derived, LANG_ID);
// default entries given
- assertEquals(entries.get(0),actual.get(0));
+ assertEquals(entries.get(0), actual.get(0));
assertEquals(entries.size(), actual.size());
}
}
@@ -499,9 +517,9 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
// contribute the entries
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(new CIncludePathEntry("path0", 0));
- entries.add(new CMacroEntry("MACRO0", "value0",0));
+ entries.add(new CMacroEntry("MACRO0", "value0", 0));
entries.add(new CIncludePathEntry("path1", 0));
- entries.add(new CMacroEntry("MACRO1", "value1",0));
+ entries.add(new CMacroEntry("MACRO1", "value1", 0));
entries.add(new CIncludePathEntry("path2", 0));
ILanguageSettingsProvider provider0 = new MockProvider(PROVIDER_0, PROVIDER_NAME_0, entries);
@@ -511,16 +529,16 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
// retrieve entries by kind
List<ICLanguageSettingEntry> includes = LanguageSettingsProvidersSerializer
- .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH);
- assertEquals(new CIncludePathEntry("path0", 0),includes.get(0));
- assertEquals(new CIncludePathEntry("path1", 0),includes.get(1));
- assertEquals(new CIncludePathEntry("path2", 0),includes.get(2));
+ .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH);
+ assertEquals(new CIncludePathEntry("path0", 0), includes.get(0));
+ assertEquals(new CIncludePathEntry("path1", 0), includes.get(1));
+ assertEquals(new CIncludePathEntry("path2", 0), includes.get(2));
assertEquals(3, includes.size());
List<ICLanguageSettingEntry> macros = LanguageSettingsProvidersSerializer
- .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.MACRO);
- assertEquals(new CMacroEntry("MACRO0", "value0",0), macros.get(0));
- assertEquals(new CMacroEntry("MACRO1", "value1",0), macros.get(1));
+ .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.MACRO);
+ assertEquals(new CMacroEntry("MACRO0", "value0", 0), macros.get(0));
+ assertEquals(new CMacroEntry("MACRO1", "value1", 0), macros.get(1));
assertEquals(2, macros.size());
}
@@ -542,9 +560,10 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
cfgDescription.setLanguageSettingProviders(providers);
// retrieve entries by kind, only first entry should be returned
- List<ICLanguageSettingEntry> includes = LanguageSettingsProvidersSerializer.getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH);
+ List<ICLanguageSettingEntry> includes = LanguageSettingsProvidersSerializer
+ .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH);
assertEquals(1, includes.size());
- assertEquals(entries.get(0),includes.get(0));
+ assertEquals(entries.get(0), includes.get(0));
}
/**
@@ -565,7 +584,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
// retrieve entries by kind, no entries should be returned
List<ICLanguageSettingEntry> includes = LanguageSettingsProvidersSerializer
- .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH);
+ .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH);
assertEquals(0, includes.size());
}
@@ -590,7 +609,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
{
// retrieve local entries
List<ICLanguageSettingEntry> includes = LanguageSettingsProvidersSerializer
- .getLocalSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH);
+ .getLocalSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH);
assertEquals(localIncludeEntry, includes.get(0));
assertEquals(1, includes.size());
}
@@ -598,7 +617,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
{
// retrieve system entries
List<ICLanguageSettingEntry> includes = LanguageSettingsProvidersSerializer
- .getSystemSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH);
+ .getSystemSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH);
assertEquals(systemIncludeEntry, includes.get(0));
assertEquals(1, includes.size());
}
@@ -606,7 +625,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
{
// retrieve both local and system
List<ICLanguageSettingEntry> includes = LanguageSettingsProvidersSerializer
- .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH);
+ .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH);
assertEquals(entries.get(0), includes.get(0));
assertEquals(entries.get(1), includes.get(1));
assertEquals(2, includes.size());
@@ -643,14 +662,14 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
// retrieve entries by kind
List<ICLanguageSettingEntry> includes = LanguageSettingsProvidersSerializer
- .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH);
+ .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH);
// path0 is taken from higher priority provider
- assertEquals(entriesHigh.get(0),includes.get(0));
+ assertEquals(entriesHigh.get(0), includes.get(0));
// path1 disablement by lower priority provider is ignored
- assertEquals(entriesHigh.get(1),includes.get(1));
+ assertEquals(entriesHigh.get(1), includes.get(1));
// path2 is removed because of DISABLED flag of high priority provider
// path3 gets there from low priority provider
- assertEquals(entriesLow.get(3),includes.get(2));
+ assertEquals(entriesLow.get(3), includes.get(2));
assertEquals(3, includes.size());
}
@@ -663,9 +682,9 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
// contribute the entries
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(new CIncludePathEntry("path0", 0));
- entries.add(new CMacroEntry("MACRO0", "value0",0));
+ entries.add(new CMacroEntry("MACRO0", "value0", 0));
entries.add(new CIncludePathEntry("path1", 0));
- entries.add(new CMacroEntry("MACRO1", "value1",0));
+ entries.add(new CMacroEntry("MACRO1", "value1", 0));
entries.add(new CIncludePathEntry("path2", 0));
entries.add(new CIncludeFileEntry("include-path-file", 0));
@@ -676,12 +695,12 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
cfgDescription.setLanguageSettingProviders(providers);
// retrieve entries by kind
- List<ICLanguageSettingEntry> result = LanguageSettingsProvidersSerializer
- .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH | ICSettingEntry.MACRO);
+ List<ICLanguageSettingEntry> result = LanguageSettingsProvidersSerializer.getSettingEntriesByKind(
+ cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH | ICSettingEntry.MACRO);
assertEquals(new CIncludePathEntry("path0", 0), result.get(0));
- assertEquals(new CMacroEntry("MACRO0", "value0",0), result.get(1));
+ assertEquals(new CMacroEntry("MACRO0", "value0", 0), result.get(1));
assertEquals(new CIncludePathEntry("path1", 0), result.get(2));
- assertEquals(new CMacroEntry("MACRO1", "value1",0), result.get(3));
+ assertEquals(new CMacroEntry("MACRO1", "value1", 0), result.get(3));
assertEquals(new CIncludePathEntry("path2", 0), result.get(4));
assertEquals(5, result.size());
}
@@ -693,19 +712,22 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
// Create model project and accompanied descriptions
String projectName = getName();
IProject project = ResourceHelper.createCDTProjectWithConfig(projectName);
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof CConfigurationDescription);
// Select a sample workspace provider for the test
- ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
+ ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
assertNotNull(workspaceProvider);
{
// ensure no test provider is set yet but default providers
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, providers.get(0).getId());
assertEquals(ReferencedProjectsLanguageSettingsProvider.ID, providers.get(1).getId());
assertEquals(ScannerDiscoveryLegacySupport.MBS_LANGUAGE_SETTINGS_PROVIDER_ID, providers.get(2).getId());
@@ -719,7 +741,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
}
{
// check that test provider got there
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(workspaceProvider, providers.get(0));
}
@@ -733,12 +756,14 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
{
// check that test provider got loaded
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, false);
ICConfigurationDescription[] loadedCfgDescriptions = prjDescription.getConfigurations();
ICConfigurationDescription loadedCfgDescription = loadedCfgDescriptions[0];
assertTrue(cfgDescription instanceof CConfigurationDescription);
- List<ILanguageSettingsProvider> loadedProviders = ((ILanguageSettingsProvidersKeeper) loadedCfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> loadedProviders = ((ILanguageSettingsProvidersKeeper) loadedCfgDescription)
+ .getLanguageSettingProviders();
assertTrue(LanguageSettingsManager.isWorkspaceProvider(loadedProviders.get(0)));
}
@@ -749,7 +774,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
*/
public void testWorkspaceProvider_Basic() throws Exception {
// get workspace provider
- ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
+ ILanguageSettingsProvider provider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
assertEquals(EXTENSION_SERIALIZABLE_PROVIDER_ID, provider.getId());
assertEquals(EXTENSION_SERIALIZABLE_PROVIDER_NAME, provider.getName());
@@ -774,7 +800,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
List<ICLanguageSettingEntry> newEntries = new ArrayList<ICLanguageSettingEntry>();
newEntries.add(new CIncludePathEntry("path0", 0));
newEntries.add(new CIncludePathEntry("path1", 0));
- ((LanguageSettingsSerializableProvider)rawProvider).setSettingEntries(null, null, null, newEntries);
+ ((LanguageSettingsSerializableProvider) rawProvider).setSettingEntries(null, null, null, newEntries);
// check that the workspace provider gets them too
List<ICLanguageSettingEntry> newRawEntries = rawProvider.getSettingEntries(null, null, null);
@@ -787,8 +813,10 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
* Test workspace providers equality.
*/
public void testWorkspaceProvider_Equals() throws Exception {
- ILanguageSettingsProvider providerA = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
- ILanguageSettingsProvider providerB = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
+ ILanguageSettingsProvider providerA = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
+ ILanguageSettingsProvider providerB = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
assertEquals(providerA, providerB);
}
@@ -797,7 +825,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
*/
public void testWorkspaceProvider_ReplaceRawProvider() throws Exception {
// get sample workspace provider
- ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID);
+ ILanguageSettingsProvider provider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID);
{
// check on its entries (1 predefined entry via extension point)
List<ICLanguageSettingEntry> entries = provider.getSettingEntries(null, null, null);
@@ -813,7 +842,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
{
// replace raw provider
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- LanguageSettingsSerializableProvider newRawProvider = new LanguageSettingsSerializableProvider(EXTENSION_EDITABLE_PROVIDER_ID, PROVIDER_NAME_0);
+ LanguageSettingsSerializableProvider newRawProvider = new LanguageSettingsSerializableProvider(
+ EXTENSION_EDITABLE_PROVIDER_ID, PROVIDER_NAME_0);
newRawProvider.setSettingEntries(null, null, null, newEntries);
providers.add(newRawProvider);
LanguageSettingsManager.setWorkspaceProviders(providers);
@@ -832,7 +862,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
*/
public void testWorkspaceProvider_ReplaceWithWorkspaceProvider() throws Exception {
// get sample workspace provider
- ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
+ ILanguageSettingsProvider provider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
assertNotSame(provider, rawProvider);
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java
index e3980125ea8..14fdba97190 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java
@@ -72,22 +72,28 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Mock configuration description.
*/
- class MockConfigurationDescription extends CModelMock.DummyCConfigurationDescription implements ILanguageSettingsProvidersKeeper {
+ class MockConfigurationDescription extends CModelMock.DummyCConfigurationDescription
+ implements ILanguageSettingsProvidersKeeper {
List<ILanguageSettingsProvider> providers;
+
public MockConfigurationDescription(String id) {
super(id);
}
+
@Override
public void setLanguageSettingProviders(List<? extends ILanguageSettingsProvider> providers) {
this.providers = new ArrayList<ILanguageSettingsProvider>(providers);
}
+
@Override
public List<ILanguageSettingsProvider> getLanguageSettingProviders() {
return providers;
}
+
@Override
public void setDefaultLanguageSettingsProvidersIds(String[] ids) {
}
+
@Override
public String[] getDefaultLanguageSettingsProvidersIds() {
return null;
@@ -99,17 +105,21 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
*/
class MockProjectDescription extends CModelMock.DummyCProjectDescription {
ICConfigurationDescription[] cfgDescriptions;
+
public MockProjectDescription(ICConfigurationDescription[] cfgDescriptions) {
this.cfgDescriptions = cfgDescriptions;
}
+
public MockProjectDescription(ICConfigurationDescription cfgDescription) {
this.cfgDescriptions = new ICConfigurationDescription[] { cfgDescription };
}
+
@Override
public ICConfigurationDescription[] getConfigurations() {
return cfgDescriptions;
}
+
@Override
public ICConfigurationDescription getConfigurationById(String id) {
for (ICConfigurationDescription cfgDescription : cfgDescriptions) {
@@ -160,7 +170,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
*/
private ICConfigurationDescription[] getConfigurationDescriptions(IProject project) {
// project description
- ICProjectDescription projectDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
+ ICProjectDescription projectDescription = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, false);
assertNotNull(projectDescription);
assertEquals(1, projectDescription.getConfigurations().length);
// configuration description
@@ -200,7 +211,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -208,11 +220,13 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertNotNull(cfgDescriptionWritable);
assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> originalProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> originalProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable)
+ .getLanguageSettingProviders();
int originalSize = originalProviders.size();
// create new provider list
- LanguageSettingsSerializableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_0, PROVIDER_NAME_0);
+ LanguageSettingsSerializableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_0,
+ PROVIDER_NAME_0);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(originalProviders);
providers.add(mockProvider);
assertTrue(originalSize != providers.size());
@@ -231,7 +245,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
{
// get read-only description
- ICProjectDescription prjDescriptionReadOnly = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
+ ICProjectDescription prjDescriptionReadOnly = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, false);
assertNotNull(prjDescriptionReadOnly);
ICConfigurationDescription cfgDescriptionReadOnly = prjDescriptionReadOnly.getDefaultSettingConfiguration();
assertNotNull(cfgDescriptionReadOnly);
@@ -248,7 +263,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
// try to write to it default providers ids
try {
- ((ILanguageSettingsProvidersKeeper) cfgDescriptionReadOnly).setDefaultLanguageSettingsProvidersIds(new String[] { PROVIDER_0 });
+ ((ILanguageSettingsProvidersKeeper) cfgDescriptionReadOnly)
+ .setDefaultLanguageSettingsProvidersIds(new String[] { PROVIDER_0 });
fail("WriteAccessException was expected but it was not throw.");
} catch (WriteAccessException e) {
// exception is expected
@@ -260,7 +276,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -269,24 +286,28 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper);
// create a provider and write to cfgDescription
- LanguageSettingsSerializableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider, true);
mockProvider.setSettingEntries(cfgDescriptionWritable, null, null, entries);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to cfgDescription default providers ids
- ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setDefaultLanguageSettingsProvidersIds(new String[] { PROVIDER_0 });
+ ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable)
+ .setDefaultLanguageSettingsProvidersIds(new String[] { PROVIDER_0 });
// apply new project description to the project model
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable);
}
{
// get read-only project descriptions
- ICProjectDescription prjDescriptionReadOnly = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
+ ICProjectDescription prjDescriptionReadOnly = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, false);
assertNotNull(prjDescriptionReadOnly);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionReadOnly.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -295,7 +316,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertTrue(cfgDescriptionReadOnly instanceof ILanguageSettingsProvidersKeeper);
// double-check providers
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionReadOnly).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionReadOnly)
+ .getLanguageSettingProviders();
assertEquals(1, providers.size());
ILanguageSettingsProvider loadedProvider = providers.get(0);
assertTrue(loadedProvider instanceof MockLanguageSettingsEditableProvider);
@@ -307,12 +329,14 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertEquals(entries.size(), actual.size());
// double-check default providers ids
- String[] actualDefaultProvidersIds = ((ILanguageSettingsProvidersKeeper) cfgDescriptionReadOnly).getDefaultLanguageSettingsProvidersIds();
+ String[] actualDefaultProvidersIds = ((ILanguageSettingsProvidersKeeper) cfgDescriptionReadOnly)
+ .getDefaultLanguageSettingsProvidersIds();
assertTrue(Arrays.equals(new String[] { PROVIDER_0 }, actualDefaultProvidersIds));
}
{
// get writable project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -321,7 +345,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper);
// check providers
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable)
+ .getLanguageSettingProviders();
assertEquals(1, providers.size());
ILanguageSettingsProvider loadedProvider = providers.get(0);
assertTrue(loadedProvider instanceof MockLanguageSettingsEditableProvider);
@@ -333,7 +358,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertEquals(entries.size(), actual.size());
// check default providers ids
- String[] actualDefaultProvidersIds = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getDefaultLanguageSettingsProvidersIds();
+ String[] actualDefaultProvidersIds = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable)
+ .getDefaultLanguageSettingsProvidersIds();
assertTrue(Arrays.equals(new String[] { PROVIDER_0 }, actualDefaultProvidersIds));
}
}
@@ -347,8 +373,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
{
// get the raw extension provider
- ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
- LanguageSettingsSerializableProvider extProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager.getRawProvider(provider);
+ ILanguageSettingsProvider provider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
+ LanguageSettingsSerializableProvider extProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager
+ .getRawProvider(provider);
assertNotNull(extProvider);
assertEquals(EXTENSION_SERIALIZABLE_PROVIDER_ID, extProvider.getId());
@@ -367,7 +395,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
{
// doublecheck it's clean
- ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
+ ILanguageSettingsProvider provider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
List<ICLanguageSettingEntry> actual = provider.getSettingEntries(null, null, null);
assertNull(actual);
}
@@ -375,7 +404,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
// re-load and check language settings of the provider
LanguageSettingsProvidersSerializer.loadLanguageSettingsWorkspace();
- ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
+ ILanguageSettingsProvider provider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
assertEquals(EXTENSION_SERIALIZABLE_PROVIDER_ID, provider.getId());
List<ICLanguageSettingEntry> actual = provider.getSettingEntries(null, null, null);
assertEquals(entries.get(0), actual.get(0));
@@ -391,12 +421,14 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
extensionEntries.add(EXTENSION_SERIALIZABLE_PROVIDER_ENTRY);
{
// test initial state of the extension provider
- ILanguageSettingsProvider extProvider = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_SERIALIZABLE_PROVIDER_ID, true);
+ ILanguageSettingsProvider extProvider = LanguageSettingsManager
+ .getExtensionProviderCopy(EXTENSION_SERIALIZABLE_PROVIDER_ID, true);
assertNull(extProvider);
}
{
// get the workspace provider
- ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
+ ILanguageSettingsProvider provider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
// check that entries match that of extension provider
assertEquals(extensionEntries, provider.getSettingEntries(null, null, null));
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
@@ -410,7 +442,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
LanguageSettingsProvidersSerializer.loadLanguageSettingsWorkspace();
// ensure the workspace provider still matches extension
- ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
+ ILanguageSettingsProvider provider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
assertEquals(EXTENSION_SERIALIZABLE_PROVIDER_ID, provider.getId());
assertEquals(extensionEntries, provider.getSettingEntries(null, null, null));
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
@@ -420,7 +453,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertTrue(rawProvider instanceof LanguageSettingsSerializableProvider);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(new CIncludePathEntry("path0", 0));
- ((LanguageSettingsSerializableProvider)rawProvider).setSettingEntries(null, null, null, entries);
+ ((LanguageSettingsSerializableProvider) rawProvider).setSettingEntries(null, null, null, entries);
// check that the extension provider is not affected
assertTrue(!LanguageSettingsManager.isEqualExtensionProvider(rawProvider, true));
@@ -433,8 +466,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
public void testWorkspacePersistence_GlobalProvider() throws Exception {
{
// get the raw extension provider
- ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
- LanguageSettingsSerializableProvider rawProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager.getRawProvider(provider);
+ ILanguageSettingsProvider provider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
+ LanguageSettingsSerializableProvider rawProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager
+ .getRawProvider(provider);
assertNotNull(rawProvider);
assertEquals(EXTENSION_SERIALIZABLE_PROVIDER_ID, rawProvider.getId());
@@ -445,14 +480,17 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
{
// save workspace provider (as opposed to raw provider)
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
+ ILanguageSettingsProvider provider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
providers.add(provider);
LanguageSettingsManager.setWorkspaceProviders(providers);
}
{
// check that it has not cleared
- ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
- LanguageSettingsSerializableProvider rawProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager.getRawProvider(provider);
+ ILanguageSettingsProvider provider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
+ LanguageSettingsSerializableProvider rawProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager
+ .getRawProvider(provider);
assertEquals(CUSTOM_PARAMETER, rawProvider.getProperty(ATTR_PARAMETER));
}
}
@@ -463,7 +501,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
public void testWorkspacePersistence_ShadowedExtensionProvider() throws Exception {
{
// get the raw extension provider
- ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
+ ILanguageSettingsProvider provider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
// confirm its type and name
assertTrue(rawProvider instanceof LanguageSettingsBaseProvider);
@@ -472,7 +511,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
}
{
// replace extension provider
- ILanguageSettingsProvider provider = new MockLanguageSettingsSerializableProvider(EXTENSION_BASE_PROVIDER_ID, PROVIDER_NAME_0);
+ ILanguageSettingsProvider provider = new MockLanguageSettingsSerializableProvider(
+ EXTENSION_BASE_PROVIDER_ID, PROVIDER_NAME_0);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(provider);
// note that this will also serialize workspace providers
@@ -480,7 +520,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
}
{
// doublecheck it's in the list
- ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
+ ILanguageSettingsProvider provider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
assertTrue(rawProvider instanceof MockLanguageSettingsSerializableProvider);
assertEquals(EXTENSION_BASE_PROVIDER_ID, rawProvider.getId());
@@ -491,7 +532,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
// re-load to check serialization
LanguageSettingsProvidersSerializer.loadLanguageSettingsWorkspace();
- ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
+ ILanguageSettingsProvider provider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
assertTrue(rawProvider instanceof MockLanguageSettingsSerializableProvider);
assertEquals(EXTENSION_BASE_PROVIDER_ID, rawProvider.getId());
@@ -504,7 +546,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
}
{
// doublecheck original one is in the list
- ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
+ ILanguageSettingsProvider provider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
assertTrue(rawProvider instanceof LanguageSettingsBaseProvider);
assertEquals(EXTENSION_BASE_PROVIDER_ID, rawProvider.getId());
@@ -514,7 +557,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
// re-load to check serialization
LanguageSettingsProvidersSerializer.loadLanguageSettingsWorkspace();
- ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
+ ILanguageSettingsProvider provider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
assertTrue(rawProvider instanceof LanguageSettingsBaseProvider);
assertEquals(EXTENSION_BASE_PROVIDER_ID, rawProvider.getId());
@@ -533,14 +577,16 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
{
// create a provider
- MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
+ MockProjectDescription mockPrjDescription = new MockProjectDescription(
+ new MockConfigurationDescription(CFG_ID));
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- LanguageSettingsSerializableProvider serializableProvider = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0);
+ LanguageSettingsSerializableProvider serializableProvider = new LanguageSettingsSerializableProvider(
+ PROVIDER_0, PROVIDER_NAME_0);
serializableProvider.setSettingEntries(null, null, null, entries);
LanguageSettingsManager.setStoringEntriesInProjectArea(serializableProvider, true);
@@ -552,12 +598,14 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
Document doc = XmlUtil.newDocument();
rootElement = XmlUtil.appendElement(doc, ELEM_TEST);
// serialize language settings to the DOM
- LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, mockPrjDescription);
+ LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null,
+ mockPrjDescription);
assertTrue(XmlUtil.toString(doc).contains(PROVIDER_0));
}
{
// re-load and check language settings of the newly loaded provider
- MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
+ MockProjectDescription mockPrjDescription = new MockProjectDescription(
+ new MockConfigurationDescription(CFG_ID));
LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(rootElement, null, mockPrjDescription);
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
@@ -567,7 +615,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertNotNull(providers);
assertEquals(1, providers.size());
ILanguageSettingsProvider provider = providers.get(0);
@@ -590,13 +639,15 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
{
// create a provider
- MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
+ MockProjectDescription mockPrjDescription = new MockProjectDescription(
+ new MockConfigurationDescription(CFG_ID));
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- ILanguageSettingsProvider provider = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, false);
+ ILanguageSettingsProvider provider = LanguageSettingsManager
+ .getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, false);
assertTrue(provider instanceof MockLanguageSettingsEditableProvider);
MockLanguageSettingsEditableProvider serializableProvider = (MockLanguageSettingsEditableProvider) provider;
serializableProvider.setSettingEntries(null, null, null, entries);
@@ -610,13 +661,15 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
Document doc = XmlUtil.newDocument();
rootElement = XmlUtil.appendElement(doc, ELEM_TEST);
// serialize language settings to the DOM
- LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, mockPrjDescription);
+ LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null,
+ mockPrjDescription);
assertTrue(XmlUtil.toString(doc).contains(EXTENSION_EDITABLE_PROVIDER_ID));
assertTrue(XmlUtil.toString(doc).contains(MockLanguageSettingsEditableProvider.class.getName()));
}
{
// re-load and check language settings of the newly loaded provider
- MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
+ MockProjectDescription mockPrjDescription = new MockProjectDescription(
+ new MockConfigurationDescription(CFG_ID));
LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(rootElement, null, mockPrjDescription);
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
@@ -626,7 +679,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertNotNull(providers);
assertEquals(1, providers.size());
ILanguageSettingsProvider provider = providers.get(0);
@@ -651,11 +705,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
{
// create a project description with 2 configuration descriptions
- MockProjectDescription mockPrjDescription = new MockProjectDescription(
- new MockConfigurationDescription[] {
- new MockConfigurationDescription(CFG_ID),
- new MockConfigurationDescription(CFG_ID_2),
- });
+ MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription[] {
+ new MockConfigurationDescription(CFG_ID), new MockConfigurationDescription(CFG_ID_2), });
{
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
assertNotNull(cfgDescriptions);
@@ -667,7 +718,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertTrue(cfgDescription1 instanceof ILanguageSettingsProvidersKeeper);
assertEquals(CFG_ID, cfgDescription1.getId());
- LanguageSettingsSerializableProvider provider1 = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0);
+ LanguageSettingsSerializableProvider provider1 = new LanguageSettingsSerializableProvider(
+ PROVIDER_0, PROVIDER_NAME_0);
LanguageSettingsManager.setStoringEntriesInProjectArea(provider1, true);
provider1.setSettingEntries(null, null, null, entries);
ArrayList<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
@@ -681,7 +733,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertTrue(cfgDescription2 instanceof ILanguageSettingsProvidersKeeper);
assertEquals(CFG_ID_2, cfgDescription2.getId());
- LanguageSettingsSerializableProvider provider2 = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0);
+ LanguageSettingsSerializableProvider provider2 = new LanguageSettingsSerializableProvider(
+ PROVIDER_0, PROVIDER_NAME_0);
LanguageSettingsManager.setStoringEntriesInProjectArea(provider2, true);
provider2.setSettingEntries(null, null, null, entries2);
ArrayList<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
@@ -700,7 +753,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
ICConfigurationDescription cfgDescription1 = cfgDescriptions[0];
assertNotNull(cfgDescription1);
assertTrue(cfgDescription1 instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription1).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription1)
+ .getLanguageSettingProviders();
assertNotNull(providers);
assertEquals(1, providers.size());
@@ -716,7 +770,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertNotNull(cfgDescription2);
assertTrue(cfgDescription2 instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription2).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription2)
+ .getLanguageSettingProviders();
assertNotNull(providers);
assertEquals(1, providers.size());
ILanguageSettingsProvider provider = providers.get(0);
@@ -731,15 +786,13 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
Document doc = XmlUtil.newDocument();
rootElement = XmlUtil.appendElement(doc, ELEM_TEST);
// serialize language settings to the DOM
- LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, mockPrjDescription);
+ LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null,
+ mockPrjDescription);
}
{
// re-create a project description and re-load language settings for each configuration
- MockProjectDescription mockPrjDescription = new MockProjectDescription(
- new MockConfigurationDescription[] {
- new MockConfigurationDescription(CFG_ID),
- new MockConfigurationDescription(CFG_ID_2),
- });
+ MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription[] {
+ new MockConfigurationDescription(CFG_ID), new MockConfigurationDescription(CFG_ID_2), });
// load
LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(rootElement, null, mockPrjDescription);
@@ -752,7 +805,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertNotNull(cfgDescription1);
assertTrue(cfgDescription1 instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription1).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription1)
+ .getLanguageSettingProviders();
assertNotNull(providers);
assertEquals(1, providers.size());
ILanguageSettingsProvider provider = providers.get(0);
@@ -766,7 +820,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
ICConfigurationDescription cfgDescription2 = cfgDescriptions[1];
assertNotNull(cfgDescription2);
assertTrue(cfgDescription2 instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription2).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription2)
+ .getLanguageSettingProviders();
assertNotNull(providers);
assertEquals(1, providers.size());
@@ -790,14 +845,16 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
{
// create a provider
- MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
+ MockProjectDescription mockPrjDescription = new MockProjectDescription(
+ new MockConfigurationDescription(CFG_ID));
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- LanguageSettingsSerializableProvider serializableProvider = new MockLanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0);
+ LanguageSettingsSerializableProvider serializableProvider = new MockLanguageSettingsSerializableProvider(
+ PROVIDER_0, PROVIDER_NAME_0);
serializableProvider.setSettingEntries(null, null, null, entries);
LanguageSettingsManager.setStoringEntriesInProjectArea(serializableProvider, true);
@@ -809,11 +866,13 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
Document doc = XmlUtil.newDocument();
rootElement = XmlUtil.appendElement(doc, ELEM_TEST);
// serialize language settings to the DOM
- LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, mockPrjDescription);
+ LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null,
+ mockPrjDescription);
}
{
// re-load and check language settings of the newly loaded provider
- MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
+ MockProjectDescription mockPrjDescription = new MockProjectDescription(
+ new MockConfigurationDescription(CFG_ID));
LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(rootElement, null, mockPrjDescription);
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
@@ -823,7 +882,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertNotNull(providers);
assertEquals(1, providers.size());
ILanguageSettingsProvider provider = providers.get(0);
@@ -842,11 +902,13 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
Element rootElement = null;
// provider of other type (not LanguageSettingsSerializableProvider) defined as an extension
- ILanguageSettingsProvider providerExt = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
+ ILanguageSettingsProvider providerExt = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
{
// create cfg description
- MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
+ MockProjectDescription mockPrjDescription = new MockProjectDescription(
+ new MockConfigurationDescription(CFG_ID));
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertNotNull(cfgDescription);
@@ -861,11 +923,13 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
Document doc = XmlUtil.newDocument();
rootElement = XmlUtil.appendElement(doc, ELEM_TEST);
// serialize language settings to the DOM
- LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, mockPrjDescription);
+ LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null,
+ mockPrjDescription);
}
{
// re-load
- MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
+ MockProjectDescription mockPrjDescription = new MockProjectDescription(
+ new MockConfigurationDescription(CFG_ID));
LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(rootElement, null, mockPrjDescription);
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
@@ -876,7 +940,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// and check the newly loaded provider which should be workspace provider
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertNotNull(providers);
assertEquals(1, providers.size());
ILanguageSettingsProvider provider = providers.get(0);
@@ -897,29 +962,32 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertNotNull(providerExt);
{
// create cfg description
- MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
+ MockProjectDescription mockPrjDescription = new MockProjectDescription(
+ new MockConfigurationDescription(CFG_ID));
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// populate with provider overriding the extension (must be SerializableLanguageSettingsProvider or a class from another extension)
- MockLanguageSettingsSerializableProvider providerOverride = new MockLanguageSettingsSerializableProvider(idExt, PROVIDER_NAME_0);
+ MockLanguageSettingsSerializableProvider providerOverride = new MockLanguageSettingsSerializableProvider(
+ idExt, PROVIDER_NAME_0);
LanguageSettingsManager.setStoringEntriesInProjectArea(providerOverride, true);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(providerOverride);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
// prepare DOM storage
Document doc = XmlUtil.newDocument();
rootElement = XmlUtil.appendElement(doc, ELEM_TEST);
// serialize language settings to the DOM
- LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, mockPrjDescription);
+ LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null,
+ mockPrjDescription);
}
{
// re-load
- MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
+ MockProjectDescription mockPrjDescription = new MockProjectDescription(
+ new MockConfigurationDescription(CFG_ID));
LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(rootElement, null, mockPrjDescription);
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
@@ -930,7 +998,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// check the newly loaded provider
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertNotNull(providers);
assertEquals(1, providers.size());
ILanguageSettingsProvider provider = providers.get(0);
@@ -941,7 +1010,6 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
}
}
-
/**
* Test serialization flavors in one storage.
*/
@@ -957,7 +1025,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
ILanguageSettingsProvider providerExt;
{
// Define providers a bunch
- MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
+ MockProjectDescription mockPrjDescription = new MockProjectDescription(
+ new MockConfigurationDescription(CFG_ID));
{
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
@@ -969,11 +1038,13 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
// 2. Providers defined in a configuration
// 2.1
- LanguageSettingsSerializableProvider mockProvider1 = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0);
+ LanguageSettingsSerializableProvider mockProvider1 = new LanguageSettingsSerializableProvider(
+ PROVIDER_0, PROVIDER_NAME_0);
LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider1, true);
mockProvider1.setSettingEntries(null, null, null, entries_31);
// 2.2
- LanguageSettingsSerializableProvider mockProvider2 = new MockLanguageSettingsSerializableProvider(PROVIDER_2, PROVIDER_NAME_2);
+ LanguageSettingsSerializableProvider mockProvider2 = new MockLanguageSettingsSerializableProvider(
+ PROVIDER_2, PROVIDER_NAME_2);
LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider2, true);
mockProvider2.setSettingEntries(null, null, null, entries_32);
@@ -988,12 +1059,14 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
Document doc = XmlUtil.newDocument();
rootElement = XmlUtil.appendElement(doc, ELEM_TEST);
// serialize language settings to the DOM
- LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, mockPrjDescription);
+ LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null,
+ mockPrjDescription);
XmlUtil.toString(doc);
}
{
// re-load and check language settings of the newly loaded provider
- MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
+ MockProjectDescription mockPrjDescription = new MockProjectDescription(
+ new MockConfigurationDescription(CFG_ID));
LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(rootElement, null, mockPrjDescription);
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
@@ -1003,7 +1076,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertNotNull(providers);
// 1. Provider reference to extension from plugin.xml
ILanguageSettingsProvider provider0 = providers.get(0);
@@ -1043,7 +1117,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -1052,13 +1127,15 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper);
// create a provider
- LanguageSettingsSerializableProvider mockProvider = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0);
+ LanguageSettingsSerializableProvider mockProvider = new LanguageSettingsSerializableProvider(PROVIDER_0,
+ PROVIDER_NAME_0);
LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider, true);
mockProvider.setSettingEntries(cfgDescriptionWritable, null, null, entries);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
@@ -1070,7 +1147,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, providers.size());
ILanguageSettingsProvider provider = providers.get(0);
assertTrue(provider instanceof LanguageSettingsSerializableProvider);
@@ -1085,7 +1163,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
// Move storage out of the way
String xmlStorageFileLocation = xmlStorageFilePrj.getLocation().toOSString();
java.io.File xmlFile = new java.io.File(xmlStorageFileLocation);
- xmlPrjOutOfTheWay = xmlStorageFileLocation+".out-of-the-way";
+ xmlPrjOutOfTheWay = xmlStorageFileLocation + ".out-of-the-way";
java.io.File xmlFileOut = new java.io.File(xmlPrjOutOfTheWay);
xmlFile.renameTo(xmlFileOut);
assertFalse(xmlFile.exists());
@@ -1093,23 +1171,27 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
}
{
// Should not pollute workspace area with file with no meaningful data
- String xmlStorageFileWspLocation = getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
+ String xmlStorageFileWspLocation = getStoreLocationInWorkspaceArea(
+ project.getName() + '.' + LANGUAGE_SETTINGS_WORKSPACE_XML);
java.io.File xmlStorageFileWsp = new java.io.File(xmlStorageFileWspLocation);
assertFalse(xmlStorageFileWsp.exists());
}
{
// clear configuration
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertNotNull(cfgDescriptionWritable);
assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper);
- ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(new ArrayList<ILanguageSettingsProvider>());
+ ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable)
+ .setLanguageSettingProviders(new ArrayList<ILanguageSettingsProvider>());
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable)
+ .getLanguageSettingProviders();
assertEquals(0, providers.size());
}
{
@@ -1118,7 +1200,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(0, providers.size());
}
{
@@ -1133,24 +1216,25 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project);
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(0, providers.size());
// Move storage back
String xmlStorageFileLocation = xmlStorageFilePrj.getLocation().toOSString();
java.io.File xmlFile = new java.io.File(xmlStorageFileLocation);
xmlFile.delete();
- assertFalse("File "+xmlFile+ " still exist", xmlFile.exists());
+ assertFalse("File " + xmlFile + " still exist", xmlFile.exists());
java.io.File xmlFileOut = new java.io.File(xmlPrjOutOfTheWay);
xmlFileOut.renameTo(xmlFile);
- assertTrue("File "+xmlFile+ " does not exist", xmlFile.exists());
- assertFalse("File "+xmlFileOut+ " still exist", xmlFileOut.exists());
+ assertTrue("File " + xmlFile + " does not exist", xmlFile.exists());
+ assertFalse("File " + xmlFileOut + " still exist", xmlFileOut.exists());
// Wait out in case indexer thread hijacks refreshLocal(), see bug 415970
waitForIndexer(CCorePlugin.getDefault().getCoreModel().create(project));
// Refresh storage in workspace
xmlStorageFilePrj.refreshLocal(IResource.DEPTH_ZERO, null);
- assertTrue("File "+xmlStorageFilePrj+ " does not exist", xmlStorageFilePrj.exists());
+ assertTrue("File " + xmlStorageFilePrj + " does not exist", xmlStorageFilePrj.exists());
// and close
project.close(null);
@@ -1165,7 +1249,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, providers.size());
ILanguageSettingsProvider loadedProvider = providers.get(0);
assertTrue(loadedProvider instanceof LanguageSettingsSerializableProvider);
@@ -1190,14 +1275,16 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
{
// create a provider
- MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
+ MockProjectDescription mockPrjDescription = new MockProjectDescription(
+ new MockConfigurationDescription(CFG_ID));
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- LanguageSettingsSerializableProvider serializableProvider = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0);
+ LanguageSettingsSerializableProvider serializableProvider = new LanguageSettingsSerializableProvider(
+ PROVIDER_0, PROVIDER_NAME_0);
serializableProvider.setSettingEntries(null, null, null, entries);
// do not store entries inside project
LanguageSettingsManager.setStoringEntriesInProjectArea(serializableProvider, false);
@@ -1212,12 +1299,15 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
Document wspDoc = XmlUtil.newDocument();
wspStorageElement = XmlUtil.appendElement(wspDoc, ELEM_TEST);
// serialize language settings to the DOM
- LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(prjStorageElement, wspStorageElement, mockPrjDescription);
+ LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(prjStorageElement, wspStorageElement,
+ mockPrjDescription);
}
{
// re-load and check language settings of the newly loaded provider
- MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
- LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(prjStorageElement, wspStorageElement, mockPrjDescription);
+ MockProjectDescription mockPrjDescription = new MockProjectDescription(
+ new MockConfigurationDescription(CFG_ID));
+ LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(prjStorageElement, wspStorageElement,
+ mockPrjDescription);
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
assertNotNull(cfgDescriptions);
@@ -1226,7 +1316,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertNotNull(providers);
assertEquals(1, providers.size());
ILanguageSettingsProvider provider = providers.get(0);
@@ -1264,7 +1355,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
{
// get project descriptions
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
@@ -1273,20 +1365,23 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper);
// create a provider
- LanguageSettingsSerializableProvider mockProvider = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0);
+ LanguageSettingsSerializableProvider mockProvider = new LanguageSettingsSerializableProvider(PROVIDER_0,
+ PROVIDER_NAME_0);
LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider, false);
mockProvider.setSettingEntries(cfgDescriptionWritable, null, null, entries);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(providers);
- List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable)
+ .getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable);
xmlStorageFilePrj = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
assertTrue(xmlStorageFilePrj.exists());
- xmlStorageFileWspLocation = getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
+ xmlStorageFileWspLocation = getStoreLocationInWorkspaceArea(
+ project.getName() + '.' + LANGUAGE_SETTINGS_WORKSPACE_XML);
java.io.File xmlStorageFileWsp = new java.io.File(xmlStorageFileWspLocation);
assertTrue(xmlStorageFileWsp.exists());
}
@@ -1295,7 +1390,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, providers.size());
ILanguageSettingsProvider provider = providers.get(0);
assertTrue(provider instanceof LanguageSettingsSerializableProvider);
@@ -1311,7 +1407,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
// project storage
String xmlStorageFilePrjLocation = xmlStorageFilePrj.getLocation().toOSString();
java.io.File xmlFile = new java.io.File(xmlStorageFilePrjLocation);
- xmlPrjOutOfTheWay = xmlStorageFilePrjLocation+".out-of-the-way";
+ xmlPrjOutOfTheWay = xmlStorageFilePrjLocation + ".out-of-the-way";
java.io.File xmlFileOut = new java.io.File(xmlPrjOutOfTheWay);
xmlFile.renameTo(xmlFileOut);
assertFalse(xmlFile.exists());
@@ -1320,7 +1416,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
// workspace storage
java.io.File xmlStorageFileWsp = new java.io.File(xmlStorageFileWspLocation);
assertTrue(xmlStorageFileWsp.exists());
- xmlWspOutOfTheWay = xmlStorageFileWspLocation+".out-of-the-way";
+ xmlWspOutOfTheWay = xmlStorageFileWspLocation + ".out-of-the-way";
java.io.File xmlWspFileOut = new java.io.File(xmlWspOutOfTheWay);
boolean result = xmlStorageFileWsp.renameTo(xmlWspFileOut);
assertTrue(result);
@@ -1330,16 +1426,19 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
{
// clear configuration
- ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
+ ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, true);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertNotNull(cfgDescriptionWritable);
assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper);
- ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(new ArrayList<ILanguageSettingsProvider>());
+ ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable)
+ .setLanguageSettingProviders(new ArrayList<ILanguageSettingsProvider>());
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable)
+ .getLanguageSettingProviders();
assertEquals(0, providers.size());
}
{
@@ -1348,7 +1447,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(0, providers.size());
}
{
@@ -1363,7 +1463,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project);
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(0, providers.size());
// Move project storage back
@@ -1371,17 +1472,17 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
String xmlStorageFilePrjLocation = xmlStorageFilePrj.getLocation().toOSString();
java.io.File xmlFile = new java.io.File(xmlStorageFilePrjLocation);
xmlFile.delete();
- assertFalse("File "+xmlFile+ " still exist", xmlFile.exists());
+ assertFalse("File " + xmlFile + " still exist", xmlFile.exists());
java.io.File xmlFileOut = new java.io.File(xmlPrjOutOfTheWay);
xmlFileOut.renameTo(xmlFile);
- assertTrue("File "+xmlFile+ " does not exist", xmlFile.exists());
- assertFalse("File "+xmlFileOut+ " still exist", xmlFileOut.exists());
+ assertTrue("File " + xmlFile + " does not exist", xmlFile.exists());
+ assertFalse("File " + xmlFileOut + " still exist", xmlFileOut.exists());
// Wait out in case indexer thread hijacks refreshLocal(), see bug 415970
waitForIndexer(CCorePlugin.getDefault().getCoreModel().create(project));
// Refresh storage in workspace
xmlStorageFilePrj.refreshLocal(IResource.DEPTH_ZERO, null);
- assertTrue("File "+xmlStorageFilePrj+ " does not exist", xmlStorageFilePrj.exists());
+ assertTrue("File " + xmlStorageFilePrj + " does not exist", xmlStorageFilePrj.exists());
// and close
project.close(null);
@@ -1391,11 +1492,11 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
// Move workspace storage back
java.io.File xmlWspFile = new java.io.File(xmlStorageFileWspLocation);
xmlWspFile.delete();
- assertFalse("File "+xmlWspFile+ " still exist", xmlWspFile.exists());
+ assertFalse("File " + xmlWspFile + " still exist", xmlWspFile.exists());
java.io.File xmlWspFileOut = new java.io.File(xmlWspOutOfTheWay);
xmlWspFileOut.renameTo(xmlWspFile);
- assertTrue("File "+xmlWspFile+ " does not exist", xmlWspFile.exists());
- assertFalse("File "+xmlWspFileOut+ " still exist", xmlWspFileOut.exists());
+ assertTrue("File " + xmlWspFile + " does not exist", xmlWspFile.exists());
+ assertFalse("File " + xmlWspFileOut + " still exist", xmlWspFileOut.exists());
}
{
@@ -1407,7 +1508,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertEquals(1, providers.size());
ILanguageSettingsProvider loadedProvider = providers.get(0);
assertTrue(loadedProvider instanceof LanguageSettingsSerializableProvider);
@@ -1427,25 +1529,27 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
Document doc = XmlUtil.newDocument();
Element storageElement = XmlUtil.appendElement(doc, ELEM_TEST);
- ILanguageSettingsProvider providerExt = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
+ ILanguageSettingsProvider providerExt = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
assertNotNull(providerExt);
{
// create a provider
- MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
+ MockProjectDescription mockPrjDescription = new MockProjectDescription(
+ new MockConfigurationDescription(CFG_ID));
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
ArrayList<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(providerExt);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
// prepare DOM storage
- LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(storageElement, null, mockPrjDescription);
+ LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(storageElement, null,
+ mockPrjDescription);
String xml = XmlUtil.toString(doc);
assertTrue(xml.contains(ELEM_PROVIDER_REFERENCE));
@@ -1455,7 +1559,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
}
{
// re-load and check language settings of the newly loaded provider
- MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
+ MockProjectDescription mockPrjDescription = new MockProjectDescription(
+ new MockConfigurationDescription(CFG_ID));
LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(storageElement, null, mockPrjDescription);
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
@@ -1465,7 +1570,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertNotNull(providers);
assertEquals(1, providers.size());
ILanguageSettingsProvider provider = providers.get(0);
@@ -1480,25 +1586,27 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
Document doc = XmlUtil.newDocument();
Element storageElement = XmlUtil.appendElement(doc, ELEM_TEST);
- ILanguageSettingsProvider providerExt = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, true);
+ ILanguageSettingsProvider providerExt = LanguageSettingsManager
+ .getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, true);
assertNotNull(providerExt);
{
// create a provider
- MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
+ MockProjectDescription mockPrjDescription = new MockProjectDescription(
+ new MockConfigurationDescription(CFG_ID));
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
ArrayList<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(providerExt);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
// prepare DOM storage
- LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(storageElement, null, mockPrjDescription);
+ LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(storageElement, null,
+ mockPrjDescription);
String xml = XmlUtil.toString(doc);
assertTrue(xml.contains(ELEM_PROVIDER));
@@ -1508,7 +1616,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
}
{
// re-load and check language settings of the newly loaded provider
- MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
+ MockProjectDescription mockPrjDescription = new MockProjectDescription(
+ new MockConfigurationDescription(CFG_ID));
LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(storageElement, null, mockPrjDescription);
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
@@ -1518,7 +1627,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertNotNull(providers);
assertEquals(1, providers.size());
ILanguageSettingsProvider provider = providers.get(0);
@@ -1534,7 +1644,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
IFile xmlStorageFilePrj = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
assertFalse(xmlStorageFilePrj.exists());
- String xmlPrjWspStorageFileLocation = getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
+ String xmlPrjWspStorageFileLocation = getStoreLocationInWorkspaceArea(
+ project.getName() + '.' + LANGUAGE_SETTINGS_WORKSPACE_XML);
java.io.File xmlStorageFilePrjWsp = new java.io.File(xmlPrjWspStorageFileLocation);
assertFalse(xmlStorageFilePrjWsp.exists());
}
@@ -1548,8 +1659,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
entries.add(new CIncludePathEntry("path0", 0));
{
// get extension provider
- ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID);
- LanguageSettingsSerializableProvider rawProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager.getRawProvider(provider);
+ ILanguageSettingsProvider provider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID);
+ LanguageSettingsSerializableProvider rawProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager
+ .getRawProvider(provider);
assertNotNull(rawProvider);
assertEquals(EXTENSION_EDITABLE_PROVIDER_ID, rawProvider.getId());
@@ -1558,8 +1671,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
}
{
// get another extension provider
- ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
- LanguageSettingsSerializableProvider rawProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager.getRawProvider(provider);
+ ILanguageSettingsProvider provider = LanguageSettingsManager
+ .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID);
+ LanguageSettingsSerializableProvider rawProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager
+ .getRawProvider(provider);
assertNotNull(rawProvider);
assertEquals(EXTENSION_SERIALIZABLE_PROVIDER_ID, rawProvider.getId());
// modify it and add it to the list
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java
index 99aca640542..d80b4cc9cff 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java
@@ -106,8 +106,13 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas
ICConfigurationDescription[] cfgDescriptions = projectDescription.getConfigurations();
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
- final ICConfigurationDescription cfgDescriptionReferenced = getConfigurationDescriptions(projectReferenced)[0];
- cfgDescription.setReferenceInfo(new HashMap<String, String>() {{ put(projectReferenced.getName(), cfgDescriptionReferenced.getId()); }});
+ final ICConfigurationDescription cfgDescriptionReferenced = getConfigurationDescriptions(
+ projectReferenced)[0];
+ cfgDescription.setReferenceInfo(new HashMap<String, String>() {
+ {
+ put(projectReferenced.getName(), cfgDescriptionReferenced.getId());
+ }
+ });
coreModel.setProjectDescription(project, projectDescription);
}
@@ -115,7 +120,7 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas
// doublecheck that it's set as expected
ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project);
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
- Map<String,String> refs = cfgDescription.getReferenceInfo();
+ Map<String, String> refs = cfgDescription.getReferenceInfo();
assertEquals(1, refs.size());
Set<String> referencedProjectsNames = new LinkedHashSet<String>(refs.keySet());
assertEquals(projectReferenced.getName(), referencedProjectsNames.toArray()[0]);
@@ -127,7 +132,8 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas
* Test that null arguments don't crash the provider.
*/
public void testNulls() throws Exception {
- ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID);
+ ILanguageSettingsProvider provider = LanguageSettingsManager
+ .getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID);
assertNotNull(provider);
List<ICLanguageSettingEntry> entries = provider.getSettingEntries(null, null, null);
assertEquals(null, entries);
@@ -140,8 +146,8 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas
// Create model project and accompanied descriptions
String projectName = getName();
IProject project = ResourceHelper.createCDTProjectWithConfig(projectName);
- IProject nonReferencedProject = ResourceHelper.createCDTProjectWithConfig(projectName+"-non-referenced");
- IProject referencedProject = ResourceHelper.createCDTProjectWithConfig(projectName+"-referenced");
+ IProject nonReferencedProject = ResourceHelper.createCDTProjectWithConfig(projectName + "-non-referenced");
+ IProject referencedProject = ResourceHelper.createCDTProjectWithConfig(projectName + "-referenced");
setReference(project, referencedProject);
// get cfgDescription
@@ -150,24 +156,29 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas
{
// double-check that provider for referenced projects is set in the configuration
- ILanguageSettingsProvider refProjectsProvider = LanguageSettingsManager.getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID);
+ ILanguageSettingsProvider refProjectsProvider = LanguageSettingsManager
+ .getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID);
assertNotNull(refProjectsProvider);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
assertTrue(providers.contains(refProjectsProvider));
}
// Check that no setting entries are set initially
{
- List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescription, project, null, ICSettingEntry.ALL);
+ List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescription,
+ project, null, ICSettingEntry.ALL);
assertEquals(0, entries.size());
}
// Add an entry into a non-referenced project
- CIncludePathEntry nonRefEntry = CDataUtil.createCIncludePathEntry("non-referenced-exported", ICSettingEntry.EXPORTED);
+ CIncludePathEntry nonRefEntry = CDataUtil.createCIncludePathEntry("non-referenced-exported",
+ ICSettingEntry.EXPORTED);
{
ICConfigurationDescription[] nonRefCfgDescriptions = getConfigurationDescriptions(nonReferencedProject);
ICConfigurationDescription nonRefCfgDescription = nonRefCfgDescriptions[0];
- List<ILanguageSettingsProvider> providersNonRef = ((ILanguageSettingsProvidersKeeper) nonRefCfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providersNonRef = ((ILanguageSettingsProvidersKeeper) nonRefCfgDescription)
+ .getLanguageSettingProviders();
// get user provider which is the first one
ILanguageSettingsProvider userProviderNonRef = providersNonRef.get(0);
assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderNonRef.getId());
@@ -179,7 +190,8 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas
}
// Confirm that that does not add entries to the main project
{
- List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescription, project, null, ICSettingEntry.ALL);
+ List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescription,
+ project, null, ICSettingEntry.ALL);
assertEquals(0, entries.size());
}
@@ -188,7 +200,8 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas
{
ICConfigurationDescription[] refCfgDescriptions = getConfigurationDescriptions(referencedProject);
ICConfigurationDescription refCfgDescription = refCfgDescriptions[0];
- List<ILanguageSettingsProvider> providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription)
+ .getLanguageSettingProviders();
// get user provider which is the first one
ILanguageSettingsProvider userProviderRef = providersRef.get(0);
assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderRef.getId());
@@ -199,12 +212,14 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas
entries.add(refEntry);
entries.add(refEntryNotExported);
((LanguageSettingsGenericProvider) userProviderRef).setSettingEntries(null, null, null, entries);
- List<ICLanguageSettingEntry> entriesActual = LanguageSettingsManager.getSettingEntriesByKind(refCfgDescription, project, null, ICSettingEntry.ALL);
+ List<ICLanguageSettingEntry> entriesActual = LanguageSettingsManager
+ .getSettingEntriesByKind(refCfgDescription, project, null, ICSettingEntry.ALL);
assertEquals(entries, entriesActual);
}
// Check that the new entries from referenced project made it to the main project
{
- List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescription, project, null, ICSettingEntry.ALL);
+ List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescription,
+ project, null, ICSettingEntry.ALL);
assertEquals(CDataUtil.createCIncludePathEntry(refEntry.getName(), 0), entries.get(0));
assertEquals(1, entries.size());
}
@@ -228,27 +243,34 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas
ICConfigurationDescription[] cfgDescriptionsB = getConfigurationDescriptions(projectB);
ICConfigurationDescription cfgDescriptionB = cfgDescriptionsB[0];
// double-check that provider for referenced projects is set in the configurations
- ILanguageSettingsProvider refProjectsProvider = LanguageSettingsManager.getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID);
+ ILanguageSettingsProvider refProjectsProvider = LanguageSettingsManager
+ .getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID);
assertNotNull(refProjectsProvider);
- List<ILanguageSettingsProvider> providersA = ((ILanguageSettingsProvidersKeeper) cfgDescriptionA).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providersA = ((ILanguageSettingsProvidersKeeper) cfgDescriptionA)
+ .getLanguageSettingProviders();
assertTrue(providersA.contains(refProjectsProvider));
- List<ILanguageSettingsProvider> providersB = ((ILanguageSettingsProvidersKeeper) cfgDescriptionB).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providersB = ((ILanguageSettingsProvidersKeeper) cfgDescriptionB)
+ .getLanguageSettingProviders();
assertTrue(providersB.contains(refProjectsProvider));
// Check that no setting entries are set initially
- List<ICLanguageSettingEntry> entriesA = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionA, projectA, null, ICSettingEntry.ALL);
+ List<ICLanguageSettingEntry> entriesA = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionA,
+ projectA, null, ICSettingEntry.ALL);
assertEquals(0, entriesA.size());
- List<ICLanguageSettingEntry> entriesB = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionA, projectB, null, ICSettingEntry.ALL);
+ List<ICLanguageSettingEntry> entriesB = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionA,
+ projectB, null, ICSettingEntry.ALL);
assertEquals(0, entriesB.size());
}
- CIncludePathEntry entryExportedA = CDataUtil.createCIncludePathEntry("referenced-exported-A", ICSettingEntry.EXPORTED);
+ CIncludePathEntry entryExportedA = CDataUtil.createCIncludePathEntry("referenced-exported-A",
+ ICSettingEntry.EXPORTED);
CIncludePathEntry entryNotExportedA = CDataUtil.createCIncludePathEntry("referenced-not-exported-A", 0);
// Add entries into a project A
{
ICConfigurationDescription[] refCfgDescriptions = getConfigurationDescriptions(projectA);
ICConfigurationDescription refCfgDescription = refCfgDescriptions[0];
- List<ILanguageSettingsProvider> providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription)
+ .getLanguageSettingProviders();
// get user provider which is the first one
ILanguageSettingsProvider userProviderRef = providersRef.get(0);
assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderRef.getId());
@@ -260,13 +282,15 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas
((LanguageSettingsGenericProvider) userProviderRef).setSettingEntries(null, null, null, entries);
}
- CIncludePathEntry entryExportedB = CDataUtil.createCIncludePathEntry("referenced-exported-B", ICSettingEntry.EXPORTED);
+ CIncludePathEntry entryExportedB = CDataUtil.createCIncludePathEntry("referenced-exported-B",
+ ICSettingEntry.EXPORTED);
CIncludePathEntry entryNotExportedB = CDataUtil.createCIncludePathEntry("referenced-not-exported-B", 0);
// Add entries into a project B
{
ICConfigurationDescription[] refCfgDescriptions = getConfigurationDescriptions(projectB);
ICConfigurationDescription refCfgDescription = refCfgDescriptions[0];
- List<ILanguageSettingsProvider> providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription)
+ .getLanguageSettingProviders();
// get user provider which is the first one
ILanguageSettingsProvider userProviderRef = providersRef.get(0);
assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderRef.getId());
@@ -282,7 +306,8 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas
{
ICConfigurationDescription[] cfgDescriptionsA = getConfigurationDescriptions(projectA);
ICConfigurationDescription cfgDescriptionA = cfgDescriptionsA[0];
- List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionA, projectA, null, ICSettingEntry.ALL);
+ List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionA,
+ projectA, null, ICSettingEntry.ALL);
assertEquals(entryExportedA, entries.get(0));
assertEquals(entryNotExportedA, entries.get(1));
assertEquals(CDataUtil.createCIncludePathEntry(entryExportedB.getName(), 0), entries.get(2));
@@ -292,7 +317,8 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas
{
ICConfigurationDescription[] cfgDescriptionsB = getConfigurationDescriptions(projectB);
ICConfigurationDescription cfgDescriptionB = cfgDescriptionsB[0];
- List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionB, projectB, null, ICSettingEntry.ALL);
+ List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionB,
+ projectB, null, ICSettingEntry.ALL);
assertEquals(entryExportedB, entries.get(0));
assertEquals(entryNotExportedB, entries.get(1));
assertEquals(CDataUtil.createCIncludePathEntry(entryExportedA.getName(), 0), entries.get(2));
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java
index f2579e0a8a5..14b2ab751a3 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java
@@ -68,7 +68,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
}
@Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
+ public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc,
+ String languageId) {
return entries;
}
}
@@ -127,7 +128,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
}
{
// triplecheck builderCWD for different project/configuration descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, READ_ONLY);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
@@ -156,7 +158,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
{
// Handle prjDescription==null
IProject project = FAKE_FILE.getProject();
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, READ_ONLY);
assertNull(prjDescription);
LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
@@ -174,7 +177,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
IFile file = ResourceHelper.createFile(project, "file");
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance()
+ .getProjectDescription(project, READ_ONLY);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
@@ -202,7 +206,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
IFile file = ResourceHelper.createFile(project, "file.c");
// confirm that language==null
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project,
+ READ_ONLY);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
@@ -224,7 +229,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
public void testRegular() throws Exception {
// create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project,
+ WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
@@ -245,7 +251,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
CIncludePathEntry includePathEntry = new CIncludePathEntry(includeFolder, 0);
CIncludePathEntry includeLocalPathEntry = new CIncludePathEntry(includeLocalFolder, ICSettingEntry.LOCAL); // #include "..."
- CMacroEntry macroEntry = new CMacroEntry("MACRO", "value",0);
+ CMacroEntry macroEntry = new CMacroEntry("MACRO", "value", 0);
CIncludeFileEntry includeFileEntry = new CIncludeFileEntry(includeFile, 0);
CMacroFileEntry macroFileEntry = new CMacroFileEntry(macroFile, 0);
@@ -296,7 +302,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
public void testLocal() throws Exception {
// create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project,
+ WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
@@ -350,7 +357,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
public void testFramework() throws Exception {
// create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project,
+ WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
@@ -393,7 +401,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
public void testDuplicate() throws Exception {
// create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project,
+ WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
@@ -443,7 +452,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
public void testWorkspacePath() throws Exception {
// create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project,
+ WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
@@ -470,9 +480,12 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
// contribute the entries
CIncludePathEntry incWorkspaceEntry_1 = new CIncludePathEntry(incWorkspace_1, 0);
- CIncludePathEntry incWorkspaceEntry_2 = new CIncludePathEntry(incWorkspacePath_2, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED);
- CIncludePathEntry incWorkspaceEntry_3 = new CIncludePathEntry(incWorkspaceRelativePath_3, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED);
- CIncludePathEntry incWorkspaceEntry_4 = new CIncludePathEntry(incWorkspacePathNoResolved_4, ICSettingEntry.VALUE_WORKSPACE_PATH);
+ CIncludePathEntry incWorkspaceEntry_2 = new CIncludePathEntry(incWorkspacePath_2,
+ ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED);
+ CIncludePathEntry incWorkspaceEntry_3 = new CIncludePathEntry(incWorkspaceRelativePath_3,
+ ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED);
+ CIncludePathEntry incWorkspaceEntry_4 = new CIncludePathEntry(incWorkspacePathNoResolved_4,
+ ICSettingEntry.VALUE_WORKSPACE_PATH);
CIncludePathEntry incFilesystemEntry = new CIncludePathEntry(incFilesystem, 0);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
@@ -514,12 +527,13 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
// change drive on build working directory
String buildCwdDevice = project.getLocation().getDevice();
-// // Test manually with a device which is different from project location device (path should exist)
-// IPath buildCWD = new Path("D:/build/path");
-// String buildCwdDevice = buildCWD.getDevice();
+ // // Test manually with a device which is different from project location device (path should exist)
+ // IPath buildCWD = new Path("D:/build/path");
+ // String buildCwdDevice = buildCWD.getDevice();
// get project/configuration descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project,
+ WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
@@ -563,15 +577,17 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
IProject project = ResourceHelper.createCDTProjectWithConfig(prjName);
String relativePath = "include";
IFolder buildFolder = ResourceHelper.createFolder(project, "buildDir");
- IFolder relativeFolder = ResourceHelper.createFolder(project, "buildDir/"+relativePath);
- IFolder relativeFolderProjName = ResourceHelper.createFolder(project, "buildDir/"+prjName);
+ IFolder relativeFolder = ResourceHelper.createFolder(project, "buildDir/" + relativePath);
+ IFolder relativeFolderProjName = ResourceHelper.createFolder(project, "buildDir/" + prjName);
String markedResolved = "-MarkedResolved";
- IFolder relativeFolderProjNameResolved = ResourceHelper.createFolder(project, "buildDir/" + prjName+markedResolved);
- IPath buildCWD=buildFolder.getLocation();
+ IFolder relativeFolderProjNameResolved = ResourceHelper.createFolder(project,
+ "buildDir/" + prjName + markedResolved);
+ IPath buildCWD = buildFolder.getLocation();
setBuilderCWD(project, buildCWD);
// get project/configuration descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project,
+ WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
@@ -583,7 +599,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
// contribute the entries
CIncludePathEntry incRelativeEntry = new CIncludePathEntry(new Path(relativePath), 0);
CIncludePathEntry incProjNameEntry = new CIncludePathEntry(new Path("${ProjName}"), 0);
- CIncludePathEntry incProjNameMarkedResolvedEntry = new CIncludePathEntry(new Path("${ProjName}"+markedResolved), ICSettingEntry.RESOLVED);
+ CIncludePathEntry incProjNameMarkedResolvedEntry = new CIncludePathEntry(
+ new Path("${ProjName}" + markedResolved), ICSettingEntry.RESOLVED);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(incRelativeEntry);
entries.add(incProjNameEntry);
@@ -612,7 +629,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
assertEquals(new Path(prjName), new Path(actualIncludePaths[3]));
// if marked RESOLVED only that path stays
- assertEquals(new Path("${ProjName}"+markedResolved), new Path(actualIncludePaths[4]));
+ assertEquals(new Path("${ProjName}" + markedResolved), new Path(actualIncludePaths[4]));
assertEquals(5, actualIncludePaths.length);
}
@@ -625,7 +642,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
// set build CWD
IFolder buildFolder = ResourceHelper.createFolder(project, "buildDir");
- IPath buildCWD=buildFolder.getLocation();
+ IPath buildCWD = buildFolder.getLocation();
setBuilderCWD(project, buildCWD);
// define a few variations of paths
@@ -637,11 +654,12 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
String relativePath_dotdot_slash = "../";
String relativePath_dotdot_slash_path = "../include";
IFolder relativeFolder_dotdot_slash_path = ResourceHelper.createFolder(project, "include");
- String locationPath_dotdot_path = buildCWD.toString()+"/../include2";
+ String locationPath_dotdot_path = buildCWD.toString() + "/../include2";
IFolder incFolder_dotdot_slash_path = ResourceHelper.createFolder(project, "include2"); // "/ProjPath/buildDir/../include2"
// get project/configuration descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project,
+ WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
@@ -652,13 +670,17 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
// contribute the entries
CIncludePathEntry incRelativeEntry_dot = new CIncludePathEntry(new Path(relativePath_dot), 0);
- CIncludePathEntry incRelativeEntry_dot_slash_path = new CIncludePathEntry(new Path(relativePath_dot_slash_path), 0);
+ CIncludePathEntry incRelativeEntry_dot_slash_path = new CIncludePathEntry(new Path(relativePath_dot_slash_path),
+ 0);
CIncludePathEntry incRelativeEntry_dotdot = new CIncludePathEntry(new Path(relativePath_dotdot), 0);
- CIncludePathEntry incRelativeEntry_dotdot_slash_path = new CIncludePathEntry(new Path(relativePath_dotdot_slash_path), 0);
+ CIncludePathEntry incRelativeEntry_dotdot_slash_path = new CIncludePathEntry(
+ new Path(relativePath_dotdot_slash_path), 0);
CIncludePathEntry incEntry_dotdot_path = new CIncludePathEntry(locationPath_dotdot_path, 0);
// use LOCAL flag not to clash with plain dot entries
- CIncludePathEntry incRelativeEntry_dotdot_slash = new CIncludePathEntry(new Path(relativePath_dotdot_slash), ICSettingEntry.LOCAL);
- CIncludePathEntry incRelativeEntry_dot_slash = new CIncludePathEntry(new Path(relativePath_dot_slash), ICSettingEntry.LOCAL);
+ CIncludePathEntry incRelativeEntry_dotdot_slash = new CIncludePathEntry(new Path(relativePath_dotdot_slash),
+ ICSettingEntry.LOCAL);
+ CIncludePathEntry incRelativeEntry_dot_slash = new CIncludePathEntry(new Path(relativePath_dot_slash),
+ ICSettingEntry.LOCAL);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(incRelativeEntry_dot);
@@ -724,7 +746,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
String envPathStr = "${ProjDirPath}/Folder";
// get project/configuration descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project,
+ WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
@@ -771,7 +794,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
}
@Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
+ public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription,
+ IResource rc, String languageId) {
if (this.rc.equals(rc))
return entries;
return null;
@@ -780,7 +804,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
// create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project,
+ WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
@@ -828,7 +853,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
String envPathStr = "${ProjDirPath}/Folder";
// get project/configuration descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project,
+ WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
@@ -874,7 +900,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
List<String> languageIds = new ArrayList<String>();
for (ICLanguageSetting ls : langSettings) {
String langId = ls.getLanguageId();
- if (langId!=null && !languageIds.contains(langId)) {
+ if (langId != null && !languageIds.contains(langId)) {
languageIds.add(langId);
}
}
@@ -885,7 +911,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
* Test composition of 2 languages.
*/
public void testResourceLanguages() throws Exception {
- class MockProviderLang extends LanguageSettingsBaseProvider implements ILanguageSettingsProvider {
+ class MockProviderLang extends LanguageSettingsBaseProvider implements ILanguageSettingsProvider {
private final String langId;
private final List<ICLanguageSettingEntry> entries;
@@ -896,8 +922,9 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
}
@Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
- if (langId==null || langId.equals(languageId))
+ public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription,
+ IResource rc, String languageId) {
+ if (langId == null || langId.equals(languageId))
return entries;
return new ArrayList<ICLanguageSettingEntry>();
}
@@ -912,7 +939,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
IFolder incFolderC = ResourceHelper.createFolder(project, "includeC");
// get project/configuration descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project,
+ WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProviderTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProviderTests.java
index c2bfa2c204d..8c2931961e6 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProviderTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProviderTests.java
@@ -114,7 +114,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
languages.add(LANG_ID);
// create a provider
- LanguageSettingsSerializableProvider mockProvider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider mockProvider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
// test isEmpty()
assertTrue(mockProvider.isEmpty());
@@ -147,7 +148,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
*/
public void testProvider_SetStoringEntriesInProjectArea() throws Exception {
// create a provider
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
assertEquals(false, LanguageSettingsManager.isStoringEntriesInProjectArea(provider));
LanguageSettingsManager.setStoringEntriesInProjectArea(provider, true);
@@ -163,7 +165,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
Element elementProvider;
{
// create customized provider
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
LanguageSettingsManager.setStoringEntriesInProjectArea(provider, true);
provider.setProperty(ATTR_PARAMETER, VALUE_PARAMETER);
@@ -194,12 +197,12 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
assertEquals(true, LanguageSettingsManager.isStoringEntriesInProjectArea(provider));
assertEquals(VALUE_PARAMETER, provider.getProperty(ATTR_PARAMETER));
assertNotNull(provider.getLanguageScope());
- assertTrue(provider.getLanguageScope().size()>0);
+ assertTrue(provider.getLanguageScope().size() > 0);
assertEquals(LANG_ID, provider.getLanguageScope().get(0));
List<ICLanguageSettingEntry> entries = provider.getSettingEntries(null, null, null);
assertNotNull(entries);
- assertTrue(entries.size()>0);
+ assertTrue(entries.size() > 0);
assertEquals(new CIncludePathEntry("path0", 1), entries.get(0));
}
}
@@ -211,7 +214,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
Element elementProvider;
{
// create customized provider
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
LanguageSettingsManager.setStoringEntriesInProjectArea(provider, true);
provider.setProperty(ATTR_PARAMETER, VALUE_PARAMETER);
@@ -244,7 +248,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
assertEquals(true, LanguageSettingsManager.isStoringEntriesInProjectArea(provider));
assertEquals(VALUE_PARAMETER, provider.getProperty(ATTR_PARAMETER));
assertNotNull(provider.getLanguageScope());
- assertTrue(provider.getLanguageScope().size()>0);
+ assertTrue(provider.getLanguageScope().size() > 0);
assertEquals(LANG_ID, provider.getLanguageScope().get(0));
// no entries should be loaded
List<ICLanguageSettingEntry> entries = provider.getSettingEntries(null, null, null);
@@ -259,7 +263,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
Element rootElement;
{
// create customized provider
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
LanguageSettingsManager.setStoringEntriesInProjectArea(provider, true);
provider.setProperty(ATTR_PARAMETER, VALUE_PARAMETER);
@@ -287,20 +292,21 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
}
{
// re-load and check language settings of the newly loaded provider
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_2, PROVIDER_NAME_2);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_2,
+ PROVIDER_NAME_2);
provider.loadEntries(rootElement);
assertEquals(PROVIDER_2, provider.getId());
assertEquals(PROVIDER_NAME_2, provider.getName());
// no attributes should be loaded
assertFalse(PROVIDER_1.equals(provider.getId()));
assertFalse(PROVIDER_NAME_1.equals(provider.getName()));
- assertFalse(true==LanguageSettingsManager.isStoringEntriesInProjectArea(provider));
+ assertFalse(true == LanguageSettingsManager.isStoringEntriesInProjectArea(provider));
assertFalse(VALUE_PARAMETER.equals(provider.getProperty(ATTR_PARAMETER)));
assertNull(provider.getLanguageScope());
// entries should be loaded
List<ICLanguageSettingEntry> entries = provider.getSettingEntries(null, null, null);
assertNotNull(entries);
- assertTrue(entries.size()>0);
+ assertTrue(entries.size() > 0);
assertEquals(new CIncludePathEntry("path0", 1), entries.get(0));
}
}
@@ -312,7 +318,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
Element elementProvider;
{
// create null provider
- LanguageSettingsSerializableProvider providerNull = new LanguageSettingsSerializableProvider(PROVIDER_NULL, PROVIDER_NAME_NULL);
+ LanguageSettingsSerializableProvider providerNull = new LanguageSettingsSerializableProvider(PROVIDER_NULL,
+ PROVIDER_NAME_NULL);
assertNull(providerNull.getSettingEntries(null, null, null));
// set and get null entries
providerNull.setSettingEntries(null, null, null, null);
@@ -340,7 +347,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
Element elementProvider;
{
// create provider with custom parameter
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
provider.setProperty(ATTR_PARAMETER, VALUE_PARAMETER);
assertEquals(VALUE_PARAMETER, provider.getProperty(ATTR_PARAMETER));
@@ -364,7 +372,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
Element elementProvider;
{
// create provider storing entries in project area
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
assertEquals(false, LanguageSettingsManager.isStoringEntriesInProjectArea(provider));
LanguageSettingsManager.setStoringEntriesInProjectArea(provider, true);
assertEquals(true, LanguageSettingsManager.isStoringEntriesInProjectArea(provider));
@@ -374,7 +383,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
elementProvider = provider.serialize(rootElement);
String xmlString = XmlUtil.toString(doc);
assertTrue(xmlString.contains(ATTR_STORE_ENTRIES_WITH_PROJECT));
- assertTrue(xmlString.contains(ATTR_STORE_ENTRIES_WITH_PROJECT+"=\"true\""));
+ assertTrue(xmlString.contains(ATTR_STORE_ENTRIES_WITH_PROJECT + "=\"true\""));
}
{
// re-load and check storing mode of the newly loaded provider
@@ -394,7 +403,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
Element elementProvider;
{
// create provider with custom language scope
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
provider.setLanguageScope(expectedLanguageIds);
List<String> actualIds = provider.getLanguageScope();
assertEquals(LANG_ID, actualIds.get(0));
@@ -434,7 +444,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
Element elementProvider;
{
// create provider with no scope by default
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
// set entries for the whole language scope (now langId=null)
provider.setSettingEntries(null, null, null, entries);
{
@@ -514,7 +525,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
entries.add(new CIncludePathEntry("path0", 0));
{
// create a provider and serialize its settings
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
provider.setSettingEntries(null, MOCK_RC, LANG_ID, entries);
Document doc = XmlUtil.newDocument();
@@ -544,7 +556,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
entries.add(new CIncludePathEntry("path0", 0));
{
// create a provider and serialize its settings
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
provider.setSettingEntries(MOCK_CFG, MOCK_RC, null, entries);
Document doc = XmlUtil.newDocument();
@@ -564,7 +577,6 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
}
}
-
/**
* Test serialization of entries when language scope is null.
*/
@@ -579,7 +591,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
{
// create a provider
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
assertEquals(null, provider.getLanguageScope());
// add null language
@@ -651,7 +664,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
entries.add(new CIncludePathEntry("path0", 0));
{
// create a provider and serialize its settings
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
provider.setSettingEntries(MOCK_CFG, null, LANG_ID, entries);
Document doc = XmlUtil.newDocument();
@@ -681,7 +695,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
entries.add(new CIncludePathEntry("path0", 0));
{
// create a provider and serialize its settings
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
provider.setSettingEntries(null, MOCK_RC, null, entries);
Document doc = XmlUtil.newDocument();
@@ -712,7 +727,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
entries.add(new CIncludePathEntry("path0", 0));
{
// create a provider and serialize its settings
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
provider.setSettingEntries(null, null, LANG_ID, entries);
Document doc = XmlUtil.newDocument();
@@ -743,7 +759,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
entries.add(new CIncludePathEntry("path0", 0));
{
// create a provider and serialize its settings
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
provider.setSettingEntries(MOCK_CFG, null, null, entries);
Document doc = XmlUtil.newDocument();
@@ -775,7 +792,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
entries.add(new CIncludePathEntry("path0", flag));
{
// create a provider and serialize its settings
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
provider.setSettingEntries(null, null, null, entries);
Document doc = XmlUtil.newDocument();
@@ -807,7 +825,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
entries.add(new CIncludePathEntry("path0", 1));
{
// create a provider and serialize its settings
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
provider.setSettingEntries(null, null, null, entries);
Document doc = XmlUtil.newDocument();
@@ -823,7 +842,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
ICLanguageSettingEntry entry = actual.get(0);
assertTrue(entry instanceof CIncludePathEntry);
- CIncludePathEntry includePathEntry = (CIncludePathEntry)entry;
+ CIncludePathEntry includePathEntry = (CIncludePathEntry) entry;
assertEquals(entries.get(0).getName(), includePathEntry.getName());
assertEquals(entries.get(0).getValue(), includePathEntry.getValue());
assertEquals(entries.get(0).getKind(), includePathEntry.getKind());
@@ -841,7 +860,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
entries.add(new CIncludeFileEntry("a-path", 1));
{
// create a provider and serialize its settings
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
provider.setSettingEntries(null, null, null, entries);
Document doc = XmlUtil.newDocument();
@@ -856,7 +876,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
List<ICLanguageSettingEntry> actual = provider.getSettingEntries(null, null, null);
ICLanguageSettingEntry entry = actual.get(0);
assertTrue(entry instanceof CIncludeFileEntry);
- CIncludeFileEntry includeFileEntry = (CIncludeFileEntry)entry;
+ CIncludeFileEntry includeFileEntry = (CIncludeFileEntry) entry;
assertEquals(entries.get(0).getName(), includeFileEntry.getName());
assertEquals(entries.get(0).getValue(), includeFileEntry.getValue());
assertEquals(entries.get(0).getKind(), includeFileEntry.getKind());
@@ -871,10 +891,11 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
public void testCMacroEntryDOM() throws Exception {
Element elementProvider;
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(new CMacroEntry("MACRO0", "value0",1));
+ entries.add(new CMacroEntry("MACRO0", "value0", 1));
{
// create a provider and serialize its settings
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
provider.setSettingEntries(null, null, null, entries);
Document doc = XmlUtil.newDocument();
@@ -889,7 +910,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
List<ICLanguageSettingEntry> actual = provider.getSettingEntries(null, null, null);
ICLanguageSettingEntry entry = actual.get(0);
assertTrue(entry instanceof CMacroEntry);
- CMacroEntry macroEntry = (CMacroEntry)entry;
+ CMacroEntry macroEntry = (CMacroEntry) entry;
assertEquals(entries.get(0).getName(), macroEntry.getName());
assertEquals(entries.get(0).getValue(), macroEntry.getValue());
assertEquals(entries.get(0).getKind(), macroEntry.getKind());
@@ -907,7 +928,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
entries.add(new CMacroFileEntry("a-path", 1));
{
// create a provider and serialize its settings
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
provider.setSettingEntries(null, null, null, entries);
Document doc = XmlUtil.newDocument();
@@ -922,7 +944,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
List<ICLanguageSettingEntry> actual = provider.getSettingEntries(null, null, null);
ICLanguageSettingEntry entry = actual.get(0);
assertTrue(entry instanceof CMacroFileEntry);
- CMacroFileEntry macroFileEntry = (CMacroFileEntry)entry;
+ CMacroFileEntry macroFileEntry = (CMacroFileEntry) entry;
assertEquals(entries.get(0).getName(), macroFileEntry.getName());
assertEquals(entries.get(0).getValue(), macroFileEntry.getValue());
assertEquals(entries.get(0).getKind(), macroFileEntry.getKind());
@@ -940,7 +962,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
entries.add(new CLibraryPathEntry("a-path", 1));
{
// create a provider and serialize its settings
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
provider.setSettingEntries(null, null, null, entries);
Document doc = XmlUtil.newDocument();
@@ -955,7 +978,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
List<ICLanguageSettingEntry> actual = provider.getSettingEntries(null, null, null);
ICLanguageSettingEntry entry = actual.get(0);
assertTrue(entry instanceof CLibraryPathEntry);
- CLibraryPathEntry libraryPathEntry = (CLibraryPathEntry)entry;
+ CLibraryPathEntry libraryPathEntry = (CLibraryPathEntry) entry;
assertEquals(entries.get(0).getName(), libraryPathEntry.getName());
assertEquals(entries.get(0).getValue(), libraryPathEntry.getValue());
assertEquals(entries.get(0).getKind(), libraryPathEntry.getKind());
@@ -973,7 +996,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
entries.add(new CLibraryFileEntry("a-path", 1));
{
// create a provider and serialize its settings
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
provider.setSettingEntries(null, null, null, entries);
Document doc = XmlUtil.newDocument();
@@ -988,7 +1012,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
List<ICLanguageSettingEntry> actual = provider.getSettingEntries(null, null, null);
ICLanguageSettingEntry entry = actual.get(0);
assertTrue(entry instanceof CLibraryFileEntry);
- CLibraryFileEntry libraryFileEntry = (CLibraryFileEntry)entry;
+ CLibraryFileEntry libraryFileEntry = (CLibraryFileEntry) entry;
assertEquals(entries.get(0).getName(), libraryFileEntry.getName());
assertEquals(entries.get(0).getValue(), libraryFileEntry.getValue());
assertEquals(entries.get(0).getKind(), libraryFileEntry.getKind());
@@ -1005,10 +1029,11 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(new CIncludePathEntry("path0", 1));
entries.add(new CIncludePathEntry("path1", 1));
- entries.add(new CMacroEntry("MACRO0", "value0",1));
+ entries.add(new CMacroEntry("MACRO0", "value0", 1));
{
// create a provider and serialize its settings
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
provider.setSettingEntries(null, null, null, entries);
Document doc = XmlUtil.newDocument();
@@ -1035,18 +1060,13 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
Element elementProvider;
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(new CIncludePathEntry("path0",
- ICSettingEntry.BUILTIN
- | ICSettingEntry.READONLY
- | ICSettingEntry.LOCAL
- | ICSettingEntry.VALUE_WORKSPACE_PATH
- | ICSettingEntry.RESOLVED
- | ICSettingEntry.UNDEFINED
- | ICSettingEntry.FRAMEWORKS_MAC
- | ICSettingEntry.EXPORTED
- ));
+ ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.LOCAL
+ | ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED | ICSettingEntry.UNDEFINED
+ | ICSettingEntry.FRAMEWORKS_MAC | ICSettingEntry.EXPORTED));
{
// create a provider and serialize its settings
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
provider.setSettingEntries(null, null, null, entries);
Document doc = XmlUtil.newDocument();
@@ -1062,7 +1082,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
ICLanguageSettingEntry entry = actual.get(0);
assertTrue(entry instanceof CIncludePathEntry);
- CIncludePathEntry includePathEntry = (CIncludePathEntry)entry;
+ CIncludePathEntry includePathEntry = (CIncludePathEntry) entry;
assertEquals(entries.get(0).getName(), includePathEntry.getName());
assertEquals(entries.get(0).getValue(), includePathEntry.getValue());
assertEquals(entries.get(0).getKind(), includePathEntry.getKind());
@@ -1096,7 +1116,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
}
{
// re-load and check language settings of the newly loaded provider
- LanguageSettingsSerializableProvider loadedProvider = new LanguageSettingsSerializableProvider(elementProvider);
+ LanguageSettingsSerializableProvider loadedProvider = new LanguageSettingsSerializableProvider(
+ elementProvider);
List<ICLanguageSettingEntry> actual = loadedProvider.getSettingEntries(null, null, null);
assertEquals(entries.get(0), actual.get(0));
@@ -1131,11 +1152,12 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
Element rootElement = XmlUtil.appendElement(doc, ELEM_TEST);
elementProvider = mockProvider.serialize(rootElement);
String xml = XmlUtil.toString(elementProvider.getOwnerDocument());
-// fail(xml); // for debugging
+ // fail(xml); // for debugging
}
{
// re-load and check language settings of the newly loaded provider
- LanguageSettingsSerializableProvider loadedProvider = new LanguageSettingsSerializableProvider(elementProvider);
+ LanguageSettingsSerializableProvider loadedProvider = new LanguageSettingsSerializableProvider(
+ elementProvider);
List<ICLanguageSettingEntry> actual = loadedProvider.getSettingEntries(null, null, LANG_ID_1);
assertEquals(entries.get(0), actual.get(0));
@@ -1178,11 +1200,12 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
Element rootElement = XmlUtil.appendElement(doc, ELEM_TEST);
elementProvider = mockProvider.serialize(rootElement);
String xml = XmlUtil.toString(elementProvider.getOwnerDocument());
-// fail(xml); // for debugging
+ // fail(xml); // for debugging
}
{
// re-load and check language settings of the newly loaded provider
- LanguageSettingsSerializableProvider loadedProvider = new LanguageSettingsSerializableProvider(elementProvider);
+ LanguageSettingsSerializableProvider loadedProvider = new LanguageSettingsSerializableProvider(
+ elementProvider);
List<ICLanguageSettingEntry> actual = loadedProvider.getSettingEntries(null, rc1, null);
assertEquals(entries.get(0), actual.get(0));
@@ -1208,7 +1231,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
assertNotNull(emptySettingsPath);
// Create provider
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
// store the entries in parent folder
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
@@ -1219,7 +1243,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
{
// retrieve entries for a parent folder itself
List<ICLanguageSettingEntry> actual = provider.getSettingEntries(null, parentFolder, LANG_ID);
- assertEquals(entries,actual);
+ assertEquals(entries, actual);
assertEquals(entries.size(), actual.size());
}
@@ -1228,14 +1252,15 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
IFile derived = ResourceHelper.createFile(project, "/ParentFolder/Subfolder/resource");
List<ICLanguageSettingEntry> actual = provider.getSettingEntries(null, derived, LANG_ID);
// NOT taken from parent folder
- assertEquals(null,actual);
+ assertEquals(null, actual);
}
{
// retrieve entries for not related resource
- IFile notRelated = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/AnotherFolder/Subfolder/resource"));
+ IFile notRelated = ResourcesPlugin.getWorkspace().getRoot()
+ .getFile(new Path("/AnotherFolder/Subfolder/resource"));
List<ICLanguageSettingEntry> actual = provider.getSettingEntries(null, notRelated, LANG_ID);
- assertEquals(null,actual);
+ assertEquals(null, actual);
}
{
@@ -1252,7 +1277,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
public void testEquals() throws Exception {
// create sample entries
List<ICLanguageSettingEntry> sampleEntries_1 = new ArrayList<ICLanguageSettingEntry>();
- sampleEntries_1.add(new CMacroEntry("MACRO0", "value0",1));
+ sampleEntries_1.add(new CMacroEntry("MACRO0", "value0", 1));
sampleEntries_1.add(new CIncludePathEntry("path0", 1));
sampleEntries_1.add(new CIncludePathEntry("path1", 1));
@@ -1264,7 +1289,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
sampleLanguages.add(LANG_ID);
// create a model provider
- LanguageSettingsSerializableProvider provider1 = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider1 = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
provider1.setLanguageScope(sampleLanguages);
provider1.setProperty(ATTR_PARAMETER, VALUE_PARAMETER);
assertEquals(false, LanguageSettingsManager.isStoringEntriesInProjectArea(provider1));
@@ -1273,7 +1299,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
provider1.setSettingEntries(null, null, LANG_ID, sampleEntries_2);
// create another provider with the same data
- LanguageSettingsSerializableProvider provider2 = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider2 = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
{
provider2.setLanguageScope(sampleLanguages);
provider2.setProperty(ATTR_PARAMETER, VALUE_PARAMETER);
@@ -1281,29 +1308,29 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
provider2.setSettingEntries(MOCK_CFG, MOCK_RC, LANG_ID, sampleEntries_1);
provider2.setSettingEntries(null, null, LANG_ID, sampleEntries_2);
// All set now, so they should be equal
- assertTrue(provider1.hashCode()==provider2.hashCode());
+ assertTrue(provider1.hashCode() == provider2.hashCode());
assertTrue(provider1.equals(provider2));
}
{
// start with provider with the same data
- assertTrue(provider1.hashCode()==provider2.hashCode());
+ assertTrue(provider1.hashCode() == provider2.hashCode());
assertTrue(provider1.equals(provider2));
// replace languages
List<String> sampleLanguages2 = new ArrayList<String>();
sampleLanguages2.add(LANG_ID_1);
provider2.setLanguageScope(sampleLanguages2);
- assertFalse(provider1.hashCode()==provider2.hashCode());
+ assertFalse(provider1.hashCode() == provider2.hashCode());
assertFalse(provider1.equals(provider2));
// restore provider
provider2.setLanguageScope(sampleLanguages);
- assertTrue(provider1.hashCode()==provider2.hashCode());
+ assertTrue(provider1.hashCode() == provider2.hashCode());
assertTrue(provider1.equals(provider2));
}
{
// start with provider with the same data
- assertTrue(provider1.hashCode()==provider2.hashCode());
+ assertTrue(provider1.hashCode() == provider2.hashCode());
assertTrue(provider1.equals(provider2));
// replace property
provider2.setProperty(ATTR_PARAMETER, "changed-parameter");
@@ -1311,12 +1338,12 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
assertFalse(provider1.equals(provider2));
// restore provider
provider2.setProperty(ATTR_PARAMETER, VALUE_PARAMETER);
- assertTrue(provider1.hashCode()==provider2.hashCode());
+ assertTrue(provider1.hashCode() == provider2.hashCode());
assertTrue(provider1.equals(provider2));
}
{
// start with provider with the same data
- assertTrue(provider1.hashCode()==provider2.hashCode());
+ assertTrue(provider1.hashCode() == provider2.hashCode());
assertTrue(provider1.equals(provider2));
// replace property
LanguageSettingsManager.setStoringEntriesInProjectArea(provider2, false);
@@ -1324,45 +1351,47 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
assertFalse(provider1.equals(provider2));
// restore provider
LanguageSettingsManager.setStoringEntriesInProjectArea(provider2, true);
- assertTrue(provider1.hashCode()==provider2.hashCode());
+ assertTrue(provider1.hashCode() == provider2.hashCode());
assertTrue(provider1.equals(provider2));
}
{
// start with provider with the same data
- assertTrue(provider1.hashCode()==provider2.hashCode());
+ assertTrue(provider1.hashCode() == provider2.hashCode());
assertTrue(provider1.equals(provider2));
// replace entries
List<ICLanguageSettingEntry> changedEntries = new ArrayList<ICLanguageSettingEntry>();
- changedEntries.add(new CMacroEntry("MACROX", "valueX",1));
+ changedEntries.add(new CMacroEntry("MACROX", "valueX", 1));
provider2.setSettingEntries(MOCK_CFG, MOCK_RC, LANG_ID, changedEntries);
- assertFalse(provider1.hashCode()==provider2.hashCode());
+ assertFalse(provider1.hashCode() == provider2.hashCode());
assertFalse(provider1.equals(provider2));
// restore provider
provider2.setSettingEntries(MOCK_CFG, MOCK_RC, LANG_ID, sampleEntries_1);
- assertTrue(provider1.hashCode()==provider2.hashCode());
+ assertTrue(provider1.hashCode() == provider2.hashCode());
assertTrue(provider1.equals(provider2));
}
{
// start with provider with the same data
- assertTrue(provider1.hashCode()==provider2.hashCode());
+ assertTrue(provider1.hashCode() == provider2.hashCode());
assertTrue(provider1.equals(provider2));
// replace default entries
List<ICLanguageSettingEntry> changedEntries = new ArrayList<ICLanguageSettingEntry>();
changedEntries.add(new CIncludePathEntry("pathX", 1));
provider2.setSettingEntries(null, null, LANG_ID, changedEntries);
- assertFalse(provider1.hashCode()==provider2.hashCode());
+ assertFalse(provider1.hashCode() == provider2.hashCode());
assertFalse(provider1.equals(provider2));
// restore provider
provider2.setSettingEntries(null, null, LANG_ID, sampleEntries_2);
- assertTrue(provider1.hashCode()==provider2.hashCode());
+ assertTrue(provider1.hashCode() == provider2.hashCode());
assertTrue(provider1.equals(provider2));
}
{
// check that subclasses are not equal
- LanguageSettingsSerializableProvider providerSub1 = new LanguageSettingsSerializableProvider() {};
- LanguageSettingsSerializableProvider providerSub2 = new LanguageSettingsSerializableProvider() {};
- assertFalse(providerSub1.hashCode()==providerSub2.hashCode());
+ LanguageSettingsSerializableProvider providerSub1 = new LanguageSettingsSerializableProvider() {
+ };
+ LanguageSettingsSerializableProvider providerSub2 = new LanguageSettingsSerializableProvider() {
+ };
+ assertFalse(providerSub1.hashCode() == providerSub2.hashCode());
assertFalse(providerSub1.equals(providerSub2));
}
}
@@ -1372,8 +1401,10 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
*/
public void testEquals_DefaultProperties() throws Exception {
// create model providers
- LanguageSettingsSerializableProvider provider1 = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
- LanguageSettingsSerializableProvider provider2 = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider1 = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider2 = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
// equality for setProperty(String, String)
{
@@ -1422,7 +1453,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
List<ICLanguageSettingEntry> sampleEntries_1 = new ArrayList<ICLanguageSettingEntry>();
sampleEntries_1.add(new CIncludePathEntry("path0", 1));
sampleEntries_1.add(new CIncludePathEntry("path1", 1));
- sampleEntries_1.add(new CMacroEntry("MACRO0", "value0",1));
+ sampleEntries_1.add(new CMacroEntry("MACRO0", "value0", 1));
List<ICLanguageSettingEntry> sampleEntries_2 = new ArrayList<ICLanguageSettingEntry>();
sampleEntries_2.add(new CIncludePathEntry("path0", 1));
@@ -1435,6 +1466,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
public MockSerializableProvider(String id, String name) {
super(id, name);
}
+
@Override
public MockSerializableProvider clone() throws CloneNotSupportedException {
return (MockSerializableProvider) super.clone();
@@ -1453,17 +1485,20 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
MockSerializableProvider providerClone = provider1.clone();
assertNotSame(provider1, providerClone);
assertTrue(provider1.equals(providerClone));
- assertTrue(provider1.getClass()==providerClone.getClass());
+ assertTrue(provider1.getClass() == providerClone.getClass());
assertEquals(provider1.getProperty(ATTR_PARAMETER), providerClone.getProperty(ATTR_PARAMETER));
// ensure we did not clone reference
provider1.setProperty(ATTR_PARAMETER, "");
assertFalse(provider1.getProperty(ATTR_PARAMETER).equals(providerClone.getProperty(ATTR_PARAMETER)));
- assertEquals(LanguageSettingsManager.isStoringEntriesInProjectArea(provider1), LanguageSettingsManager.isStoringEntriesInProjectArea(providerClone));
+ assertEquals(LanguageSettingsManager.isStoringEntriesInProjectArea(provider1),
+ LanguageSettingsManager.isStoringEntriesInProjectArea(providerClone));
// ensure we did not clone reference
- LanguageSettingsManager.setStoringEntriesInProjectArea(provider1, !LanguageSettingsManager.isStoringEntriesInProjectArea(providerClone));
- assertFalse(LanguageSettingsManager.isStoringEntriesInProjectArea(provider1) == LanguageSettingsManager.isStoringEntriesInProjectArea(providerClone));
+ LanguageSettingsManager.setStoringEntriesInProjectArea(provider1,
+ !LanguageSettingsManager.isStoringEntriesInProjectArea(providerClone));
+ assertFalse(LanguageSettingsManager.isStoringEntriesInProjectArea(provider1) == LanguageSettingsManager
+ .isStoringEntriesInProjectArea(providerClone));
assertEquals(provider1.getLanguageScope().get(0), providerClone.getLanguageScope().get(0));
@@ -1493,6 +1528,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
public MockSerializableProvider(String id, String name) {
super(id, name);
}
+
@Override
public MockSerializableProvider cloneShallow() throws CloneNotSupportedException {
return (MockSerializableProvider) super.cloneShallow();
@@ -1513,9 +1549,10 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
MockSerializableProvider providerClone = provider1.cloneShallow();
assertNotSame(provider1, providerClone);
assertFalse(provider1.equals(providerClone));
- assertTrue(provider1.getClass()==providerClone.getClass());
+ assertTrue(provider1.getClass() == providerClone.getClass());
assertEquals(provider1.getProperty(ATTR_PARAMETER), providerClone.getProperty(ATTR_PARAMETER));
- assertEquals(LanguageSettingsManager.isStoringEntriesInProjectArea(provider1), LanguageSettingsManager.isStoringEntriesInProjectArea(providerClone));
+ assertEquals(LanguageSettingsManager.isStoringEntriesInProjectArea(provider1),
+ LanguageSettingsManager.isStoringEntriesInProjectArea(providerClone));
assertEquals(provider1.getLanguageScope().get(0), providerClone.getLanguageScope().get(0));
List<ICLanguageSettingEntry> actual = providerClone.getSettingEntries(null, null, null);
@@ -1556,11 +1593,12 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
unsortedEntries.add(libraryPathEntry2);
// create a provider and set the entries
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
provider.setSettingEntries(null, null, null, unsortedEntries);
// retrieve and check that language settings got sorted properly
- int i=0;
+ int i = 0;
List<ICLanguageSettingEntry> actual = provider.getSettingEntries(null, null, null);
assertEquals(includePathEntry1, actual.get(i++));
assertEquals(includePathEntry2, actual.get(i++));
@@ -1614,11 +1652,12 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
unsortedEntries.add(libraryPathEntry2);
// create a provider and set the entries
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
provider.setSettingEntries(null, null, null, unsortedEntries);
// retrieve and check that language settings got sorted properly
- int i=0;
+ int i = 0;
List<ICLanguageSettingEntry> actual = provider.getSettingEntries(null, null, null);
assertEquals(includePathEntry1, actual.get(i++));
assertEquals(includePathEntry2, actual.get(i++));
@@ -1657,11 +1696,12 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase {
unsortedEntries.add(macroEntry2C);
// create a provider and set the entries
- LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
+ LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1,
+ PROVIDER_NAME_1);
provider.setSettingEntries(null, null, null, unsortedEntries);
// retrieve and check that language settings got sorted properly
- int i=0;
+ int i = 0;
List<ICLanguageSettingEntry> actual = provider.getSettingEntries(null, null, null);
assertEquals(macroEntry1, actual.get(i++));
assertEquals(macroEntry2A, actual.get(i++));
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockLanguageSettingsEditableProvider.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockLanguageSettingsEditableProvider.java
index 7fee0568511..232db07b7a6 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockLanguageSettingsEditableProvider.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockLanguageSettingsEditableProvider.java
@@ -14,11 +14,11 @@
package org.eclipse.cdt.core.language.settings.providers;
-
/**
* Mock of {@link ILanguageSettingsEditableProvider} for testing.
*/
-public class MockLanguageSettingsEditableProvider extends LanguageSettingsSerializableProvider implements ILanguageSettingsEditableProvider {
+public class MockLanguageSettingsEditableProvider extends LanguageSettingsSerializableProvider
+ implements ILanguageSettingsEditableProvider {
public MockLanguageSettingsEditableProvider() {
super();
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockLanguageSettingsProvider.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockLanguageSettingsProvider.java
index 536a58aab9b..4f97c98a9f5 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockLanguageSettingsProvider.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockLanguageSettingsProvider.java
@@ -26,7 +26,8 @@ import org.eclipse.core.resources.IResource;
*/
public class MockLanguageSettingsProvider extends AbstractExecutableExtensionBase implements ILanguageSettingsProvider {
@Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
+ public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc,
+ String languageId) {
return null;
}
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockListenerRegisterer.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockListenerRegisterer.java
index 22f22aaf969..e2111b05977 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockListenerRegisterer.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockListenerRegisterer.java
@@ -23,18 +23,21 @@ import org.eclipse.core.runtime.Assert;
/**
* Mock Language Settings Provider that keeps count how many times it has been registered.
*/
-public class MockListenerRegisterer extends LanguageSettingsSerializableProvider implements ILanguageSettingsEditableProvider, ICListenerAgent {
+public class MockListenerRegisterer extends LanguageSettingsSerializableProvider
+ implements ILanguageSettingsEditableProvider, ICListenerAgent {
private static MockListenerManager mockListenerManager = new MockListenerManager();
private static class MockListenerManager {
private class ListenerCount {
private MockListenerRegisterer listener;
private int count;
+
public ListenerCount(MockListenerRegisterer l, int cnt) {
listener = l;
count = cnt;
}
}
+
private List<ListenerCount> register = new ArrayList<ListenerCount>();
public void registerListener(MockListenerRegisterer listener) {
@@ -52,7 +55,7 @@ public class MockListenerRegisterer extends LanguageSettingsSerializableProvider
for (ListenerCount lc : register) {
if (lc.listener == listener) {
lc.count--;
- Assert.isTrue(lc.count>=0);
+ Assert.isTrue(lc.count >= 0);
return;
}
}
@@ -80,9 +83,11 @@ public class MockListenerRegisterer extends LanguageSettingsSerializableProvider
public MockListenerRegisterer() {
super();
}
+
public MockListenerRegisterer(String id, String name) {
super(id, name);
}
+
@Override
public void registerListener(ICConfigurationDescription cfgDescription) {
mockListenerManager.registerListener(this);
@@ -92,10 +97,12 @@ public class MockListenerRegisterer extends LanguageSettingsSerializableProvider
public void unregisterListener() {
mockListenerManager.unregisterListener(this);
}
+
@Override
public MockListenerRegisterer cloneShallow() throws CloneNotSupportedException {
return (MockListenerRegisterer) super.cloneShallow();
}
+
@Override
public MockListenerRegisterer clone() throws CloneNotSupportedException {
return (MockListenerRegisterer) super.clone();
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ASTCacheTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ASTCacheTests.java
index 5bc50e98838..d972ca998c2 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ASTCacheTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ASTCacheTests.java
@@ -43,8 +43,8 @@ import org.eclipse.core.runtime.Status;
* Tests for the {@link ASTCache}.
*/
public class ASTCacheTests extends BaseTestCase {
- private final static boolean DEBUG= false;
-
+ private final static boolean DEBUG = false;
+
private static int fgReconcilerCount;
public class MockReconciler extends Thread {
@@ -54,31 +54,34 @@ public class ASTCacheTests extends BaseTestCase {
public IASTTranslationUnit fAST;
public MockReconciler(ITranslationUnit tu, ASTCache cache) {
- super("MockReconciler-"+fgReconcilerCount++);
- fTU= tu;
- fCache= cache;
+ super("MockReconciler-" + fgReconcilerCount++);
+ fTU = tu;
+ fCache = cache;
setDaemon(true);
}
+
@Override
public void run() {
while (!fStopped) {
try {
synchronized (this) {
fCache.aboutToBeReconciled(fTU);
- if (DEBUG) System.out.println("about ot reconcile "+fTU.getElementName());
- fAST= null;
+ if (DEBUG)
+ System.out.println("about ot reconcile " + fTU.getElementName());
+ fAST = null;
notify();
}
Thread.sleep(50);
- IASTTranslationUnit ast= fCache.createAST(fTU, fIndex, null);
+ IASTTranslationUnit ast = fCache.createAST(fTU, fIndex, null);
synchronized (this) {
- fAST= ast;
- if (DEBUG) System.out.println("reconciled "+fTU.getElementName());
+ fAST = ast;
+ if (DEBUG)
+ System.out.println("reconciled " + fTU.getElementName());
fCache.reconciled(fAST, fTU);
}
Thread.sleep(50);
} catch (InterruptedException exc) {
- fStopped= true;
+ fStopped = true;
break;
}
}
@@ -95,29 +98,29 @@ public class ASTCacheTests extends BaseTestCase {
}
public static Test suite() {
- TestSuite suite= new TestSuite(ASTCacheTests.class);
+ TestSuite suite = new TestSuite(ASTCacheTests.class);
return suite;
}
- private final String SOURCE1= "void foo1() {}"; //$NON-NLS-1$
- private final String SOURCE2= "void foo2() {}"; //$NON-NLS-1$
+ private final String SOURCE1 = "void foo1() {}"; //$NON-NLS-1$
+ private final String SOURCE2 = "void foo2() {}"; //$NON-NLS-1$
@Override
public void setUp() throws Exception {
super.setUp();
- IProgressMonitor npm= new NullProgressMonitor();
- fProject= createProject("ASTCacheTest");
+ IProgressMonitor npm = new NullProgressMonitor();
+ fProject = createProject("ASTCacheTest");
assertNotNull(fProject);
- IFile file1= createFile(fProject.getProject(), "source1.cpp", SOURCE1);
+ IFile file1 = createFile(fProject.getProject(), "source1.cpp", SOURCE1);
assertNotNull(file1);
- IFile file2= createFile(fProject.getProject(), "source2.cpp", SOURCE2);
+ IFile file2 = createFile(fProject.getProject(), "source2.cpp", SOURCE2);
assertNotNull(file2);
- fTU1= (ITranslationUnit) CoreModel.getDefault().create(file1);
+ fTU1 = (ITranslationUnit) CoreModel.getDefault().create(file1);
assertNotNull(fTU1);
- fTU2= (ITranslationUnit) CoreModel.getDefault().create(file2);
+ fTU2 = (ITranslationUnit) CoreModel.getDefault().create(file2);
assertNotNull(fTU2);
waitForIndexer(fProject);
- fIndex= CCorePlugin.getIndexManager().getIndex(fProject);
+ fIndex = CCorePlugin.getIndexManager().getIndex(fProject);
fIndex.acquireReadLock();
}
@@ -146,9 +149,9 @@ public class ASTCacheTests extends BaseTestCase {
checkAccessWithSequentialReconciler();
checkAccessWithConcurrentReconciler();
}
-
+
private void checkActiveElement() throws Exception {
- ASTCache cache= new ASTCache();
+ ASTCache cache = new ASTCache();
assertFalse(cache.isActiveElement(fTU1));
assertFalse(cache.isActiveElement(fTU2));
cache.setActiveElement(fTU1);
@@ -158,12 +161,12 @@ public class ASTCacheTests extends BaseTestCase {
assertFalse(cache.isActiveElement(fTU1));
assertTrue(cache.isActiveElement(fTU2));
}
-
+
private void checkSingleThreadAccess() throws Exception {
- final ASTCache cache= new ASTCache();
- final int[] counter= {0};
+ final ASTCache cache = new ASTCache();
+ final int[] counter = { 0 };
cache.setActiveElement(fTU1);
- IStatus status= cache.runOnAST(fTU1, false, null, new ASTRunnable() {
+ IStatus status = cache.runOnAST(fTU1, false, null, new ASTRunnable() {
@Override
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
assertNull(ast);
@@ -173,9 +176,9 @@ public class ASTCacheTests extends BaseTestCase {
});
assertEquals(1, counter[0]);
- IProgressMonitor npm= new NullProgressMonitor();
+ IProgressMonitor npm = new NullProgressMonitor();
npm.setCanceled(true);
- status= cache.runOnAST(fTU1, true, npm, new ASTRunnable() {
+ status = cache.runOnAST(fTU1, true, npm, new ASTRunnable() {
@Override
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
assertNull(ast);
@@ -186,7 +189,7 @@ public class ASTCacheTests extends BaseTestCase {
assertEquals(2, counter[0]);
npm.setCanceled(false);
- status= cache.runOnAST(fTU1, true, npm, new ASTRunnable() {
+ status = cache.runOnAST(fTU1, true, npm, new ASTRunnable() {
@Override
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
assertNotNull(ast);
@@ -198,9 +201,9 @@ public class ASTCacheTests extends BaseTestCase {
}
private void checkAccessWithSequentialReconciler() throws Exception {
- final ASTCache cache= new ASTCache();
- final MockReconciler reconciler1= new MockReconciler(fTU1, cache);
- final MockReconciler reconciler2= new MockReconciler(fTU2, cache);
+ final ASTCache cache = new ASTCache();
+ final MockReconciler reconciler1 = new MockReconciler(fTU1, cache);
+ final MockReconciler reconciler2 = new MockReconciler(fTU2, cache);
try {
cache.setActiveElement(fTU1);
assertFalse(cache.isReconciling(fTU1));
@@ -211,8 +214,8 @@ public class ASTCacheTests extends BaseTestCase {
assertTrue(cache.isActiveElement(fTU1));
assertTrue(cache.isReconciling(fTU1));
}
- reconciler1.fStopped= true;
- IStatus status= cache.runOnAST(fTU1, true, null, new ASTRunnable() {
+ reconciler1.fStopped = true;
+ IStatus status = cache.runOnAST(fTU1, true, null, new ASTRunnable() {
@Override
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
assertNotNull(ast);
@@ -222,7 +225,7 @@ public class ASTCacheTests extends BaseTestCase {
return Status.OK_STATUS;
}
});
-
+
// change active element
cache.setActiveElement(fTU2);
assertFalse(cache.isReconciling(fTU2));
@@ -233,9 +236,9 @@ public class ASTCacheTests extends BaseTestCase {
assertTrue(cache.isActiveElement(fTU2));
assertTrue(cache.isReconciling(fTU2));
}
- reconciler2.fStopped= true;
-
- status= cache.runOnAST(fTU2, true, null, new ASTRunnable() {
+ reconciler2.fStopped = true;
+
+ status = cache.runOnAST(fTU2, true, null, new ASTRunnable() {
@Override
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
assertNotNull(ast);
@@ -246,25 +249,26 @@ public class ASTCacheTests extends BaseTestCase {
}
});
} finally {
- reconciler1.fStopped= true;
+ reconciler1.fStopped = true;
reconciler1.join(1000);
- reconciler2.fStopped= true;
+ reconciler2.fStopped = true;
reconciler2.join(1000);
}
}
private void checkAccessWithConcurrentReconciler() throws Exception {
- ASTCache cache= new ASTCache();
- MockReconciler reconciler1= new MockReconciler(fTU1, cache);
- MockReconciler reconciler2= new MockReconciler(fTU2, cache);
+ ASTCache cache = new ASTCache();
+ MockReconciler reconciler1 = new MockReconciler(fTU1, cache);
+ MockReconciler reconciler2 = new MockReconciler(fTU2, cache);
reconciler1.start();
Thread.sleep(50);
reconciler2.start();
try {
- int iterations= 0;
+ int iterations = 0;
while (iterations < 10) {
++iterations;
- if (DEBUG) System.out.println("iteration="+iterations);
+ if (DEBUG)
+ System.out.println("iteration=" + iterations);
cache.setActiveElement(fTU1);
Thread.sleep(50);
waitForAST(cache, fTU1, new ASTRunnable() {
@@ -305,23 +309,24 @@ public class ASTCacheTests extends BaseTestCase {
return Status.OK_STATUS;
}
});
-}
+ }
} finally {
- reconciler1.fStopped= true;
+ reconciler1.fStopped = true;
reconciler1.join(1000);
- reconciler2.fStopped= true;
+ reconciler2.fStopped = true;
reconciler2.join(1000);
}
}
private void waitForAST(ASTCache cache, ITranslationUnit tUnit, ASTRunnable runnable) {
- if (DEBUG) System.out.println("waiting for "+tUnit.getElementName());
- long start= System.currentTimeMillis();
+ if (DEBUG)
+ System.out.println("waiting for " + tUnit.getElementName());
+ long start = System.currentTimeMillis();
try {
cache.runOnAST(tUnit, true, null, runnable);
- }
- finally {
- if (DEBUG) System.out.println("wait time= " + (System.currentTimeMillis() - start));
+ } finally {
+ if (DEBUG)
+ System.out.println("wait time= " + (System.currentTimeMillis() - start));
}
}
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllCoreTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllCoreTests.java
index 9a50c8e78ae..15565718ee4 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllCoreTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllCoreTests.java
@@ -21,7 +21,6 @@ import org.eclipse.cdt.core.language.settings.providers.AllLanguageSettingsProvi
import org.eclipse.cdt.core.settings.model.AllCProjectDescriptionTests;
import org.eclipse.cdt.core.settings.model.PathSettingsContainerTests;
-
/**
*
* AllTests.java
@@ -33,28 +32,28 @@ import org.eclipse.cdt.core.settings.model.PathSettingsContainerTests;
*/
public class AllCoreTests {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
- public static Test suite() {
- TestSuite suite = new TestSuite(AllCoreTests.class.getName());
+ public static Test suite() {
+ TestSuite suite = new TestSuite(AllCoreTests.class.getName());
- // Just add more test cases here as you create them for
- // each class being tested
+ // Just add more test cases here as you create them for
+ // each class being tested
suite.addTest(AllLanguageInterfaceTests.suite());
- suite.addTest(CModelTests.suite());
- suite.addTest(CModelElementsTests.suite());
- suite.addTest(CModelIdentifierTests.suite());
- suite.addTest(CModelExceptionTest.suite());
- suite.addTest(CModelBuilderInactiveCodeTest.suite());
- suite.addTest(FlagTests.suite());
- suite.addTest(ArchiveTests.suite());
- suite.addTest(BinaryTests.suite());
- suite.addTest(TranslationUnitTests.suite());
+ suite.addTest(CModelTests.suite());
+ suite.addTest(CModelElementsTests.suite());
+ suite.addTest(CModelIdentifierTests.suite());
+ suite.addTest(CModelExceptionTest.suite());
+ suite.addTest(CModelBuilderInactiveCodeTest.suite());
+ suite.addTest(FlagTests.suite());
+ suite.addTest(ArchiveTests.suite());
+ suite.addTest(BinaryTests.suite());
+ suite.addTest(TranslationUnitTests.suite());
suite.addTest(DeclaratorsTests.suite());
suite.addTest(MacroTests.suite());
-// suite.addTest(FailedMacroTests.suite());
+ // suite.addTest(FailedMacroTests.suite());
suite.addTest(CPathEntryTest.suite());
//the CProjectDescriptionTests now groups all New Project Model related tests
//which includes the CConfigurationDescriptionReferenceTests
@@ -66,8 +65,7 @@ public class AllCoreTests {
suite.addTest(Bug311189.suite());
suite.addTest(AllLanguageSettingsProvidersCoreTests.suite());
- return suite;
+ return suite;
- }
+ }
} // End of AllCoreTests.java
-
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllLanguageInterfaceTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllLanguageInterfaceTests.java
index 80b7e475552..795a7d8f123 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllLanguageInterfaceTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllLanguageInterfaceTests.java
@@ -30,23 +30,23 @@ import junit.framework.TestSuite;
public class AllLanguageInterfaceTests {
/**
- *
+ *
*/
public static Test suite() {
TestSuite suite = new TestSuite(AllLanguageInterfaceTests.class.getName());
- // Just add more test cases here as you create them for
+ // Just add more test cases here as you create them for
// each class being tested
-
+
suite.addTest(IIncludeTests.suite());
suite.addTest(IMacroTests.suite());
suite.addTest(StructuralMacroTests.suite());
suite.addTest(IStructureTests.suite());
- suite.addTest(StructuralStructureTests.suite());
+ suite.addTest(StructuralStructureTests.suite());
suite.addTest(ITemplateTests.suite());
- suite.addTest(StructuralTemplateTests.suite());
+ suite.addTest(StructuralTemplateTests.suite());
return suite;
-
+
}
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ArchiveTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ArchiveTests.java
index 2a0316a8f3e..f905f2b9f16 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ArchiveTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ArchiveTests.java
@@ -44,177 +44,175 @@ import org.eclipse.core.runtime.Path;
*
*/
public class ArchiveTests extends TestCase {
- IWorkspace workspace;
- IWorkspaceRoot root;
- ICProject testProject;
- IFile cfile, exefile, libfile, archfile, objfile;
- Path cpath, exepath, libpath, archpath, objpath;
- NullProgressMonitor monitor;
-
-
- /**
- * Constructor for ArchiveTests
- * @param name
- */
- public ArchiveTests(String name) {
- super(name);
- /***
- * The assume that they have a working workspace
- * and workspace root object to use to create projects/files in,
- * so we need to get them setup first.
- */
- workspace= ResourcesPlugin.getWorkspace();
- root= workspace.getRoot();
- monitor = new NullProgressMonitor();
- if (workspace==null)
- fail("Workspace was not setup");
- if (root==null)
- fail("Workspace root was not setup");
-
- }
-
- /**
- * Sets up the test fixture.
- *
- * Called before every test case method.
- *
- * Example code test the packages in the project
- * "com.qnx.tools.ide.cdt.core"
- */
- @Override
+ IWorkspace workspace;
+ IWorkspaceRoot root;
+ ICProject testProject;
+ IFile cfile, exefile, libfile, archfile, objfile;
+ Path cpath, exepath, libpath, archpath, objpath;
+ NullProgressMonitor monitor;
+
+ /**
+ * Constructor for ArchiveTests
+ * @param name
+ */
+ public ArchiveTests(String name) {
+ super(name);
+ /***
+ * The assume that they have a working workspace
+ * and workspace root object to use to create projects/files in,
+ * so we need to get them setup first.
+ */
+ workspace = ResourcesPlugin.getWorkspace();
+ root = workspace.getRoot();
+ monitor = new NullProgressMonitor();
+ if (workspace == null)
+ fail("Workspace was not setup");
+ if (root == null)
+ fail("Workspace root was not setup");
+
+ }
+
+ /**
+ * Sets up the test fixture.
+ *
+ * Called before every test case method.
+ *
+ * Example code test the packages in the project
+ * "com.qnx.tools.ide.cdt.core"
+ */
+ @Override
protected void setUp() throws Exception {
-
- /***
- * Setup the various files, paths and projects that are needed by the
- * tests
- */
- testProject=CProjectHelper.createCProject("filetest", "none", IPDOMManager.ID_NO_INDEXER);
- if (testProject==null)
- fail("Unable to create project");
-
- cfile = testProject.getProject().getFile("exetest.c");
- if (!cfile.exists()) {
- cfile.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/main.c"))),
- false, monitor);
- }
- cpath=new Path(workspace.getRoot().getLocation()+"/filetest/main.c");
- objfile = testProject.getProject().getFile("exetest.o");
- if (!objfile.exists()) {
- objfile.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/main.o"))),
+ /***
+ * Setup the various files, paths and projects that are needed by the
+ * tests
+ */
+ testProject = CProjectHelper.createCProject("filetest", "none", IPDOMManager.ID_NO_INDEXER);
+ if (testProject == null)
+ fail("Unable to create project");
+
+ cfile = testProject.getProject().getFile("exetest.c");
+ if (!cfile.exists()) {
+ cfile.create(
+ new FileInputStream(CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/main.c"))),
+ false, monitor);
+ }
+ cpath = new Path(workspace.getRoot().getLocation() + "/filetest/main.c");
+
+ objfile = testProject.getProject().getFile("exetest.o");
+ if (!objfile.exists()) {
+ objfile.create(
+ new FileInputStream(
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/main.o"))),
false, monitor);
- }
- objpath=new Path(workspace.getRoot().getLocation()+"/filetest/main.o");
-
- exefile = testProject.getProject().getFile("test_g");
- if (!exefile.exists()) {
- exefile.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/exe_g"))),
+ }
+ objpath = new Path(workspace.getRoot().getLocation() + "/filetest/main.o");
+
+ exefile = testProject.getProject().getFile("test_g");
+ if (!exefile.exists()) {
+ exefile.create(
+ new FileInputStream(
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/exe_g"))),
false, monitor);
- }
- exepath=new Path(workspace.getRoot().getLocation()+"/filetest/exe_g");
-
- archfile = testProject.getProject().getFile("libtestlib_g.a");
- if (!archfile.exists()) {
- archfile.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/a.g/libtestlib_g.a"))),
+ }
+ exepath = new Path(workspace.getRoot().getLocation() + "/filetest/exe_g");
+
+ archfile = testProject.getProject().getFile("libtestlib_g.a");
+ if (!archfile.exists()) {
+ archfile.create(new FileInputStream(
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/a.g/libtestlib_g.a"))),
false, monitor);
- }
- libpath=new Path(workspace.getRoot().getLocation()+"/filetest/libtestlib_g.so");
-
- libfile = testProject.getProject().getFile("libtestlib_g.so");
- if (!libfile.exists()) {
- libfile.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/so.g/libtestlib_g.so"))),
+ }
+ libpath = new Path(workspace.getRoot().getLocation() + "/filetest/libtestlib_g.so");
+
+ libfile = testProject.getProject().getFile("libtestlib_g.so");
+ if (!libfile.exists()) {
+ libfile.create(new FileInputStream(
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/so.g/libtestlib_g.so"))),
false, monitor);
- }
- archpath=new Path(workspace.getRoot().getLocation()+"/filetest/libtestlib_g.a");
- }
-
- /**
- * Tears down the test fixture.
- *
- * Called after every test case method.
- */
- @Override
- protected void tearDown() {
- CProjectHelper.delete(testProject);
- }
-
- public static TestSuite suite() {
- return new TestSuite(ArchiveTests.class);
- }
-
- public static void main (String[] args){
- junit.textui.TestRunner.run(suite());
- }
-
-
-
- public void testGetBinaries() throws CoreException,FileNotFoundException {
- IArchive myArchive;
- IBinary[] bins;
- ICElement[] elements;
- ExpectedStrings expBin, expObj[];
- String[] myStrings;
- int x;
-
-
- /****
- * Setup the expected strings for the binaries, and the elements within
- * the binaries
- */
- myStrings=new String[2];
- myStrings[0]="test.o";
- myStrings[1]="test2.o";
- expBin=new ExpectedStrings(myStrings);
-
- expObj=new ExpectedStrings[2];
- myStrings[0]="func1";
- myStrings[1]="func2";
- expObj[0]=new ExpectedStrings(myStrings);
- myStrings[0]="test2func1";
- myStrings[1]="test2func2";
- expObj[1]=new ExpectedStrings(myStrings);
-
- /***
- * Grab the archive we want to test, and find all the binaries and
- * all the elements in all the binaries and make sure we get
- * everything we expect.
- */
- myArchive=CProjectHelper.findArchive(testProject, "libtestlib_g.a");
- if (myArchive==null)
- fail("Could not find archive");
- bins=myArchive.getBinaries();
- for (x=0;x<bins.length;x++) {
- expBin.foundString(bins[x].getElementName());
- elements=bins[x].getChildren();
- for (int i=0;i<elements.length;i++) {
- expObj[x].foundString(elements[i].getElementName());
- }
- }
-
- assertTrue(expBin.getMissingString(), expBin.gotAll());
- assertTrue(expBin.getExtraString(), !expBin.gotExtra());
- for (x=0;x<expObj.length;x++) {
- assertTrue("Binary " + expBin.expStrings[x] + " " +expObj[x].getMissingString(), expObj[x].gotAll());
- assertTrue("Binary " + expBin.expStrings[x] + " " + expObj[x].getExtraString(), !expObj[x].gotExtra());
- }
- }
- /***
- * Simple sanity test to make sure Archive.isArchive returns true
- *
- */
- public void testIsArchive() throws CoreException,FileNotFoundException {
- IArchive myArchive;
- myArchive=CProjectHelper.findArchive(testProject, "libtestlib_g.a");
-
- assertTrue("A archive", myArchive != null);
- myArchive=null;
-
-
- }
+ }
+ archpath = new Path(workspace.getRoot().getLocation() + "/filetest/libtestlib_g.a");
+ }
+
+ /**
+ * Tears down the test fixture.
+ *
+ * Called after every test case method.
+ */
+ @Override
+ protected void tearDown() {
+ CProjectHelper.delete(testProject);
+ }
+
+ public static TestSuite suite() {
+ return new TestSuite(ArchiveTests.class);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public void testGetBinaries() throws CoreException, FileNotFoundException {
+ IArchive myArchive;
+ IBinary[] bins;
+ ICElement[] elements;
+ ExpectedStrings expBin, expObj[];
+ String[] myStrings;
+ int x;
+
+ /****
+ * Setup the expected strings for the binaries, and the elements within
+ * the binaries
+ */
+ myStrings = new String[2];
+ myStrings[0] = "test.o";
+ myStrings[1] = "test2.o";
+ expBin = new ExpectedStrings(myStrings);
+
+ expObj = new ExpectedStrings[2];
+ myStrings[0] = "func1";
+ myStrings[1] = "func2";
+ expObj[0] = new ExpectedStrings(myStrings);
+ myStrings[0] = "test2func1";
+ myStrings[1] = "test2func2";
+ expObj[1] = new ExpectedStrings(myStrings);
+
+ /***
+ * Grab the archive we want to test, and find all the binaries and
+ * all the elements in all the binaries and make sure we get
+ * everything we expect.
+ */
+ myArchive = CProjectHelper.findArchive(testProject, "libtestlib_g.a");
+ if (myArchive == null)
+ fail("Could not find archive");
+ bins = myArchive.getBinaries();
+ for (x = 0; x < bins.length; x++) {
+ expBin.foundString(bins[x].getElementName());
+ elements = bins[x].getChildren();
+ for (int i = 0; i < elements.length; i++) {
+ expObj[x].foundString(elements[i].getElementName());
+ }
+ }
+
+ assertTrue(expBin.getMissingString(), expBin.gotAll());
+ assertTrue(expBin.getExtraString(), !expBin.gotExtra());
+ for (x = 0; x < expObj.length; x++) {
+ assertTrue("Binary " + expBin.expStrings[x] + " " + expObj[x].getMissingString(), expObj[x].gotAll());
+ assertTrue("Binary " + expBin.expStrings[x] + " " + expObj[x].getExtraString(), !expObj[x].gotExtra());
+ }
+ }
+
+ /***
+ * Simple sanity test to make sure Archive.isArchive returns true
+ *
+ */
+ public void testIsArchive() throws CoreException, FileNotFoundException {
+ IArchive myArchive;
+ myArchive = CProjectHelper.findArchive(testProject, "libtestlib_g.a");
+
+ assertTrue("A archive", myArchive != null);
+ myArchive = null;
+
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AsmModelBuilderTest.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AsmModelBuilderTest.java
index 0489e375f51..3fd58284d7a 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AsmModelBuilderTest.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AsmModelBuilderTest.java
@@ -40,82 +40,81 @@ public class AsmModelBuilderTest extends BaseTestCase {
}
private ICProject fCProject;
- private ITranslationUnit fTU;
-
+ private ITranslationUnit fTU;
+
public AsmModelBuilderTest(String name) {
super(name);
}
-
+
@Override
protected void setUp() throws Exception {
super.setUp();
- fCProject= CProjectHelper.createCProject(getName(), null, IPDOMManager.ID_FAST_INDEXER);
+ fCProject = CProjectHelper.createCProject(getName(), null, IPDOMManager.ID_FAST_INDEXER);
assertNotNull(fCProject);
CProjectHelper.importSourcesFromPlugin(fCProject, CTestPlugin.getDefault().getBundle(), "/resources/asmTests");
- fTU= (ITranslationUnit) CProjectHelper.findElement(fCProject, "AsmTest.S");
+ fTU = (ITranslationUnit) CProjectHelper.findElement(fCProject, "AsmTest.S");
assertNotNull(fTU);
}
@Override
protected void tearDown() throws Exception {
- CProjectHelper.delete(fCProject);
- super.tearDown();
- }
-
+ CProjectHelper.delete(fCProject);
+ super.tearDown();
+ }
+
public void testAsmModelElements() throws Exception {
- ICElement[] children= fTU.getChildren();
+ ICElement[] children = fTU.getChildren();
assertEquals(8, children.length);
-
- int idx= 0;
+
+ int idx = 0;
assertEquals(ICElement.C_INCLUDE, children[idx].getElementType());
- assertTrue(((IInclude)children[idx]).isStandard());
+ assertTrue(((IInclude) children[idx]).isStandard());
assertEquals("include1.h", children[idx++].getElementName());
assertEquals(ICElement.C_INCLUDE, children[idx].getElementType());
- assertFalse(((IInclude)children[idx]).isStandard());
+ assertFalse(((IInclude) children[idx]).isStandard());
assertEquals("include2.h", children[idx++].getElementName());
-
-
+
assertEquals(ICElement.ASM_LABEL, children[idx].getElementType());
assertEquals("nonGlobalLabel", children[idx].getElementName());
- assertFalse(((IAsmLabel)children[idx]).isGlobal());
- assertEquals(0, ((IParent)children[idx++]).getChildren().length);
-
+ assertFalse(((IAsmLabel) children[idx]).isGlobal());
+ assertEquals(0, ((IParent) children[idx++]).getChildren().length);
+
assertEquals(ICElement.ASM_LABEL, children[idx].getElementType());
assertEquals("globalLabel1", children[idx].getElementName());
- assertTrue(((IAsmLabel)children[idx]).isGlobal());
- assertEquals(2, ((IParent)children[idx++]).getChildren().length);
-
+ assertTrue(((IAsmLabel) children[idx]).isGlobal());
+ assertEquals(2, ((IParent) children[idx++]).getChildren().length);
+
assertEquals(ICElement.C_MACRO, children[idx].getElementType());
assertEquals("MACRO", children[idx++].getElementName());
-
+
assertEquals(ICElement.ASM_LABEL, children[idx].getElementType());
assertEquals("globalLabel2", children[idx].getElementName());
- assertTrue(((IAsmLabel)children[idx]).isGlobal());
- assertEquals(1, ((IParent)children[idx++]).getChildren().length);
-
+ assertTrue(((IAsmLabel) children[idx]).isGlobal());
+ assertEquals(1, ((IParent) children[idx++]).getChildren().length);
+
assertEquals(ICElement.ASM_LABEL, children[idx].getElementType());
assertEquals("globalLabel3", children[idx].getElementName());
- assertTrue(((IAsmLabel)children[idx]).isGlobal());
- assertEquals(1, ((IParent)children[idx++]).getChildren().length);
-
+ assertTrue(((IAsmLabel) children[idx]).isGlobal());
+ assertEquals(1, ((IParent) children[idx++]).getChildren().length);
+
assertEquals(ICElement.ASM_LABEL, children[idx].getElementType());
assertEquals("alloca", children[idx].getElementName());
- assertTrue(((IAsmLabel)children[idx]).isGlobal());
- assertEquals(0, ((IParent)children[idx++]).getChildren().length);
+ assertTrue(((IAsmLabel) children[idx]).isGlobal());
+ assertEquals(0, ((IParent) children[idx++]).getChildren().length);
}
public void testAsmLabelRanges() throws Exception {
- String source= fTU.getBuffer().getContents();
- ICElement[] labels= fTU.getChildrenOfType(ICElement.ASM_LABEL).toArray(new ICElement[0]);
+ String source = fTU.getBuffer().getContents();
+ ICElement[] labels = fTU.getChildrenOfType(ICElement.ASM_LABEL).toArray(new ICElement[0]);
for (ICElement label2 : labels) {
- String name= label2.getElementName();
- ISourceReference label= (ISourceReference)label2;
- ISourceRange range= label.getSourceRange();
+ String name = label2.getElementName();
+ ISourceReference label = (ISourceReference) label2;
+ ISourceRange range = label.getSourceRange();
assertEquals(source.substring(range.getIdStartPos(), range.getIdStartPos() + range.getIdLength()), name);
- int endOfLabel= source.indexOf("/* end */", range.getIdStartPos());
+ int endOfLabel = source.indexOf("/* end */", range.getIdStartPos());
assertEquals(range.getIdStartPos(), range.getStartPos());
assertEquals(endOfLabel, range.getStartPos() + range.getLength());
}
}
-
+
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/BinaryTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/BinaryTests.java
index 6e21138fd43..28cfc8c0616 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/BinaryTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/BinaryTests.java
@@ -40,8 +40,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
-
-
/**
* @author Peter Graves
*
@@ -50,385 +48,373 @@ import org.eclipse.core.runtime.Path;
*
*/
public class BinaryTests extends TestCase {
- IWorkspace workspace;
- IWorkspaceRoot root;
- ICProject testProject;
- IFile cfile, exefile, libfile, archfile, objfile, bigexe, ppcexefile, ndexe;
- Path cpath, exepath, libpath, archpath, objpath;
- NullProgressMonitor monitor;
-
-
-
- /**
- * Constructor for BinaryTests
- * @param name
- */
- public BinaryTests(String name) {
- super(name);
-
- }
-
- /**
- * Sets up the test fixture.
- *
- * Called before every test case method.
- *
- * Example code test the packages in the project
- * "com.qnx.tools.ide.cdt.core"
- */
- @Override
- protected void setUp() throws Exception {
- /***
- * The tests assume that they have a working workspace
- * and workspace root object to use to create projects/files in,
- * so we need to get them setup first.
- */
- workspace= ResourcesPlugin.getWorkspace();
- root= workspace.getRoot();
- monitor = new NullProgressMonitor();
- if (workspace==null)
- fail("Workspace was not setup");
- if (root==null)
- fail("Workspace root was not setup");
-
-
- /***
- * Setup the various files, paths and projects that are needed by the
- * tests
- */
-
- testProject=CProjectHelper.createCProject("filetest", "none", IPDOMManager.ID_NO_INDEXER);
-
- // since our test require that we can read the debug info from the exe we must set the GNU elf
- // binary parser since the default (generic elf binary parser) does not do this.
- ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(testProject.getProject(), true);
- ICConfigurationDescription defaultConfig = projDesc.getDefaultSettingConfiguration();
- defaultConfig.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
- defaultConfig.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, "org.eclipse.cdt.core.GNU_ELF");
- CoreModel.getDefault().setProjectDescription(testProject.getProject(), projDesc);
-
- if (testProject==null)
- fail("Unable to create project");
-
- cfile = testProject.getProject().getFile("exetest.c");
- if (!cfile.exists()) {
- cfile.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/main.c"))),
- false, monitor);
- }
- cpath=new Path(workspace.getRoot().getLocation()+"/filetest/main.c");
+ IWorkspace workspace;
+ IWorkspaceRoot root;
+ ICProject testProject;
+ IFile cfile, exefile, libfile, archfile, objfile, bigexe, ppcexefile, ndexe;
+ Path cpath, exepath, libpath, archpath, objpath;
+ NullProgressMonitor monitor;
+
+ /**
+ * Constructor for BinaryTests
+ * @param name
+ */
+ public BinaryTests(String name) {
+ super(name);
+
+ }
- objfile = testProject.getProject().getFile("exetest.o");
- if (!objfile.exists()) {
- objfile.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/main.o"))),
+ /**
+ * Sets up the test fixture.
+ *
+ * Called before every test case method.
+ *
+ * Example code test the packages in the project
+ * "com.qnx.tools.ide.cdt.core"
+ */
+ @Override
+ protected void setUp() throws Exception {
+ /***
+ * The tests assume that they have a working workspace
+ * and workspace root object to use to create projects/files in,
+ * so we need to get them setup first.
+ */
+ workspace = ResourcesPlugin.getWorkspace();
+ root = workspace.getRoot();
+ monitor = new NullProgressMonitor();
+ if (workspace == null)
+ fail("Workspace was not setup");
+ if (root == null)
+ fail("Workspace root was not setup");
+
+ /***
+ * Setup the various files, paths and projects that are needed by the
+ * tests
+ */
+
+ testProject = CProjectHelper.createCProject("filetest", "none", IPDOMManager.ID_NO_INDEXER);
+
+ // since our test require that we can read the debug info from the exe we must set the GNU elf
+ // binary parser since the default (generic elf binary parser) does not do this.
+ ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(testProject.getProject(), true);
+ ICConfigurationDescription defaultConfig = projDesc.getDefaultSettingConfiguration();
+ defaultConfig.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
+ defaultConfig.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, "org.eclipse.cdt.core.GNU_ELF");
+ CoreModel.getDefault().setProjectDescription(testProject.getProject(), projDesc);
+
+ if (testProject == null)
+ fail("Unable to create project");
+
+ cfile = testProject.getProject().getFile("exetest.c");
+ if (!cfile.exists()) {
+ cfile.create(
+ new FileInputStream(CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/main.c"))),
false, monitor);
- }
- objpath=new Path(workspace.getRoot().getLocation()+"/filetest/exetest.o");
-
- exefile = testProject.getProject().getFile("test_g");
- if (!exefile.exists()) {
- exefile.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/exe_g"))),
+ }
+ cpath = new Path(workspace.getRoot().getLocation() + "/filetest/main.c");
+
+ objfile = testProject.getProject().getFile("exetest.o");
+ if (!objfile.exists()) {
+ objfile.create(
+ new FileInputStream(
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/main.o"))),
false, monitor);
- }
- exepath=new Path(workspace.getRoot().getLocation()+"/filetest/exe_g");
- ppcexefile = testProject.getProject().getFile("ppctest_g");
- if (!ppcexefile.exists()) {
- ppcexefile.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/ppc/be.g/exe_g"))),
+ }
+ objpath = new Path(workspace.getRoot().getLocation() + "/filetest/exetest.o");
+
+ exefile = testProject.getProject().getFile("test_g");
+ if (!exefile.exists()) {
+ exefile.create(
+ new FileInputStream(
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/exe_g"))),
false, monitor);
- }
- ndexe = testProject.getProject().getFile("exetest");
- if (!ndexe.exists()) {
- ndexe.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o/exe"))),
+ }
+ exepath = new Path(workspace.getRoot().getLocation() + "/filetest/exe_g");
+ ppcexefile = testProject.getProject().getFile("ppctest_g");
+ if (!ppcexefile.exists()) {
+ ppcexefile.create(
+ new FileInputStream(
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/ppc/be.g/exe_g"))),
false, monitor);
- }
-
-
+ }
+ ndexe = testProject.getProject().getFile("exetest");
+ if (!ndexe.exists()) {
+ ndexe.create(
+ new FileInputStream(CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o/exe"))),
+ false, monitor);
+ }
- bigexe = testProject.getProject().getFile("exebig_g");
- if (!bigexe.exists()) {
- bigexe.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exebig/x86/o.g/exebig_g"))),
+ bigexe = testProject.getProject().getFile("exebig_g");
+ if (!bigexe.exists()) {
+ bigexe.create(
+ new FileInputStream(
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exebig/x86/o.g/exebig_g"))),
false, monitor);
- }
-
- archfile = testProject.getProject().getFile("libtestlib_g.a");
- if (!archfile.exists()) {
- archfile.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/a.g/libtestlib_g.a"))),
+ }
+
+ archfile = testProject.getProject().getFile("libtestlib_g.a");
+ if (!archfile.exists()) {
+ archfile.create(new FileInputStream(
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/a.g/libtestlib_g.a"))),
false, monitor);
- }
- libpath=new Path(workspace.getRoot().getLocation()+"/filetest/libtestlib_g.so");
-
- libfile = testProject.getProject().getFile("libtestlib_g.so");
- if (!libfile.exists()) {
- libfile.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/so.g/libtestlib_g.so"))),
+ }
+ libpath = new Path(workspace.getRoot().getLocation() + "/filetest/libtestlib_g.so");
+
+ libfile = testProject.getProject().getFile("libtestlib_g.so");
+ if (!libfile.exists()) {
+ libfile.create(new FileInputStream(
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/so.g/libtestlib_g.so"))),
false, monitor);
- }
- archpath=new Path(workspace.getRoot().getLocation()+"/filetest/libtestlib_g.a");
-
-
-
-
- }
-
- /**
- * Tears down the test fixture.
- *
- * Called after every test case method.
- */
- @Override
- protected void tearDown() throws CoreException, InterruptedException {
- System.gc();
- System.runFinalization();
- CProjectHelper.delete(testProject);
- }
-
- public static TestSuite suite() {
- return new TestSuite(BinaryTests.class);
- }
-
- public static void main (String[] args){
- junit.textui.TestRunner.run(suite());
- }
-
-
-
- /****
- * Simple tests to make sure we can get all of a binarys children
- */
- public void testGetChildren() throws CoreException,FileNotFoundException {
- IBinary myBinary;
- ICElement[] elements;
- ExpectedStrings expSyms;
-// String[] myStrings = {"test.c", "_init","main.c", "_start", "test2.c", "_btext"};
- // On Windows at least, it appears the .c files aren't included in the binary
- String[] myStrings = {"_init", "_start", "_btext"};
-
- expSyms=new ExpectedStrings(myStrings);
-
- /***
- * Grab the IBinary we want to test, and find all the elements in all
- * the binarie and make sure we get everything we expect.
- */
- myBinary=CProjectHelper.findBinary(testProject, "test_g");
- elements=myBinary.getChildren();
- for (int i=0;i<elements.length;i++) {
- expSyms.foundString(elements[i].getElementName());
- }
-
- assertTrue(expSyms.getMissingString(), expSyms.gotAll());
-// assertTrue(expSyms.getExtraString(), !expSyms.gotExtra());
- }
-
- /***
- * A quick check to make sure the getBSS function works as expected.
- */
- public void testGetBss() throws CModelException{
- IBinary bigBinary,littleBinary;
- bigBinary=CProjectHelper.findBinary(testProject, "exebig_g");
- littleBinary=CProjectHelper.findBinary(testProject, "test_g");
-
- assertTrue("Expected 432, Got: " + bigBinary.getBSS(), bigBinary.getBSS()==432);
- assertTrue("Expected 4, Got: " + littleBinary.getBSS(), littleBinary.getBSS()==4);
- }
- /***
- * A quick check to make sure the getBSS function works as expected.
- */
- public void testGetData() throws CModelException{
- IBinary bigBinary,littleBinary;
- bigBinary=CProjectHelper.findBinary(testProject, "exebig_g");
- littleBinary=CProjectHelper.findBinary(testProject, "test_g");
+ }
+ archpath = new Path(workspace.getRoot().getLocation() + "/filetest/libtestlib_g.a");
+
+ }
+
+ /**
+ * Tears down the test fixture.
+ *
+ * Called after every test case method.
+ */
+ @Override
+ protected void tearDown() throws CoreException, InterruptedException {
+ System.gc();
+ System.runFinalization();
+ CProjectHelper.delete(testProject);
+ }
+
+ public static TestSuite suite() {
+ return new TestSuite(BinaryTests.class);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ /****
+ * Simple tests to make sure we can get all of a binarys children
+ */
+ public void testGetChildren() throws CoreException, FileNotFoundException {
+ IBinary myBinary;
+ ICElement[] elements;
+ ExpectedStrings expSyms;
+ // String[] myStrings = {"test.c", "_init","main.c", "_start", "test2.c", "_btext"};
+ // On Windows at least, it appears the .c files aren't included in the binary
+ String[] myStrings = { "_init", "_start", "_btext" };
+
+ expSyms = new ExpectedStrings(myStrings);
+
+ /***
+ * Grab the IBinary we want to test, and find all the elements in all
+ * the binarie and make sure we get everything we expect.
+ */
+ myBinary = CProjectHelper.findBinary(testProject, "test_g");
+ elements = myBinary.getChildren();
+ for (int i = 0; i < elements.length; i++) {
+ expSyms.foundString(elements[i].getElementName());
+ }
+
+ assertTrue(expSyms.getMissingString(), expSyms.gotAll());
+ // assertTrue(expSyms.getExtraString(), !expSyms.gotExtra());
+ }
+
+ /***
+ * A quick check to make sure the getBSS function works as expected.
+ */
+ public void testGetBss() throws CModelException {
+ IBinary bigBinary, littleBinary;
+ bigBinary = CProjectHelper.findBinary(testProject, "exebig_g");
+ littleBinary = CProjectHelper.findBinary(testProject, "test_g");
+
+ assertTrue("Expected 432, Got: " + bigBinary.getBSS(), bigBinary.getBSS() == 432);
+ assertTrue("Expected 4, Got: " + littleBinary.getBSS(), littleBinary.getBSS() == 4);
+ }
+
+ /***
+ * A quick check to make sure the getBSS function works as expected.
+ */
+ public void testGetData() throws CModelException {
+ IBinary bigBinary, littleBinary;
+ bigBinary = CProjectHelper.findBinary(testProject, "exebig_g");
+ littleBinary = CProjectHelper.findBinary(testProject, "test_g");
/* These two test used to fail due to pr 23602 */
- assertTrue("Expected 256 Got: " + bigBinary.getData(), bigBinary.getData()==256);
- assertTrue("Expected 196, Got: " + littleBinary.getData(), littleBinary.getData()==196);
- }
-
- /***
- * A very small set of tests to make usre Binary.getCPU() seems to return
- * something sane for the most common exe type (x86) and one other (ppc)
- * This is not a in depth test at all.
- */
- public void testGetCpu() throws CModelException {
- IBinary myBinary;
- myBinary=CProjectHelper.findBinary(testProject, "exebig_g");
-
- assertTrue("Expected: x86 Got: " + myBinary.getCPU(),myBinary.getCPU().equals("x86"));
- myBinary=CProjectHelper.findBinary(testProject, ppcexefile.getLocation().lastSegment());
- assertTrue("Expected: ppc Got: " + myBinary.getCPU(),myBinary.getCPU().equals("ppc"));
-
- }
-
- /****
- * A set of simple tests to make sute getNeededSharedLibs seems to be sane
- */
- public void testGetNeededSharedLibs() throws CModelException {
- IBinary myBinary;
- String[] exelibs={"libsocket.so.2", "libc.so.2"};
- String[] bigexelibs={"libc.so.2"};
- String[] gotlibs;
- ExpectedStrings exp;
- int x;
-
- exp=new ExpectedStrings(exelibs);
- myBinary=CProjectHelper.findBinary(testProject, "test_g");
- gotlibs=myBinary.getNeededSharedLibs();
- for (x=0;x<gotlibs.length;x++) {
- exp.foundString(gotlibs[x]);
- }
- assertTrue(exp.getMissingString(), exp.gotAll());
- assertTrue(exp.getExtraString(), !exp.gotExtra());
-
- exp=new ExpectedStrings(bigexelibs);
- myBinary=CProjectHelper.findBinary(testProject,"exebig_g");
- gotlibs=myBinary.getNeededSharedLibs();
- for (x=0;x<gotlibs.length;x++) {
- exp.foundString(gotlibs[x]);
- }
- assertTrue(exp.getMissingString(), exp.gotAll());
- assertTrue(exp.getExtraString(), !exp.gotExtra());
-
- exp=new ExpectedStrings(bigexelibs);
- myBinary=CProjectHelper.findBinary(testProject, "libtestlib_g.so");
- gotlibs=myBinary.getNeededSharedLibs();
- for (x=0;x<gotlibs.length;x++) {
- exp.foundString(gotlibs[x]);
- }
- assertTrue(exp.getMissingString(), exp.gotAll());
- assertTrue(exp.getExtraString(), !exp.gotExtra());
-
- }
-
- /****
- * Simple tests for the getSoname method;
- */
- public void testGetSoname() throws CModelException {
- IBinary myBinary;
- String name;
- myBinary=CProjectHelper.findBinary(testProject, "test_g");
- assertTrue(myBinary.getSoname().isEmpty());
-
- myBinary=CProjectHelper.findBinary(testProject, "libtestlib_g.so");
- name=myBinary.getSoname();
- assertNotNull(name);
- assertTrue("Expected: libtestlib_g.so.1 Got: " + name,
- name.equals("libtestlib_g.so.1"));
-
- }
-
- /***
- * Simple tests for getText
- */
- public void testGetText() throws CModelException {
- IBinary bigBinary,littleBinary;
- bigBinary=CProjectHelper.findBinary(testProject, bigexe.getLocation().lastSegment());
- littleBinary=CProjectHelper.findBinary(testProject, exefile.getLocation().lastSegment());
+ assertTrue("Expected 256 Got: " + bigBinary.getData(), bigBinary.getData() == 256);
+ assertTrue("Expected 196, Got: " + littleBinary.getData(), littleBinary.getData() == 196);
+ }
+
+ /***
+ * A very small set of tests to make usre Binary.getCPU() seems to return
+ * something sane for the most common exe type (x86) and one other (ppc)
+ * This is not a in depth test at all.
+ */
+ public void testGetCpu() throws CModelException {
+ IBinary myBinary;
+ myBinary = CProjectHelper.findBinary(testProject, "exebig_g");
+
+ assertTrue("Expected: x86 Got: " + myBinary.getCPU(), myBinary.getCPU().equals("x86"));
+ myBinary = CProjectHelper.findBinary(testProject, ppcexefile.getLocation().lastSegment());
+ assertTrue("Expected: ppc Got: " + myBinary.getCPU(), myBinary.getCPU().equals("ppc"));
+
+ }
+
+ /****
+ * A set of simple tests to make sute getNeededSharedLibs seems to be sane
+ */
+ public void testGetNeededSharedLibs() throws CModelException {
+ IBinary myBinary;
+ String[] exelibs = { "libsocket.so.2", "libc.so.2" };
+ String[] bigexelibs = { "libc.so.2" };
+ String[] gotlibs;
+ ExpectedStrings exp;
+ int x;
+
+ exp = new ExpectedStrings(exelibs);
+ myBinary = CProjectHelper.findBinary(testProject, "test_g");
+ gotlibs = myBinary.getNeededSharedLibs();
+ for (x = 0; x < gotlibs.length; x++) {
+ exp.foundString(gotlibs[x]);
+ }
+ assertTrue(exp.getMissingString(), exp.gotAll());
+ assertTrue(exp.getExtraString(), !exp.gotExtra());
+
+ exp = new ExpectedStrings(bigexelibs);
+ myBinary = CProjectHelper.findBinary(testProject, "exebig_g");
+ gotlibs = myBinary.getNeededSharedLibs();
+ for (x = 0; x < gotlibs.length; x++) {
+ exp.foundString(gotlibs[x]);
+ }
+ assertTrue(exp.getMissingString(), exp.gotAll());
+ assertTrue(exp.getExtraString(), !exp.gotExtra());
+
+ exp = new ExpectedStrings(bigexelibs);
+ myBinary = CProjectHelper.findBinary(testProject, "libtestlib_g.so");
+ gotlibs = myBinary.getNeededSharedLibs();
+ for (x = 0; x < gotlibs.length; x++) {
+ exp.foundString(gotlibs[x]);
+ }
+ assertTrue(exp.getMissingString(), exp.gotAll());
+ assertTrue(exp.getExtraString(), !exp.gotExtra());
+
+ }
+
+ /****
+ * Simple tests for the getSoname method;
+ */
+ public void testGetSoname() throws CModelException {
+ IBinary myBinary;
+ String name;
+ myBinary = CProjectHelper.findBinary(testProject, "test_g");
+ assertTrue(myBinary.getSoname().isEmpty());
+
+ myBinary = CProjectHelper.findBinary(testProject, "libtestlib_g.so");
+ name = myBinary.getSoname();
+ assertNotNull(name);
+ assertTrue("Expected: libtestlib_g.so.1 Got: " + name, name.equals("libtestlib_g.so.1"));
+
+ }
+
+ /***
+ * Simple tests for getText
+ */
+ public void testGetText() throws CModelException {
+ IBinary bigBinary, littleBinary;
+ bigBinary = CProjectHelper.findBinary(testProject, bigexe.getLocation().lastSegment());
+ littleBinary = CProjectHelper.findBinary(testProject, exefile.getLocation().lastSegment());
/* These two asserts used to fail due to pr 23602 */
- assertTrue("Expected 886, Got: " + bigBinary.getText(), bigBinary.getText()==886);
- assertTrue("Expected 1223, Got: " + littleBinary.getText(), littleBinary.getText()==1223);
+ assertTrue("Expected 886, Got: " + bigBinary.getText(), bigBinary.getText() == 886);
+ assertTrue("Expected 1223, Got: " + littleBinary.getText(), littleBinary.getText() == 1223);
+ }
+
+ /***
+ * Simple tests for the hadDebug call
+ */
+ public void testHasDebug() throws CModelException {
+ IBinary myBinary;
+ myBinary = CProjectHelper.findBinary(testProject, "test_g");
+ assertTrue(myBinary.hasDebug());
+ myBinary = CProjectHelper.findBinary(testProject, "libtestlib_g.so");
+ assertTrue(myBinary.hasDebug());
+ myBinary = CProjectHelper.findBinary(testProject, "exetest");
+ assertTrue(!myBinary.hasDebug());
+ }
+
+ /***
+ * Sanity - isBinary and isReadonly should always return true;
+ */
+ public void testisBinRead() throws CModelException {
+ IBinary myBinary;
+ myBinary = CProjectHelper.findBinary(testProject, "test_g");
+ assertTrue(myBinary != null);
+ assertTrue(myBinary.isReadOnly());
+
+ }
+
+ /***
+ * Quick tests to make sure isObject works as expected.
+ */
+ public void testIsObject() throws CModelException {
+ IBinary myBinary;
+ myBinary = CProjectHelper.findObject(testProject, "exetest.o");
+ assertTrue(myBinary.isObject());
+
+ myBinary = CProjectHelper.findBinary(testProject, "test_g");
+ assertTrue(!myBinary.isObject());
+
+ myBinary = CProjectHelper.findBinary(testProject, "libtestlib_g.so");
+ assertTrue(!myBinary.isObject());
+
+ myBinary = CProjectHelper.findBinary(testProject, "exetest");
+ assertTrue(!myBinary.isObject());
+
+ }
+
+ /***
+ * Quick tests to make sure isSharedLib works as expected.
+ */
+ public void testIsSharedLib() throws CModelException {
+ IBinary myBinary;
+
+ myBinary = CProjectHelper.findObject(testProject, "exetest.o");
+ assertTrue(!myBinary.isSharedLib());
+
+ myBinary = CProjectHelper.findBinary(testProject, "libtestlib_g.so");
+ assertTrue(myBinary.isSharedLib());
+
+ myBinary = CProjectHelper.findBinary(testProject, "test_g");
+ assertTrue(!myBinary.isSharedLib());
+
+ myBinary = CProjectHelper.findBinary(testProject, "exetest");
+ assertTrue(!myBinary.isSharedLib());
+
+ }
+
+ /***
+ * Quick tests to make sure isExecutable works as expected.
+ */
+ public void testIsExecutable() throws InterruptedException, CModelException {
+ IBinary myBinary;
+ myBinary = CProjectHelper.findObject(testProject, "exetest.o");
+ assertTrue(!myBinary.isExecutable());
+
+ myBinary = CProjectHelper.findBinary(testProject, "test_g");
+ assertTrue(myBinary.isExecutable());
+
+ myBinary = CProjectHelper.findBinary(testProject, "libtestlib_g.so");
+ assertTrue(!myBinary.isExecutable());
+
+ myBinary = CProjectHelper.findBinary(testProject, "exetest");
+ assertTrue(myBinary.isExecutable());
+
}
-
- /***
- * Simple tests for the hadDebug call
- */
- public void testHasDebug() throws CModelException {
- IBinary myBinary;
- myBinary = CProjectHelper.findBinary(testProject, "test_g");
- assertTrue(myBinary.hasDebug());
- myBinary = CProjectHelper.findBinary(testProject, "libtestlib_g.so");
- assertTrue(myBinary.hasDebug());
- myBinary = CProjectHelper.findBinary(testProject, "exetest");
- assertTrue(!myBinary.hasDebug());
- }
-
- /***
- * Sanity - isBinary and isReadonly should always return true;
- */
- public void testisBinRead() throws CModelException {
- IBinary myBinary;
- myBinary =CProjectHelper.findBinary(testProject, "test_g");
- assertTrue(myBinary != null);
- assertTrue(myBinary.isReadOnly());
-
- }
-
- /***
- * Quick tests to make sure isObject works as expected.
- */
- public void testIsObject() throws CModelException {
- IBinary myBinary;
- myBinary=CProjectHelper.findObject(testProject, "exetest.o");
- assertTrue(myBinary.isObject());
-
-
- myBinary= CProjectHelper.findBinary(testProject, "test_g");
- assertTrue(!myBinary.isObject());
-
- myBinary= CProjectHelper.findBinary(testProject, "libtestlib_g.so");
- assertTrue(!myBinary.isObject());
-
- myBinary= CProjectHelper.findBinary(testProject, "exetest");
- assertTrue(!myBinary.isObject());
-
- }
-
- /***
- * Quick tests to make sure isSharedLib works as expected.
- */
- public void testIsSharedLib() throws CModelException {
- IBinary myBinary;
-
- myBinary=CProjectHelper.findObject(testProject, "exetest.o");
- assertTrue(!myBinary.isSharedLib());
-
- myBinary= CProjectHelper.findBinary(testProject, "libtestlib_g.so");
- assertTrue(myBinary.isSharedLib());
-
- myBinary= CProjectHelper.findBinary(testProject, "test_g");
- assertTrue(!myBinary.isSharedLib());
-
-
- myBinary= CProjectHelper.findBinary(testProject, "exetest");
- assertTrue(!myBinary.isSharedLib());
-
- }
-
- /***
- * Quick tests to make sure isExecutable works as expected.
- */
- public void testIsExecutable() throws InterruptedException, CModelException {
- IBinary myBinary;
- myBinary=CProjectHelper.findObject(testProject, "exetest.o");
- assertTrue(!myBinary.isExecutable());
-
- myBinary=CProjectHelper.findBinary(testProject, "test_g");
- assertTrue(myBinary.isExecutable());
-
- myBinary= CProjectHelper.findBinary(testProject, "libtestlib_g.so");
- assertTrue(!myBinary.isExecutable());
-
-
- myBinary= CProjectHelper.findBinary(testProject, "exetest");
- assertTrue(myBinary.isExecutable());
-
- }
-
- /***
- * Simple sanity test to make sure Binary.isBinary returns true
- *
- */
- public void testIsBinary() throws CoreException,FileNotFoundException,Exception {
- IBinary myBinary;
-
- myBinary=CProjectHelper.findBinary(testProject, "exebig_g");
- assertTrue("A Binary", myBinary != null);
- }
-
-
-
-
+
+ /***
+ * Simple sanity test to make sure Binary.isBinary returns true
+ *
+ */
+ public void testIsBinary() throws CoreException, FileNotFoundException, Exception {
+ IBinary myBinary;
+
+ myBinary = CProjectHelper.findBinary(testProject, "exebig_g");
+ assertTrue("A Binary", myBinary != null);
+ }
+
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/Bug311189.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/Bug311189.java
index 30c70d6d9b9..a91d000aaf2 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/Bug311189.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/Bug311189.java
@@ -62,9 +62,9 @@ public class Bug311189 extends BaseTestCase {
// create a source folder and set it as a source entry
srcFolder.create(true, true, null);
- CoreModel.setRawPathEntries(CoreModel.getDefault().create(project), new IPathEntry[] {sourceEntry}, null);
+ CoreModel.setRawPathEntries(CoreModel.getDefault().create(project), new IPathEntry[] { sourceEntry }, null);
IPathEntry[] rawEntries = CoreModel.getPathEntryStore(project).getRawPathEntries();
- assertTrue ("Path entry unset!", Arrays.asList(rawEntries).contains(sourceEntry));
+ assertTrue("Path entry unset!", Arrays.asList(rawEntries).contains(sourceEntry));
try {
// None-batched resource change, though we do hold a scheduling rule
@@ -88,8 +88,7 @@ public class Bug311189 extends BaseTestCase {
IPathEntryStore store = CoreModel.getPathEntryStore(project);
rawEntries = store.getRawPathEntries();
- assertTrue ("Path entry gone!", Arrays.asList(rawEntries).contains(sourceEntry));
+ assertTrue("Path entry gone!", Arrays.asList(rawEntries).contains(sourceEntry));
}
-
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderBugsTest.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderBugsTest.java
index 65e53fb8424..38b9e9df94f 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderBugsTest.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderBugsTest.java
@@ -36,38 +36,38 @@ public class CModelBuilderBugsTest extends BaseTestCase {
}
private ICProject fCProject;
- private ITranslationUnit fTU;
-
+ private ITranslationUnit fTU;
+
public CModelBuilderBugsTest(String name) {
super(name);
}
-
+
@Override
protected void setUp() throws Exception {
super.setUp();
- fCProject= CProjectHelper.createCProject(getName(), null, IPDOMManager.ID_FAST_INDEXER);
+ fCProject = CProjectHelper.createCProject(getName(), null, IPDOMManager.ID_FAST_INDEXER);
assertNotNull(fCProject);
CProjectHelper.importSourcesFromPlugin(fCProject, CTestPlugin.getDefault().getBundle(), "/resources/cmodel");
- fTU= (ITranslationUnit) CProjectHelper.findElement(fCProject, "CModelBuilderTest.cpp");
+ fTU = (ITranslationUnit) CProjectHelper.findElement(fCProject, "CModelBuilderTest.cpp");
assertNotNull(fTU);
}
@Override
protected void tearDown() throws Exception {
- CProjectHelper.delete(fCProject);
- super.tearDown();
- }
-
+ CProjectHelper.delete(fCProject);
+ super.tearDown();
+ }
+
public void testModelBuilderBug222398() throws Exception {
- IStructure clazz= (IStructure) fTU.getElement("Test");
+ IStructure clazz = (IStructure) fTU.getElement("Test");
assertNotNull(clazz);
- ICElement[] methods= clazz.getChildren();
+ ICElement[] methods = clazz.getChildren();
assertEquals(2, methods.length);
assertEquals("inlined", methods[0].getElementName());
assertEquals("decl", methods[1].getElementName());
-
- INamespace ns= (INamespace) fTU.getElement("nsTest");
- ICElement[] functions= ns.getChildren();
+
+ INamespace ns = (INamespace) fTU.getElement("nsTest");
+ ICElement[] functions = ns.getChildren();
assertEquals(2, functions.length);
assertEquals("inlined", functions[0].getElementName());
assertEquals("decl", functions[1].getElementName());
@@ -79,9 +79,9 @@ public class CModelBuilderBugsTest extends BaseTestCase {
}
public void testModelBuilderBug274490() throws Exception {
- IStructure clazz= (IStructure) fTU.getElement("Bug274490");
+ IStructure clazz = (IStructure) fTU.getElement("Bug274490");
assertNotNull(clazz);
- ICElement[] methods= clazz.getChildren();
+ ICElement[] methods = clazz.getChildren();
assertEquals(2, methods.length);
assertEquals("int", ((IFunctionDeclaration) methods[0]).getReturnType());
assertEquals("const char*", ((IFunctionDeclaration) methods[1]).getReturnType());
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderInactiveCodeTest.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderInactiveCodeTest.java
index 6a21aab1e9b..17e4597a271 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderInactiveCodeTest.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderInactiveCodeTest.java
@@ -35,38 +35,38 @@ public class CModelBuilderInactiveCodeTest extends BaseTestCase {
}
private ICProject fCProject;
- private ITranslationUnit fTU;
-
+ private ITranslationUnit fTU;
+
public CModelBuilderInactiveCodeTest(String name) {
super(name);
}
-
+
@Override
protected void setUp() throws Exception {
super.setUp();
- fCProject= CProjectHelper.createCProject(getName(), null, IPDOMManager.ID_FAST_INDEXER);
+ fCProject = CProjectHelper.createCProject(getName(), null, IPDOMManager.ID_FAST_INDEXER);
assertNotNull(fCProject);
CProjectHelper.importSourcesFromPlugin(fCProject, CTestPlugin.getDefault().getBundle(), "/resources/cmodel");
- fTU= (ITranslationUnit) CProjectHelper.findElement(fCProject, "CModelBuilderInactiveCodeTest.cpp");
+ fTU = (ITranslationUnit) CProjectHelper.findElement(fCProject, "CModelBuilderInactiveCodeTest.cpp");
assertNotNull(fTU);
}
@Override
protected void tearDown() throws Exception {
- CProjectHelper.delete(fCProject);
- super.tearDown();
- }
-
+ CProjectHelper.delete(fCProject);
+ super.tearDown();
+ }
+
public void testPreprocessorNodes() throws Exception {
- ISourceReference e= (ISourceReference) fTU.getElement("include");
+ ISourceReference e = (ISourceReference) fTU.getElement("include");
assertTrue(e instanceof IInclude);
assertFalse(e.isActive());
- e= (ISourceReference) fTU.getElement("MACRO1");
+ e = (ISourceReference) fTU.getElement("MACRO1");
assertTrue(e instanceof IMacro);
assertFalse(e.isActive());
- e= (ISourceReference) fTU.getElement("MACRO2");
+ e = (ISourceReference) fTU.getElement("MACRO2");
assertTrue(e instanceof IMacro);
assertFalse(e.isActive());
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java
index fd0b2b8e46e..568980e01d2 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java
@@ -55,36 +55,36 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
-public class CModelElementsTests extends BaseTestCase {
+public class CModelElementsTests extends BaseTestCase {
private ICProject fCProject;
private IFile headerFile;
private IFile includedFile;
private NullProgressMonitor monitor;
-
+
public static Test suite() {
- TestSuite suite= new TestSuite(CModelElementsTests.class.getName());
+ TestSuite suite = new TestSuite(CModelElementsTests.class.getName());
suite.addTest(new CModelElementsTests("testCModelElements"));
return suite;
- }
-
+ }
+
public CModelElementsTests(String name) {
super(name);
}
-
+
@Override
protected void setUp() throws Exception {
monitor = new NullProgressMonitor();
- fCProject= CProjectHelper.createCCProject("TestProject1", "bin", IPDOMManager.ID_FAST_INDEXER);
+ fCProject = CProjectHelper.createCCProject("TestProject1", "bin", IPDOMManager.ID_FAST_INDEXER);
headerFile = fCProject.getProject().getFile("CModelElementsTest.h");
includedFile = fCProject.getProject().getFile("included.h");
if (!headerFile.exists()) {
- try{
- FileInputStream fileIn = new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/cfiles/CModelElementsTestStart.h")));
- headerFile.create(fileIn,false, monitor);
+ try {
+ FileInputStream fileIn = new FileInputStream(CTestPlugin.getDefault()
+ .getFileInPlugin(new Path("resources/cfiles/CModelElementsTestStart.h")));
+ headerFile.create(fileIn, false, monitor);
FileInputStream includedFileIn = new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/cfiles/included.h")));
- includedFile.create(includedFileIn,false, monitor);
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/cfiles/included.h")));
+ includedFile.create(includedFileIn, false, monitor);
} catch (CoreException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
@@ -95,25 +95,24 @@ public class CModelElementsTests extends BaseTestCase {
waitForIndexer(fCProject);
}
-
@Override
protected void tearDown() {
- CProjectHelper.delete(fCProject);
- }
-
- public void testCModelElements() throws CModelException{
- ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(headerFile);
+ CProjectHelper.delete(fCProject);
+ }
+
+ public void testCModelElements() throws CModelException {
+ ITranslationUnit tu = (ITranslationUnit) CoreModel.getDefault().create(headerFile);
//ITranslationUnit included = (ITranslationUnit)CoreModel.getDefault().create(includedFile);
- // parse the translation unit to get the elements tree
-// tu.parse();
-
+ // parse the translation unit to get the elements tree
+ // tu.parse();
+
// tu ---> include
checkInclude(tu);
-
+
// tu ---> macro
checkMacro(tu);
-
+
// tu ---> namespace: MyPackage
List tuPackages = tu.getChildrenOfType(ICElement.C_NAMESPACE);
INamespace namespace = (INamespace) tuPackages.get(0);
@@ -121,21 +120,21 @@ public class CModelElementsTests extends BaseTestCase {
checkElementOffset(namespace);
checkLineNumbers(namespace, 8, 130);
checkClass(namespace);
-
- checkEnums(namespace);
-
- checkVariables(namespace);
- checkVariableDeclarations(namespace);
-
+ checkEnums(namespace);
+
+ checkVariables(namespace);
+
+ checkVariableDeclarations(namespace);
+
checkFunctions(namespace);
-
+
checkStructs(namespace);
-
+
checkTemplates(namespace);
-
+
checkArrays(tu);
-
+
checkBug180815(tu);
checkBug352350(tu);
}
@@ -144,7 +143,7 @@ public class CModelElementsTests extends BaseTestCase {
private void checkBug180815(IParent parent) throws CModelException {
List structs = parent.getChildrenOfType(ICElement.C_STRUCT);
assertEquals(1, structs.size());
- IStructure struct= (IStructure)structs.get(0);
+ IStructure struct = (IStructure) structs.get(0);
assertEquals("bug180815", struct.getElementName());
assertEquals(2, struct.getChildren().length);
}
@@ -154,37 +153,37 @@ public class CModelElementsTests extends BaseTestCase {
List namespaces = parent.getChildrenOfType(ICElement.C_NAMESPACE);
assertEquals(2, namespaces.size());
for (Object o : namespaces) {
- INamespace namespace = (INamespace)o;
+ INamespace namespace = (INamespace) o;
if (namespace.getElementName().length() == 0) {
assertTrue(namespace.equals(namespace));
}
}
}
-
- private void checkInclude(IParent tu) throws CModelException{
+
+ private void checkInclude(IParent tu) throws CModelException {
List tuIncludes = tu.getChildrenOfType(ICElement.C_INCLUDE);
IInclude inc1 = (IInclude) tuIncludes.get(0);
assertEquals(inc1.getElementName(), "included.h");
checkElementOffset(inc1);
checkLineNumbers(inc1, 2, 2);
}
-
- private void checkMacro(IParent tu) throws CModelException{
+
+ private void checkMacro(IParent tu) throws CModelException {
List tuMacros = tu.getChildrenOfType(ICElement.C_MACRO);
IMacro mac1 = (IMacro) tuMacros.get(0);
assertEquals(mac1.getElementName(), "PRINT");
checkElementOffset(mac1);
checkLineNumbers(mac1, 5, 5);
}
-
- private void checkClass(IParent namespace) throws CModelException{
+
+ private void checkClass(IParent namespace) throws CModelException {
// MyPackage ---> class: Hello
- List nsClasses = namespace.getChildrenOfType(ICElement.C_CLASS);
+ List nsClasses = namespace.getChildrenOfType(ICElement.C_CLASS);
IStructure classHello = (IStructure) nsClasses.get(0);
assertEquals(classHello.getElementName(), "Hello");
checkElementOffset(classHello);
checkLineNumbers(classHello, 12, 53);
-
+
// Hello --> field: int x
List helloFields = classHello.getChildrenOfType(ICElement.C_FIELD);
IField intX = (IField) helloFields.get(0);
@@ -192,11 +191,11 @@ public class CModelElementsTests extends BaseTestCase {
checkElementOffset(intX);
assertEquals(intX.getTypeName(), "int");
checkLineNumbers(intX, 17, 17);
-
- ASTAccessVisibility xVisibility = intX.getVisibility();
+
+ ASTAccessVisibility xVisibility = intX.getVisibility();
if (xVisibility != ASTAccessVisibility.PROTECTED)
fail("visibility should be protected!");
-
+
// Hello ---> method: void setX(int X)
List helloMethods = classHello.getChildrenOfType(ICElement.C_METHOD);
IMethod setX = (IMethod) helloMethods.get(0);
@@ -205,61 +204,63 @@ public class CModelElementsTests extends BaseTestCase {
assertEquals(setX.getReturnType(), "void");
checkLineNumbers(setX, 19, 22);
int setXNumOfParam = setX.getNumberOfParameters();
- if(setXNumOfParam != 1)
+ if (setXNumOfParam != 1)
fail("setX should have one parameter!");
String[] setXParamTypes = setX.getParameterTypes();
String firstParamType = setXParamTypes[0];
assertEquals(firstParamType, "int");
// TODO : check for the inline here
-
+
checkNestedNamespace(classHello);
}
- private void checkNestedNamespace(IParent classHello) throws CModelException{
- // Hello ---> namespace: MyNestedPackage
+
+ private void checkNestedNamespace(IParent classHello) throws CModelException {
+ // Hello ---> namespace: MyNestedPackage
List helloNamespaces = classHello.getChildrenOfType(ICElement.C_NAMESPACE);
INamespace myNestedPackage = (INamespace) helloNamespaces.get(0);
assertEquals(myNestedPackage.getElementName(), "MyNestedPackage");
checkElementOffset(myNestedPackage);
checkLineNumbers(myNestedPackage, 25, 52);
- checkParentNestedClass(myNestedPackage);
+ checkParentNestedClass(myNestedPackage);
checkDerivedNestedClass(myNestedPackage);
}
- private void checkParentNestedClass(IParent myNestedPackage) throws CModelException{
- // MyNestedPackage ---> class: Y
- List nestedClasses = myNestedPackage.getChildrenOfType(ICElement.C_CLASS);
+
+ private void checkParentNestedClass(IParent myNestedPackage) throws CModelException {
+ // MyNestedPackage ---> class: Y
+ List nestedClasses = myNestedPackage.getChildrenOfType(ICElement.C_CLASS);
IStructure classY = (IStructure) nestedClasses.get(0);
assertEquals(classY.getElementName(), "Y");
checkElementOffset(classY);
checkLineNumbers(classY, 28, 35);
-
+
// Y ---> constructor: Y
List yMethods = classY.getChildrenOfType(ICElement.C_METHOD_DECLARATION);
- IMethodDeclaration constructor = (IMethodDeclaration) yMethods.get(0);
+ IMethodDeclaration constructor = (IMethodDeclaration) yMethods.get(0);
assertEquals(constructor.getElementName(), "Y");
checkElementOffset(constructor);
- assertTrue (constructor.isConstructor());
+ assertTrue(constructor.isConstructor());
checkLineNumbers(constructor, 32, 32);
-
+
// Y ---> destructor: ~Y
- IMethodDeclaration destructor = (IMethodDeclaration) yMethods.get(1);
+ IMethodDeclaration destructor = (IMethodDeclaration) yMethods.get(1);
assertEquals(destructor.getElementName(), "~Y");
checkElementOffset(destructor);
- assertTrue (destructor.isDestructor());
+ assertTrue(destructor.isDestructor());
checkLineNumbers(destructor, 34, 34);
// TODO: check for virtual on destructors
-
+
}
-
- private void checkDerivedNestedClass(IParent myNestedPackage) throws CModelException{
- // MyNestedPackage ---> class: X public Y
- List nestedClasses = myNestedPackage.getChildrenOfType(ICElement.C_CLASS);
+
+ private void checkDerivedNestedClass(IParent myNestedPackage) throws CModelException {
+ // MyNestedPackage ---> class: X public Y
+ List nestedClasses = myNestedPackage.getChildrenOfType(ICElement.C_CLASS);
IStructure classX = (IStructure) nestedClasses.get(1);
assertEquals(classX.getElementName(), "X");
checkElementOffset(classX);
checkLineNumbers(classX, 38, 51);
// TODO : Check for base classes here
-
+
// X --> field: B b
List xFieldChildren = classX.getChildrenOfType(ICElement.C_FIELD);
IField bB = (IField) xFieldChildren.get(0);
@@ -267,16 +268,16 @@ public class CModelElementsTests extends BaseTestCase {
checkElementOffset(bB);
assertEquals(bB.getTypeName(), "B");
checkLineNumbers(bB, 42, 42);
- ASTAccessVisibility bVisibility = bB.getVisibility();
+ ASTAccessVisibility bVisibility = bB.getVisibility();
if (bVisibility != ASTAccessVisibility.PRIVATE)
fail("visibility should be private!");
-
- // X ---> constructor chain: X
+
+ // X ---> constructor chain: X
List xMethodChildren = classX.getChildrenOfType(ICElement.C_METHOD);
- IMethod xconstructor = (IMethod) xMethodChildren.get(0);
+ IMethod xconstructor = (IMethod) xMethodChildren.get(0);
assertEquals(xconstructor.getElementName(), "X");
checkElementOffset(xconstructor);
- assertTrue (xconstructor.isConstructor());
+ assertTrue(xconstructor.isConstructor());
checkLineNumbers(xconstructor, 46, 48);
// X ---> method declaration: doNothing
@@ -287,15 +288,15 @@ public class CModelElementsTests extends BaseTestCase {
assertEquals(xDoNothing.getReturnType(), "int");
checkLineNumbers(xDoNothing, 50, 50);
}
-
- private void checkEnums(IParent namespace) throws CModelException{
+
+ private void checkEnums(IParent namespace) throws CModelException {
// MyPackage ---> enum: Noname
- List nsEnums = namespace.getChildrenOfType(ICElement.C_ENUMERATION);
+ List nsEnums = namespace.getChildrenOfType(ICElement.C_ENUMERATION);
IEnumeration enumaration = (IEnumeration) nsEnums.get(0);
assertEquals(enumaration.getElementName(), "");
checkElementOffset(enumaration);
checkLineNumbers(enumaration, 57, 61);
-
+
// enum ---> enumerator: first = 1
List enumEnumerators = enumaration.getChildrenOfType(ICElement.C_ENUMERATOR);
IEnumerator first = (IEnumerator) enumEnumerators.get(0);
@@ -311,13 +312,13 @@ public class CModelElementsTests extends BaseTestCase {
checkElementOffset(third);
assertEquals(third.getElementName(), "third");
checkElementOffset(third);
-
+
// MyPackage ---> enum: MyEnum
IEnumeration myEnum = (IEnumeration) nsEnums.get(1);
assertEquals(myEnum.getElementName(), "MyEnum");
checkElementOffset(myEnum);
checkLineNumbers(myEnum, 64, 67);
-
+
// enum ---> enumerator: first
List myEnumEnumerators = myEnum.getChildrenOfType(ICElement.C_ENUMERATOR);
IEnumerator f = (IEnumerator) myEnumEnumerators.get(0);
@@ -333,7 +334,7 @@ public class CModelElementsTests extends BaseTestCase {
checkElementOffset(t);
}
- private void checkVariables(IParent namespace) throws CModelException{
+ private void checkVariables(IParent namespace) throws CModelException {
// MyPackage ---> int v
List nsVars = namespace.getChildrenOfType(ICElement.C_VARIABLE);
IVariable var1 = (IVariable) nsVars.get(0);
@@ -341,7 +342,7 @@ public class CModelElementsTests extends BaseTestCase {
checkElementOffset(var1);
assertEquals(var1.getTypeName(), "int");
checkLineNumbers(var1, 71, 71);
-
+
// MyPackage ---> unsigned long vuLong
IVariable var2 = (IVariable) nsVars.get(1);
assertEquals(var2.getElementName(), "vuLong");
@@ -355,16 +356,16 @@ public class CModelElementsTests extends BaseTestCase {
checkElementOffset(var3);
assertEquals(var3.getTypeName(), "unsigned short");
checkLineNumbers(var3, 75, 75);
-
+
// MyPackage ---> function pointer: orig_malloc_hook
IVariable vDecl2 = (IVariable) nsVars.get(3);
assertEquals(vDecl2.getElementName(), "orig_malloc_hook");
checkElementOffset(vDecl2);
- assertEquals(vDecl2.getTypeName(), new String ("void*(*)(const char*, int, int)"));
+ assertEquals(vDecl2.getTypeName(), new String("void*(*)(const char*, int, int)"));
checkLineNumbers(vDecl2, 81, 81);
}
- private void checkVariableDeclarations(IParent namespace) throws CModelException{
+ private void checkVariableDeclarations(IParent namespace) throws CModelException {
// MyPackage ---> extern int evar
List nsVarDecls = namespace.getChildrenOfType(ICElement.C_VARIABLE_DECLARATION);
IVariableDeclaration vDecl1 = (IVariableDeclaration) nsVarDecls.get(0);
@@ -373,8 +374,8 @@ public class CModelElementsTests extends BaseTestCase {
assertEquals(vDecl1.getTypeName(), "int");
checkLineNumbers(vDecl1, 79, 79);
}
-
- private void checkFunctions(IParent namespace) throws CModelException{
+
+ private void checkFunctions(IParent namespace) throws CModelException {
List nsFunctionDeclarations = namespace.getChildrenOfType(ICElement.C_FUNCTION_DECLARATION);
// MyPackage ---> function: void foo()
@@ -383,7 +384,7 @@ public class CModelElementsTests extends BaseTestCase {
checkElementOffset(f1);
assertEquals(f1.getReturnType(), "void");
checkLineNumbers(f1, 85, 85);
-
+
// MyPackage ---> function: char* foo(int&, char**)
IFunctionDeclaration f2 = (IFunctionDeclaration) nsFunctionDeclarations.get(1);
assertEquals(f2.getElementName(), "foo");
@@ -391,26 +392,26 @@ public class CModelElementsTests extends BaseTestCase {
assertEquals(f2.getReturnType(), "char*");
checkLineNumbers(f2, 87, 88);
int fooNumOfParam = f2.getNumberOfParameters();
- if(fooNumOfParam != 2)
+ if (fooNumOfParam != 2)
fail("foo should have two parameter!");
String[] paramTypes = f2.getParameterTypes();
assertEquals(paramTypes[0], "int&");
assertEquals(paramTypes[1], "char**");
-
- // MyPackage ---> function: void boo() {}
+
+ // MyPackage ---> function: void boo() {}
List nsFunctions = namespace.getChildrenOfType(ICElement.C_FUNCTION);
- IFunction f3 = (IFunction) nsFunctions.get(0);
+ IFunction f3 = (IFunction) nsFunctions.get(0);
assertEquals(f3.getElementName(), "boo");
checkElementOffset(f3);
assertEquals(f3.getReturnType(), "void");
checkLineNumbers(f3, 90, 92);
}
- private void checkStructs(IParent namespace) throws CModelException{
+ private void checkStructs(IParent namespace) throws CModelException {
// struct with name
List nsStructs = namespace.getChildrenOfType(ICElement.C_STRUCT);
IStructure struct1 = (IStructure) nsStructs.get(0);
- assertEquals(struct1.getElementName(), new String ("MyStruct"));
+ assertEquals(struct1.getElementName(), new String("MyStruct"));
checkElementOffset(struct1);
checkLineNumbers(struct1, 95, 97);
List struct1Fields = struct1.getChildrenOfType(ICElement.C_FIELD);
@@ -419,21 +420,21 @@ public class CModelElementsTests extends BaseTestCase {
checkElementOffset(field1);
assertEquals(field1.getTypeName(), "int");
checkLineNumbers(field1, 96, 96);
-
- if(field1.getVisibility() != ASTAccessVisibility.PUBLIC)
+
+ if (field1.getVisibility() != ASTAccessVisibility.PUBLIC)
fail("field visibility should be public!");
-
+
// struct no name
IStructure struct2;
List nsTypeDefs = namespace.getChildrenOfType(ICElement.C_TYPEDEF);
ITypeDef td = (ITypeDef) nsTypeDefs.get(1);
if (td instanceof IParent) {
// nested in typedef decl
- struct2 = (IStructure) ((IParent)td).getChildren()[0];
+ struct2 = (IStructure) ((IParent) td).getChildren()[0];
} else {
struct2 = (IStructure) nsStructs.get(1);
}
- assertEquals(struct2.getElementName(), new String (""));
+ assertEquals(struct2.getElementName(), new String(""));
checkElementOffset(struct2);
checkLineNumbers(struct2, 101, 103);
List struct2Fields = struct2.getChildrenOfType(ICElement.C_FIELD);
@@ -442,19 +443,19 @@ public class CModelElementsTests extends BaseTestCase {
checkElementOffset(field2);
assertEquals(field2.getTypeName(), "int");
checkLineNumbers(field2, 102, 102);
- if(field2.getVisibility() != ASTAccessVisibility.PUBLIC)
+ if (field2.getVisibility() != ASTAccessVisibility.PUBLIC)
fail("field visibility should be public!");
-
+
// typedefs
ITypeDef td1 = (ITypeDef) nsTypeDefs.get(0);
- assertEquals(td1.getElementName(), new String ("myStruct"));
+ assertEquals(td1.getElementName(), new String("myStruct"));
checkElementOffset(td1);
- assertEquals(td1.getTypeName(), new String ("struct MyStruct"));
+ assertEquals(td1.getTypeName(), new String("struct MyStruct"));
checkLineNumbers(td1, 99, 99);
ITypeDef td2 = (ITypeDef) nsTypeDefs.get(1);
- assertEquals(td2.getElementName(), new String ("myTypedef"));
+ assertEquals(td2.getElementName(), new String("myTypedef"));
checkElementOffset(td2);
- assertEquals(td2.getTypeName(), new String ("struct"));
+ assertEquals(td2.getTypeName(), new String("struct"));
checkLineNumbers(td2, 103, 103);
// union
@@ -469,35 +470,35 @@ public class CModelElementsTests extends BaseTestCase {
checkElementOffset(field3);
assertEquals(field3.getTypeName(), "int");
checkLineNumbers(field3, 106, 106);
- if(field3.getVisibility() != ASTAccessVisibility.PUBLIC)
+ if (field3.getVisibility() != ASTAccessVisibility.PUBLIC)
fail("field visibility should be public!");
}
- private void checkTemplates(IParent namespace) throws CModelException{
+ private void checkTemplates(IParent namespace) throws CModelException {
// template function
List functionTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION_DECLARATION);
- IFunctionTemplateDeclaration ft = (IFunctionTemplateDeclaration)functionTemplates.get(0);
+ IFunctionTemplateDeclaration ft = (IFunctionTemplateDeclaration) functionTemplates.get(0);
assertEquals(ft.getElementName(), "aTemplatedFunction");
checkElementOffset(ft);
ft.getTemplateSignature();
assertEquals(ft.getTemplateSignature(), "aTemplatedFunction<A, B>(B) : A");
checkLineNumbers(ft, 112, 113);
-
+
// template method
List nsClasses = namespace.getChildrenOfType(ICElement.C_CLASS);
IStructure enclosingClass = (IStructure) nsClasses.get(1);
checkLineNumbers(enclosingClass, 115, 120);
List methodTemplates = enclosingClass.getChildrenOfType(ICElement.C_TEMPLATE_METHOD_DECLARATION);
- IMethodTemplateDeclaration mt = (IMethodTemplateDeclaration)methodTemplates.get(0);
+ IMethodTemplateDeclaration mt = (IMethodTemplateDeclaration) methodTemplates.get(0);
assertEquals(mt.getElementName(), "aTemplatedMethod");
checkElementOffset(mt);
assertEquals(mt.getTemplateSignature(), "aTemplatedMethod<A, B>(B) : A");
- checkLineNumbers(mt, 118, 119 );
+ checkLineNumbers(mt, 118, 119);
assertEquals(mt.getVisibility(), ASTAccessVisibility.PUBLIC);
-
+
// template class
List classTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_CLASS);
- IStructureTemplate ct = (IStructureTemplate)classTemplates.get(0);
+ IStructureTemplate ct = (IStructureTemplate) classTemplates.get(0);
assertEquals(ct.getElementName(), "myarray");
checkElementOffset(ct);
assertEquals(ct.getTemplateSignature(), "myarray<T, Tibor>");
@@ -505,7 +506,7 @@ public class CModelElementsTests extends BaseTestCase {
// template struct
List structTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT);
- IStructureTemplate st = (IStructureTemplate)structTemplates.get(0);
+ IStructureTemplate st = (IStructureTemplate) structTemplates.get(0);
assertEquals(st.getElementName(), "mystruct");
checkElementOffset(st);
assertEquals(st.getTemplateSignature(), "mystruct<T, Tibor>");
@@ -514,15 +515,15 @@ public class CModelElementsTests extends BaseTestCase {
// moved to failed tests
// also commented in the source file
// template variable
-// ArrayList variableTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_VARIABLE);
-// VariableTemplate vt = (VariableTemplate)variableTemplates.get(0);
-// assertEquals(vt.getElementName(), "default_alloc_template<__threads,__inst>::_S_start_free");
-// checkElementOffset(mac1);
-// assertEquals(vt.getTemplateSignature(), "default_alloc_template<__threads,__inst>::_S_start_free<bool, int> : char*");
-// checkLineNumbers(vt, 128, 129);
+ // ArrayList variableTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_VARIABLE);
+ // VariableTemplate vt = (VariableTemplate)variableTemplates.get(0);
+ // assertEquals(vt.getElementName(), "default_alloc_template<__threads,__inst>::_S_start_free");
+ // checkElementOffset(mac1);
+ // assertEquals(vt.getTemplateSignature(), "default_alloc_template<__threads,__inst>::_S_start_free<bool, int> : char*");
+ // checkLineNumbers(vt, 128, 129);
}
-
- private void checkArrays(IParent tu) throws CModelException{
+
+ private void checkArrays(IParent tu) throws CModelException {
// array variable
List variables = tu.getChildrenOfType(ICElement.C_VARIABLE);
IVariable arrayVar = (IVariable) variables.get(0);
@@ -530,43 +531,44 @@ public class CModelElementsTests extends BaseTestCase {
checkElementOffset(arrayVar);
assertEquals(arrayVar.getTypeName(), "int[][]");
checkLineNumbers(arrayVar, 133, 133);
-
+
// array parameter in function main
List functions = tu.getChildrenOfType(ICElement.C_FUNCTION);
- IFunction mainFunction = (IFunction) functions.get(0);
+ IFunction mainFunction = (IFunction) functions.get(0);
assertEquals(mainFunction.getElementName(), "main");
checkElementOffset(mainFunction);
assertEquals(mainFunction.getReturnType(), "int");
checkLineNumbers(mainFunction, 134, 136);
int NumOfParam = mainFunction.getNumberOfParameters();
- if(NumOfParam != 2)
+ if (NumOfParam != 2)
fail("main should have two parameter!");
String[] paramTypes = mainFunction.getParameterTypes();
assertEquals(paramTypes[0], "int");
assertEquals(paramTypes[1], "char*[]");
-
+
}
+
private void checkLineNumbers(ICElement element, int startLine, int endLine) throws CModelException {
- ISourceRange range = ((ISourceReference)element).getSourceRange();
+ ISourceRange range = ((ISourceReference) element).getSourceRange();
assertEquals(startLine, range.getStartLine());
- assertEquals(endLine, range.getEndLine());
+ assertEquals(endLine, range.getEndLine());
}
+
private void checkElementOffset(ICElement element) throws CModelException {
String name = element.getElementName();
- ISourceRange range = ((ISourceReference)element).getSourceRange();
- if(name.length() > 0 ){
- assertTrue (range.getStartPos() <= range.getIdStartPos());
- assertEquals (range.getIdLength(), name.length());
- }
- else{
- assertEquals (range.getStartPos(), range.getIdStartPos());
- if(element instanceof ITypeDef)
- assertEquals (range.getIdLength(), ((ITypeDef)element).getTypeName().length());
- else if(element instanceof IEnumeration)
- assertEquals (range.getIdLength(), ((IEnumeration)element).getTypeName().length());
- else if(element instanceof IStructure)
- assertEquals (range.getIdLength(), ((IStructure)element).getTypeName().length());
+ ISourceRange range = ((ISourceReference) element).getSourceRange();
+ if (name.length() > 0) {
+ assertTrue(range.getStartPos() <= range.getIdStartPos());
+ assertEquals(range.getIdLength(), name.length());
+ } else {
+ assertEquals(range.getStartPos(), range.getIdStartPos());
+ if (element instanceof ITypeDef)
+ assertEquals(range.getIdLength(), ((ITypeDef) element).getTypeName().length());
+ else if (element instanceof IEnumeration)
+ assertEquals(range.getIdLength(), ((IEnumeration) element).getTypeName().length());
+ else if (element instanceof IStructure)
+ assertEquals(range.getIdLength(), ((IStructure) element).getTypeName().length());
}
-
+
}
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelExceptionTest.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelExceptionTest.java
index e08f5ebfaf0..4c547caa670 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelExceptionTest.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelExceptionTest.java
@@ -24,14 +24,14 @@ import org.eclipse.core.runtime.CoreException;
/**
* CModelExceptionTest
- *
+ *
* @author Judy N. Green
* @since Jul 19, 2002
*/
public class CModelExceptionTest extends TestCase {
- // Shared values setup and torn down
- private CModelStatus cModelStatus;
- private CoreException coreException;
+ // Shared values setup and torn down
+ private CModelStatus cModelStatus;
+ private CoreException coreException;
/**
* Constructor for TestCModelException.
@@ -40,66 +40,66 @@ public class CModelExceptionTest extends TestCase {
public CModelExceptionTest(String name) {
super(name);
}
-
- /**
- * Sets up the test fixture.
- *
- * Called before every test case method.
- *
- * Example code test the packages in the project
- * "com.qnx.tools.ide.cdt.core"
- */
- @Override
+
+ /**
+ * Sets up the test fixture.
+ *
+ * Called before every test case method.
+ *
+ * Example code test the packages in the project
+ * "com.qnx.tools.ide.cdt.core"
+ */
+ @Override
protected void setUp() {
- // create shared resources and setup the test fixture
- cModelStatus = new CModelStatus();
- coreException = new CoreException(cModelStatus);
- }
-
- /**
- * Tears down the test fixture.
- *
- * Called after every test case method.
- */
- @Override
+ // create shared resources and setup the test fixture
+ cModelStatus = new CModelStatus();
+ coreException = new CoreException(cModelStatus);
+ }
+
+ /**
+ * Tears down the test fixture.
+ *
+ * Called after every test case method.
+ */
+ @Override
protected void tearDown() {
- // release resources here and clean-up
- }
-
- public static TestSuite suite() {
- return new TestSuite(CModelExceptionTest.class);
- }
-
- public static void main (String[] args){
- junit.textui.TestRunner.run(suite());
- }
-
- public void testCreationNoStatus(){
- CModelException testException = new CModelException(coreException);
- // should be the same object inside
- assertTrue("Object compare failed", testException.getException() == coreException);
- }
- public void testCreationWithStatus(){
- CModelException testException = new CModelException(coreException,
- ICModelStatusConstants.INDEX_OUT_OF_BOUNDS);
- // should not be null
- assertTrue("TestException.getStatus() is null", (testException.getStatus() != null));
-
- // should have the same status as was set on creation
- assertTrue("Object compare failed", testException.getStatus().getCode() == ICModelStatusConstants.INDEX_OUT_OF_BOUNDS);
- }
-
- public void testElementDoesNotExist(){
- CModelException testException = new CModelException(coreException,
- ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST);
- // should not exist since this is the value we set on creation
- assertTrue("Object unexpectedly exists", testException.doesNotExist());
- }
-
- public void testElementExists(){
- CModelException testException = new CModelException(coreException,
- ICModelStatusConstants.INVALID_CONTENTS);
- // should not exist since this is the value we set on creation
- assertTrue("Object unexpectedly does not exist", !testException.doesNotExist());
- }
+ // release resources here and clean-up
+ }
+
+ public static TestSuite suite() {
+ return new TestSuite(CModelExceptionTest.class);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public void testCreationNoStatus() {
+ CModelException testException = new CModelException(coreException);
+ // should be the same object inside
+ assertTrue("Object compare failed", testException.getException() == coreException);
+ }
+
+ public void testCreationWithStatus() {
+ CModelException testException = new CModelException(coreException, ICModelStatusConstants.INDEX_OUT_OF_BOUNDS);
+ // should not be null
+ assertTrue("TestException.getStatus() is null", (testException.getStatus() != null));
+
+ // should have the same status as was set on creation
+ assertTrue("Object compare failed",
+ testException.getStatus().getCode() == ICModelStatusConstants.INDEX_OUT_OF_BOUNDS);
+ }
+
+ public void testElementDoesNotExist() {
+ CModelException testException = new CModelException(coreException,
+ ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST);
+ // should not exist since this is the value we set on creation
+ assertTrue("Object unexpectedly exists", testException.doesNotExist());
+ }
+
+ public void testElementExists() {
+ CModelException testException = new CModelException(coreException, ICModelStatusConstants.INVALID_CONTENTS);
+ // should not exist since this is the value we set on creation
+ assertTrue("Object unexpectedly does not exist", !testException.doesNotExist());
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelIdentifierTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelIdentifierTests.java
index 0c924e35681..8dcf372aa3c 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelIdentifierTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelIdentifierTests.java
@@ -37,7 +37,7 @@ import org.eclipse.core.runtime.Path;
/**
* Tests for CModel identifier API.
- *
+ *
* @see ICElement#getHandleIdentifier()
* @see CoreModel#create(String)
*
@@ -55,14 +55,14 @@ public class CModelIdentifierTests extends BaseTestCase {
@Override
protected void setUp() throws Exception {
// reusing project setup from CModelElementsTests
- NullProgressMonitor monitor= new NullProgressMonitor();
- fCProject= CProjectHelper.createCCProject("CModelIdentifierTests", "bin", IPDOMManager.ID_FAST_INDEXER);
+ NullProgressMonitor monitor = new NullProgressMonitor();
+ fCProject = CProjectHelper.createCCProject("CModelIdentifierTests", "bin", IPDOMManager.ID_FAST_INDEXER);
fHeaderFile = fCProject.getProject().getFile("CModelIdentifierTests.h");
if (!fHeaderFile.exists()) {
- try{
- FileInputStream fileIn = new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/cfiles/CModelElementsTestStart.h")));
- fHeaderFile.create(fileIn,false, monitor);
+ try {
+ FileInputStream fileIn = new FileInputStream(CTestPlugin.getDefault()
+ .getFileInPlugin(new Path("resources/cfiles/CModelElementsTestStart.h")));
+ fHeaderFile.create(fileIn, false, monitor);
} catch (CoreException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
@@ -75,41 +75,42 @@ public class CModelIdentifierTests extends BaseTestCase {
@Override
protected void tearDown() {
CProjectHelper.delete(fCProject);
- }
+ }
public void testIdentifierConsistency() throws Exception {
- ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(fHeaderFile);
+ ITranslationUnit tu = (ITranslationUnit) CoreModel.getDefault().create(fHeaderFile);
- final String cModelIdentifier= tu.getCModel().getHandleIdentifier();
+ final String cModelIdentifier = tu.getCModel().getHandleIdentifier();
assertNotNull(cModelIdentifier);
assertEquals(tu.getCModel(), CoreModel.create(cModelIdentifier));
-
- final String cProjectIdentifier= tu.getCProject().getHandleIdentifier();
+
+ final String cProjectIdentifier = tu.getCProject().getHandleIdentifier();
assertNotNull(cProjectIdentifier);
assertEquals(tu.getCProject(), CoreModel.create(cProjectIdentifier));
- final String tUnitIdentifier= tu.getHandleIdentifier();
+ final String tUnitIdentifier = tu.getHandleIdentifier();
assertNotNull(tUnitIdentifier);
assertEquals(tu, CoreModel.create(tUnitIdentifier));
- final List elements= new ArrayList();
- final List identifiers= new ArrayList();
- ICElementVisitor visitor= new ICElementVisitor() {
+ final List elements = new ArrayList();
+ final List identifiers = new ArrayList();
+ ICElementVisitor visitor = new ICElementVisitor() {
@Override
public boolean visit(ICElement element) throws CoreException {
elements.add(element);
identifiers.add(element.getHandleIdentifier());
return true;
- }};
+ }
+ };
tu.accept(visitor);
-
+
assertEquals(elements.size(), identifiers.size());
- int size= elements.size();
+ int size = elements.size();
for (int i = 0; i < size; i++) {
- ICElement expected= (ICElement) elements.get(i);
- String identifier= (String) identifiers.get(i);
- assertNotNull("Could not create identifier for element: "+ expected, identifier);
- ICElement actual= CoreModel.create(identifier);
+ ICElement expected = (ICElement) elements.get(i);
+ String identifier = (String) identifiers.get(i);
+ assertNotNull("Could not create identifier for element: " + expected, identifier);
+ ICElement actual = CoreModel.create(identifier);
assertNotNull("Cannot create element '" + expected + "' from identifier: " + identifier, actual);
assertEquals(expected.getElementName(), actual.getElementName());
assertEquals(expected.getElementType(), actual.getElementType());
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java
index ca8e0bd4dec..5e697161ddc 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java
@@ -64,398 +64,395 @@ import org.eclipse.ui.wizards.datatransfer.ImportOperation;
import org.osgi.framework.Bundle;
/**
- * This file contains a set of generic tests for the core C model. Nothing
+ * This file contains a set of generic tests for the core C model. Nothing
* exotic, but should be a small sanity set of tests.
*/
public class CModelTests extends TestCase {
- IWorkspace workspace;
- IWorkspaceRoot root;
- IProject project_c, project_cc;
- NullProgressMonitor monitor;
-
- /**
- * Constructor for CModelTests.
- * @param name
- */
- public CModelTests(String name) {
- super(name);
- }
-
- /**
- * Sets up the test fixture.
- *
- * Called before every test case method.
- *
- * Example code test the packages in the project
- * "com.qnx.tools.ide.cdt.core"
- */
- @Override
+ IWorkspace workspace;
+ IWorkspaceRoot root;
+ IProject project_c, project_cc;
+ NullProgressMonitor monitor;
+
+ /**
+ * Constructor for CModelTests.
+ * @param name
+ */
+ public CModelTests(String name) {
+ super(name);
+ }
+
+ /**
+ * Sets up the test fixture.
+ *
+ * Called before every test case method.
+ *
+ * Example code test the packages in the project
+ * "com.qnx.tools.ide.cdt.core"
+ */
+ @Override
protected void setUp() throws Exception {
- /***
- * The test of the tests assume that they have a working workspace
- * and workspace root object to use to create projects/files in,
- * so we need to get them setup first.
- */
- IWorkspaceDescription desc;
- workspace= ResourcesPlugin.getWorkspace();
- root= workspace.getRoot();
- monitor = new NullProgressMonitor();
- if (workspace==null)
- fail("Workspace was not setup");
- if (root==null)
- fail("Workspace root was not setup");
- desc=workspace.getDescription();
+ /***
+ * The test of the tests assume that they have a working workspace
+ * and workspace root object to use to create projects/files in,
+ * so we need to get them setup first.
+ */
+ IWorkspaceDescription desc;
+ workspace = ResourcesPlugin.getWorkspace();
+ root = workspace.getRoot();
+ monitor = new NullProgressMonitor();
+ if (workspace == null)
+ fail("Workspace was not setup");
+ if (root == null)
+ fail("Workspace root was not setup");
+ desc = workspace.getDescription();
desc.setAutoBuilding(false);
workspace.setDescription(desc);
- }
-
- /**
- * Tears down the test fixture.
- *
- * Called after every test case method.
- */
- @Override
+ }
+
+ /**
+ * Tears down the test fixture.
+ *
+ * Called after every test case method.
+ */
+ @Override
protected void tearDown() {
- // release resources here and clean-up
- }
-
- public static TestSuite suite() {
- return new TestSuite(CModelTests.class);
- }
-
- public static void main (String[] args){
- junit.textui.TestRunner.run(suite());
- }
-
-
- /***
- * The follow are a simple set of tests to make usre the HasC/CCNature calls
- * seem to be sane.
- *
- * Assumes that the CProjectHelper.createCProject properly creates a C
- * project with a C nature, but does not add the CC nature.
- * It also assums that the AddCCNature call works
- *
- * @see CProjectHelper#createCProject
- * @see CoreModel#addCCNature
- */
- public void testHasNature() throws CoreException {
- ICProject testProject;
- testProject=CProjectHelper.createCProject("naturetest", "none", IPDOMManager.ID_NO_INDEXER);
- if (testProject==null)
- fail("Unable to create project");
- assertTrue("hasCNature works", CoreModel.hasCNature(testProject.getProject()));
- assertTrue("hasCCNature works without ccnature", !(CoreModel.hasCCNature(testProject.getProject())));
-
-
- CCProjectNature.addCCNature(testProject.getProject(), monitor);
- assertTrue("hasCCNature works", (CoreModel.hasCCNature(testProject.getProject())));
-
- CCProjectNature.removeCCNature(testProject.getProject(), monitor);
- CProjectNature.removeCNature(testProject.getProject(), monitor);
- assertTrue("hasCNature works without cnature", !CoreModel.hasCNature(testProject.getProject()));
- assertTrue("hasCCNature works without ccnature or cnature", !(CoreModel.hasCCNature(testProject.getProject())));
- try{
- testProject.getProject().delete(true,true,monitor);
- }
- catch (CoreException e) {}
- }
-
- /***
- * Simple tests to make sure the models file identification methods seem
- * to work as expected.
- */
- public void testFileType() throws CoreException,FileNotFoundException {
- ICProject testProject;
- testProject=CProjectHelper.createCProject("filetest", "none", IPDOMManager.ID_NO_INDEXER);
- if (testProject==null)
- fail("Unable to create project");
-
- IFile file = testProject.getProject().getFile("exetest_g");
- if (!file.exists()) {
- file.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/exe_g"))),
- false, monitor);
- }
- /***
- * file should be a binary, executable, not shared or archive
- */
- assertTrue("isBinary", CoreModel.getDefault().isBinary(file));
- assertTrue("isExecutable", CoreModel.getDefault().isExecutable(file));
- assertTrue("isSharedLib", !CoreModel.getDefault().isSharedLib(file));
- assertTrue("isArchive", !CoreModel.getDefault().isArchive(file));
- assertTrue("isObject", !CoreModel.getDefault().isObject(file));
- assertTrue("isTranslationUnit", !CoreModel.isTranslationUnit(file));
-
-
- file = testProject.getProject().getFile("exetest.c");
- if (!file.exists()) {
- file.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/main.c"))),
+ // release resources here and clean-up
+ }
+
+ public static TestSuite suite() {
+ return new TestSuite(CModelTests.class);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ /***
+ * The follow are a simple set of tests to make usre the HasC/CCNature calls
+ * seem to be sane.
+ *
+ * Assumes that the CProjectHelper.createCProject properly creates a C
+ * project with a C nature, but does not add the CC nature.
+ * It also assums that the AddCCNature call works
+ *
+ * @see CProjectHelper#createCProject
+ * @see CoreModel#addCCNature
+ */
+ public void testHasNature() throws CoreException {
+ ICProject testProject;
+ testProject = CProjectHelper.createCProject("naturetest", "none", IPDOMManager.ID_NO_INDEXER);
+ if (testProject == null)
+ fail("Unable to create project");
+ assertTrue("hasCNature works", CoreModel.hasCNature(testProject.getProject()));
+ assertTrue("hasCCNature works without ccnature", !(CoreModel.hasCCNature(testProject.getProject())));
+
+ CCProjectNature.addCCNature(testProject.getProject(), monitor);
+ assertTrue("hasCCNature works", (CoreModel.hasCCNature(testProject.getProject())));
+
+ CCProjectNature.removeCCNature(testProject.getProject(), monitor);
+ CProjectNature.removeCNature(testProject.getProject(), monitor);
+ assertTrue("hasCNature works without cnature", !CoreModel.hasCNature(testProject.getProject()));
+ assertTrue("hasCCNature works without ccnature or cnature", !(CoreModel.hasCCNature(testProject.getProject())));
+ try {
+ testProject.getProject().delete(true, true, monitor);
+ } catch (CoreException e) {
+ }
+ }
+
+ /***
+ * Simple tests to make sure the models file identification methods seem
+ * to work as expected.
+ */
+ public void testFileType() throws CoreException, FileNotFoundException {
+ ICProject testProject;
+ testProject = CProjectHelper.createCProject("filetest", "none", IPDOMManager.ID_NO_INDEXER);
+ if (testProject == null)
+ fail("Unable to create project");
+
+ IFile file = testProject.getProject().getFile("exetest_g");
+ if (!file.exists()) {
+ file.create(
+ new FileInputStream(
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/exe_g"))),
+ false, monitor);
+ }
+ /***
+ * file should be a binary, executable, not shared or archive
+ */
+ assertTrue("isBinary", CoreModel.getDefault().isBinary(file));
+ assertTrue("isExecutable", CoreModel.getDefault().isExecutable(file));
+ assertTrue("isSharedLib", !CoreModel.getDefault().isSharedLib(file));
+ assertTrue("isArchive", !CoreModel.getDefault().isArchive(file));
+ assertTrue("isObject", !CoreModel.getDefault().isObject(file));
+ assertTrue("isTranslationUnit", !CoreModel.isTranslationUnit(file));
+
+ file = testProject.getProject().getFile("exetest.c");
+ if (!file.exists()) {
+ file.create(new FileInputStream(CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/main.c"))),
false, monitor);
- }
- /***
- * file should be a translation unit
- */
- assertTrue("isBinary", !CoreModel.getDefault().isBinary(file));
- assertTrue("isExecutable", !CoreModel.getDefault().isExecutable(file));
- assertTrue("isSharedLib", !CoreModel.getDefault().isSharedLib(file));
- assertTrue("isArchive", !CoreModel.getDefault().isArchive(file));
- assertTrue("isObject", !CoreModel.getDefault().isObject(file));
- assertTrue("isTranslationUnit", CoreModel.isTranslationUnit(file));
-
- file = testProject.getProject().getFile("exetest.o");
- if (!file.exists()) {
- file.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/main.o"))),
+ }
+ /***
+ * file should be a translation unit
+ */
+ assertTrue("isBinary", !CoreModel.getDefault().isBinary(file));
+ assertTrue("isExecutable", !CoreModel.getDefault().isExecutable(file));
+ assertTrue("isSharedLib", !CoreModel.getDefault().isSharedLib(file));
+ assertTrue("isArchive", !CoreModel.getDefault().isArchive(file));
+ assertTrue("isObject", !CoreModel.getDefault().isObject(file));
+ assertTrue("isTranslationUnit", CoreModel.isTranslationUnit(file));
+
+ file = testProject.getProject().getFile("exetest.o");
+ if (!file.exists()) {
+ file.create(
+ new FileInputStream(
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/main.o"))),
false, monitor);
- }
- /***
- * file should be a object file unit
- */
- assertTrue("isBinary", CoreModel.getDefault().isBinary(file));
- assertTrue("isExecutable", !CoreModel.getDefault().isExecutable(file));
- assertTrue("isSharedLib", !CoreModel.getDefault().isSharedLib(file));
- assertTrue("isArchive", !CoreModel.getDefault().isArchive(file));
- assertTrue("isObject", CoreModel.getDefault().isObject(file));
- assertTrue("isTranslationUnit", !CoreModel.isTranslationUnit(file));
-
- file = testProject.getProject().getFile("liblibtest_g.so");
- if (!file.exists()) {
- file.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/so.g/libtestlib_g.so"))),
+ }
+ /***
+ * file should be a object file unit
+ */
+ assertTrue("isBinary", CoreModel.getDefault().isBinary(file));
+ assertTrue("isExecutable", !CoreModel.getDefault().isExecutable(file));
+ assertTrue("isSharedLib", !CoreModel.getDefault().isSharedLib(file));
+ assertTrue("isArchive", !CoreModel.getDefault().isArchive(file));
+ assertTrue("isObject", CoreModel.getDefault().isObject(file));
+ assertTrue("isTranslationUnit", !CoreModel.isTranslationUnit(file));
+
+ file = testProject.getProject().getFile("liblibtest_g.so");
+ if (!file.exists()) {
+ file.create(new FileInputStream(
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/so.g/libtestlib_g.so"))),
false, monitor);
- }
- /***
- * file should be a sharedlib/binary file
- */
- assertTrue("isBinary", CoreModel.getDefault().isBinary(file));
- assertTrue("isExecutable", !CoreModel.getDefault().isExecutable(file));
- assertTrue("isSharedLib", CoreModel.getDefault().isSharedLib(file));
- assertTrue("isArchive", !CoreModel.getDefault().isArchive(file));
- assertTrue("isObject", !CoreModel.getDefault().isObject(file));
- assertTrue("isTranslationUnit", !CoreModel.isTranslationUnit(file));
-
- file = testProject.getProject().getFile("liblibtest_g.a");
- if (!file.exists()) {
- file.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/a.g/libtestlib_g.a"))),
+ }
+ /***
+ * file should be a sharedlib/binary file
+ */
+ assertTrue("isBinary", CoreModel.getDefault().isBinary(file));
+ assertTrue("isExecutable", !CoreModel.getDefault().isExecutable(file));
+ assertTrue("isSharedLib", CoreModel.getDefault().isSharedLib(file));
+ assertTrue("isArchive", !CoreModel.getDefault().isArchive(file));
+ assertTrue("isObject", !CoreModel.getDefault().isObject(file));
+ assertTrue("isTranslationUnit", !CoreModel.isTranslationUnit(file));
+
+ file = testProject.getProject().getFile("liblibtest_g.a");
+ if (!file.exists()) {
+ file.create(new FileInputStream(
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/a.g/libtestlib_g.a"))),
false, monitor);
- } else {
- fail("Does not exist?");
- }
- /***
- * file should be a archive file
- */
- assertTrue("isArchive", CoreModel.getDefault().isArchive(file));
- assertTrue("isBinary:", !CoreModel.getDefault().isBinary(file));
- assertTrue("isExecutable", !CoreModel.getDefault().isExecutable(file));
- assertTrue("isSharedLib", !CoreModel.getDefault().isSharedLib(file));
- assertTrue("isArchive", CoreModel.getDefault().isArchive(file));
- assertTrue("isObject", !CoreModel.getDefault().isObject(file));
- assertTrue("isTranslationUnit", !CoreModel.isTranslationUnit(file));
-
-
-
- try{
- testProject.getProject().delete(true,true,monitor);
- }
- catch (CoreException e) {}
- }
-
- /****
- * Some simple tests for isValidTranslationUnitName
- */
- public void testIsValidTranslationUnitName() throws CoreException {
- assertTrue("Invalid C file", !CoreModel.isValidTranslationUnitName(null, "notcfile"));
- assertTrue("Invalid C file", !CoreModel.isValidTranslationUnitName(null, "not.c.file"));
- assertTrue("Invalid C file", !CoreModel.isValidTranslationUnitName(null, "not.ca"));
- assertTrue("Valid C file", CoreModel.isValidTranslationUnitName(null, "areal.c"));
- }
-
- // bug 275609
- public void testSourceExclusionFilters_275609() throws Exception {
- ICProject testProject;
- testProject=CProjectHelper.createCProject("bug257609", "none", IPDOMManager.ID_NO_INDEXER);
- if (testProject==null)
- fail("Unable to create project");
-
- IFolder testFolder = testProject.getProject().getFolder("test");
- testFolder.create(true, true, monitor);
- IFolder subFolder1 = testFolder.getFolder("1");
- subFolder1.create(true, true, monitor);
- IFolder subFolder2 = testFolder.getFolder("2");
- subFolder2.create(true, true, monitor);
- IFile file0 = testFolder.getFile("test0.c");
- file0.create(new ByteArrayInputStream(new byte[0]), true, monitor);
- IFile file1 = subFolder1.getFile("test1.c");
- file1.create(new ByteArrayInputStream(new byte[0]), true, monitor);
- IFile file2 = subFolder2.getFile("test2.c");
- file2.create(new ByteArrayInputStream(new byte[0]), true, monitor);
-
- List<ICElement> cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER);
- assertEquals(1, cSourceRoots.size());
- assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName());
-
- ISourceRoot sourceRoot = (ISourceRoot) cSourceRoots.get(0);
-
- List<ICElement> cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER);
- assertEquals(1, cContainers.size());
- assertEquals("test", cContainers.get(0).getElementName());
-
- ICContainer testContainer = (ICContainer) cContainers.get(0);
-
- List<ICElement> subContainers = testContainer.getChildrenOfType(ICElement.C_CCONTAINER);
- assertEquals(2, subContainers.size());
- assertEquals("1", subContainers.get(0).getElementName());
- assertEquals("2", subContainers.get(1).getElementName());
- Object[] nonCResources= testContainer.getNonCResources();
+ } else {
+ fail("Does not exist?");
+ }
+ /***
+ * file should be a archive file
+ */
+ assertTrue("isArchive", CoreModel.getDefault().isArchive(file));
+ assertTrue("isBinary:", !CoreModel.getDefault().isBinary(file));
+ assertTrue("isExecutable", !CoreModel.getDefault().isExecutable(file));
+ assertTrue("isSharedLib", !CoreModel.getDefault().isSharedLib(file));
+ assertTrue("isArchive", CoreModel.getDefault().isArchive(file));
+ assertTrue("isObject", !CoreModel.getDefault().isObject(file));
+ assertTrue("isTranslationUnit", !CoreModel.isTranslationUnit(file));
+
+ try {
+ testProject.getProject().delete(true, true, monitor);
+ } catch (CoreException e) {
+ }
+ }
+
+ /****
+ * Some simple tests for isValidTranslationUnitName
+ */
+ public void testIsValidTranslationUnitName() throws CoreException {
+ assertTrue("Invalid C file", !CoreModel.isValidTranslationUnitName(null, "notcfile"));
+ assertTrue("Invalid C file", !CoreModel.isValidTranslationUnitName(null, "not.c.file"));
+ assertTrue("Invalid C file", !CoreModel.isValidTranslationUnitName(null, "not.ca"));
+ assertTrue("Valid C file", CoreModel.isValidTranslationUnitName(null, "areal.c"));
+ }
+
+ // bug 275609
+ public void testSourceExclusionFilters_275609() throws Exception {
+ ICProject testProject;
+ testProject = CProjectHelper.createCProject("bug257609", "none", IPDOMManager.ID_NO_INDEXER);
+ if (testProject == null)
+ fail("Unable to create project");
+
+ IFolder testFolder = testProject.getProject().getFolder("test");
+ testFolder.create(true, true, monitor);
+ IFolder subFolder1 = testFolder.getFolder("1");
+ subFolder1.create(true, true, monitor);
+ IFolder subFolder2 = testFolder.getFolder("2");
+ subFolder2.create(true, true, monitor);
+ IFile file0 = testFolder.getFile("test0.c");
+ file0.create(new ByteArrayInputStream(new byte[0]), true, monitor);
+ IFile file1 = subFolder1.getFile("test1.c");
+ file1.create(new ByteArrayInputStream(new byte[0]), true, monitor);
+ IFile file2 = subFolder2.getFile("test2.c");
+ file2.create(new ByteArrayInputStream(new byte[0]), true, monitor);
+
+ List<ICElement> cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER);
+ assertEquals(1, cSourceRoots.size());
+ assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName());
+
+ ISourceRoot sourceRoot = (ISourceRoot) cSourceRoots.get(0);
+
+ List<ICElement> cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER);
+ assertEquals(1, cContainers.size());
+ assertEquals("test", cContainers.get(0).getElementName());
+
+ ICContainer testContainer = (ICContainer) cContainers.get(0);
+
+ List<ICElement> subContainers = testContainer.getChildrenOfType(ICElement.C_CCONTAINER);
+ assertEquals(2, subContainers.size());
+ assertEquals("1", subContainers.get(0).getElementName());
+ assertEquals("2", subContainers.get(1).getElementName());
+ Object[] nonCResources = testContainer.getNonCResources();
assertEquals(0, nonCResources.length);
-
- List<ICElement> tUnits = testContainer.getChildrenOfType(ICElement.C_UNIT);
- assertEquals(1, tUnits.size());
- assertEquals("test0.c", tUnits.get(0).getElementName());
- ICProjectDescription prjDesc= CoreModel.getDefault().getProjectDescription(testProject.getProject(), true);
- ICConfigurationDescription activeCfg= prjDesc.getActiveConfiguration();
+ List<ICElement> tUnits = testContainer.getChildrenOfType(ICElement.C_UNIT);
+ assertEquals(1, tUnits.size());
+ assertEquals("test0.c", tUnits.get(0).getElementName());
+
+ ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(testProject.getProject(), true);
+ ICConfigurationDescription activeCfg = prjDesc.getActiveConfiguration();
assertNotNull(activeCfg);
-
+
// add filter to source entry
ICSourceEntry[] entries = activeCfg.getSourceEntries();
final String sourceEntryName = entries[0].getName();
final IPath[] exclusionPatterns = new IPath[] { new Path("test/*") };
ICSourceEntry entry = new CSourceEntry(sourceEntryName, exclusionPatterns, entries[0].getFlags());
- activeCfg.setSourceEntries(new ICSourceEntry[] {entry});
+ activeCfg.setSourceEntries(new ICSourceEntry[] { entry });
// store the changed configuration
CoreModel.getDefault().setProjectDescription(testProject.getProject(), prjDesc);
-
- cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER);
- assertEquals(1, cSourceRoots.size());
- assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName());
-
- sourceRoot = (ISourceRoot) cSourceRoots.get(0);
-
- cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER);
- assertEquals(1, cContainers.size());
- assertEquals("test", cContainers.get(0).getElementName());
-
- testContainer = (ICContainer) cContainers.get(0);
-
- tUnits = testContainer.getChildrenOfType(ICElement.C_UNIT);
- assertEquals(0, tUnits.size());
-
- subContainers = testContainer.getChildrenOfType(ICElement.C_CCONTAINER);
- assertEquals(0, subContainers.size());
- nonCResources= testContainer.getNonCResources();
+
+ cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER);
+ assertEquals(1, cSourceRoots.size());
+ assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName());
+
+ sourceRoot = (ISourceRoot) cSourceRoots.get(0);
+
+ cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER);
+ assertEquals(1, cContainers.size());
+ assertEquals("test", cContainers.get(0).getElementName());
+
+ testContainer = (ICContainer) cContainers.get(0);
+
+ tUnits = testContainer.getChildrenOfType(ICElement.C_UNIT);
+ assertEquals(0, tUnits.size());
+
+ subContainers = testContainer.getChildrenOfType(ICElement.C_CCONTAINER);
+ assertEquals(0, subContainers.size());
+ nonCResources = testContainer.getNonCResources();
assertEquals(3, nonCResources.length);
assertEquals(subFolder1, nonCResources[0]);
assertEquals(subFolder2, nonCResources[1]);
assertEquals(file0, nonCResources[2]);
-
+
try {
- testProject.getProject().delete(true,true,monitor);
- }
- catch (CoreException e) {}
+ testProject.getProject().delete(true, true, monitor);
+ } catch (CoreException e) {
+ }
}
- // bug 179474
- public void testSourceExclusionFilters_179474() throws Exception {
- ICProject testProject;
- testProject= CProjectHelper.createCProject("bug179474", "none", IPDOMManager.ID_NO_INDEXER);
- if (testProject == null)
- fail("Unable to create project");
-
- IFolder subFolder = testProject.getProject().getFolder("sub");
- subFolder.create(true, true, monitor);
- IFile fileA = testProject.getProject().getFile("a.cpp");
- fileA.create(new ByteArrayInputStream(new byte[0]), true, monitor);
- IFile fileB = subFolder.getFile("b.cpp");
- fileB.create(new ByteArrayInputStream(new byte[0]), true, monitor);
-
- List<ICElement> cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER);
- assertEquals(1, cSourceRoots.size());
- assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName());
-
- ISourceRoot sourceRoot = (ISourceRoot) cSourceRoots.get(0);
-
- List<ICElement> cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER);
- assertEquals(1, cContainers.size());
- assertEquals(subFolder.getName(), cContainers.get(0).getElementName());
-
- ICContainer subContainer = (ICContainer) cContainers.get(0);
-
- List<ICElement> tUnits = subContainer.getChildrenOfType(ICElement.C_UNIT);
- assertEquals(1, tUnits.size());
- assertEquals(fileB.getName(), tUnits.get(0).getElementName());
-
- tUnits = sourceRoot.getChildrenOfType(ICElement.C_UNIT);
- assertEquals(1, tUnits.size());
- assertEquals(fileA.getName(), tUnits.get(0).getElementName());
-
- ICProjectDescription prjDesc= CoreModel.getDefault().getProjectDescription(testProject.getProject(), true);
- ICConfigurationDescription activeCfg= prjDesc.getActiveConfiguration();
+ // bug 179474
+ public void testSourceExclusionFilters_179474() throws Exception {
+ ICProject testProject;
+ testProject = CProjectHelper.createCProject("bug179474", "none", IPDOMManager.ID_NO_INDEXER);
+ if (testProject == null)
+ fail("Unable to create project");
+
+ IFolder subFolder = testProject.getProject().getFolder("sub");
+ subFolder.create(true, true, monitor);
+ IFile fileA = testProject.getProject().getFile("a.cpp");
+ fileA.create(new ByteArrayInputStream(new byte[0]), true, monitor);
+ IFile fileB = subFolder.getFile("b.cpp");
+ fileB.create(new ByteArrayInputStream(new byte[0]), true, monitor);
+
+ List<ICElement> cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER);
+ assertEquals(1, cSourceRoots.size());
+ assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName());
+
+ ISourceRoot sourceRoot = (ISourceRoot) cSourceRoots.get(0);
+
+ List<ICElement> cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER);
+ assertEquals(1, cContainers.size());
+ assertEquals(subFolder.getName(), cContainers.get(0).getElementName());
+
+ ICContainer subContainer = (ICContainer) cContainers.get(0);
+
+ List<ICElement> tUnits = subContainer.getChildrenOfType(ICElement.C_UNIT);
+ assertEquals(1, tUnits.size());
+ assertEquals(fileB.getName(), tUnits.get(0).getElementName());
+
+ tUnits = sourceRoot.getChildrenOfType(ICElement.C_UNIT);
+ assertEquals(1, tUnits.size());
+ assertEquals(fileA.getName(), tUnits.get(0).getElementName());
+
+ ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(testProject.getProject(), true);
+ ICConfigurationDescription activeCfg = prjDesc.getActiveConfiguration();
assertNotNull(activeCfg);
-
+
// add filter to source entry
ICSourceEntry[] entries = activeCfg.getSourceEntries();
final String sourceEntryName = entries[0].getName();
final IPath[] exclusionPatterns = new IPath[] { new Path("**/*.cpp") };
ICSourceEntry entry = new CSourceEntry(sourceEntryName, exclusionPatterns, entries[0].getFlags());
- activeCfg.setSourceEntries(new ICSourceEntry[] {entry});
+ activeCfg.setSourceEntries(new ICSourceEntry[] { entry });
// store the changed configuration
CoreModel.getDefault().setProjectDescription(testProject.getProject(), prjDesc);
-
- cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER);
- assertEquals(1, cSourceRoots.size());
- assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName());
-
- sourceRoot = (ISourceRoot) cSourceRoots.get(0);
-
- cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER);
- assertEquals(1, cContainers.size());
- assertEquals(subFolder.getName(), cContainers.get(0).getElementName());
-
- subContainer = (ICContainer) cContainers.get(0);
-
- tUnits = subContainer.getChildrenOfType(ICElement.C_UNIT);
- assertEquals(0, tUnits.size());
-
- tUnits = sourceRoot.getChildrenOfType(ICElement.C_UNIT);
- assertEquals(0, tUnits.size());
-
- Object[] nonCResources = subContainer.getNonCResources();
+
+ cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER);
+ assertEquals(1, cSourceRoots.size());
+ assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName());
+
+ sourceRoot = (ISourceRoot) cSourceRoots.get(0);
+
+ cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER);
+ assertEquals(1, cContainers.size());
+ assertEquals(subFolder.getName(), cContainers.get(0).getElementName());
+
+ subContainer = (ICContainer) cContainers.get(0);
+
+ tUnits = subContainer.getChildrenOfType(ICElement.C_UNIT);
+ assertEquals(0, tUnits.size());
+
+ tUnits = sourceRoot.getChildrenOfType(ICElement.C_UNIT);
+ assertEquals(0, tUnits.size());
+
+ Object[] nonCResources = subContainer.getNonCResources();
assertEquals(1, nonCResources.length);
assertEquals(fileB, nonCResources[0]);
nonCResources = sourceRoot.getNonCResources();
assertTrue(Arrays.asList(nonCResources).contains(fileA));
-
+
try {
- testProject.getProject().delete(true,true,monitor);
- }
- catch (CoreException e) {}
+ testProject.getProject().delete(true, true, monitor);
+ } catch (CoreException e) {
+ }
}
-
- // bug 294965
- public void testBinaryInProjectRoot_294965() throws Exception {
- ICProject testProject;
- testProject = CProjectHelper.createCProject("bug294965", "none", IPDOMManager.ID_NO_INDEXER);
- if (testProject == null) {
- fail("Unable to create project");
- }
- CProjectHelper.addDefaultBinaryParser(testProject.getProject());
- CProjectHelper.importSourcesFromPlugin(testProject, CTestPlugin.getDefault().getBundle(), "resources/exe/x86/o");
+
+ // bug 294965
+ public void testBinaryInProjectRoot_294965() throws Exception {
+ ICProject testProject;
+ testProject = CProjectHelper.createCProject("bug294965", "none", IPDOMManager.ID_NO_INDEXER);
+ if (testProject == null) {
+ fail("Unable to create project");
+ }
+ CProjectHelper.addDefaultBinaryParser(testProject.getProject());
+ CProjectHelper.importSourcesFromPlugin(testProject, CTestPlugin.getDefault().getBundle(),
+ "resources/exe/x86/o");
testProject.getProject().getFolder("out").create(true, true, monitor);
-
- ICProjectDescription prjDesc= CoreModel.getDefault().getProjectDescription(testProject.getProject(), true);
- ICConfigurationDescription cfg= prjDesc.getActiveConfiguration();
+
+ ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(testProject.getProject(), true);
+ ICConfigurationDescription cfg = prjDesc.getActiveConfiguration();
assertNotNull(cfg);
// add filter to source entry
@@ -469,188 +466,189 @@ public class CModelTests extends TestCase {
// set output entry
ICOutputEntry outputEntry = new COutputEntry(testProject.getProject().getFolder("out"), new IPath[0], 0);
cfg.getBuildSetting().setOutputDirectories(new ICOutputEntry[] { outputEntry });
-
+
assertEquals(outputEntry, cfg.getBuildSetting().getOutputDirectories()[0]);
-
+
// store the changed configuration
CoreModel.getDefault().setProjectDescription(testProject.getProject(), prjDesc, true, monitor);
testProject.close();
testProject.getProject().close(monitor);
testProject.getProject().open(monitor);
- prjDesc= CoreModel.getDefault().getProjectDescription(testProject.getProject(), false);
- cfg= prjDesc.getActiveConfiguration();
+ prjDesc = CoreModel.getDefault().getProjectDescription(testProject.getProject(), false);
+ cfg = prjDesc.getActiveConfiguration();
assertEquals(outputEntry, cfg.getBuildSetting().getOutputDirectories()[0]);
- Object[] nonCResources = testProject.getNonCResources();
+ Object[] nonCResources = testProject.getNonCResources();
assertEquals(7, nonCResources.length);
-
+
try {
- testProject.getProject().delete(true,true,monitor);
- }
- catch (CoreException e) {}
- }
-
- // bug 131165
- public void testPickUpBinariesInNewFolder_131165() throws Exception {
- ICProject testProject;
- testProject = CProjectHelper.createCProject("bug131165", "none", IPDOMManager.ID_NO_INDEXER);
- if (testProject == null) {
- fail("Unable to create project");
- }
- CProjectHelper.addDefaultBinaryParser(testProject.getProject());
-
- final IBinaryContainer bin = testProject.getBinaryContainer();
- assertEquals(0, bin.getBinaries().length);
-
- final boolean binContainerChanged[] = { false };
-
- IElementChangedListener elementChangedListener = new IElementChangedListener() {
- @Override
+ testProject.getProject().delete(true, true, monitor);
+ } catch (CoreException e) {
+ }
+ }
+
+ // bug 131165
+ public void testPickUpBinariesInNewFolder_131165() throws Exception {
+ ICProject testProject;
+ testProject = CProjectHelper.createCProject("bug131165", "none", IPDOMManager.ID_NO_INDEXER);
+ if (testProject == null) {
+ fail("Unable to create project");
+ }
+ CProjectHelper.addDefaultBinaryParser(testProject.getProject());
+
+ final IBinaryContainer bin = testProject.getBinaryContainer();
+ assertEquals(0, bin.getBinaries().length);
+
+ final boolean binContainerChanged[] = { false };
+
+ IElementChangedListener elementChangedListener = new IElementChangedListener() {
+ @Override
public void elementChanged(ElementChangedEvent event) {
- ICElementDelta delta = event.getDelta();
- processDelta(delta);
- }
- private boolean processDelta(ICElementDelta delta) {
- if (delta.getElement().equals(bin)) {
- synchronized (binContainerChanged) {
- binContainerChanged[0] = true;
- binContainerChanged.notify();
- }
- return true;
- }
- ICElementDelta[] childDeltas = delta.getChangedChildren();
- for (ICElementDelta childDelta : childDeltas) {
- if (processDelta(childDelta)) {
- return true;
- }
- }
- return false;
- }
- };
- CoreModel.getDefault().addElementChangedListener(elementChangedListener );
-
- Thread waiter = new Thread() {
- @Override
- public void run() {
- synchronized (binContainerChanged) {
- try {
- binContainerChanged.wait(1000);
- } catch (InterruptedException exc) {
- }
- }
- }
- };
- waiter.start();
- Thread.sleep(50);
-
- // import with folder structure
- importSourcesFromPlugin(testProject, CTestPlugin.getDefault().getBundle(), "resources/exe/x86");
-
- // wait for delta notification
- waiter.join(1000);
-
- assertTrue(binContainerChanged[0]);
- assertEquals(2, bin.getBinaries().length);
-
- try {
- testProject.getProject().delete(true,true,monitor);
- }
- catch (CoreException e) {}
- }
-
- // same as CprojectHelper.importSourcesFromPlugin(), but preserving folder structure
- private static void importSourcesFromPlugin(ICProject project, Bundle bundle, String sources) throws CoreException {
- try {
- String baseDir= FileLocator.toFileURL(FileLocator.find(bundle, new Path(sources), null)).getFile();
- ImportOperation importOp = new ImportOperation(project.getProject().getFullPath(),
- new File(baseDir), FileSystemStructureProvider.INSTANCE, new IOverwriteQuery() {
- @Override
+ ICElementDelta delta = event.getDelta();
+ processDelta(delta);
+ }
+
+ private boolean processDelta(ICElementDelta delta) {
+ if (delta.getElement().equals(bin)) {
+ synchronized (binContainerChanged) {
+ binContainerChanged[0] = true;
+ binContainerChanged.notify();
+ }
+ return true;
+ }
+ ICElementDelta[] childDeltas = delta.getChangedChildren();
+ for (ICElementDelta childDelta : childDeltas) {
+ if (processDelta(childDelta)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ };
+ CoreModel.getDefault().addElementChangedListener(elementChangedListener);
+
+ Thread waiter = new Thread() {
+ @Override
+ public void run() {
+ synchronized (binContainerChanged) {
+ try {
+ binContainerChanged.wait(1000);
+ } catch (InterruptedException exc) {
+ }
+ }
+ }
+ };
+ waiter.start();
+ Thread.sleep(50);
+
+ // import with folder structure
+ importSourcesFromPlugin(testProject, CTestPlugin.getDefault().getBundle(), "resources/exe/x86");
+
+ // wait for delta notification
+ waiter.join(1000);
+
+ assertTrue(binContainerChanged[0]);
+ assertEquals(2, bin.getBinaries().length);
+
+ try {
+ testProject.getProject().delete(true, true, monitor);
+ } catch (CoreException e) {
+ }
+ }
+
+ // same as CprojectHelper.importSourcesFromPlugin(), but preserving folder structure
+ private static void importSourcesFromPlugin(ICProject project, Bundle bundle, String sources) throws CoreException {
+ try {
+ String baseDir = FileLocator.toFileURL(FileLocator.find(bundle, new Path(sources), null)).getFile();
+ ImportOperation importOp = new ImportOperation(project.getProject().getFullPath(), new File(baseDir),
+ FileSystemStructureProvider.INSTANCE, new IOverwriteQuery() {
+ @Override
public String queryOverwrite(String file) {
- return ALL;
- }});
- importOp.setCreateContainerStructure(true);
- importOp.run(new NullProgressMonitor());
- }
- catch (Exception e) {
- throw new CoreException(new Status(IStatus.ERROR, CTestPlugin.PLUGIN_ID, 0, "Import Interrupted", e));
- }
- }
-
- public void testBinaryContainerDeltaAfterCloseProjDeleteBin_349564() throws Exception {
- ICProject testProject;
- testProject = CProjectHelper.createCProject("bug349564", "none", IPDOMManager.ID_NO_INDEXER);
- if (testProject == null) {
- fail("Unable to create project");
- }
- CProjectHelper.addDefaultBinaryParser(testProject.getProject());
-
- final IBinaryContainer bin = testProject.getBinaryContainer();
- assertEquals(0, bin.getBinaries().length);
- // import with folder structure
- importSourcesFromPlugin(testProject, CTestPlugin.getDefault().getBundle(), "resources/exe/x86/o");
- assertEquals(1, bin.getBinaries().length);
- IResource resource = bin.getBinaries()[0].getResource();
-
- final boolean binContainerChanged[] = { false };
-
- IElementChangedListener elementChangedListener = new IElementChangedListener() {
- @Override
+ return ALL;
+ }
+ });
+ importOp.setCreateContainerStructure(true);
+ importOp.run(new NullProgressMonitor());
+ } catch (Exception e) {
+ throw new CoreException(new Status(IStatus.ERROR, CTestPlugin.PLUGIN_ID, 0, "Import Interrupted", e));
+ }
+ }
+
+ public void testBinaryContainerDeltaAfterCloseProjDeleteBin_349564() throws Exception {
+ ICProject testProject;
+ testProject = CProjectHelper.createCProject("bug349564", "none", IPDOMManager.ID_NO_INDEXER);
+ if (testProject == null) {
+ fail("Unable to create project");
+ }
+ CProjectHelper.addDefaultBinaryParser(testProject.getProject());
+
+ final IBinaryContainer bin = testProject.getBinaryContainer();
+ assertEquals(0, bin.getBinaries().length);
+ // import with folder structure
+ importSourcesFromPlugin(testProject, CTestPlugin.getDefault().getBundle(), "resources/exe/x86/o");
+ assertEquals(1, bin.getBinaries().length);
+ IResource resource = bin.getBinaries()[0].getResource();
+
+ final boolean binContainerChanged[] = { false };
+
+ IElementChangedListener elementChangedListener = new IElementChangedListener() {
+ @Override
public void elementChanged(ElementChangedEvent event) {
- ICElementDelta delta = event.getDelta();
- processDelta(delta);
- }
- private boolean processDelta(ICElementDelta delta) {
- if (delta.getElement() instanceof IBinaryContainer) {
- synchronized (binContainerChanged) {
- binContainerChanged[0] = true;
- binContainerChanged.notify();
- }
- return true;
- }
- ICElementDelta[] childDeltas = delta.getChangedChildren();
- for (ICElementDelta childDelta : childDeltas) {
- if (processDelta(childDelta)) {
- return true;
- }
- }
- return false;
- }
- };
-
- Thread waiter = new Thread() {
- @Override
- public void run() {
- synchronized (binContainerChanged) {
- try {
- binContainerChanged.wait(1000);
- } catch (InterruptedException exc) {
- }
- }
- }
- };
-
- CoreModel.getDefault().addElementChangedListener(elementChangedListener);
-
- testProject.close();
- testProject.open(monitor);
-
-
- waiter.start();
- Thread.sleep(50);
-
- workspace.delete(new IResource[] { resource }, false, monitor);
-
- // wait for delta notification
- waiter.join(1000);
-
- assertEquals(0, testProject.getBinaryContainer().getBinaries().length);
- assertTrue(binContainerChanged[0]);
-
- try {
- testProject.getProject().delete(true, true, monitor);
- }
- catch (CoreException e) {}
- }
+ ICElementDelta delta = event.getDelta();
+ processDelta(delta);
+ }
+
+ private boolean processDelta(ICElementDelta delta) {
+ if (delta.getElement() instanceof IBinaryContainer) {
+ synchronized (binContainerChanged) {
+ binContainerChanged[0] = true;
+ binContainerChanged.notify();
+ }
+ return true;
+ }
+ ICElementDelta[] childDeltas = delta.getChangedChildren();
+ for (ICElementDelta childDelta : childDeltas) {
+ if (processDelta(childDelta)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ };
+
+ Thread waiter = new Thread() {
+ @Override
+ public void run() {
+ synchronized (binContainerChanged) {
+ try {
+ binContainerChanged.wait(1000);
+ } catch (InterruptedException exc) {
+ }
+ }
+ }
+ };
+
+ CoreModel.getDefault().addElementChangedListener(elementChangedListener);
+
+ testProject.close();
+ testProject.open(monitor);
+
+ waiter.start();
+ Thread.sleep(50);
+
+ workspace.delete(new IResource[] { resource }, false, monitor);
+
+ // wait for delta notification
+ waiter.join(1000);
+
+ assertEquals(0, testProject.getBinaryContainer().getBinaries().length);
+ assertTrue(binContainerChanged[0]);
+
+ try {
+ testProject.getProject().delete(true, true, monitor);
+ } catch (CoreException e) {
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CPathEntryTest.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CPathEntryTest.java
index b14fd62f80f..371cd15495a 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CPathEntryTest.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CPathEntryTest.java
@@ -54,25 +54,25 @@ public class CPathEntryTest extends BaseTestCase {
void processDelta(ICElementDelta delta) {
if (delta == null) {
- return ;
+ return;
}
int flags = delta.getFlags();
int kind = delta.getKind();
- if (kind == ICElementDelta.CHANGED ) {
+ if (kind == ICElementDelta.CHANGED) {
if ((flags & ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE) != 0) {
count++;
}
}
- ICElementDelta[] affectedChildren= delta.getAffectedChildren();
- for (int i= 0; i < affectedChildren.length; i++) {
+ ICElementDelta[] affectedChildren = delta.getAffectedChildren();
+ for (int i = 0; i < affectedChildren.length; i++) {
processDelta(affectedChildren[i]);
}
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.cdt.core.model.IElementChangedListener#elementChanged(org.eclipse.cdt.core.model.ElementChangedEvent)
*/
@Override
@@ -84,7 +84,7 @@ public class CPathEntryTest extends BaseTestCase {
/**
* Constructor for CModelTests.
- *
+ *
* @param name
*/
public CPathEntryTest(String name) {
@@ -93,9 +93,9 @@ public class CPathEntryTest extends BaseTestCase {
/**
* Sets up the test fixture.
- *
+ *
* Called before every test case method.
- *
+ *
*/
@Override
protected void setUp() throws CoreException {
@@ -107,7 +107,7 @@ public class CPathEntryTest extends BaseTestCase {
/**
* Tears down the test fixture.
- *
+ *
* Called after every test case method.
*/
@Override
@@ -121,7 +121,7 @@ public class CPathEntryTest extends BaseTestCase {
/*******************************************************************************************************************************
* Check if the PathEntry's are generated.
- *
+ *
* @see CProjectHelper#createCProject
*/
public void testCPathEntries() throws CoreException {
@@ -133,7 +133,8 @@ public class CPathEntryTest extends BaseTestCase {
entries = new IPathEntry[3];
entries[0] = CoreModel.newIncludeEntry(new Path(""), null, new Path("/usr/include"), true);
entries[1] = CoreModel.newIncludeEntry(new Path("cpaththest/foo.c"), null, new Path("/usr/include"), true);
- entries[2] = CoreModel.newLibraryEntry(new Path(""), null, new Path("/usr/lib/libc.so.1"), null, null, null, false);
+ entries[2] = CoreModel.newLibraryEntry(new Path(""), null, new Path("/usr/lib/libc.so.1"), null, null, null,
+ false);
testProject.setRawPathEntries(entries, new NullProgressMonitor());
entries = testProject.getResolvedPathEntries();
// We always have at least two entries:
@@ -145,7 +146,7 @@ public class CPathEntryTest extends BaseTestCase {
/*******************************************************************************************************************************
* Check if the PathEntry's are generated.
- *
+ *
* @see CProjectHelper#createCProject
*/
public void testCPathEntriesDelta() throws CoreException {
@@ -153,7 +154,8 @@ public class CPathEntryTest extends BaseTestCase {
IPathEntry[] entries = new IPathEntry[3];
entries[0] = CoreModel.newIncludeEntry(new Path(""), null, new Path("/usr/include"), true);
entries[1] = CoreModel.newIncludeEntry(new Path("foo"), null, new Path("/usr/include"), true);
- entries[2] = CoreModel.newLibraryEntry(new Path(""), null, new Path("/usr/lib/libc.so.1"), null, null, null, false);
+ entries[2] = CoreModel.newLibraryEntry(new Path(""), null, new Path("/usr/lib/libc.so.1"), null, null, null,
+ false);
CElementListener listener = new CElementListener();
CoreModel.getDefault().addElementChangedListener(listener);
testProject.setRawPathEntries(entries, new NullProgressMonitor());
@@ -176,7 +178,8 @@ public class CPathEntryTest extends BaseTestCase {
IPathEntry[] entries = new IPathEntry[3];
entries[0] = CoreModel.newIncludeEntry(new Path(""), null, new Path("/usr/include"), true);
entries[1] = CoreModel.newIncludeEntry(new Path("foo.c"), null, new Path("/usr/include"), true);
- entries[2] = CoreModel.newLibraryEntry(new Path(""), null, new Path("/usr/lib/libc.so.1"), null, null, null, true);
+ entries[2] = CoreModel.newLibraryEntry(new Path(""), null, new Path("/usr/lib/libc.so.1"), null, null,
+ null, true);
return entries;
}
@@ -189,49 +192,50 @@ public class CPathEntryTest extends BaseTestCase {
public IPath getPath() {
return containerID;
}
-
+
};
- CoreModel.setRawPathEntries(testProject, new IPathEntry[]{containerEntry}, new NullProgressMonitor());
- CoreModel.setPathEntryContainer(new ICProject[]{testProject}, container, new NullProgressMonitor());
+ CoreModel.setRawPathEntries(testProject, new IPathEntry[] { containerEntry }, new NullProgressMonitor());
+ CoreModel.setPathEntryContainer(new ICProject[] { testProject }, container, new NullProgressMonitor());
IPathEntry[] entries = testProject.getResolvedPathEntries();
// We always have at least two entries:
// 1) the default sourceEntry becomes the project
// 2) the default outputEntry becomes the project
assertTrue("Expecting 3 pathentries from container", entries.length == (3 + 2));
-
- }
-
+
+ }
+
public void testSetExclusionFilter_Bug197486() throws Exception {
// get project description
- ICProjectDescription prjDesc= CoreModel.getDefault().getProjectDescription(testProject.getProject(), true);
- ICConfigurationDescription activeCfg= prjDesc.getActiveConfiguration();
+ ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(testProject.getProject(), true);
+ ICConfigurationDescription activeCfg = prjDesc.getActiveConfiguration();
assertNotNull(activeCfg);
-
+
// add filter to source entry
ICSourceEntry[] entries = activeCfg.getSourceEntries();
final String sourceEntryName = entries[0].getName();
final IPath[] exclusionPatterns = new IPath[] { new Path("dummy*"), new Path("dummy2/*") };
ICSourceEntry entry = new CSourceEntry(sourceEntryName, exclusionPatterns, entries[0].getFlags());
- activeCfg.setSourceEntries(new ICSourceEntry[] {entry});
-
+ activeCfg.setSourceEntries(new ICSourceEntry[] { entry });
+
// check the modified configuration for the exclusion patterns
checkExclusionPatterns(sourceEntryName, exclusionPatterns, activeCfg);
-
+
// store the changed configuration
CoreModel.getDefault().setProjectDescription(testProject.getProject(), prjDesc);
// check again.
- prjDesc= CoreModel.getDefault().getProjectDescription(testProject.getProject(), false);
- ICConfigurationDescription[] allConfigs= prjDesc.getConfigurations();
+ prjDesc = CoreModel.getDefault().getProjectDescription(testProject.getProject(), false);
+ ICConfigurationDescription[] allConfigs = prjDesc.getConfigurations();
assertEquals(1, allConfigs.length);
checkExclusionPatterns(sourceEntryName, exclusionPatterns, allConfigs[0]);
-
- activeCfg= prjDesc.getActiveConfiguration();
+
+ activeCfg = prjDesc.getActiveConfiguration();
checkExclusionPatterns(sourceEntryName, exclusionPatterns, activeCfg);
}
- private void checkExclusionPatterns(String sourceEntryName, IPath[] exclusionPatterns, ICConfigurationDescription cfg) {
+ private void checkExclusionPatterns(String sourceEntryName, IPath[] exclusionPatterns,
+ ICConfigurationDescription cfg) {
assertNotNull(cfg);
ICSourceEntry[] entries = cfg.getSourceEntries();
@@ -241,7 +245,7 @@ public class CPathEntryTest extends BaseTestCase {
assertEquals(exclusionPatterns.length, actualExclusionPatterns.length);
assertEquals(toSet(exclusionPatterns), toSet(actualExclusionPatterns));
}
-
+
private Set toSet(Object[] array) {
HashSet set = new HashSet();
for (int i = 0; i < array.length; i++) {
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/DeclaratorsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/DeclaratorsTests.java
index 75d912e46f7..c3329c589e7 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/DeclaratorsTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/DeclaratorsTests.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -28,7 +28,6 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.ITypeDef;
import org.eclipse.cdt.core.model.IVariable;
-
/**
* @author bnicolle
*
@@ -40,7 +39,7 @@ public class DeclaratorsTests extends IntegratedCModelTest {
public DeclaratorsTests(String name) {
super(name);
}
-
+
/**
* @see org.eclipse.cdt.internal.core.model.IntegratedCModelTest
*/
@@ -56,72 +55,71 @@ public class DeclaratorsTests extends IntegratedCModelTest {
public String getSourcefileResource() {
return "DeclaratorsTests.cpp";
}
-
+
/**
* @returns a test suite named after this class
* containing all its public members named "test*"
*/
public static Test suite() {
- TestSuite suite= new TestSuite(DeclaratorsTests.class);
+ TestSuite suite = new TestSuite(DeclaratorsTests.class);
return suite;
}
+ public void testDeclarators_0001() throws CModelException {
+ ITranslationUnit tu = getTU();
+ ICElement element = tu.getElement("decl_0001");
+ assertNotNull(element);
+ assertEquals(element.getElementType(), ICElement.C_FUNCTION_DECLARATION);
+ IFunctionDeclaration decl = (IFunctionDeclaration) element;
+ assertEquals(decl.getSignature(), "decl_0001(char)");
+ assertEquals(decl.getReturnType(), "void");
+ }
- public void testDeclarators_0001() throws CModelException {
- ITranslationUnit tu = getTU();
- ICElement element = tu.getElement("decl_0001");
- assertNotNull(element);
- assertEquals(element.getElementType(), ICElement.C_FUNCTION_DECLARATION);
- IFunctionDeclaration decl = (IFunctionDeclaration)element;
- assertEquals(decl.getSignature(), "decl_0001(char)");
- assertEquals(decl.getReturnType(), "void");
- }
-
- public void testDeclarators_0002() throws CModelException {
- ITranslationUnit tu = getTU();
- ICElement element = tu.getElement("decl_0002");
- assertNotNull(element);
- assertEquals(element.getElementType(), ICElement.C_FUNCTION_DECLARATION);
- IFunctionDeclaration decl = (IFunctionDeclaration)element;
- assertEquals(decl.getSignature(), "decl_0002(char)");
- assertEquals(decl.getReturnType(), "void");
- }
+ public void testDeclarators_0002() throws CModelException {
+ ITranslationUnit tu = getTU();
+ ICElement element = tu.getElement("decl_0002");
+ assertNotNull(element);
+ assertEquals(element.getElementType(), ICElement.C_FUNCTION_DECLARATION);
+ IFunctionDeclaration decl = (IFunctionDeclaration) element;
+ assertEquals(decl.getSignature(), "decl_0002(char)");
+ assertEquals(decl.getReturnType(), "void");
+ }
public void testDeclarators_0003() throws CModelException {
ITranslationUnit tu = getTU();
ICElement element = tu.getElement("decl_0003");
- assertNotNull(element);
+ assertNotNull(element);
assertEquals(element.getElementType(), ICElement.C_FUNCTION_DECLARATION);
- IFunctionDeclaration decl = (IFunctionDeclaration)element;
+ IFunctionDeclaration decl = (IFunctionDeclaration) element;
assertEquals(decl.getSignature(), "decl_0003(char)");
assertEquals(decl.getReturnType(), "void");
- }
-
- public void testDeclarators_0004() throws CModelException {
- ITranslationUnit tu = getTU();
- ICElement element = tu.getElement("decl_0004");
- assertNotNull(element);
- assertEquals(element.getElementType(), ICElement.C_FUNCTION_DECLARATION);
- IFunctionDeclaration decl = (IFunctionDeclaration)element;
- assertEquals(decl.getSignature(), "decl_0004(char)");
- assertEquals(decl.getReturnType(), "void*");
- }
-
- public void testDeclarators_0005() throws CModelException {
- ITranslationUnit tu = getTU();
- ICElement element = tu.getElement("decl_0005");
- assertNotNull(element);
- assertEquals(element.getElementType(), ICElement.C_VARIABLE);
- IVariable decl = (IVariable)element;
- assertEquals(decl.getTypeName(), "void(*)(char)");
- }
+ }
+
+ public void testDeclarators_0004() throws CModelException {
+ ITranslationUnit tu = getTU();
+ ICElement element = tu.getElement("decl_0004");
+ assertNotNull(element);
+ assertEquals(element.getElementType(), ICElement.C_FUNCTION_DECLARATION);
+ IFunctionDeclaration decl = (IFunctionDeclaration) element;
+ assertEquals(decl.getSignature(), "decl_0004(char)");
+ assertEquals(decl.getReturnType(), "void*");
+ }
+
+ public void testDeclarators_0005() throws CModelException {
+ ITranslationUnit tu = getTU();
+ ICElement element = tu.getElement("decl_0005");
+ assertNotNull(element);
+ assertEquals(element.getElementType(), ICElement.C_VARIABLE);
+ IVariable decl = (IVariable) element;
+ assertEquals(decl.getTypeName(), "void(*)(char)");
+ }
public void testDeclarators_0006() throws CModelException {
ITranslationUnit tu = getTU();
ICElement element = tu.getElement("decl_0006");
assertNotNull(element);
assertEquals(element.getElementType(), ICElement.C_VARIABLE);
- IVariable decl = (IVariable)element;
+ IVariable decl = (IVariable) element;
assertEquals(decl.getTypeName(), "void(*)(char)");
}
@@ -130,17 +128,16 @@ public class DeclaratorsTests extends IntegratedCModelTest {
ICElement element = tu.getElement("decl_0007");
assertNotNull(element);
assertEquals(element.getElementType(), ICElement.C_VARIABLE);
- IVariable decl = (IVariable)element;
+ IVariable decl = (IVariable) element;
assertEquals(decl.getTypeName(), "void(*)(char)");
}
-
public void testDeclarators_0011() throws CModelException {
ITranslationUnit tu = getTU();
ICElement element = tu.getElement("decl_0011");
assertNotNull(element);
assertEquals(element.getElementType(), ICElement.C_TYPEDEF);
- ITypeDef decl = (ITypeDef)element;
+ ITypeDef decl = (ITypeDef) element;
assertEquals(decl.getTypeName(), "void(char)");
}
@@ -149,7 +146,7 @@ public class DeclaratorsTests extends IntegratedCModelTest {
ICElement element = tu.getElement("decl_0012");
assertNotNull(element);
assertEquals(element.getElementType(), ICElement.C_TYPEDEF);
- ITypeDef decl = (ITypeDef)element;
+ ITypeDef decl = (ITypeDef) element;
assertEquals(decl.getTypeName(), "void(char)");
}
@@ -158,7 +155,7 @@ public class DeclaratorsTests extends IntegratedCModelTest {
ICElement element = tu.getElement("decl_0013");
assertNotNull(element);
assertEquals(element.getElementType(), ICElement.C_TYPEDEF);
- ITypeDef decl = (ITypeDef)element;
+ ITypeDef decl = (ITypeDef) element;
assertEquals(decl.getTypeName(), "void(char)");
}
@@ -167,25 +164,25 @@ public class DeclaratorsTests extends IntegratedCModelTest {
ICElement element = tu.getElement("decl_0014");
assertNotNull(element);
assertEquals(element.getElementType(), ICElement.C_TYPEDEF);
- ITypeDef decl = (ITypeDef)element;
+ ITypeDef decl = (ITypeDef) element;
assertEquals(decl.getTypeName(), "void*(char)");
}
- public void testDeclarators_0015() throws CModelException {
- ITranslationUnit tu = getTU();
- ICElement element = tu.getElement("decl_0015");
- assertNotNull(element);
- assertEquals(element.getElementType(), ICElement.C_TYPEDEF);
- ITypeDef decl = (ITypeDef)element;
- assertEquals(decl.getTypeName(), "void(*)(char)");
- }
-
+ public void testDeclarators_0015() throws CModelException {
+ ITranslationUnit tu = getTU();
+ ICElement element = tu.getElement("decl_0015");
+ assertNotNull(element);
+ assertEquals(element.getElementType(), ICElement.C_TYPEDEF);
+ ITypeDef decl = (ITypeDef) element;
+ assertEquals(decl.getTypeName(), "void(*)(char)");
+ }
+
public void testDeclarators_0016() throws CModelException {
ITranslationUnit tu = getTU();
ICElement element = tu.getElement("decl_0016");
assertNotNull(element);
assertEquals(element.getElementType(), ICElement.C_TYPEDEF);
- ITypeDef decl = (ITypeDef)element;
+ ITypeDef decl = (ITypeDef) element;
assertEquals(decl.getTypeName(), "void(*)(char)");
}
@@ -194,35 +191,35 @@ public class DeclaratorsTests extends IntegratedCModelTest {
ICElement element = tu.getElement("decl_0017");
assertNotNull(element);
assertEquals(element.getElementType(), ICElement.C_TYPEDEF);
- ITypeDef decl = (ITypeDef)element;
+ ITypeDef decl = (ITypeDef) element;
assertEquals(decl.getTypeName(), "void(*)(char)");
}
-
+
public void testDeclarators_0023() throws CModelException {
ITranslationUnit tu = getTU();
ICElement element = tu.getElement("decl_0023");
assertNotNull(element);
assertEquals(element.getElementType(), ICElement.C_FUNCTION);
- IFunction decl = (IFunction)element;
+ IFunction decl = (IFunction) element;
assertEquals(decl.getSignature(), "decl_0023(int)");
assertEquals(decl.getReturnType(), "void(**)(char)");
- }
+ }
public void testDeclarators_0024() throws CModelException {
ITranslationUnit tu = getTU();
ICElement element = tu.getElement("decl_0024");
assertNotNull(element);
assertEquals(element.getElementType(), ICElement.C_VARIABLE);
- IVariable decl = (IVariable)element;
+ IVariable decl = (IVariable) element;
assertEquals(decl.getTypeName(), "void(*(*(*)(int))(float))(char)");
- }
-
- public void testDeclarators_0031() throws CModelException {
- ITranslationUnit tu = getTU();
- ICElement element = tu.getElement("decl_0031");
- assertNotNull(element);
- assertEquals(element.getElementType(), ICElement.C_VARIABLE);
- IVariable decl = (IVariable)element;
- assertEquals(decl.getTypeName(), "int(*)(char(*)(bool))");
- }
+ }
+
+ public void testDeclarators_0031() throws CModelException {
+ ITranslationUnit tu = getTU();
+ ICElement element = tu.getElement("decl_0031");
+ assertNotNull(element);
+ assertEquals(element.getElementType(), ICElement.C_VARIABLE);
+ IVariable decl = (IVariable) element;
+ assertEquals(decl.getTypeName(), "int(*)(char(*)(bool))");
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ElementDeltaTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ElementDeltaTests.java
index ce151b85bad..c76c9f57e79 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ElementDeltaTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ElementDeltaTests.java
@@ -13,8 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.core.model.tests;
-
-
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Iterator;
@@ -45,7 +43,7 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
/**
- * Class for testing the C Element Delta Builder.
+ * Class for testing the C Element Delta Builder.
*/
public class ElementDeltaTests extends TestCase implements IElementChangedListener {
private ICProject fCProject;
@@ -54,40 +52,40 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
private Vector addedElements;
private Vector removedElements;
private Vector changedElements;
-
+
public static void main(String[] args) {
TestPluginLauncher.run(TestPluginLauncher.getLocationFromProperties(), WorkingCopyTests.class, args);
}
-
+
public static Test suite() {
- TestSuite suite= new TestSuite(ElementDeltaTests.class.getName());
+ TestSuite suite = new TestSuite(ElementDeltaTests.class.getName());
suite.addTest(new ElementDeltaTests("testElementDeltas"));
return suite;
- }
-
+ }
+
public ElementDeltaTests(String name) {
super(name);
}
-
+
@Override
protected void setUp() throws Exception {
monitor = new NullProgressMonitor();
- fCProject= CProjectHelper.createCCProject("TestProject1", "bin", IPDOMManager.ID_NO_INDEXER);
+ fCProject = CProjectHelper.createCCProject("TestProject1", "bin", IPDOMManager.ID_NO_INDEXER);
//Path filePath = new Path(ResourcesPlugin.getWorkspace().getRoot().getLocation().toString()+ fCProject.getPath().toString()+ "/WorkingCopyTest.h");
headerFile = fCProject.getProject().getFile("WorkingCopyTest.h");
if (!headerFile.exists()) {
- try{
+ try {
FileInputStream fileIn = new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/cfiles/WorkingCopyTestStart.h")));
- headerFile.create(fileIn,false, monitor);
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/cfiles/WorkingCopyTestStart.h")));
+ headerFile.create(fileIn, false, monitor);
} catch (CoreException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
-
+
// register with the model manager to listen to delta changes
CModelManager.getDefault().addElementChangedListener(this);
addedElements = new Vector(10);
@@ -96,27 +94,26 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
}
@Override
- protected void tearDown() {
- CProjectHelper.delete(fCProject);
- }
-
-
+ protected void tearDown() {
+ CProjectHelper.delete(fCProject);
+ }
+
public void testElementDeltas() throws Exception {
//ITranslationUnit tu = new TranslationUnit(fCProject, headerFile);
ICElement celement = CoreModel.getDefault().create(headerFile);
ITranslationUnit tu = null;
if (celement instanceof ITranslationUnit) {
- tu = (ITranslationUnit)celement;
+ tu = (ITranslationUnit) celement;
}
- assertNotNull (tu);
+ assertNotNull(tu);
IWorkingCopy wc = tu.getWorkingCopy();
- assertNotNull (wc);
- assertNotNull (wc.getBuffer());
- assertTrue (wc.exists());
-
+ assertNotNull(wc);
+ assertNotNull(wc.getBuffer());
+ assertTrue(wc.exists());
+
// add the class Hello
IBuffer wcBuf = wc.getBuffer();
- wcBuf.setContents ("\n class Hello{ \n};");
+ wcBuf.setContents("\n class Hello{ \n};");
wc.reconcile();
wc.commit(true, monitor);
assertChangedElement(ICElement.C_MODEL, "");
@@ -126,10 +123,10 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
assertAddedElement(ICElement.C_CLASS, "Hello");
assertRemovedElement(ICElement.C_INCLUDE, "stdio.h");
assertEmptyDelta();
-
- // add the field x
- wcBuf.setContents ("\n class Hello{\n int x; \n};");
- wc.reconcile();
+
+ // add the field x
+ wcBuf.setContents("\n class Hello{\n int x; \n};");
+ wc.reconcile();
wc.commit(true, monitor);
assertChangedElement(ICElement.C_MODEL, "");
assertChangedElement(ICElement.C_PROJECT, "TestProject1");
@@ -138,10 +135,10 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
assertChangedElement(ICElement.C_CLASS, "Hello");
assertAddedElement(ICElement.C_FIELD, "x");
assertEmptyDelta();
-
+
// add the method setValue
- wcBuf.setContents ("\n class Hello{\n int x; \n void setValue(int val); \n};");
- wc.reconcile();
+ wcBuf.setContents("\n class Hello{\n int x; \n void setValue(int val); \n};");
+ wc.reconcile();
wc.commit(true, monitor);
assertChangedElement(ICElement.C_MODEL, "");
assertChangedElement(ICElement.C_PROJECT, "TestProject1");
@@ -150,11 +147,11 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
assertChangedElement(ICElement.C_CLASS, "Hello");
assertAddedElement(ICElement.C_METHOD_DECLARATION, "setValue");
assertEmptyDelta();
-
+
// rename x to y
// this is not a change, this is add and remove
- wcBuf.setContents ("\n class Hello{\n int y; \n void setValue(int val); \n};");
- wc.reconcile();
+ wcBuf.setContents("\n class Hello{\n int y; \n void setValue(int val); \n};");
+ wc.reconcile();
wc.commit(true, monitor);
assertChangedElement(ICElement.C_MODEL, "");
assertChangedElement(ICElement.C_PROJECT, "TestProject1");
@@ -166,8 +163,8 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
assertEmptyDelta();
// remove the method
- wcBuf.setContents ("\n class Hello{\n String y; \n};");
- wc.reconcile();
+ wcBuf.setContents("\n class Hello{\n String y; \n};");
+ wc.reconcile();
wc.commit(true, monitor);
assertChangedElement(ICElement.C_MODEL, "");
assertChangedElement(ICElement.C_PROJECT, "TestProject1");
@@ -177,9 +174,9 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
assertChangedElement(ICElement.C_FIELD, "y");
assertRemovedElement(ICElement.C_METHOD_DECLARATION, "setValue");
assertEmptyDelta();
-
- // remove the field
- wcBuf.setContents ("\n class Hello{ \n};");
+
+ // remove the field
+ wcBuf.setContents("\n class Hello{ \n};");
wc.reconcile();
wc.commit(true, monitor);
assertChangedElement(ICElement.C_MODEL, "");
@@ -191,7 +188,7 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
assertEmptyDelta();
// remove the class
- wcBuf.setContents ("");
+ wcBuf.setContents("");
wc.reconcile();
wc.commit(true, monitor);
assertChangedElement(ICElement.C_MODEL, "");
@@ -202,90 +199,93 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
assertEmptyDelta();
wc.destroy();
- assertFalse(wc.exists());
+ assertFalse(wc.exists());
}
-
- public void assertAddedElement(int elementType, String elementName){
- if(!isElementInList(elementType, elementName, addedElements))
+
+ public void assertAddedElement(int elementType, String elementName) {
+ if (!isElementInList(elementType, elementName, addedElements))
fail("Element NOT found in Added list");
}
- public void assertRemovedElement(int elementType, String elementName){
- if(!isElementInList(elementType, elementName, removedElements))
+
+ public void assertRemovedElement(int elementType, String elementName) {
+ if (!isElementInList(elementType, elementName, removedElements))
fail("Element NOT found in Removed list");
}
- public void assertChangedElement(int elementType, String elementName){
- if(!isElementInList(elementType, elementName, changedElements))
+
+ public void assertChangedElement(int elementType, String elementName) {
+ if (!isElementInList(elementType, elementName, changedElements))
fail("Element NOT found in Changed list");
}
+
public void assertEmptyDelta() {
assertTrue(addedElements.isEmpty());
assertTrue(removedElements.isEmpty());
assertTrue(changedElements.isEmpty());
}
+
public boolean isElementInList(int elementType, String elementName, Vector elementList) {
boolean found = false;
Iterator i = elementList.iterator();
- while( i.hasNext()){
- ICElement element = (ICElement)i.next();
-
- if ((element.getElementName().equals(elementName)) &&
- (element.getElementType() == elementType)){
- // return true;
- // just to print the whole list
- found = true;
- // Remove the element
- elementList.remove(element);
- break;
- }
+ while (i.hasNext()) {
+ ICElement element = (ICElement) i.next();
+
+ if ((element.getElementName().equals(elementName)) && (element.getElementType() == elementType)) {
+ // return true;
+ // just to print the whole list
+ found = true;
+ // Remove the element
+ elementList.remove(element);
+ break;
+ }
}
//return false;
- return found;
+ return found;
}
-
+
@Override
- public void elementChanged(ElementChangedEvent event){
+ public void elementChanged(ElementChangedEvent event) {
try {
addedElements.clear();
removedElements.clear();
changedElements.clear();
ICElementDelta delta = event.getDelta();
processDelta(delta);
- } catch(CModelException e) {
- }
+ } catch (CModelException e) {
+ }
}
protected void processDelta(ICElementDelta delta) throws CModelException {
// check the delta elements
- int kind= delta.getKind();
- int flags= delta.getFlags();
- ICElement element= delta.getElement();
-
+ int kind = delta.getKind();
+ int flags = delta.getFlags();
+ ICElement element = delta.getElement();
+
// handle open and closing of a solution or project
if ((flags & ICElementDelta.F_CLOSED) != 0) {
}
if ((flags & ICElementDelta.F_OPENED) != 0) {
}
if (kind == ICElementDelta.REMOVED) {
- removedElements.add(element);
+ removedElements.add(element);
}
if (kind == ICElementDelta.ADDED) {
- addedElements.add(element);
+ addedElements.add(element);
}
if (kind == ICElementDelta.CHANGED) {
changedElements.add(element);
-
- if (flags == ICElementDelta.F_MODIFIERS) {
+
+ if (flags == ICElementDelta.F_MODIFIERS) {
}
- if (flags == ICElementDelta.F_CONTENT) {
+ if (flags == ICElementDelta.F_CONTENT) {
}
- if (flags == ICElementDelta.F_CHILDREN) {
+ if (flags == ICElementDelta.F_CHILDREN) {
}
}
- ICElementDelta[] affectedChildren= delta.getAffectedChildren();
- for (int i= 0; i < affectedChildren.length; i++) {
+ ICElementDelta[] affectedChildren = delta.getAffectedChildren();
+ for (int i = 0; i < affectedChildren.length; i++) {
processDelta(affectedChildren[i]);
}
}
-
+
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/FlagTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/FlagTests.java
index f5c6203d140..6c19496a57f 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/FlagTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/FlagTests.java
@@ -23,198 +23,183 @@ import org.eclipse.cdt.internal.core.model.IConstants;
* @author Peter Graves
*
* This is a very simple set of sanity tests for the flags class to make sure
- * there are no very silly problems in the class. It also verifies that there
+ * there are no very silly problems in the class. It also verifies that there
* is no overlap in the IConstants.
*/
public class FlagTests extends TestCase {
- int flags[];
- /**
- * Constructor for FlagTests.
- * @param name
- */
- public FlagTests(String name) {
- super(name);
- }
- /**
- * Sets up the test fixture.
- *
- * Called before every test case method.
- *
- * Example code test the packages in the project
- * "com.qnx.tools.ide.cdt.core"
- */
- @Override
+ int flags[];
+
+ /**
+ * Constructor for FlagTests.
+ * @param name
+ */
+ public FlagTests(String name) {
+ super(name);
+ }
+
+ /**
+ * Sets up the test fixture.
+ *
+ * Called before every test case method.
+ *
+ * Example code test the packages in the project
+ * "com.qnx.tools.ide.cdt.core"
+ */
+ @Override
protected void setUp() {
- flags=new int[15];
- flags[0]=IConstants.AccPublic;
- flags[1]=IConstants.AccPrivate;
- flags[2]=IConstants.AccProtected;
- flags[3]=IConstants.AccStatic;
- flags[4]=IConstants.AccExtern;
- flags[5]=IConstants.AccInline;
- flags[6]=IConstants.AccVolatile;
- flags[7]=IConstants.AccRegister;
- flags[8]=IConstants.AccExplicit;
- flags[9]=IConstants.AccExport;
- flags[10]=IConstants.AccAbstract;
- flags[11]=IConstants.AccMutable;
- flags[12]=IConstants.AccAuto;
- flags[13]=IConstants.AccVirtual;
- flags[14]=IConstants.AccTypename;
-
- }
-
- /**
- * Tears down the test fixture.
- *
- * Called after every test case method.
- */
- @Override
+ flags = new int[15];
+ flags[0] = IConstants.AccPublic;
+ flags[1] = IConstants.AccPrivate;
+ flags[2] = IConstants.AccProtected;
+ flags[3] = IConstants.AccStatic;
+ flags[4] = IConstants.AccExtern;
+ flags[5] = IConstants.AccInline;
+ flags[6] = IConstants.AccVolatile;
+ flags[7] = IConstants.AccRegister;
+ flags[8] = IConstants.AccExplicit;
+ flags[9] = IConstants.AccExport;
+ flags[10] = IConstants.AccAbstract;
+ flags[11] = IConstants.AccMutable;
+ flags[12] = IConstants.AccAuto;
+ flags[13] = IConstants.AccVirtual;
+ flags[14] = IConstants.AccTypename;
+
+ }
+
+ /**
+ * Tears down the test fixture.
+ *
+ * Called after every test case method.
+ */
+ @Override
protected void tearDown() {
- // release resources here and clean-up
- }
-
- public static TestSuite suite() {
- return new TestSuite(FlagTests.class);
- }
-
- public static void main (String[] args){
- junit.textui.TestRunner.run(suite());
- }
-
- public void testIsStatic()
- {
- int x;
- assertTrue("isStatic with a static", Flags.isStatic(IConstants.AccStatic));
- for (x=0;x<flags.length;x++) {
- if (flags[x]!=IConstants.AccStatic)
- assertTrue("isStatic with a non-static", !Flags.isStatic(flags[x]));
- }
- }
-
- public void testIsAbstract()
- {
- int x;
- assertTrue("isAbstract with a abstract", Flags.isAbstract(IConstants.AccAbstract));
- for (x=0;x<flags.length;x++) {
- if (flags[x]!=IConstants.AccAbstract)
- assertTrue("isAbstract with a non-abstract", !Flags.isAbstract(flags[x]));
- }
- }
-
- public void testIsExplicit()
- {
- int x;
- assertTrue("isExplicit with a explicit", Flags.isExplicit(IConstants.AccExplicit));
- for (x=0;x<flags.length;x++) {
- if (flags[x]!=IConstants.AccExplicit)
- assertTrue("isExplicit with a non-explicit", !Flags.isExplicit(flags[x]));
- }
- }
-
- public void testIsExport()
- {
- int x;
- assertTrue("isExport with a Export", Flags.isExport(IConstants.AccExport));
- for (x=0;x<flags.length;x++) {
- if (flags[x]!=IConstants.AccExport)
- assertTrue("isExport with a non-Export", !Flags.isExport(flags[x]));
- }
- }
- public void testIsExtern()
- {
- int x;
- assertTrue("isExtern with a Extern", Flags.isExtern(IConstants.AccExtern));
- for (x=0;x<flags.length;x++) {
- if (flags[x]!=IConstants.AccExtern)
- assertTrue("isExtern with a non-Extern", !Flags.isExtern(flags[x]));
- }
- }
-
- public void testIsInline()
- {
- int x;
- assertTrue("isInline with a Inline", Flags.isInline(IConstants.AccInline));
- for (x=0;x<flags.length;x++) {
- if (flags[x]!=IConstants.AccInline)
- assertTrue("isInline with a non-Inline", !Flags.isInline(flags[x]));
- }
- }
-
- public void testIsMutable()
- {
- int x;
- assertTrue("isMutable with a Mutable", Flags.isMutable(IConstants.AccMutable));
- for (x=0;x<flags.length;x++) {
- if (flags[x]!=IConstants.AccMutable)
- assertTrue("isMutable with a non-Mutable", !Flags.isMutable(flags[x]));
- }
- }
-
- public void testIsPrivate()
- {
- int x;
- assertTrue("isPrivate with a Private", Flags.isPrivate(IConstants.AccPrivate));
- for (x=0;x<flags.length;x++) {
- if (flags[x]!=IConstants.AccPrivate)
- assertTrue("isPrivate with a non-Private", !Flags.isPrivate(flags[x]));
- }
- }
-
- public void testIsPublic()
- {
- int x;
- assertTrue("isPublic with a Public", Flags.isPublic(IConstants.AccPublic));
- for (x=0;x<flags.length;x++) {
- if (flags[x]!=IConstants.AccPublic)
- assertTrue("isPublic with a non-Public", !Flags.isPublic(flags[x]));
- }
- }
-
- public void testIsProtected()
- {
- int x;
- assertTrue("isProtected with a Protected", Flags.isProtected(IConstants.AccProtected));
- for (x=0;x<flags.length;x++) {
- if (flags[x]!=IConstants.AccProtected)
- assertTrue("isProtected with a non-Protected", !Flags.isProtected(flags[x]));
- }
- }
-
- public void testIsRegister()
- {
- int x;
- assertTrue("isRegister with a Register", Flags.isRegister(IConstants.AccRegister));
- for (x=0;x<flags.length;x++) {
- if (flags[x]!=IConstants.AccRegister)
- assertTrue("isRegister with a non-Register", !Flags.isRegister(flags[x]));
- }
- }
-
- public void testIsVirtual()
- {
- int x;
- assertTrue("isVirtual with a Virtual", Flags.isVirtual(IConstants.AccVirtual));
- for (x=0;x<flags.length;x++) {
- if (flags[x]!=IConstants.AccVirtual)
- assertTrue("isVirtual with a non-Virtual", !Flags.isVirtual(flags[x]));
- }
- }
-
- public void testIsVolatile()
- {
- int x;
- assertTrue("isVolatile with a Volatile", Flags.isVolatile(IConstants.AccVolatile));
- for (x=0;x<flags.length;x++) {
- if (flags[x]!=IConstants.AccVolatile)
- assertTrue("isVolatile with a non-Volatile", !Flags.isVolatile(flags[x]));
- }
- }
-
-
-
-
-
+ // release resources here and clean-up
+ }
+
+ public static TestSuite suite() {
+ return new TestSuite(FlagTests.class);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public void testIsStatic() {
+ int x;
+ assertTrue("isStatic with a static", Flags.isStatic(IConstants.AccStatic));
+ for (x = 0; x < flags.length; x++) {
+ if (flags[x] != IConstants.AccStatic)
+ assertTrue("isStatic with a non-static", !Flags.isStatic(flags[x]));
+ }
+ }
+
+ public void testIsAbstract() {
+ int x;
+ assertTrue("isAbstract with a abstract", Flags.isAbstract(IConstants.AccAbstract));
+ for (x = 0; x < flags.length; x++) {
+ if (flags[x] != IConstants.AccAbstract)
+ assertTrue("isAbstract with a non-abstract", !Flags.isAbstract(flags[x]));
+ }
+ }
+
+ public void testIsExplicit() {
+ int x;
+ assertTrue("isExplicit with a explicit", Flags.isExplicit(IConstants.AccExplicit));
+ for (x = 0; x < flags.length; x++) {
+ if (flags[x] != IConstants.AccExplicit)
+ assertTrue("isExplicit with a non-explicit", !Flags.isExplicit(flags[x]));
+ }
+ }
+
+ public void testIsExport() {
+ int x;
+ assertTrue("isExport with a Export", Flags.isExport(IConstants.AccExport));
+ for (x = 0; x < flags.length; x++) {
+ if (flags[x] != IConstants.AccExport)
+ assertTrue("isExport with a non-Export", !Flags.isExport(flags[x]));
+ }
+ }
+
+ public void testIsExtern() {
+ int x;
+ assertTrue("isExtern with a Extern", Flags.isExtern(IConstants.AccExtern));
+ for (x = 0; x < flags.length; x++) {
+ if (flags[x] != IConstants.AccExtern)
+ assertTrue("isExtern with a non-Extern", !Flags.isExtern(flags[x]));
+ }
+ }
+
+ public void testIsInline() {
+ int x;
+ assertTrue("isInline with a Inline", Flags.isInline(IConstants.AccInline));
+ for (x = 0; x < flags.length; x++) {
+ if (flags[x] != IConstants.AccInline)
+ assertTrue("isInline with a non-Inline", !Flags.isInline(flags[x]));
+ }
+ }
+
+ public void testIsMutable() {
+ int x;
+ assertTrue("isMutable with a Mutable", Flags.isMutable(IConstants.AccMutable));
+ for (x = 0; x < flags.length; x++) {
+ if (flags[x] != IConstants.AccMutable)
+ assertTrue("isMutable with a non-Mutable", !Flags.isMutable(flags[x]));
+ }
+ }
+
+ public void testIsPrivate() {
+ int x;
+ assertTrue("isPrivate with a Private", Flags.isPrivate(IConstants.AccPrivate));
+ for (x = 0; x < flags.length; x++) {
+ if (flags[x] != IConstants.AccPrivate)
+ assertTrue("isPrivate with a non-Private", !Flags.isPrivate(flags[x]));
+ }
+ }
+
+ public void testIsPublic() {
+ int x;
+ assertTrue("isPublic with a Public", Flags.isPublic(IConstants.AccPublic));
+ for (x = 0; x < flags.length; x++) {
+ if (flags[x] != IConstants.AccPublic)
+ assertTrue("isPublic with a non-Public", !Flags.isPublic(flags[x]));
+ }
+ }
+
+ public void testIsProtected() {
+ int x;
+ assertTrue("isProtected with a Protected", Flags.isProtected(IConstants.AccProtected));
+ for (x = 0; x < flags.length; x++) {
+ if (flags[x] != IConstants.AccProtected)
+ assertTrue("isProtected with a non-Protected", !Flags.isProtected(flags[x]));
+ }
+ }
+
+ public void testIsRegister() {
+ int x;
+ assertTrue("isRegister with a Register", Flags.isRegister(IConstants.AccRegister));
+ for (x = 0; x < flags.length; x++) {
+ if (flags[x] != IConstants.AccRegister)
+ assertTrue("isRegister with a non-Register", !Flags.isRegister(flags[x]));
+ }
+ }
+
+ public void testIsVirtual() {
+ int x;
+ assertTrue("isVirtual with a Virtual", Flags.isVirtual(IConstants.AccVirtual));
+ for (x = 0; x < flags.length; x++) {
+ if (flags[x] != IConstants.AccVirtual)
+ assertTrue("isVirtual with a non-Virtual", !Flags.isVirtual(flags[x]));
+ }
+ }
+
+ public void testIsVolatile() {
+ int x;
+ assertTrue("isVolatile with a Volatile", Flags.isVolatile(IConstants.AccVolatile));
+ for (x = 0; x < flags.length; x++) {
+ if (flags[x] != IConstants.AccVolatile)
+ assertTrue("isVolatile with a non-Volatile", !Flags.isVolatile(flags[x]));
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IIncludeTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IIncludeTests.java
index e4e2c8f0066..bfa67ddb55f 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IIncludeTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IIncludeTests.java
@@ -37,7 +37,7 @@ public class IIncludeTests extends IntegratedCModelTest {
* @param string
*/
public IIncludeTests(String string) {
- super( string );
+ super(string);
}
/**
@@ -61,23 +61,20 @@ public class IIncludeTests extends IntegratedCModelTest {
* containing all its public members named "test*"
*/
public static Test suite() {
- TestSuite suite= new TestSuite(IIncludeTests.class);
+ TestSuite suite = new TestSuite(IIncludeTests.class);
return suite;
- }
+ }
- public void testGetIncludeName() throws CModelException
- {
+ public void testGetIncludeName() throws CModelException {
ITranslationUnit tu = getTU();
IInclude[] theIncludes = null;
try {
theIncludes = tu.getIncludes();
- }
- catch( CModelException c )
- {
- assertNotNull("CModelException thrown",c);
+ } catch (CModelException c) {
+ assertNotNull("CModelException thrown", c);
}
- LinkedHashMap expectIncludes= new LinkedHashMap();
+ LinkedHashMap expectIncludes = new LinkedHashMap();
expectIncludes.put("stdio.h", Boolean.TRUE);
expectIncludes.put("whatever.h", Boolean.FALSE);
expectIncludes.put("src/slash.h", Boolean.TRUE);
@@ -91,22 +88,20 @@ public class IIncludeTests extends IntegratedCModelTest {
expectIncludes.put("no_extension", Boolean.TRUE);
expectIncludes.put("whitespace_after_hash", Boolean.FALSE);
expectIncludes.put("whitespace_before_hash", Boolean.FALSE);
- expectIncludes.put("resync_after_bad_parse_1", Boolean.FALSE);
+ expectIncludes.put("resync_after_bad_parse_1", Boolean.FALSE);
expectIncludes.put("resync_after_bad_parse_2", Boolean.FALSE);
- expectIncludes.put("one", Boolean.FALSE); // C-spec does not allow this, gcc warns and includes, so we should include it, also.
+ expectIncludes.put("one", Boolean.FALSE); // C-spec does not allow this, gcc warns and includes, so we should include it, also.
expectIncludes.put("resync_after_bad_parse_3", Boolean.FALSE);
expectIncludes.put("myInclude1.h", Boolean.FALSE);
- expectIncludes.put("vers2.h", Boolean.FALSE);
+ expectIncludes.put("vers2.h", Boolean.FALSE);
- String[] getIncludeNameList= (String[]) expectIncludes.keySet().toArray(new String[expectIncludes.size()]);
- assertEquals( getIncludeNameList.length, theIncludes.length );
- for( int i=0; i<getIncludeNameList.length; i++ )
- {
+ String[] getIncludeNameList = (String[]) expectIncludes.keySet().toArray(new String[expectIncludes.size()]);
+ assertEquals(getIncludeNameList.length, theIncludes.length);
+ for (int i = 0; i < getIncludeNameList.length; i++) {
IInclude inc1 = theIncludes[i];
- String expectName= getIncludeNameList[i];
- assertEquals( expectName, inc1.getIncludeName() );
- assertEquals( ((Boolean) expectIncludes.get(expectName)).booleanValue(), inc1.isStandard());
+ String expectName = getIncludeNameList[i];
+ assertEquals(expectName, inc1.getIncludeName());
+ assertEquals(((Boolean) expectIncludes.get(expectName)).booleanValue(), inc1.isStandard());
}
}
}
-
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IMacroTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IMacroTests.java
index ab87fb99829..ef9efde182d 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IMacroTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IMacroTests.java
@@ -29,8 +29,8 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.tests.IntegratedCModelTest;
/**
- * IMacroTest - Class for testing IMacro
- *
+ * IMacroTest - Class for testing IMacro
+ *
* @author bnicolle
*
*/
@@ -40,12 +40,12 @@ public class IMacroTests extends IntegratedCModelTest {
* containing all its public members named "test*"
*/
public static Test suite() {
- TestSuite suite= new TestSuite( IMacroTests.class.getName() );
- suite.addTest( new IMacroTests("testGetElementName"));
+ TestSuite suite = new TestSuite(IMacroTests.class.getName());
+ suite.addTest(new IMacroTests("testGetElementName"));
// TODO Bug# 38740: suite.addTest( new IMacroTest("testGetIdentifierList"));
// TODO Bug# 38740: suite.addTest( new IMacroTest("testGetTokenSequence"));
return suite;
- }
+ }
/**
* @param name
@@ -72,52 +72,37 @@ public class IMacroTests extends IntegratedCModelTest {
public void testGetElementName() throws CModelException {
ITranslationUnit tu = getTU();
- List arrayElements = tu.getChildrenOfType( ICElement.C_MACRO );
+ List arrayElements = tu.getChildrenOfType(ICElement.C_MACRO);
- String expectedList[] = new String[] {
- "SINGLETON",
- "NUMBER",
- "PRINT"
- };
- assertEquals( expectedList.length, arrayElements.size() );
- for( int i=0; i<expectedList.length; i++ )
- {
+ String expectedList[] = new String[] { "SINGLETON", "NUMBER", "PRINT" };
+ assertEquals(expectedList.length, arrayElements.size());
+ for (int i = 0; i < expectedList.length; i++) {
IMacro iMacro = (IMacro) arrayElements.get(i);
- assertEquals( expectedList[i], iMacro.getElementName() );
+ assertEquals(expectedList[i], iMacro.getElementName());
}
}
-
+
public void testGetIdentifierList() throws CModelException {
ITranslationUnit tu = getTU();
- List arrayElements = tu.getChildrenOfType( ICElement.C_MACRO );
+ List arrayElements = tu.getChildrenOfType(ICElement.C_MACRO);
- String expectedList[] = new String[] {
- "",
- "",
- "string,msg"
- };
- assertEquals( expectedList.length, arrayElements.size() );
- for( int i=0; i<expectedList.length; i++ )
- {
+ String expectedList[] = new String[] { "", "", "string,msg" };
+ assertEquals(expectedList.length, arrayElements.size());
+ for (int i = 0; i < expectedList.length; i++) {
IMacro iMacro = (IMacro) arrayElements.get(i);
- assertEquals( expectedList[i], iMacro.getIdentifierList() );
+ assertEquals(expectedList[i], iMacro.getIdentifierList());
}
}
public void testGetTokenSequence() throws CModelException {
ITranslationUnit tu = getTU();
- List arrayElements = tu.getChildrenOfType( ICElement.C_MACRO );
+ List arrayElements = tu.getChildrenOfType(ICElement.C_MACRO);
- String expectedList[] = new String[] {
- "",
- "1",
- "printf(string, msg)"
- };
- assertEquals( expectedList.length, arrayElements.size() );
- for( int i=0; i<expectedList.length; i++ )
- {
+ String expectedList[] = new String[] { "", "1", "printf(string, msg)" };
+ assertEquals(expectedList.length, arrayElements.size());
+ for (int i = 0; i < expectedList.length; i++) {
IMacro iMacro = (IMacro) arrayElements.get(i);
- assertEquals( expectedList[i], iMacro.getTokenSequence() );
+ assertEquals(expectedList[i], iMacro.getTokenSequence());
}
- }
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IStructureTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IStructureTests.java
index 837ff2ebb32..228572df0d5 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IStructureTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IStructureTests.java
@@ -36,7 +36,7 @@ public class IStructureTests extends IntegratedCModelTest {
public IStructureTests(String name) {
super(name);
}
-
+
/**
* @see org.eclipse.cdt.internal.core.model.IntegratedCModelTest
*/
@@ -52,16 +52,16 @@ public class IStructureTests extends IntegratedCModelTest {
public String getSourcefileResource() {
return "IStructure.cpp";
}
-
+
/**
* @returns a test suite named after this class
* containing all its public members named "test*"
*/
public static Test suite() {
- TestSuite suite= new TestSuite(IStructureTests.class.getName());
-
+ TestSuite suite = new TestSuite(IStructureTests.class.getName());
+
// TODO check C-only behaviour using C_NATURE vs CC_NATURE
-
+
// Interface tests:
suite.addTest(new IStructureTests("testGetChildrenOfTypeStruct"));
suite.addTest(new IStructureTests("testGetChildrenOfTypeClass")); // C++ only
@@ -77,37 +77,34 @@ public class IStructureTests extends IntegratedCModelTest {
suite.addTest(new IStructureTests("testIsAbstract")); // C++ only
suite.addTest(new IStructureTests("testGetBaseTypes")); // C++ only
suite.addTest(new IStructureTests("testGetAccessControl")); // C++ only
-
- // Language Specification tests:
+
+ // Language Specification tests:
suite.addTest(new IStructureTests("testAnonymousStructObject"));
suite.addTest(new IStructureTests("testInnerStruct"));
-
+
return suite;
}
public void testGetChildrenOfTypeStruct() throws CModelException {
ITranslationUnit tu = getTU();
List arrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
- String[] myExpectedStructs = {
- "testStruct1", "testStruct2", "testStruct3", "testStruct4NoSemicolon",
- /* 2 anonymous structs */ "", "", "testStruct7",
- "testStruct8"
- };
- assertEquals(myExpectedStructs.length,arrayStructs.size());
- for (int i= 0; i < myExpectedStructs.length; i++) {
+ String[] myExpectedStructs = { "testStruct1", "testStruct2", "testStruct3", "testStruct4NoSemicolon",
+ /* 2 anonymous structs */ "", "", "testStruct7", "testStruct8" };
+ assertEquals(myExpectedStructs.length, arrayStructs.size());
+ for (int i = 0; i < myExpectedStructs.length; i++) {
IStructure myIStruct = (IStructure) arrayStructs.get(i);
assertNotNull("Failed on " + i, myIStruct);
assertEquals(myExpectedStructs[i], myIStruct.getElementName());
}
}
+
public void testGetChildrenOfTypeClass() throws CModelException {
ITranslationUnit tu = getTU();
List arrayClasses = tu.getChildrenOfType(ICElement.C_CLASS);
- String[] myExpectedClasses = {
- "testClass1", "testClass2NoSemicolon", "testClass3", "testClass4Abstract",
- "testClass5", "testClass6" };
- assertEquals(myExpectedClasses.length,arrayClasses.size());
- for (int i= 0; i < myExpectedClasses.length; i++) {
+ String[] myExpectedClasses = { "testClass1", "testClass2NoSemicolon", "testClass3", "testClass4Abstract",
+ "testClass5", "testClass6" };
+ assertEquals(myExpectedClasses.length, arrayClasses.size());
+ for (int i = 0; i < myExpectedClasses.length; i++) {
IStructure myIStruct = (IStructure) arrayClasses.get(i);
assertNotNull("Failed on " + i, myIStruct);
assertEquals(myExpectedClasses[i], myIStruct.getElementName());
@@ -119,16 +116,12 @@ public class IStructureTests extends IntegratedCModelTest {
List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
IField[] myArrayIField = myIStruct.getFields();
- String[] myExpectedFields = {
- "m_field1","m_field2","m_field3",
- "m_field4","m_field5","m_field6",
- };
+ String[] myExpectedFields = { "m_field1", "m_field2", "m_field3", "m_field4", "m_field5", "m_field6", };
assertEquals(myExpectedFields.length, myArrayIField.length);
- for (int i= 0; i < myArrayIField.length; i++) {
+ for (int i = 0; i < myArrayIField.length; i++) {
assertNotNull("Failed on " + i, myArrayIField[i]);
- assertEquals("Failed on " + i,
- myExpectedFields[i], myArrayIField[i].getElementName());
- }
+ assertEquals("Failed on " + i, myExpectedFields[i], myArrayIField[i].getElementName());
+ }
}
// TODO Bug# 38985: remove testGetFieldsHack()
@@ -136,55 +129,46 @@ public class IStructureTests extends IntegratedCModelTest {
ITranslationUnit tu = getTU();
List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
- String[] myExpectedFields = {
- "m_field1","m_field2","m_field3",
- "m_field4","m_field5","m_field6",
- };
+ String[] myExpectedFields = { "m_field1", "m_field2", "m_field3", "m_field4", "m_field5", "m_field6", };
List myArrayIField = myIStruct.getChildrenOfType(ICElement.C_FIELD);
assertEquals(myExpectedFields.length, myArrayIField.size());
- for (int i= 0; i < myArrayIField.size(); i++) {
+ for (int i = 0; i < myArrayIField.size(); i++) {
IField myIField = (IField) myArrayIField.get(i);
assertNotNull("Failed on " + i, myIField);
- assertEquals("Failed on " + i,
- myExpectedFields[i], myIField.getElementName());
- }
+ assertEquals("Failed on " + i, myExpectedFields[i], myIField.getElementName());
+ }
}
+
public void testGetField() throws CModelException {
ITranslationUnit tu = getTU();
List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
- String[] myExpectedFields = {
- "m_field1","m_field2","m_field3",
- "m_field4","m_field5","m_field6",
- };
- for (int i= 0; i < myExpectedFields.length; i++) {
+ String[] myExpectedFields = { "m_field1", "m_field2", "m_field3", "m_field4", "m_field5", "m_field6", };
+ for (int i = 0; i < myExpectedFields.length; i++) {
IField myIField = myIStruct.getField(myExpectedFields[i]);
assertNotNull("Failed on " + i, myIField);
- }
-
- String[] myUnexpectedFields = {
- "m_field7","m_field8","m_field9",
- };
- for (int i= 0; i < myUnexpectedFields.length; i++) {
+ }
+
+ String[] myUnexpectedFields = { "m_field7", "m_field8", "m_field9", };
+ for (int i = 0; i < myUnexpectedFields.length; i++) {
IField myIField = myIStruct.getField(myUnexpectedFields[i]);
assertNull("Failed on " + i, myIField);
- }
+ }
}
+
public void testGetMethods() throws CModelException {
ITranslationUnit tu = getTU();
List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
IMethodDeclaration[] myArrayIMethod = myIStruct.getMethods();
- String[] myExpectedMethods = {
- "method1","method2","testStruct1","~testStruct1"
- };
+ String[] myExpectedMethods = { "method1", "method2", "testStruct1", "~testStruct1" };
assertEquals(myExpectedMethods.length, myArrayIMethod.length);
- for (int i= 0; i < myArrayIMethod.length; i++) {
+ for (int i = 0; i < myArrayIMethod.length; i++) {
assertNotNull("Failed on " + i, myArrayIMethod[i]);
- assertEquals("Failed on " + i,
- myExpectedMethods[i], myArrayIMethod[i].getElementName());
- }
+ assertEquals("Failed on " + i, myExpectedMethods[i], myArrayIMethod[i].getElementName());
+ }
}
+
// TODO Bug# 38985: remove testGetMethodsHack()
public void testGetMethodsHack() throws CModelException {
ITranslationUnit tu = getTU();
@@ -192,38 +176,32 @@ public class IStructureTests extends IntegratedCModelTest {
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
List myArrayIMethod = myIStruct.getChildrenOfType(ICElement.C_METHOD_DECLARATION);
myArrayIMethod.addAll(myIStruct.getChildrenOfType(ICElement.C_METHOD));
- String[] myExpectedMethods = {
- "method1","method2","testStruct1","~testStruct1"
- };
+ String[] myExpectedMethods = { "method1", "method2", "testStruct1", "~testStruct1" };
assertEquals(myExpectedMethods.length, myArrayIMethod.size());
- for (int i= 0; i < myArrayIMethod.size(); i++) {
+ for (int i = 0; i < myArrayIMethod.size(); i++) {
IMethodDeclaration myIMethod = (IMethodDeclaration) myArrayIMethod.get(i);
assertNotNull("Failed on " + i, myIMethod);
- assertEquals("Failed on " + i,
- myExpectedMethods[i], myIMethod.getElementName());
- }
+ assertEquals("Failed on " + i, myExpectedMethods[i], myIMethod.getElementName());
+ }
}
+
public void testGetMethod() throws CModelException {
ITranslationUnit tu = getTU();
List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
- String[] myExpectedMethods = {
- "method1","method2","testStruct1","~testStruct1"
- };
- for (int i= 0; i < myExpectedMethods.length; i++) {
+ String[] myExpectedMethods = { "method1", "method2", "testStruct1", "~testStruct1" };
+ for (int i = 0; i < myExpectedMethods.length; i++) {
IMethodDeclaration myIMethod = myIStruct.getMethod(myExpectedMethods[i]);
assertNotNull("Failed on " + i, myIMethod);
- }
-
- String[] myUnexpectedMethods = {
- "method7","method8","method9",
- };
- for (int i= 0; i < myUnexpectedMethods.length; i++) {
+ }
+
+ String[] myUnexpectedMethods = { "method7", "method8", "method9", };
+ for (int i = 0; i < myUnexpectedMethods.length; i++) {
IMethodDeclaration myIMethod = myIStruct.getMethod(myUnexpectedMethods[i]);
assertNull("Failed on " + i, myIMethod);
- }
+ }
}
-
+
public void testIsUnion() throws CModelException {
ITranslationUnit tu = getTU();
ICElement myElementUnion = null;
@@ -235,13 +213,13 @@ public class IStructureTests extends IntegratedCModelTest {
assertNotNull("CModelException thrown", e);
}
assertNotNull(myElementUnion);
- assertTrue(myElementUnion.getElementType() == ICElement.C_UNION);
+ assertTrue(myElementUnion.getElementType() == ICElement.C_UNION);
IStructure myStructUnion = (IStructure) myElementUnion;
assertNotNull(myStructUnion);
assertTrue(myStructUnion.isUnion());
assertNotNull(myElementNonUnion);
- assertTrue(myElementNonUnion.getElementType() != ICElement.C_UNION);
+ assertTrue(myElementNonUnion.getElementType() != ICElement.C_UNION);
IStructure myStructNonUnion = (IStructure) myElementNonUnion;
assertNotNull(myStructNonUnion);
assertFalse(myStructNonUnion.isUnion());
@@ -258,18 +236,18 @@ public class IStructureTests extends IntegratedCModelTest {
assertNotNull("CModelException thrown", e);
}
assertNotNull(myElementStruct);
- assertTrue(myElementStruct.getElementType() == ICElement.C_STRUCT);
+ assertTrue(myElementStruct.getElementType() == ICElement.C_STRUCT);
IStructure myStructStruct = (IStructure) myElementStruct;
assertNotNull(myStructStruct);
assertTrue(myStructStruct.isStruct());
assertNotNull(myElementNonStruct);
- assertTrue(myElementNonStruct.getElementType() != ICElement.C_STRUCT);
+ assertTrue(myElementNonStruct.getElementType() != ICElement.C_STRUCT);
IStructure myStructNonStruct = (IStructure) myElementNonStruct;
assertNotNull(myStructNonStruct);
assertFalse(myStructNonStruct.isStruct());
}
-
+
public void testIsClass() throws CModelException {
ITranslationUnit tu = getTU();
ICElement myElementClass = null;
@@ -281,18 +259,18 @@ public class IStructureTests extends IntegratedCModelTest {
assertNotNull("CModelException thrown", e);
}
assertNotNull(myElementClass);
- assertTrue(myElementClass.getElementType() == ICElement.C_CLASS);
+ assertTrue(myElementClass.getElementType() == ICElement.C_CLASS);
IStructure myStructClass = (IStructure) myElementClass;
assertNotNull(myStructClass);
assertTrue(myStructClass.isClass());
assertNotNull(myElementNonClass);
- assertTrue(myElementNonClass.getElementType() != ICElement.C_CLASS);
+ assertTrue(myElementNonClass.getElementType() != ICElement.C_CLASS);
IStructure myStructNonClass = (IStructure) myElementNonClass;
assertNotNull(myStructNonClass);
assertFalse(myStructNonClass.isClass());
}
-
+
public void testIsAbstract() throws CModelException {
ITranslationUnit tu = getTU();
ICElement myElementAbstract = null;
@@ -304,13 +282,13 @@ public class IStructureTests extends IntegratedCModelTest {
assertNotNull("CModelException thrown", e);
}
assertNotNull(myElementAbstract);
- assertTrue(myElementAbstract.getElementType() == ICElement.C_CLASS);
+ assertTrue(myElementAbstract.getElementType() == ICElement.C_CLASS);
IStructure myStructAbstract = (IStructure) myElementAbstract;
assertNotNull(myStructAbstract);
assertTrue(myStructAbstract.isAbstract());
assertNotNull(myElementNonAbstract);
- assertTrue(myElementNonAbstract.getElementType() == ICElement.C_CLASS);
+ assertTrue(myElementNonAbstract.getElementType() == ICElement.C_CLASS);
IStructure myStructNonAbstract = (IStructure) myElementNonAbstract;
assertNotNull(myStructNonAbstract);
assertFalse(myStructNonAbstract.isAbstract());
@@ -324,21 +302,19 @@ public class IStructureTests extends IntegratedCModelTest {
try {
myElementDerived = tu.getElement("testClass5"); // throws
assertNotNull(myElementDerived);
- assertTrue(myElementDerived.getElementType() == ICElement.C_CLASS);
+ assertTrue(myElementDerived.getElementType() == ICElement.C_CLASS);
IStructure myStructDerived = (IStructure) myElementDerived;
assertNotNull(myStructDerived);
myBaseTypes = myStructDerived.getSuperClassesNames();
} catch (CModelException e) {
assertNotNull("CModelException thrown", e);
}
-
- String[] myExpectedBaseTypes = {
- "testClass1", "testClass3","testClass4Abstract"
- };
+
+ String[] myExpectedBaseTypes = { "testClass1", "testClass3", "testClass4Abstract" };
assertEquals(myExpectedBaseTypes.length, myBaseTypes.length);
- for (int i= 0; i < myBaseTypes.length; i++) {
+ for (int i = 0; i < myBaseTypes.length; i++) {
assertEquals("Failed on " + i, myExpectedBaseTypes[i], myBaseTypes[i]);
- }
+ }
}
// IInheritance
@@ -349,22 +325,19 @@ public class IStructureTests extends IntegratedCModelTest {
try {
myElementDerived = tu.getElement("testClass5"); // throws
assertNotNull(myElementDerived);
- assertTrue(myElementDerived.getElementType() == ICElement.C_CLASS);
+ assertTrue(myElementDerived.getElementType() == ICElement.C_CLASS);
IStructure myStructDerived = (IStructure) myElementDerived;
assertNotNull(myStructDerived);
myBaseTypes = myStructDerived.getSuperClassesNames();
-
+
ASTAccessVisibility[] myExpectedAccessControl = {
- // TODO #38986: expect appropriate access control tags
- ASTAccessVisibility.PUBLIC,
- ASTAccessVisibility.PROTECTED,
- ASTAccessVisibility.PRIVATE
- };
+ // TODO #38986: expect appropriate access control tags
+ ASTAccessVisibility.PUBLIC, ASTAccessVisibility.PROTECTED, ASTAccessVisibility.PRIVATE };
assertEquals(myExpectedAccessControl.length, myBaseTypes.length);
- for (int i= 0; i < myBaseTypes.length; i++) {
+ for (int i = 0; i < myBaseTypes.length; i++) {
ASTAccessVisibility myAccessControl = myStructDerived.getSuperClassAccess(myBaseTypes[i]);
assertEquals("Failed on " + i, myExpectedAccessControl[i], myAccessControl);
- }
+ }
} catch (CModelException e) {
assertNotNull("CModelException thrown", e);
}
@@ -379,12 +352,12 @@ public class IStructureTests extends IntegratedCModelTest {
// TODO: Not tested; Bug# 38958. public void testIsConst()
// TODO: Not tested; Bug# 38958. public void testIsStatic()
// TODO: Not tested; Bug# 38958. public void testIsVolatile()
- // TODO: Not tested; Bug# 38958. public void testGetAccessControl_Void()
-
+ // TODO: Not tested; Bug# 38958. public void testGetAccessControl_Void()
+
//
// Language Specification Tests
//
-
+
public void testAnonymousStructObject() throws CModelException {
ITranslationUnit tu = getTU();
ICElement myElement = null;
@@ -396,7 +369,7 @@ public class IStructureTests extends IntegratedCModelTest {
assertNotNull(myElement);
assertEquals(ICElement.C_VARIABLE, myElement.getElementType());
}
-
+
public void testInnerStruct() throws CModelException {
ITranslationUnit tu = getTU();
ICElement myElement = null;
@@ -409,15 +382,13 @@ public class IStructureTests extends IntegratedCModelTest {
IStructure myIStruct = (IStructure) myElement;
assertNotNull(myIStruct);
- String[] myExpectedInnerStructs = {
- "testStruct9Inner", "testStruct10Inner"
- };
+ String[] myExpectedInnerStructs = { "testStruct9Inner", "testStruct10Inner" };
List myInnerStructs = myIStruct.getChildrenOfType(ICElement.C_STRUCT);
assertEquals(myExpectedInnerStructs.length, myInnerStructs.size());
- for (int i= 0; i < myExpectedInnerStructs.length; i++) {
+ for (int i = 0; i < myExpectedInnerStructs.length; i++) {
IStructure myInnerStruct = (IStructure) myInnerStructs.get(i);
assertNotNull("Failed on " + i, myInnerStruct);
assertEquals("Failed on " + i, myExpectedInnerStructs[i], myInnerStruct.getElementName());
- }
+ }
}
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ITemplateTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ITemplateTests.java
index d4c6a967e05..03dc60f103a 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ITemplateTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ITemplateTests.java
@@ -31,8 +31,6 @@ import org.eclipse.cdt.core.model.ITemplate;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IVariable;
-
-
/**
* Class for testing ITemplate interface
* @author bnicolle
@@ -61,33 +59,32 @@ public class ITemplateTests extends IntegratedCModelTest {
public String getSourcefileResource() {
return "ITemplate.cpp";
}
+
/**
* @returns a test suite named after this class
* containing all its public members named "test*"
*/
public static Test suite() {
- TestSuite suite= new TestSuite( IStructureTests.class.getName() );
-
+ TestSuite suite = new TestSuite(IStructureTests.class.getName());
+
// Interface tests:
- suite.addTest( new ITemplateTests("testGetChildrenOfTypeTemplate"));
- suite.addTest( new ITemplateTests("testGetNumberOfTemplateParameters"));
- suite.addTest( new ITemplateTests("testGetTemplateParameterTypes"));
- suite.addTest( new ITemplateTests("testGetTemplateSignature"));
-
- // Language Specification tests:
+ suite.addTest(new ITemplateTests("testGetChildrenOfTypeTemplate"));
+ suite.addTest(new ITemplateTests("testGetNumberOfTemplateParameters"));
+ suite.addTest(new ITemplateTests("testGetTemplateParameterTypes"));
+ suite.addTest(new ITemplateTests("testGetTemplateSignature"));
+
+ // Language Specification tests:
// TBD.
-
+
return suite;
}
- public List getTemplateMethods(ITranslationUnit tu) throws CModelException
- {
+ public List getTemplateMethods(ITranslationUnit tu) throws CModelException {
IStructure myElem = null;
try {
myElem = (IStructure) tu.getElement("TemplateContainer");
- }
- catch( CModelException c ) {
- assertNotNull( c );
+ } catch (CModelException c) {
+ assertNotNull(c);
}
assertNotNull(myElem);
List list = myElem.getChildrenOfType(ICElement.C_TEMPLATE_METHOD_DECLARATION);
@@ -99,254 +96,226 @@ public class ITemplateTests extends IntegratedCModelTest {
ITranslationUnit tu = getTU();
{
List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT);
- String[] myExpectedValues = {
- "Map"
- };
+ String[] myExpectedValues = { "Map" };
assertEquals(myExpectedValues.length, arrayElements.size());
- for(int i=0; i<myExpectedValues.length; i++) {
+ for (int i = 0; i < myExpectedValues.length; i++) {
ICElement celement = (ICElement) arrayElements.get(i);
- ITemplate myITemplate = (ITemplate)celement;
- assertNotNull( "Failed on "+i, myITemplate);
- assertEquals("Failed on "+i, myExpectedValues[i], celement.getElementName());
+ ITemplate myITemplate = (ITemplate) celement;
+ assertNotNull("Failed on " + i, myITemplate);
+ assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName());
}
}
{
List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_CLASS);
- String[] myExpectedValues = {
- "nonVector"
- };
+ String[] myExpectedValues = { "nonVector" };
assertEquals(myExpectedValues.length, arrayElements.size());
- for(int i=0; i<myExpectedValues.length; i++) {
+ for (int i = 0; i < myExpectedValues.length; i++) {
ICElement celement = (ICElement) arrayElements.get(i);
- ITemplate myITemplate = (ITemplate)celement;
- assertNotNull( "Failed on "+i, myITemplate);
- assertEquals("Failed on "+i, myExpectedValues[i], celement.getElementName());
+ ITemplate myITemplate = (ITemplate) celement;
+ assertNotNull("Failed on " + i, myITemplate);
+ assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName());
}
}
{
List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_UNION);
- String[] myExpectedValues = {
- "ArrayOverlay"
- };
+ String[] myExpectedValues = { "ArrayOverlay" };
assertEquals(myExpectedValues.length, arrayElements.size());
- for(int i=0; i<myExpectedValues.length; i++) {
+ for (int i = 0; i < myExpectedValues.length; i++) {
ICElement celement = (ICElement) arrayElements.get(i);
- ITemplate myITemplate = (ITemplate)celement;
- assertNotNull( "Failed on "+i, myITemplate);
- assertEquals("Failed on "+i, myExpectedValues[i], celement.getElementName());
+ ITemplate myITemplate = (ITemplate) celement;
+ assertNotNull("Failed on " + i, myITemplate);
+ assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName());
}
}
{
// Method from the TemplateContainer
List arrayElements = getTemplateMethods(tu);
- String[] myExpectedValues = {
- "fum",
- "scrum",
- };
- assertEquals(myExpectedValues.length, arrayElements.size());
- // This test is no correct there is no guaranty on the order
- // for this particular case
- for(int i=0; i<myExpectedValues.length; i++) {
- ICElement celement = (ICElement) arrayElements.get(i);
- ITemplate myITemplate = (ITemplate)celement;
- assertNotNull( "Failed on "+i, myITemplate);
- assertEquals("Failed on "+i, myExpectedValues[i], celement.getElementName());
- }
+ String[] myExpectedValues = { "fum", "scrum", };
+ assertEquals(myExpectedValues.length, arrayElements.size());
+ // This test is no correct there is no guaranty on the order
+ // for this particular case
+ for (int i = 0; i < myExpectedValues.length; i++) {
+ ICElement celement = (ICElement) arrayElements.get(i);
+ ITemplate myITemplate = (ITemplate) celement;
+ assertNotNull("Failed on " + i, myITemplate);
+ assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName());
+ }
}
{
// Check the template function
List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION);
// actually, none of the two are function templates, but method templates
String[] myExpectedValues = {
-// "nonVector<T>::first",
-// "Foo::fum",
- };
- assertEquals(myExpectedValues.length, arrayElements.size());
- // This test is no correct there is no guaranty on the order
- // for this particular case
- for(int i=0; i<myExpectedValues.length; i++) {
- ICElement celement = (ICElement) arrayElements.get(i);
- ITemplate myITemplate = (ITemplate)celement;
- assertNotNull( "Failed on "+i, myITemplate);
- assertEquals("Failed on "+i, myExpectedValues[i], celement.getElementName());
- }
+ // "nonVector<T>::first",
+ // "Foo::fum",
+ };
+ assertEquals(myExpectedValues.length, arrayElements.size());
+ // This test is no correct there is no guaranty on the order
+ // for this particular case
+ for (int i = 0; i < myExpectedValues.length; i++) {
+ ICElement celement = (ICElement) arrayElements.get(i);
+ ITemplate myITemplate = (ITemplate) celement;
+ assertNotNull("Failed on " + i, myITemplate);
+ assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName());
+ }
}
{
// Check the template method
List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_METHOD);
- String[] myExpectedValues = {
- "nonVector<T>::first",
- "Foo::fum",
- };
- assertEquals(myExpectedValues.length, arrayElements.size());
- // This test is no correct there is no guaranty on the order
- // for this particular case
- for(int i=0; i<myExpectedValues.length; i++) {
- ICElement celement = (ICElement) arrayElements.get(i);
- ITemplate myITemplate = (ITemplate)celement;
- assertNotNull( "Failed on "+i, myITemplate);
- assertEquals("Failed on "+i, myExpectedValues[i], celement.getElementName());
- }
+ String[] myExpectedValues = { "nonVector<T>::first", "Foo::fum", };
+ assertEquals(myExpectedValues.length, arrayElements.size());
+ // This test is no correct there is no guaranty on the order
+ // for this particular case
+ for (int i = 0; i < myExpectedValues.length; i++) {
+ ICElement celement = (ICElement) arrayElements.get(i);
+ ITemplate myITemplate = (ITemplate) celement;
+ assertNotNull("Failed on " + i, myITemplate);
+ assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName());
+ }
}
{
// Template function declation
List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION_DECLARATION);
- String[] myExpectedValues = {
- "IsGreaterThan"
- };
+ String[] myExpectedValues = { "IsGreaterThan" };
assertEquals(myExpectedValues.length, arrayElements.size());
// This test is no correct there is no guaranty on the order
// for this particular case
- for(int i=0; i<myExpectedValues.length; i++) {
+ for (int i = 0; i < myExpectedValues.length; i++) {
ICElement celement = (ICElement) arrayElements.get(i);
- ITemplate myITemplate = (ITemplate)celement;
- assertNotNull( "Failed on "+i, myITemplate);
- assertEquals("Failed on "+i, myExpectedValues[i], celement.getElementName());
+ ITemplate myITemplate = (ITemplate) celement;
+ assertNotNull("Failed on " + i, myITemplate);
+ assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName());
}
}
{
-// // Methods and Functions are tested together as
-// // Function declarations in Quick Parse mode
-// // are considered Method Declarations in Structural parse mode
-// List arrayElements = getTemplateMethods(tu);
-// arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION));
-// arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION_DECLARATION));
-// String[] myExpectedValues = {
-// "fum",
-// "scrum",
-// "nonVector<T>::first",
-// "Foo::fum",
-// "IsGreaterThan"
-// };
-// assertEquals(myExpectedValues.length, arrayElements.size());
-// // This test is no correct there is no guaranty on the order
-// // for this particular case
-// for(int i=0; i<myExpectedValues.length; i++) {
-// ICElement celement = (ICElement) arrayElements.get(i);
-// ITemplate myITemplate = (ITemplate)celement;
-// assertNotNull( "Failed on "+i, myITemplate);
-// assertEquals("Failed on "+i, myExpectedValues[i], celement.getElementName());
-// }
+ // // Methods and Functions are tested together as
+ // // Function declarations in Quick Parse mode
+ // // are considered Method Declarations in Structural parse mode
+ // List arrayElements = getTemplateMethods(tu);
+ // arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION));
+ // arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION_DECLARATION));
+ // String[] myExpectedValues = {
+ // "fum",
+ // "scrum",
+ // "nonVector<T>::first",
+ // "Foo::fum",
+ // "IsGreaterThan"
+ // };
+ // assertEquals(myExpectedValues.length, arrayElements.size());
+ // // This test is no correct there is no guaranty on the order
+ // // for this particular case
+ // for(int i=0; i<myExpectedValues.length; i++) {
+ // ICElement celement = (ICElement) arrayElements.get(i);
+ // ITemplate myITemplate = (ITemplate)celement;
+ // assertNotNull( "Failed on "+i, myITemplate);
+ // assertEquals("Failed on "+i, myExpectedValues[i], celement.getElementName());
+ // }
}
- {
+ {
List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_VARIABLE);
- String[] myExpectedValues = {
- "default_alloc_template<threads,inst>::S_start_free"
- };
+ String[] myExpectedValues = { "default_alloc_template<threads,inst>::S_start_free" };
assertEquals(myExpectedValues.length, arrayElements.size());
- for(int i=0; i<myExpectedValues.length; i++) {
+ for (int i = 0; i < myExpectedValues.length; i++) {
IVariable myITemplate = (IVariable) arrayElements.get(i);
- assertNotNull( "Failed on "+i, myITemplate);
- assertEquals("Failed on "+i, myExpectedValues[i], myITemplate.getElementName());
+ assertNotNull("Failed on " + i, myITemplate);
+ assertEquals("Failed on " + i, myExpectedValues[i], myITemplate.getElementName());
}
}
}
-
- public void testGetNumberOfTemplateParameters() throws CModelException
- {
+ public void testGetNumberOfTemplateParameters() throws CModelException {
ITranslationUnit tu = getTU();
ArrayList arrayElements = new ArrayList();
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT ) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_CLASS ) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_UNION ) );
- arrayElements.addAll( getTemplateMethods(tu) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION ) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_METHOD ) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION_DECLARATION ) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_VARIABLE ) );
-
- int[] myExpectedNumbers = {
- 3,1,3,1,1,1,1,1,2
- };
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_CLASS));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_UNION));
+ arrayElements.addAll(getTemplateMethods(tu));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_METHOD));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION_DECLARATION));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_VARIABLE));
+
+ int[] myExpectedNumbers = { 3, 1, 3, 1, 1, 1, 1, 1, 2 };
assertEquals(myExpectedNumbers.length, arrayElements.size());
- for(int i=0; i<myExpectedNumbers.length; i++) {
+ for (int i = 0; i < myExpectedNumbers.length; i++) {
ITemplate myTemplate = (ITemplate) arrayElements.get(i);
- assertNotNull( "Failed on "+i, myTemplate );
- assertEquals( "Failed on "+i, myExpectedNumbers[i],
- myTemplate.getNumberOfTemplateParameters());
+ assertNotNull("Failed on " + i, myTemplate);
+ assertEquals("Failed on " + i, myExpectedNumbers[i], myTemplate.getNumberOfTemplateParameters());
}
}
- public void testGetTemplateParameterTypes() throws CModelException
- {
+
+ public void testGetTemplateParameterTypes() throws CModelException {
ITranslationUnit tu = getTU();
ArrayList arrayElements = new ArrayList();
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT ) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_CLASS ) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_UNION ) );
- arrayElements.addAll( getTemplateMethods(tu) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_METHOD ) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION ) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION_DECLARATION ) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_VARIABLE ) );
-
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_CLASS));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_UNION));
+ arrayElements.addAll(getTemplateMethods(tu));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_METHOD));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION_DECLARATION));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_VARIABLE));
+
String[][] myExpectedValues = {
- //"Map"
- {"Key", "Value", "SortAlgorithm"},
- //"nonVector"
- {"T"},
- //"ArrayOverlay"
- {"X","Y","int=16"},
- //"TemplateContainer::fum"
- {"Bar"},
- //"TemplateParameter::scrum"
- {"int"},
- //"nonVector::first"
- {"T"},
- //"Foo::fum"
- {"Bar"},
- //"IsGreaterThan"
- {"X"},
- //"default_alloc_template::S_start_free"
- {"bool", "int"},
- };
+ //"Map"
+ { "Key", "Value", "SortAlgorithm" },
+ //"nonVector"
+ { "T" },
+ //"ArrayOverlay"
+ { "X", "Y", "int=16" },
+ //"TemplateContainer::fum"
+ { "Bar" },
+ //"TemplateParameter::scrum"
+ { "int" },
+ //"nonVector::first"
+ { "T" },
+ //"Foo::fum"
+ { "Bar" },
+ //"IsGreaterThan"
+ { "X" },
+ //"default_alloc_template::S_start_free"
+ { "bool", "int" }, };
assertEquals(myExpectedValues.length, arrayElements.size());
- for(int i=0; i<myExpectedValues.length; i++) {
+ for (int i = 0; i < myExpectedValues.length; i++) {
ITemplate myTemplate = (ITemplate) arrayElements.get(i);
- assertNotNull( "Failed on "+i, myTemplate );
+ assertNotNull("Failed on " + i, myTemplate);
String[] myExpectedParams = myExpectedValues[i];
String[] myParams = myTemplate.getTemplateParameterTypes();
- assertEquals( "Failed on "+i, myExpectedParams.length, myParams.length );
- for(int j=0; j<myExpectedParams.length; j++) {
- assertEquals( "Failed on "+i+","+j, myExpectedParams[j], myParams[j] );
+ assertEquals("Failed on " + i, myExpectedParams.length, myParams.length);
+ for (int j = 0; j < myExpectedParams.length; j++) {
+ assertEquals("Failed on " + i + "," + j, myExpectedParams[j], myParams[j]);
}
}
}
- public void testGetTemplateSignature() throws CModelException
- {
+
+ public void testGetTemplateSignature() throws CModelException {
ITranslationUnit tu = getTU();
ArrayList arrayElements = new ArrayList();
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT ) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_CLASS ) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_UNION ) );
- arrayElements.addAll( getTemplateMethods(tu) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_METHOD ) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION ) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION_DECLARATION ) );
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_CLASS));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_UNION));
+ arrayElements.addAll(getTemplateMethods(tu));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_METHOD));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION_DECLARATION));
// TEMPLATE_VARIABLE moved to failed tests
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_VARIABLE ) );
-
- String[] myExpectedValues = {
- "Map<Key, Value, SortAlgorithm>",
- "nonVector<T>",
- "ArrayOverlay<X, Y, int=16>",
- "fum<Bar>(int) : void",
- "scrum<int>(void) : void", // TODO: deduce the rules of () versus (void), compare below.
- "nonVector<T>::first<T>() const : const T&", // TODO: where should <T> be?
- "Foo::fum<Bar>(int) : void",
- // TODO: shouldn't signature indicate const function as well?
- "IsGreaterThan<X>(X, X) : bool",
- "default_alloc_template<threads,inst>::S_start_free<bool, int> : char*",
- };
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_VARIABLE));
+
+ String[] myExpectedValues = { "Map<Key, Value, SortAlgorithm>", "nonVector<T>", "ArrayOverlay<X, Y, int=16>",
+ "fum<Bar>(int) : void", "scrum<int>(void) : void", // TODO: deduce the rules of () versus (void), compare below.
+ "nonVector<T>::first<T>() const : const T&", // TODO: where should <T> be?
+ "Foo::fum<Bar>(int) : void",
+ // TODO: shouldn't signature indicate const function as well?
+ "IsGreaterThan<X>(X, X) : bool",
+ "default_alloc_template<threads,inst>::S_start_free<bool, int> : char*", };
assertEquals(myExpectedValues.length, arrayElements.size());
- for(int i=0; i<myExpectedValues.length; i++) {
+ for (int i = 0; i < myExpectedValues.length; i++) {
ITemplate myTemplate = (ITemplate) arrayElements.get(i);
- assertNotNull( "Failed on "+i, myTemplate );
- assertEquals( "Failed on "+i, myExpectedValues[i],
- myTemplate.getTemplateSignature() );
+ assertNotNull("Failed on " + i, myTemplate);
+ assertEquals("Failed on " + i, myExpectedValues[i], myTemplate.getTemplateSignature());
}
}
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IntegratedCModelTest.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IntegratedCModelTest.java
index 569664708fc..a0bdf30402f 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IntegratedCModelTest.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IntegratedCModelTest.java
@@ -64,13 +64,13 @@ public abstract class IntegratedCModelTest extends BaseTestCase {
@Override
public void setUp() throws Exception {
monitor = new NullProgressMonitor();
- fCProject= CProjectHelper.createCCProject("TestProject1", "bin", IPDOMManager.ID_FAST_INDEXER);
- sourceFile = fCProject.getProject().getFile( getSourcefileResource() );
+ fCProject = CProjectHelper.createCCProject("TestProject1", "bin", IPDOMManager.ID_FAST_INDEXER);
+ sourceFile = fCProject.getProject().getFile(getSourcefileResource());
if (!sourceFile.exists()) {
- try{
- FileInputStream fileIn = new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path(getSourcefileSubdir() + getSourcefileResource())));
- sourceFile.create(fileIn,false, monitor);
+ try {
+ FileInputStream fileIn = new FileInputStream(CTestPlugin.getDefault()
+ .getFileInPlugin(new Path(getSourcefileSubdir() + getSourcefileResource())));
+ sourceFile.create(fileIn, false, monitor);
} catch (CoreException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
@@ -83,24 +83,26 @@ public abstract class IntegratedCModelTest extends BaseTestCase {
@Override
protected void tearDown() {
CProjectHelper.delete(fCProject);
- }
+ }
protected ITranslationUnit getTU() throws CModelException {
- ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(sourceFile);
+ ITranslationUnit tu = (ITranslationUnit) CoreModel.getDefault().create(sourceFile);
CCorePlugin.getDefault().setStructuralParseMode(isStructuralParse());
- // parse the translation unit to get the elements tree
+ // parse the translation unit to get the elements tree
// Force the parsing now to do this in the right ParseMode.
tu.close();
tu.open(new NullProgressMonitor());
CCorePlugin.getDefault().setStructuralParseMode(false);
return tu;
}
+
/**
* @return Returns the structuralParse.
*/
public boolean isStructuralParse() {
return structuralParse;
}
+
/**
* @param structuralParse The structuralParse to set.
*/
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/MacroTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/MacroTests.java
index bd1424d9650..6f8a2b197f7 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/MacroTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/MacroTests.java
@@ -28,7 +28,6 @@ import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DefaultLineTracker;
import org.eclipse.jface.text.ILineTracker;
-
/**
* @author bnicolle
*
@@ -40,7 +39,7 @@ public class MacroTests extends IntegratedCModelTest {
public MacroTests(String name) {
super(name);
}
-
+
/**
* @see org.eclipse.cdt.internal.core.model.IntegratedCModelTest
*/
@@ -56,83 +55,82 @@ public class MacroTests extends IntegratedCModelTest {
public String getSourcefileResource() {
return "MacroTests.cpp";
}
-
+
/**
* @returns a test suite named after this class
* containing all its public members named "test*"
*/
public static Test suite() {
- TestSuite suite= new TestSuite(MacroTests.class);
+ TestSuite suite = new TestSuite(MacroTests.class);
return suite;
}
- public void testBug40759 () throws CModelException, BadLocationException {
- /* This is a list of elements in the test .c file. It will be used
+ public void testBug40759() throws CModelException, BadLocationException {
+ /* This is a list of elements in the test .c file. It will be used
* in a number of places in the tests
*/
- String[] expectedStringList= {"Z", "X", "Y",
- "SomeName", "A::BCD", "DEFA", "DB", "B::SomeName",
- "PINT", "myPINT", "foobar"};
- int[] expectedOffsets={ 8,26,39,55,89,114,130,152,187,212,227};
- int[] expectedLengths={ 1, 1, 1, 1, 8, 4, 2, 18, 4, 6, 6};
- /* This is a list of that the types of the above list of elements is
+ String[] expectedStringList = { "Z", "X", "Y", "SomeName", "A::BCD", "DEFA", "DB", "B::SomeName", "PINT",
+ "myPINT", "foobar" };
+ int[] expectedOffsets = { 8, 26, 39, 55, 89, 114, 130, 152, 187, 212, 227 };
+ int[] expectedLengths = { 1, 1, 1, 1, 8, 4, 2, 18, 4, 6, 6 };
+ /* This is a list of that the types of the above list of elements is
* expected to be.
*/
- int[] expectedTypes= { ICElement.C_MACRO, ICElement.C_MACRO,
- ICElement.C_MACRO, ICElement.C_STRUCT,
- ICElement.C_VARIABLE, ICElement.C_MACRO,
- ICElement.C_MACRO, ICElement.C_VARIABLE, ICElement.C_MACRO,
- ICElement.C_VARIABLE, ICElement.C_FUNCTION_DECLARATION};
+ int[] expectedTypes = { ICElement.C_MACRO, ICElement.C_MACRO, ICElement.C_MACRO, ICElement.C_STRUCT,
+ ICElement.C_VARIABLE, ICElement.C_MACRO, ICElement.C_MACRO, ICElement.C_VARIABLE, ICElement.C_MACRO,
+ ICElement.C_VARIABLE, ICElement.C_FUNCTION_DECLARATION };
ITranslationUnit myTranslationUnit = getTU();
// fix offsets in case source file is not in windows format
- IBuffer buffer= myTranslationUnit.getBuffer();
- ILineTracker lineTracker= new DefaultLineTracker();
+ IBuffer buffer = myTranslationUnit.getBuffer();
+ ILineTracker lineTracker = new DefaultLineTracker();
lineTracker.set(buffer.getContents());
if (lineTracker.getLineDelimiter(0).length() == 1) {
- lineTracker.set(buffer.getContents().replaceAll("[\r\n]","\r\n"));
+ lineTracker.set(buffer.getContents().replaceAll("[\r\n]", "\r\n"));
for (int i = 0; i < expectedOffsets.length; i++) {
expectedOffsets[i] -= lineTracker.getLineNumberOfOffset(expectedOffsets[i]);
}
}
ICElement myElement;
- Stack missing=new Stack();
+ Stack missing = new Stack();
int x;
- for (x=0;x<expectedStringList.length;x++) {
- myElement=myTranslationUnit.getElement(expectedStringList[x]);
- if (myElement==null)
+ for (x = 0; x < expectedStringList.length; x++) {
+ myElement = myTranslationUnit.getElement(expectedStringList[x]);
+ if (myElement == null)
missing.push(expectedStringList[x]);
else {
assertTrue("Expected:" + expectedStringList[x] + " Got:" + myElement.getElementName(),
expectedStringList[x].equals(myElement.getElementName()));
- assertTrue("Expected type for '" + expectedStringList[x] + "':" + expectedTypes[x] + " Got:" + myElement.getElementType(),
- expectedTypes[x] == myElement.getElementType());
+ assertTrue("Expected type for '" + expectedStringList[x] + "':" + expectedTypes[x] + " Got:"
+ + myElement.getElementType(), expectedTypes[x] == myElement.getElementType());
int offset = -1;
int length = -1;
if (myElement instanceof ISourceReference) {
- ISourceRange range = ((ISourceReference)myElement).getSourceRange();
+ ISourceRange range = ((ISourceReference) myElement).getSourceRange();
offset = range.getIdStartPos();
length = range.getIdLength();
}
- assertTrue("Expected offset for '" + expectedStringList[x] + "':" + expectedOffsets[x] + " Got:" + offset,
+ assertTrue(
+ "Expected offset for '" + expectedStringList[x] + "':" + expectedOffsets[x] + " Got:" + offset,
expectedOffsets[x] == offset);
- assertTrue( "Expected length for '" + expectedStringList[x] + "':" + expectedLengths[x] + " Got:" + length,
+ assertTrue(
+ "Expected length for '" + expectedStringList[x] + "':" + expectedLengths[x] + " Got:" + length,
expectedLengths[x] == length);
}
}
if (!missing.empty()) {
- String output="Could not get elements: ";
+ String output = "Could not get elements: ";
while (!missing.empty())
- output+=missing.pop() + " ";
+ output += missing.pop() + " ";
assertTrue(output, false);
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralCModelElementsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralCModelElementsTests.java
index 39ec0fbe855..71039b90a4f 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralCModelElementsTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralCModelElementsTests.java
@@ -56,36 +56,36 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
-public class StructuralCModelElementsTests extends BaseTestCase {
+public class StructuralCModelElementsTests extends BaseTestCase {
private ICProject fCProject;
private IFile headerFile;
private IFile includedFile;
private NullProgressMonitor monitor;
-
+
public static Test suite() {
- TestSuite suite= new TestSuite(StructuralCModelElementsTests.class.getName());
+ TestSuite suite = new TestSuite(StructuralCModelElementsTests.class.getName());
suite.addTest(new StructuralCModelElementsTests("testCModelElements")); //$NON-NLS-1$
return suite;
- }
-
+ }
+
public StructuralCModelElementsTests(String name) {
super(name);
}
-
+
@Override
protected void setUp() throws Exception {
monitor = new NullProgressMonitor();
- fCProject= CProjectHelper.createCCProject("TestProject1", "bin", IPDOMManager.ID_FAST_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
+ fCProject = CProjectHelper.createCCProject("TestProject1", "bin", IPDOMManager.ID_FAST_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
headerFile = fCProject.getProject().getFile("CModelElementsTest.h"); //$NON-NLS-1$
includedFile = fCProject.getProject().getFile("included.h"); //$NON-NLS-1$
if (!headerFile.exists()) {
- try{
- FileInputStream fileIn = new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/cfiles/CModelElementsTestStart.h"))); //$NON-NLS-1$
- headerFile.create(fileIn,false, monitor);
+ try {
+ FileInputStream fileIn = new FileInputStream(CTestPlugin.getDefault()
+ .getFileInPlugin(new Path("resources/cfiles/CModelElementsTestStart.h"))); //$NON-NLS-1$
+ headerFile.create(fileIn, false, monitor);
FileInputStream includedFileIn = new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/cfiles/included.h"))); //$NON-NLS-1$
- includedFile.create(includedFileIn,false, monitor);
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/cfiles/included.h"))); //$NON-NLS-1$
+ includedFile.create(includedFileIn, false, monitor);
} catch (CoreException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
@@ -95,24 +95,23 @@ public class StructuralCModelElementsTests extends BaseTestCase {
waitForIndexer(fCProject);
}
-
@Override
protected void tearDown() {
- CProjectHelper.delete(fCProject);
- }
-
- public void testCModelElements() throws CModelException{
- ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(headerFile);
+ CProjectHelper.delete(fCProject);
+ }
+
+ public void testCModelElements() throws CModelException {
+ ITranslationUnit tu = (ITranslationUnit) CoreModel.getDefault().create(headerFile);
// turn on the structural parse mode
tu.close();
CCorePlugin.getDefault().setStructuralParseMode(true);
-
+
// tu ---> include
checkInclude(tu);
-
+
// tu ---> macro
checkMacro(tu);
-
+
// tu ---> namespace: MyPackage
List tuPackages = tu.getChildrenOfType(ICElement.C_NAMESPACE);
INamespace namespace = (INamespace) tuPackages.get(0);
@@ -120,19 +119,19 @@ public class StructuralCModelElementsTests extends BaseTestCase {
checkElementOffset(namespace);
checkLineNumbers(namespace, 8, 130);
checkClass(namespace);
-
- checkEnums(namespace);
-
- checkVariables(namespace);
- checkVariableDeclarations(namespace);
-
+ checkEnums(namespace);
+
+ checkVariables(namespace);
+
+ checkVariableDeclarations(namespace);
+
checkFunctions(namespace);
-
+
checkStructs(namespace);
-
+
checkTemplates(namespace);
-
+
checkArrays(tu);
// turn off the structural parse mode
@@ -140,30 +139,30 @@ public class StructuralCModelElementsTests extends BaseTestCase {
}
- private void checkInclude(IParent tu) throws CModelException{
+ private void checkInclude(IParent tu) throws CModelException {
List tuIncludes = tu.getChildrenOfType(ICElement.C_INCLUDE);
IInclude inc1 = (IInclude) tuIncludes.get(0);
assertEquals(inc1.getElementName(), "included.h"); //$NON-NLS-1$
checkElementOffset(inc1);
checkLineNumbers(inc1, 2, 2);
}
-
- private void checkMacro(IParent tu) throws CModelException{
+
+ private void checkMacro(IParent tu) throws CModelException {
List tuMacros = tu.getChildrenOfType(ICElement.C_MACRO);
IMacro mac1 = (IMacro) tuMacros.get(0);
assertEquals(mac1.getElementName(), "PRINT"); //$NON-NLS-1$
checkElementOffset(mac1);
checkLineNumbers(mac1, 5, 5);
}
-
- private void checkClass(IParent namespace) throws CModelException{
+
+ private void checkClass(IParent namespace) throws CModelException {
// MyPackage ---> class: Hello
- List nsClasses = namespace.getChildrenOfType(ICElement.C_CLASS);
+ List nsClasses = namespace.getChildrenOfType(ICElement.C_CLASS);
IStructure classHello = (IStructure) nsClasses.get(0);
assertEquals(classHello.getElementName(), "Hello"); //$NON-NLS-1$
checkElementOffset(classHello);
checkLineNumbers(classHello, 12, 53);
-
+
// Hello --> field: int x
List helloFields = classHello.getChildrenOfType(ICElement.C_FIELD);
IField intX = (IField) helloFields.get(0);
@@ -171,11 +170,11 @@ public class StructuralCModelElementsTests extends BaseTestCase {
checkElementOffset(intX);
assertEquals(intX.getTypeName(), "int"); //$NON-NLS-1$
checkLineNumbers(intX, 17, 17);
-
- ASTAccessVisibility xVisibility = intX.getVisibility();
+
+ ASTAccessVisibility xVisibility = intX.getVisibility();
if (xVisibility != ASTAccessVisibility.PROTECTED)
fail("visibility should be protected!"); //$NON-NLS-1$
-
+
// Hello ---> method: void setX(int X)
List helloMethods = classHello.getChildrenOfType(ICElement.C_METHOD);
IMethod setX = (IMethod) helloMethods.get(0);
@@ -184,61 +183,63 @@ public class StructuralCModelElementsTests extends BaseTestCase {
assertEquals(setX.getReturnType(), "void"); //$NON-NLS-1$
checkLineNumbers(setX, 19, 22);
int setXNumOfParam = setX.getNumberOfParameters();
- if(setXNumOfParam != 1)
+ if (setXNumOfParam != 1)
fail("setX should have one parameter!"); //$NON-NLS-1$
String[] setXParamTypes = setX.getParameterTypes();
String firstParamType = setXParamTypes[0];
assertEquals(firstParamType, "int"); //$NON-NLS-1$
// TODO : check for the inline here
-
+
checkNestedNamespace(classHello);
}
- private void checkNestedNamespace(IParent classHello) throws CModelException{
- // Hello ---> namespace: MyNestedPackage
+
+ private void checkNestedNamespace(IParent classHello) throws CModelException {
+ // Hello ---> namespace: MyNestedPackage
List helloNamespaces = classHello.getChildrenOfType(ICElement.C_NAMESPACE);
INamespace myNestedPackage = (INamespace) helloNamespaces.get(0);
assertEquals(myNestedPackage.getElementName(), "MyNestedPackage"); //$NON-NLS-1$
checkElementOffset(myNestedPackage);
checkLineNumbers(myNestedPackage, 25, 52);
- checkParentNestedClass(myNestedPackage);
+ checkParentNestedClass(myNestedPackage);
checkDerivedNestedClass(myNestedPackage);
}
- private void checkParentNestedClass(IParent myNestedPackage) throws CModelException{
- // MyNestedPackage ---> class: Y
- List nestedClasses = myNestedPackage.getChildrenOfType(ICElement.C_CLASS);
+
+ private void checkParentNestedClass(IParent myNestedPackage) throws CModelException {
+ // MyNestedPackage ---> class: Y
+ List nestedClasses = myNestedPackage.getChildrenOfType(ICElement.C_CLASS);
IStructure classY = (IStructure) nestedClasses.get(0);
assertEquals(classY.getElementName(), "Y"); //$NON-NLS-1$
checkElementOffset(classY);
checkLineNumbers(classY, 28, 35);
-
+
// Y ---> constructor: Y
List yMethods = classY.getChildrenOfType(ICElement.C_METHOD_DECLARATION);
- IMethodDeclaration constructor = (IMethodDeclaration) yMethods.get(0);
+ IMethodDeclaration constructor = (IMethodDeclaration) yMethods.get(0);
assertEquals(constructor.getElementName(), "Y"); //$NON-NLS-1$
checkElementOffset(constructor);
- assertTrue (constructor.isConstructor());
+ assertTrue(constructor.isConstructor());
checkLineNumbers(constructor, 32, 32);
-
+
// Y ---> destructor: ~Y
- IMethodDeclaration destructor = (IMethodDeclaration) yMethods.get(1);
+ IMethodDeclaration destructor = (IMethodDeclaration) yMethods.get(1);
assertEquals(destructor.getElementName(), "~Y"); //$NON-NLS-1$
checkElementOffset(destructor);
- assertTrue (destructor.isDestructor());
+ assertTrue(destructor.isDestructor());
checkLineNumbers(destructor, 34, 34);
// TODO: check for virtual on destructors
-
+
}
-
- private void checkDerivedNestedClass(IParent myNestedPackage) throws CModelException{
- // MyNestedPackage ---> class: X public Y
- List nestedClasses = myNestedPackage.getChildrenOfType(ICElement.C_CLASS);
+
+ private void checkDerivedNestedClass(IParent myNestedPackage) throws CModelException {
+ // MyNestedPackage ---> class: X public Y
+ List nestedClasses = myNestedPackage.getChildrenOfType(ICElement.C_CLASS);
IStructure classX = (IStructure) nestedClasses.get(1);
assertEquals(classX.getElementName(), "X"); //$NON-NLS-1$
checkElementOffset(classX);
checkLineNumbers(classX, 38, 51);
// TODO : Check for base classes here
-
+
// X --> field: B b
List xFieldChildren = classX.getChildrenOfType(ICElement.C_FIELD);
IField bB = (IField) xFieldChildren.get(0);
@@ -246,16 +247,16 @@ public class StructuralCModelElementsTests extends BaseTestCase {
checkElementOffset(bB);
assertEquals(bB.getTypeName(), "B"); //$NON-NLS-1$
checkLineNumbers(bB, 42, 42);
- ASTAccessVisibility bVisibility = bB.getVisibility();
+ ASTAccessVisibility bVisibility = bB.getVisibility();
if (bVisibility != ASTAccessVisibility.PRIVATE)
fail("visibility should be private!"); //$NON-NLS-1$
-
- // X ---> constructor chain: X
+
+ // X ---> constructor chain: X
List xMethodChildren = classX.getChildrenOfType(ICElement.C_METHOD);
- IMethod xconstructor = (IMethod) xMethodChildren.get(0);
+ IMethod xconstructor = (IMethod) xMethodChildren.get(0);
assertEquals(xconstructor.getElementName(), "X"); //$NON-NLS-1$
checkElementOffset(xconstructor);
- assertTrue (xconstructor.isConstructor());
+ assertTrue(xconstructor.isConstructor());
checkLineNumbers(xconstructor, 46, 48);
// X ---> method declaration: doNothing
@@ -263,18 +264,18 @@ public class StructuralCModelElementsTests extends BaseTestCase {
IMethodDeclaration xDoNothing = (IMethodDeclaration) xMethodDeclarations.get(0);
assertEquals(xDoNothing.getElementName(), "doNothing"); //$NON-NLS-1$
checkElementOffset(xDoNothing);
- assertEquals(xDoNothing.getReturnType(), "int"); //$NON-NLS-1$
+ assertEquals(xDoNothing.getReturnType(), "int"); //$NON-NLS-1$
checkLineNumbers(xDoNothing, 50, 50);
}
-
- private void checkEnums(IParent namespace) throws CModelException{
+
+ private void checkEnums(IParent namespace) throws CModelException {
// MyPackage ---> enum: Noname
- List nsEnums = namespace.getChildrenOfType(ICElement.C_ENUMERATION);
+ List nsEnums = namespace.getChildrenOfType(ICElement.C_ENUMERATION);
IEnumeration enumarate = (IEnumeration) nsEnums.get(0);
assertEquals(enumarate.getElementName(), ""); //$NON-NLS-1$
checkElementOffset(enumarate);
checkLineNumbers(enumarate, 57, 61);
-
+
// enum ---> enumerator: first = 1
List enumEnumerators = enumarate.getChildrenOfType(ICElement.C_ENUMERATOR);
IEnumerator first = (IEnumerator) enumEnumerators.get(0);
@@ -290,13 +291,13 @@ public class StructuralCModelElementsTests extends BaseTestCase {
checkElementOffset(third);
assertEquals(third.getElementName(), "third"); //$NON-NLS-1$
checkElementOffset(third);
-
+
// MyPackage ---> enum: MyEnum
IEnumeration myEnum = (IEnumeration) nsEnums.get(1);
assertEquals(myEnum.getElementName(), "MyEnum"); //$NON-NLS-1$
checkElementOffset(myEnum);
checkLineNumbers(myEnum, 64, 67);
-
+
// enum ---> enumerator: first
List myEnumEnumerators = myEnum.getChildrenOfType(ICElement.C_ENUMERATOR);
IEnumerator f = (IEnumerator) myEnumEnumerators.get(0);
@@ -312,7 +313,7 @@ public class StructuralCModelElementsTests extends BaseTestCase {
checkElementOffset(t);
}
- private void checkVariables(IParent namespace) throws CModelException{
+ private void checkVariables(IParent namespace) throws CModelException {
// MyPackage ---> int v
List nsVars = namespace.getChildrenOfType(ICElement.C_VARIABLE);
IVariable var1 = (IVariable) nsVars.get(0);
@@ -320,7 +321,7 @@ public class StructuralCModelElementsTests extends BaseTestCase {
checkElementOffset(var1);
assertEquals(var1.getTypeName(), "int"); //$NON-NLS-1$
checkLineNumbers(var1, 71, 71);
-
+
// MyPackage ---> unsigned long vuLong
IVariable var2 = (IVariable) nsVars.get(1);
assertEquals(var2.getElementName(), "vuLong"); //$NON-NLS-1$
@@ -334,17 +335,17 @@ public class StructuralCModelElementsTests extends BaseTestCase {
checkElementOffset(var3);
assertEquals(var3.getTypeName(), "unsigned short"); //$NON-NLS-1$
checkLineNumbers(var3, 75, 75);
-
+
// MyPackage ---> function pointer: orig_malloc_hook
IVariable vDecl2 = (IVariable) nsVars.get(3);
assertEquals(vDecl2.getElementName(), "orig_malloc_hook"); //$NON-NLS-1$
checkElementOffset(vDecl2);
- assertEquals(vDecl2.getTypeName(), new String ("void*(*)(const char*, int, int)")); //$NON-NLS-1$
+ assertEquals(vDecl2.getTypeName(), new String("void*(*)(const char*, int, int)")); //$NON-NLS-1$
checkLineNumbers(vDecl2, 81, 81);
-
+
}
- private void checkVariableDeclarations(IParent namespace) throws CModelException{
+ private void checkVariableDeclarations(IParent namespace) throws CModelException {
// MyPackage ---> extern int evar
List nsVarDecls = namespace.getChildrenOfType(ICElement.C_VARIABLE_DECLARATION);
IVariableDeclaration vDecl1 = (IVariableDeclaration) nsVarDecls.get(0);
@@ -353,8 +354,8 @@ public class StructuralCModelElementsTests extends BaseTestCase {
assertEquals(vDecl1.getTypeName(), "int"); //$NON-NLS-1$
checkLineNumbers(vDecl1, 79, 79);
}
-
- private void checkFunctions(IParent namespace) throws CModelException{
+
+ private void checkFunctions(IParent namespace) throws CModelException {
List nsFunctionDeclarations = namespace.getChildrenOfType(ICElement.C_FUNCTION_DECLARATION);
// MyPackage ---> function: void foo()
@@ -363,7 +364,7 @@ public class StructuralCModelElementsTests extends BaseTestCase {
checkElementOffset(f1);
assertEquals(f1.getReturnType(), "void"); //$NON-NLS-1$
checkLineNumbers(f1, 85, 85);
-
+
// MyPackage ---> function: char* foo(int&, char**)
IFunctionDeclaration f2 = (IFunctionDeclaration) nsFunctionDeclarations.get(1);
assertEquals(f2.getElementName(), "foo"); //$NON-NLS-1$
@@ -371,26 +372,26 @@ public class StructuralCModelElementsTests extends BaseTestCase {
assertEquals(f2.getReturnType(), "char*"); //$NON-NLS-1$
checkLineNumbers(f2, 87, 88);
int fooNumOfParam = f2.getNumberOfParameters();
- if(fooNumOfParam != 2)
+ if (fooNumOfParam != 2)
fail("foo should have two parameter!"); //$NON-NLS-1$
String[] paramTypes = f2.getParameterTypes();
assertEquals(paramTypes[0], "int&"); //$NON-NLS-1$
assertEquals(paramTypes[1], "char**"); //$NON-NLS-1$
-
- // MyPackage ---> function: void boo() {}
+
+ // MyPackage ---> function: void boo() {}
List nsFunctions = namespace.getChildrenOfType(ICElement.C_FUNCTION);
- IFunction f3 = (IFunction) nsFunctions.get(0);
+ IFunction f3 = (IFunction) nsFunctions.get(0);
assertEquals(f3.getElementName(), "boo"); //$NON-NLS-1$
checkElementOffset(f3);
assertEquals(f3.getReturnType(), "void"); //$NON-NLS-1$
checkLineNumbers(f3, 90, 92);
}
- private void checkStructs(IParent namespace) throws CModelException{
+ private void checkStructs(IParent namespace) throws CModelException {
// struct with name
List nsStructs = namespace.getChildrenOfType(ICElement.C_STRUCT);
IStructure struct1 = (IStructure) nsStructs.get(0);
- assertEquals(struct1.getElementName(), new String ("MyStruct")); //$NON-NLS-1$
+ assertEquals(struct1.getElementName(), new String("MyStruct")); //$NON-NLS-1$
checkElementOffset(struct1);
checkLineNumbers(struct1, 95, 97);
List struct1Fields = struct1.getChildrenOfType(ICElement.C_FIELD);
@@ -399,21 +400,21 @@ public class StructuralCModelElementsTests extends BaseTestCase {
checkElementOffset(field1);
assertEquals(field1.getTypeName(), "int"); //$NON-NLS-1$
checkLineNumbers(field1, 96, 96);
-
- if(field1.getVisibility() != ASTAccessVisibility.PUBLIC)
+
+ if (field1.getVisibility() != ASTAccessVisibility.PUBLIC)
fail("field visibility should be public!"); //$NON-NLS-1$
-
+
// struct no name
IStructure struct2;
List nsTypeDefs = namespace.getChildrenOfType(ICElement.C_TYPEDEF);
ITypeDef td = (ITypeDef) nsTypeDefs.get(1);
if (td instanceof IParent) {
// nested in typedef decl
- struct2 = (IStructure) ((IParent)td).getChildren()[0];
+ struct2 = (IStructure) ((IParent) td).getChildren()[0];
} else {
struct2 = (IStructure) nsStructs.get(1);
}
- assertEquals(struct2.getElementName(), new String ("")); //$NON-NLS-1$
+ assertEquals(struct2.getElementName(), new String("")); //$NON-NLS-1$
checkElementOffset(struct2);
checkLineNumbers(struct2, 101, 103);
List struct2Fields = struct2.getChildrenOfType(ICElement.C_FIELD);
@@ -422,25 +423,25 @@ public class StructuralCModelElementsTests extends BaseTestCase {
checkElementOffset(field2);
assertEquals(field2.getTypeName(), "int"); //$NON-NLS-1$
checkLineNumbers(field2, 102, 102);
- if(field2.getVisibility() != ASTAccessVisibility.PUBLIC)
+ if (field2.getVisibility() != ASTAccessVisibility.PUBLIC)
fail("field visibility should be public!"); //$NON-NLS-1$
-
+
// typedefs
ITypeDef td1 = (ITypeDef) nsTypeDefs.get(0);
- assertEquals(td1.getElementName(), new String ("myStruct")); //$NON-NLS-1$
+ assertEquals(td1.getElementName(), new String("myStruct")); //$NON-NLS-1$
checkElementOffset(td1);
- assertEquals(td1.getTypeName(), new String ("struct MyStruct")); //$NON-NLS-1$
+ assertEquals(td1.getTypeName(), new String("struct MyStruct")); //$NON-NLS-1$
checkLineNumbers(td1, 99, 99);
ITypeDef td2 = (ITypeDef) nsTypeDefs.get(1);
- assertEquals(td2.getElementName(), new String ("myTypedef")); //$NON-NLS-1$
+ assertEquals(td2.getElementName(), new String("myTypedef")); //$NON-NLS-1$
checkElementOffset(td2);
- assertEquals(td2.getTypeName(), new String ("struct")); //$NON-NLS-1$
+ assertEquals(td2.getTypeName(), new String("struct")); //$NON-NLS-1$
checkLineNumbers(td2, 103, 103);
// union
List nsUnions = namespace.getChildrenOfType(ICElement.C_UNION);
IStructure u0 = (IStructure) nsUnions.get(0);
- assertEquals(u0.getElementName(), "U"); //$NON-NLS-1$
+ assertEquals(u0.getElementName(), "U"); //$NON-NLS-1$
checkElementOffset(u0);
checkLineNumbers(u0, 105, 107);
List u0Fields = u0.getChildrenOfType(ICElement.C_FIELD);
@@ -449,35 +450,35 @@ public class StructuralCModelElementsTests extends BaseTestCase {
checkElementOffset(field3);
assertEquals(field3.getTypeName(), "int"); //$NON-NLS-1$
checkLineNumbers(field3, 106, 106);
- if(field3.getVisibility() != ASTAccessVisibility.PUBLIC)
+ if (field3.getVisibility() != ASTAccessVisibility.PUBLIC)
fail("field visibility should be public!"); //$NON-NLS-1$
}
- private void checkTemplates(IParent namespace) throws CModelException{
+ private void checkTemplates(IParent namespace) throws CModelException {
// template function
List functionTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION_DECLARATION);
- IFunctionTemplateDeclaration ft = (IFunctionTemplateDeclaration)functionTemplates.get(0);
+ IFunctionTemplateDeclaration ft = (IFunctionTemplateDeclaration) functionTemplates.get(0);
assertEquals(ft.getElementName(), "aTemplatedFunction"); //$NON-NLS-1$
checkElementOffset(ft);
ft.getTemplateSignature();
assertEquals(ft.getTemplateSignature(), "aTemplatedFunction<A, B>(B) : A"); //$NON-NLS-1$
checkLineNumbers(ft, 112, 113);
-
+
// template method
List nsClasses = namespace.getChildrenOfType(ICElement.C_CLASS);
IStructure enclosingClass = (IStructure) nsClasses.get(1);
checkLineNumbers(enclosingClass, 115, 120);
List methodTemplates = enclosingClass.getChildrenOfType(ICElement.C_TEMPLATE_METHOD_DECLARATION);
- IMethodTemplateDeclaration mt = (IMethodTemplateDeclaration)methodTemplates.get(0);
+ IMethodTemplateDeclaration mt = (IMethodTemplateDeclaration) methodTemplates.get(0);
assertEquals(mt.getElementName(), "aTemplatedMethod"); //$NON-NLS-1$
checkElementOffset(mt);
assertEquals(mt.getTemplateSignature(), "aTemplatedMethod<A, B>(B) : A"); //$NON-NLS-1$
- checkLineNumbers(mt, 118, 119 );
+ checkLineNumbers(mt, 118, 119);
assertEquals(mt.getVisibility(), ASTAccessVisibility.PUBLIC);
-
+
// template class
List classTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_CLASS);
- IStructureTemplate ct = (IStructureTemplate)classTemplates.get(0);
+ IStructureTemplate ct = (IStructureTemplate) classTemplates.get(0);
assertEquals(ct.getElementName(), "myarray"); //$NON-NLS-1$
checkElementOffset(ct);
assertEquals(ct.getTemplateSignature(), "myarray<T, Tibor>"); //$NON-NLS-1$
@@ -485,7 +486,7 @@ public class StructuralCModelElementsTests extends BaseTestCase {
// template struct
List structTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT);
- IStructureTemplate st = (IStructureTemplate)structTemplates.get(0);
+ IStructureTemplate st = (IStructureTemplate) structTemplates.get(0);
assertEquals(st.getElementName(), "mystruct"); //$NON-NLS-1$
checkElementOffset(st);
assertEquals(st.getTemplateSignature(), "mystruct<T, Tibor>"); //$NON-NLS-1$
@@ -494,15 +495,15 @@ public class StructuralCModelElementsTests extends BaseTestCase {
// moved to failed tests
// also commented in the source file
// template variable
-// ArrayList variableTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_VARIABLE);
-// VariableTemplate vt = (VariableTemplate)variableTemplates.get(0);
-// assertEquals(vt.getElementName(), "default_alloc_template<__threads,__inst>::_S_start_free");
-// checkElementOffset((CElement)mac1);
-// assertEquals(vt.getTemplateSignature(), "default_alloc_template<__threads,__inst>::_S_start_free<bool, int> : char*");
-// checkLineNumbers((CElement)vt, 128, 129);
+ // ArrayList variableTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_VARIABLE);
+ // VariableTemplate vt = (VariableTemplate)variableTemplates.get(0);
+ // assertEquals(vt.getElementName(), "default_alloc_template<__threads,__inst>::_S_start_free");
+ // checkElementOffset((CElement)mac1);
+ // assertEquals(vt.getTemplateSignature(), "default_alloc_template<__threads,__inst>::_S_start_free<bool, int> : char*");
+ // checkLineNumbers((CElement)vt, 128, 129);
}
-
- private void checkArrays(IParent tu) throws CModelException{
+
+ private void checkArrays(IParent tu) throws CModelException {
// array variable
List variables = tu.getChildrenOfType(ICElement.C_VARIABLE);
IVariable arrayVar = (IVariable) variables.get(0);
@@ -510,42 +511,43 @@ public class StructuralCModelElementsTests extends BaseTestCase {
checkElementOffset(arrayVar);
assertEquals(arrayVar.getTypeName(), "int[][]"); //$NON-NLS-1$
checkLineNumbers(arrayVar, 133, 133);
-
+
// array parameter in function main
List functions = tu.getChildrenOfType(ICElement.C_FUNCTION);
- IFunction mainFunction = (IFunction) functions.get(0);
+ IFunction mainFunction = (IFunction) functions.get(0);
assertEquals(mainFunction.getElementName(), "main"); //$NON-NLS-1$
checkElementOffset(mainFunction);
assertEquals(mainFunction.getReturnType(), "int"); //$NON-NLS-1$
checkLineNumbers(mainFunction, 134, 136);
int NumOfParam = mainFunction.getNumberOfParameters();
- if(NumOfParam != 2)
+ if (NumOfParam != 2)
fail("main should have two parameter!"); //$NON-NLS-1$
String[] paramTypes = mainFunction.getParameterTypes();
assertEquals(paramTypes[0], "int"); //$NON-NLS-1$
assertEquals(paramTypes[1], "char*[]"); //$NON-NLS-1$
-
+
}
+
private void checkLineNumbers(ICElement element, int startLine, int endLine) throws CModelException {
- ISourceRange range = ((ISourceReference)element).getSourceRange();
+ ISourceRange range = ((ISourceReference) element).getSourceRange();
assertEquals(startLine, range.getStartLine());
- assertEquals(endLine, range.getEndLine());
+ assertEquals(endLine, range.getEndLine());
}
-
- private void checkElementOffset(ICElement element) throws CModelException{
+
+ private void checkElementOffset(ICElement element) throws CModelException {
String name = element.getElementName();
- ISourceRange range = ((ISourceReference)element).getSourceRange();
- if(name.length() > 0 ){
- assertTrue (range.getStartPos() <= range.getIdStartPos());
- assertEquals (range.getIdLength(), name.length());
+ ISourceRange range = ((ISourceReference) element).getSourceRange();
+ if (name.length() > 0) {
+ assertTrue(range.getStartPos() <= range.getIdStartPos());
+ assertEquals(range.getIdLength(), name.length());
} else {
- assertEquals (range.getStartPos(), range.getIdStartPos());
+ assertEquals(range.getStartPos(), range.getIdStartPos());
if (element instanceof ITypeDef)
- assertEquals (range.getIdLength(), ((ITypeDef)element).getTypeName().length());
- else if(element instanceof IEnumeration)
- assertEquals (range.getIdLength(), ((IEnumeration)element).getTypeName().length());
- else if(element instanceof IStructure)
- assertEquals (range.getIdLength(), ((IStructure)element).getTypeName().length());
+ assertEquals(range.getIdLength(), ((ITypeDef) element).getTypeName().length());
+ else if (element instanceof IEnumeration)
+ assertEquals(range.getIdLength(), ((IEnumeration) element).getTypeName().length());
+ else if (element instanceof IStructure)
+ assertEquals(range.getIdLength(), ((IStructure) element).getTypeName().length());
}
}
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralMacroTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralMacroTests.java
index 3a252de2c7e..7ed0b3a36a8 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralMacroTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralMacroTests.java
@@ -29,10 +29,10 @@ public class StructuralMacroTests extends IMacroTests {
* containing all its public members named "test*"
*/
public static Test suite() {
- TestSuite suite= new TestSuite( StructuralMacroTests.class.getName() );
- suite.addTest( new StructuralMacroTests("testGetElementName"));
+ TestSuite suite = new TestSuite(StructuralMacroTests.class.getName());
+ suite.addTest(new StructuralMacroTests("testGetElementName"));
return suite;
- }
+ }
/**
* @param name
@@ -40,11 +40,10 @@ public class StructuralMacroTests extends IMacroTests {
public StructuralMacroTests(String name) {
super(name);
}
-
-
+
@Override
public void testGetElementName() throws CModelException {
setStructuralParse(true);
super.testGetElementName();
- }
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralStructureTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralStructureTests.java
index fd2ad7efac3..6b082a00f77 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralStructureTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralStructureTests.java
@@ -12,6 +12,7 @@
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.model.tests;
+
import org.eclipse.cdt.core.model.CModelException;
import junit.framework.*;
@@ -27,30 +28,30 @@ public class StructuralStructureTests extends IStructureTests {
public StructuralStructureTests(String name) {
super(name);
}
-
+
public static Test suite() {
- TestSuite suite= new TestSuite( StructuralStructureTests.class.getName() );
-
+ TestSuite suite = new TestSuite(StructuralStructureTests.class.getName());
+
// TODO check C-only behaviour using C_NATURE vs CC_NATURE
-
+
// Interface tests:
- suite.addTest( new StructuralStructureTests("testGetChildrenOfTypeStruct"));
- suite.addTest( new StructuralStructureTests("testGetChildrenOfTypeClass")); // C++ only
- suite.addTest( new StructuralStructureTests("testGetFields"));
- suite.addTest( new StructuralStructureTests("testGetField"));
- suite.addTest( new StructuralStructureTests("testGetMethods")); // C++ only
- suite.addTest( new StructuralStructureTests("testGetMethod")); // C++ only
- suite.addTest( new StructuralStructureTests("testIsStruct"));
- suite.addTest( new StructuralStructureTests("testIsClass")); // C++ only
- suite.addTest( new StructuralStructureTests("testIsUnion"));
- suite.addTest( new StructuralStructureTests("testIsAbstract")); // C++ only
- suite.addTest( new StructuralStructureTests("testGetBaseTypes")); // C++ only
- suite.addTest( new StructuralStructureTests("testGetAccessControl")); // C++ only
-
- // Language Specification tests:
- suite.addTest( new StructuralStructureTests("testAnonymousStructObject"));
- suite.addTest( new StructuralStructureTests("testInnerStruct"));
-
+ suite.addTest(new StructuralStructureTests("testGetChildrenOfTypeStruct"));
+ suite.addTest(new StructuralStructureTests("testGetChildrenOfTypeClass")); // C++ only
+ suite.addTest(new StructuralStructureTests("testGetFields"));
+ suite.addTest(new StructuralStructureTests("testGetField"));
+ suite.addTest(new StructuralStructureTests("testGetMethods")); // C++ only
+ suite.addTest(new StructuralStructureTests("testGetMethod")); // C++ only
+ suite.addTest(new StructuralStructureTests("testIsStruct"));
+ suite.addTest(new StructuralStructureTests("testIsClass")); // C++ only
+ suite.addTest(new StructuralStructureTests("testIsUnion"));
+ suite.addTest(new StructuralStructureTests("testIsAbstract")); // C++ only
+ suite.addTest(new StructuralStructureTests("testGetBaseTypes")); // C++ only
+ suite.addTest(new StructuralStructureTests("testGetAccessControl")); // C++ only
+
+ // Language Specification tests:
+ suite.addTest(new StructuralStructureTests("testAnonymousStructObject"));
+ suite.addTest(new StructuralStructureTests("testInnerStruct"));
+
return suite;
}
@@ -62,6 +63,7 @@ public class StructuralStructureTests extends IStructureTests {
setStructuralParse(true);
super.testAnonymousStructObject();
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetAccessControl()
*/
@@ -70,6 +72,7 @@ public class StructuralStructureTests extends IStructureTests {
setStructuralParse(true);
super.testGetAccessControl();
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetBaseTypes()
*/
@@ -78,6 +81,7 @@ public class StructuralStructureTests extends IStructureTests {
setStructuralParse(true);
super.testGetBaseTypes();
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetChildrenOfTypeClass()
*/
@@ -86,6 +90,7 @@ public class StructuralStructureTests extends IStructureTests {
setStructuralParse(true);
super.testGetChildrenOfTypeClass();
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetChildrenOfTypeStruct()
*/
@@ -94,6 +99,7 @@ public class StructuralStructureTests extends IStructureTests {
setStructuralParse(true);
super.testGetChildrenOfTypeStruct();
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetField()
*/
@@ -102,6 +108,7 @@ public class StructuralStructureTests extends IStructureTests {
setStructuralParse(true);
super.testGetField();
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetFields()
*/
@@ -110,6 +117,7 @@ public class StructuralStructureTests extends IStructureTests {
setStructuralParse(true);
super.testGetFields();
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetFieldsHack()
*/
@@ -118,6 +126,7 @@ public class StructuralStructureTests extends IStructureTests {
setStructuralParse(true);
super.testGetFieldsHack();
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetMethod()
*/
@@ -126,6 +135,7 @@ public class StructuralStructureTests extends IStructureTests {
setStructuralParse(true);
super.testGetMethod();
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetMethods()
*/
@@ -134,6 +144,7 @@ public class StructuralStructureTests extends IStructureTests {
setStructuralParse(true);
super.testGetMethods();
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetMethodsHack()
*/
@@ -142,6 +153,7 @@ public class StructuralStructureTests extends IStructureTests {
setStructuralParse(true);
super.testGetMethodsHack();
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetStructureInfo()
*/
@@ -150,6 +162,7 @@ public class StructuralStructureTests extends IStructureTests {
setStructuralParse(true);
super.testGetStructureInfo();
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testInnerStruct()
*/
@@ -158,6 +171,7 @@ public class StructuralStructureTests extends IStructureTests {
setStructuralParse(true);
super.testInnerStruct();
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testIsAbstract()
*/
@@ -166,6 +180,7 @@ public class StructuralStructureTests extends IStructureTests {
setStructuralParse(true);
super.testIsAbstract();
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testIsClass()
*/
@@ -174,6 +189,7 @@ public class StructuralStructureTests extends IStructureTests {
setStructuralParse(true);
super.testIsClass();
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testIsStruct()
*/
@@ -182,6 +198,7 @@ public class StructuralStructureTests extends IStructureTests {
setStructuralParse(true);
super.testIsStruct();
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.IStructureTests#testIsUnion()
*/
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralTemplateTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralTemplateTests.java
index 59a5a1a8783..d4ed43f96bf 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralTemplateTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralTemplateTests.java
@@ -12,6 +12,7 @@
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.model.tests;
+
import java.util.ArrayList;
import java.util.List;
@@ -34,18 +35,18 @@ public class StructuralTemplateTests extends ITemplateTests {
public StructuralTemplateTests(String name) {
super(name);
}
+
public static Test suite() {
- TestSuite suite= new TestSuite( StructuralTemplateTests.class.getName() );
-
+ TestSuite suite = new TestSuite(StructuralTemplateTests.class.getName());
+
// Interface tests:
- suite.addTest( new StructuralTemplateTests("testGetChildrenOfTypeTemplate"));
- suite.addTest( new StructuralTemplateTests("testGetNumberOfTemplateParameters"));
- suite.addTest( new StructuralTemplateTests("testGetTemplateParameterTypes"));
- suite.addTest( new StructuralTemplateTests("testGetTemplateSignature"));
-
+ suite.addTest(new StructuralTemplateTests("testGetChildrenOfTypeTemplate"));
+ suite.addTest(new StructuralTemplateTests("testGetNumberOfTemplateParameters"));
+ suite.addTest(new StructuralTemplateTests("testGetTemplateParameterTypes"));
+ suite.addTest(new StructuralTemplateTests("testGetTemplateSignature"));
+
return suite;
}
-
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.ITemplateTests#testGetChildrenOfTypeTemplate()
@@ -56,67 +57,56 @@ public class StructuralTemplateTests extends ITemplateTests {
ITranslationUnit tu = getTU();
{
List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT);
- String[] myExpectedValues = {
- "Map"
- };
+ String[] myExpectedValues = { "Map" };
assertEquals(myExpectedValues.length, arrayElements.size());
- for(int i=0; i<myExpectedValues.length; i++) {
+ for (int i = 0; i < myExpectedValues.length; i++) {
ICElement celement = (ICElement) arrayElements.get(i);
- ITemplate myITemplate = (ITemplate)celement;
- assertNotNull( "Failed on "+i, myITemplate);
- assertEquals("Failed on "+i, myExpectedValues[i], celement.getElementName());
+ ITemplate myITemplate = (ITemplate) celement;
+ assertNotNull("Failed on " + i, myITemplate);
+ assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName());
}
}
{
List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_CLASS);
- String[] myExpectedValues = {
- "nonVector"
- };
+ String[] myExpectedValues = { "nonVector" };
assertEquals(myExpectedValues.length, arrayElements.size());
- for(int i=0; i<myExpectedValues.length; i++) {
+ for (int i = 0; i < myExpectedValues.length; i++) {
ICElement celement = (ICElement) arrayElements.get(i);
- ITemplate myITemplate = (ITemplate)celement;
- assertNotNull( "Failed on "+i, myITemplate);
- assertEquals("Failed on "+i, myExpectedValues[i], celement.getElementName());
+ ITemplate myITemplate = (ITemplate) celement;
+ assertNotNull("Failed on " + i, myITemplate);
+ assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName());
}
}
{
List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_UNION);
- String[] myExpectedValues = {
- "ArrayOverlay"
- };
+ String[] myExpectedValues = { "ArrayOverlay" };
assertEquals(myExpectedValues.length, arrayElements.size());
- for(int i=0; i<myExpectedValues.length; i++) {
+ for (int i = 0; i < myExpectedValues.length; i++) {
ICElement celement = (ICElement) arrayElements.get(i);
- ITemplate myITemplate = (ITemplate)celement;
- assertNotNull( "Failed on "+i, myITemplate);
- assertEquals("Failed on "+i, myExpectedValues[i], celement.getElementName());
+ ITemplate myITemplate = (ITemplate) celement;
+ assertNotNull("Failed on " + i, myITemplate);
+ assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName());
}
}
{
- // Methods and Functions are tested together as
- // Function declarations in Quick Parse mode
+ // Methods and Functions are tested together as
+ // Function declarations in Quick Parse mode
// are considered Method Declarations in Structural parse mode
List arrayElements = getTemplateMethods(tu);
arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_METHOD));
arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION));
arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION_DECLARATION));
- String[] myExpectedValues = {
- "fum",
- "scrum",
- "nonVector<T>::first",
- "Foo::fum",
- "IsGreaterThan",
- };
+ String[] myExpectedValues = { "fum", "scrum", "nonVector<T>::first", "Foo::fum", "IsGreaterThan", };
assertEquals(myExpectedValues.length, arrayElements.size());
- for(int i=0; i<myExpectedValues.length; i++) {
+ for (int i = 0; i < myExpectedValues.length; i++) {
ICElement celement = (ICElement) arrayElements.get(i);
- ITemplate myITemplate = (ITemplate)celement;
- assertNotNull( "Failed on "+i, myITemplate);
- assertEquals("Failed on "+i, myExpectedValues[i], celement.getElementName());
+ ITemplate myITemplate = (ITemplate) celement;
+ assertNotNull("Failed on " + i, myITemplate);
+ assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName());
}
}
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.ITemplateTests#testGetNumberOfTemplateParameters()
*/
@@ -125,28 +115,28 @@ public class StructuralTemplateTests extends ITemplateTests {
setStructuralParse(true);
ITranslationUnit tu = getTU();
ArrayList arrayElements = new ArrayList();
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT ) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_CLASS ) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_UNION ) );
- arrayElements.addAll( getTemplateMethods(tu) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION ) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION_DECLARATION ) );
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_CLASS));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_UNION));
+ arrayElements.addAll(getTemplateMethods(tu));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION_DECLARATION));
arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_METHOD));
// TEMPLATE_VARIABLE moved to failed tests
//arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_VARIABLE ) );
-
+
int[] myExpectedNumbers = {
-// 3,1,3,1,1,3
- 3,1,3,1,1,1,1,1/*,2*/
+ // 3,1,3,1,1,3
+ 3, 1, 3, 1, 1, 1, 1, 1/*,2*/
};
assertEquals(myExpectedNumbers.length, arrayElements.size());
- for(int i=0; i<myExpectedNumbers.length; i++) {
+ for (int i = 0; i < myExpectedNumbers.length; i++) {
ITemplate myTemplate = (ITemplate) arrayElements.get(i);
- assertNotNull( "Failed on "+i, myTemplate );
- assertEquals( "Failed on "+i, myExpectedNumbers[i],
- myTemplate.getNumberOfTemplateParameters());
+ assertNotNull("Failed on " + i, myTemplate);
+ assertEquals("Failed on " + i, myExpectedNumbers[i], myTemplate.getNumberOfTemplateParameters());
}
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.ITemplateTests#testGetTemplateParameterTypes()
*/
@@ -155,49 +145,50 @@ public class StructuralTemplateTests extends ITemplateTests {
setStructuralParse(true);
ITranslationUnit tu = getTU();
ArrayList arrayElements = new ArrayList();
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT ) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_CLASS ) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_UNION ) );
- arrayElements.addAll( getTemplateMethods(tu) );
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_CLASS));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_UNION));
+ arrayElements.addAll(getTemplateMethods(tu));
arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_METHOD));
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION ) );
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION));
arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION_DECLARATION));
// TEMPLATE_VARIABLE moved to failed tests
//arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_VARIABLE ) );
-
+
String[][] myExpectedValues = {
- //"Map"
- {"Key", "Value", "SortAlgorithm"},
- //"nonVector"
- {"T"},
- //"ArrayOverlay"
- {"X","Y","int=16"},
- //"TemplateContainer::fum"
- {"Bar"},
- //"TemplateParameter::scrum"
- {"int"},
- //"nonVector::first"
- {"T"},
- //"Foo::fum"
- {"Bar"},
- //"IsGreaterThan"
- {"X"},
- /*
- //"default_alloc_template::S_start_free"
- {"bool", "int"},*/
+ //"Map"
+ { "Key", "Value", "SortAlgorithm" },
+ //"nonVector"
+ { "T" },
+ //"ArrayOverlay"
+ { "X", "Y", "int=16" },
+ //"TemplateContainer::fum"
+ { "Bar" },
+ //"TemplateParameter::scrum"
+ { "int" },
+ //"nonVector::first"
+ { "T" },
+ //"Foo::fum"
+ { "Bar" },
+ //"IsGreaterThan"
+ { "X" },
+ /*
+ //"default_alloc_template::S_start_free"
+ {"bool", "int"},*/
};
assertEquals(myExpectedValues.length, arrayElements.size());
- for(int i=0; i<myExpectedValues.length; i++) {
+ for (int i = 0; i < myExpectedValues.length; i++) {
ITemplate myTemplate = (ITemplate) arrayElements.get(i);
- assertNotNull( "Failed on "+i, myTemplate );
+ assertNotNull("Failed on " + i, myTemplate);
String[] myExpectedParams = myExpectedValues[i];
String[] myParams = myTemplate.getTemplateParameterTypes();
- assertEquals( "Failed on "+i, myExpectedParams.length, myParams.length );
- for(int j=0; j<myExpectedParams.length; j++) {
- assertEquals( "Failed on "+i+","+j, myExpectedParams[j], myParams[j] );
+ assertEquals("Failed on " + i, myExpectedParams.length, myParams.length);
+ for (int j = 0; j < myExpectedParams.length; j++) {
+ assertEquals("Failed on " + i + "," + j, myExpectedParams[j], myParams[j]);
}
}
}
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.tests.ITemplateTests#testGetTemplateSignature()
*/
@@ -206,33 +197,27 @@ public class StructuralTemplateTests extends ITemplateTests {
setStructuralParse(true);
ITranslationUnit tu = getTU();
ArrayList arrayElements = new ArrayList();
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT ) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_CLASS ) );
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_UNION ) );
- arrayElements.addAll( getTemplateMethods(tu) );
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_CLASS));
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_UNION));
+ arrayElements.addAll(getTemplateMethods(tu));
arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_METHOD));
- arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION ) );
+ arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION));
arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION_DECLARATION));
// TEMPLATE_VARIABLE moved to failed tests
//arrayElements.addAll( tu.getChildrenOfType(ICElement.C_TEMPLATE_VARIABLE ) );
-
- String[] myExpectedValues = {
- "Map<Key, Value, SortAlgorithm>",
- "nonVector<T>",
- "ArrayOverlay<X, Y, int=16>",
- "fum<Bar>(int) : void",
- "scrum<int>(void) : void", // TODO: deduce the rules of () versus (void), compare below.
- "nonVector<T>::first<T>() const : const T&", // TODO: where should <T> be?
- "Foo::fum<Bar>(int) : void",
- "IsGreaterThan<X>(X, X) : bool",
- /*"default_alloc_template<threads,inst>::S_start_free<bool, int> : char*",*/
+
+ String[] myExpectedValues = { "Map<Key, Value, SortAlgorithm>", "nonVector<T>", "ArrayOverlay<X, Y, int=16>",
+ "fum<Bar>(int) : void", "scrum<int>(void) : void", // TODO: deduce the rules of () versus (void), compare below.
+ "nonVector<T>::first<T>() const : const T&", // TODO: where should <T> be?
+ "Foo::fum<Bar>(int) : void", "IsGreaterThan<X>(X, X) : bool",
+ /*"default_alloc_template<threads,inst>::S_start_free<bool, int> : char*",*/
};
assertEquals(myExpectedValues.length, arrayElements.size());
- for(int i=0; i<myExpectedValues.length; i++) {
+ for (int i = 0; i < myExpectedValues.length; i++) {
ITemplate myTemplate = (ITemplate) arrayElements.get(i);
- assertNotNull( "Failed on "+i, myTemplate );
- assertEquals( "Failed on "+i, myExpectedValues[i],
- myTemplate.getTemplateSignature() );
+ assertNotNull("Failed on " + i, myTemplate);
+ assertEquals("Failed on " + i, myExpectedValues[i], myTemplate.getTemplateSignature());
}
}
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitBaseTest.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitBaseTest.java
index 00b5130f03e..b760b41dde5 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitBaseTest.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitBaseTest.java
@@ -34,128 +34,130 @@ import org.eclipse.core.runtime.Path;
* @author jcamelon
*
*/
-public class TranslationUnitBaseTest extends TestCase
-{
- /**
- *
- */
- public TranslationUnitBaseTest()
- {
- super();
- // TODO Auto-generated constructor stub
- }
- /**
- * @param name
- */
- public TranslationUnitBaseTest(String name)
- {
- super(name);
- // TODO Auto-generated constructor stub
- }
- protected IWorkspace workspace;
- protected IWorkspaceRoot root;
- protected ICProject testProject;
- protected IFile objfile;
- protected IFile archfile;
- protected IFile libfile;
- protected IFile exefile;
- protected IFile cfile;
- protected Path objpath;
- protected Path archpath;
- protected Path libpath;
- protected Path exepath;
- protected Path cpath;
- protected NullProgressMonitor monitor;
- /**
- * Sets up the test fixture.
- *
- * Called before every test case method.
- *
- * Example code test the packages in the project
- * "com.qnx.tools.ide.cdt.core"
- */
- @Override
- protected void setUp() throws Exception
- {
- /***
- * The rest of the tests assume that they have a working workspace
- * and workspace root object to use to create projects/files in,
- * so we need to get them setup first.
- */
- IWorkspaceDescription desc;
- workspace= ResourcesPlugin.getWorkspace();
- root= workspace.getRoot();
- monitor = new NullProgressMonitor();
- if (workspace==null)
- fail("Workspace was not setup");
- if (root==null)
- fail("Workspace root was not setup");
-
- desc=workspace.getDescription();
- desc.setAutoBuilding(false);
- workspace.setDescription(desc);
-
- /***
- * Setup the various files, paths and projects that are needed by the
- * tests
- */
-
- testProject=CProjectHelper.createCProject("filetest", "none", IPDOMManager.ID_NO_INDEXER);
- if (testProject==null)
- fail("Unable to create project");
-
- cfile = testProject.getProject().getFile("exetest.c");
- if (!cfile.exists()) {
- cfile.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/cfiles/TranslationUnits.c"))),
+public class TranslationUnitBaseTest extends TestCase {
+ /**
+ *
+ */
+ public TranslationUnitBaseTest() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param name
+ */
+ public TranslationUnitBaseTest(String name) {
+ super(name);
+ // TODO Auto-generated constructor stub
+ }
+
+ protected IWorkspace workspace;
+ protected IWorkspaceRoot root;
+ protected ICProject testProject;
+ protected IFile objfile;
+ protected IFile archfile;
+ protected IFile libfile;
+ protected IFile exefile;
+ protected IFile cfile;
+ protected Path objpath;
+ protected Path archpath;
+ protected Path libpath;
+ protected Path exepath;
+ protected Path cpath;
+ protected NullProgressMonitor monitor;
+
+ /**
+ * Sets up the test fixture.
+ *
+ * Called before every test case method.
+ *
+ * Example code test the packages in the project
+ * "com.qnx.tools.ide.cdt.core"
+ */
+ @Override
+ protected void setUp() throws Exception {
+ /***
+ * The rest of the tests assume that they have a working workspace
+ * and workspace root object to use to create projects/files in,
+ * so we need to get them setup first.
+ */
+ IWorkspaceDescription desc;
+ workspace = ResourcesPlugin.getWorkspace();
+ root = workspace.getRoot();
+ monitor = new NullProgressMonitor();
+ if (workspace == null)
+ fail("Workspace was not setup");
+ if (root == null)
+ fail("Workspace root was not setup");
+
+ desc = workspace.getDescription();
+ desc.setAutoBuilding(false);
+ workspace.setDescription(desc);
+
+ /***
+ * Setup the various files, paths and projects that are needed by the
+ * tests
+ */
+
+ testProject = CProjectHelper.createCProject("filetest", "none", IPDOMManager.ID_NO_INDEXER);
+ if (testProject == null)
+ fail("Unable to create project");
+
+ cfile = testProject.getProject().getFile("exetest.c");
+ if (!cfile.exists()) {
+ cfile.create(
+ new FileInputStream(
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/cfiles/TranslationUnits.c"))),
false, monitor);
- }
- cpath=new Path(workspace.getRoot().getLocation()+"/filetest/main.c");
-
- objfile = testProject.getProject().getFile("exetest.o");
- if (!objfile.exists()) {
- objfile.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/main.o"))),
+ }
+ cpath = new Path(workspace.getRoot().getLocation() + "/filetest/main.c");
+
+ objfile = testProject.getProject().getFile("exetest.o");
+ if (!objfile.exists()) {
+ objfile.create(
+ new FileInputStream(
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/main.o"))),
false, monitor);
- }
- objpath=new Path(workspace.getRoot().getLocation()+"/filetest/main.o");
-
- exefile = testProject.getProject().getFile("test_g");
- if (!exefile.exists()) {
- exefile.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/exe_g"))),
+ }
+ objpath = new Path(workspace.getRoot().getLocation() + "/filetest/main.o");
+
+ exefile = testProject.getProject().getFile("test_g");
+ if (!exefile.exists()) {
+ exefile.create(
+ new FileInputStream(
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/exe_g"))),
false, monitor);
- }
- exepath=new Path(workspace.getRoot().getLocation()+"/filetest/exe_g");
-
- archfile = testProject.getProject().getFile("libtestlib_g.a");
- if (!archfile.exists()) {
- archfile.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/a.g/libtestlib_g.a"))),
+ }
+ exepath = new Path(workspace.getRoot().getLocation() + "/filetest/exe_g");
+
+ archfile = testProject.getProject().getFile("libtestlib_g.a");
+ if (!archfile.exists()) {
+ archfile.create(new FileInputStream(
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/a.g/libtestlib_g.a"))),
false, monitor);
- }
- libpath=new Path(workspace.getRoot().getLocation()+"/filetest/libtestlib_g.so");
-
- libfile = testProject.getProject().getFile("libtestlib_g.so");
- if (!libfile.exists()) {
- libfile.create(new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/so.g/libtestlib_g.so"))),
+ }
+ libpath = new Path(workspace.getRoot().getLocation() + "/filetest/libtestlib_g.so");
+
+ libfile = testProject.getProject().getFile("libtestlib_g.so");
+ if (!libfile.exists()) {
+ libfile.create(new FileInputStream(
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/so.g/libtestlib_g.so"))),
false, monitor);
- }
- archpath=new Path(workspace.getRoot().getLocation()+"/filetest/libtestlib_g.a");
- }
- /**
- * Tears down the test fixture.
- *
- * Called after every test case method.
- */
- @Override
- protected void tearDown()
- {
- // release resources here and clean-up
- try {
- testProject.getProject().delete(true,true,monitor);
- } catch (CoreException e) {
- }
- }
+ }
+ archpath = new Path(workspace.getRoot().getLocation() + "/filetest/libtestlib_g.a");
+ }
+
+ /**
+ * Tears down the test fixture.
+ *
+ * Called after every test case method.
+ */
+ @Override
+ protected void tearDown() {
+ // release resources here and clean-up
+ try {
+ testProject.getProject().delete(true, true, monitor);
+ } catch (CoreException e) {
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitTests.java
index b1e29be5fb6..d05e61e2d12 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitTests.java
@@ -28,7 +28,7 @@ import org.eclipse.cdt.core.testplugin.util.ExpectedStrings;
/**
* @author Peter Graves
- *
+ *
* This file contains a set of generic tests for the core C model's TranslationUnit class.
* There is nothing exotic here, mostly just sanity type tests.
*/
@@ -37,9 +37,8 @@ public class TranslationUnitTests extends TranslationUnitBaseTest {
* This is a list of elements in the test .c file. It will be used in a
* number of places in the tests
*/
- private static final String[] expectedStringList = {
- "stdio.h", "unistd.h", "func2p", "globalvar", "myenum", "mystruct_t",
- "mystruct", "myunion", "mytype", "func1", "func2", "main", "func3" };
+ private static final String[] expectedStringList = { "stdio.h", "unistd.h", "func2p", "globalvar", "myenum",
+ "mystruct_t", "mystruct", "myunion", "mytype", "func1", "func2", "main", "func3" };
public TranslationUnitTests(String name) {
super(name);
@@ -87,8 +86,7 @@ public class TranslationUnitTests extends TranslationUnitBaseTest {
if (myElement == null) {
missing.push(expectedStringList[x]);
} else {
- assertTrue("Expected: \"" + expectedStringList[x]
- + "\". Got:" + myElement.getElementName(),
+ assertTrue("Expected: \"" + expectedStringList[x] + "\". Got:" + myElement.getElementName(),
expectedStringList[x].equals(myElement.getElementName()));
}
}
@@ -115,8 +113,7 @@ public class TranslationUnitTests extends TranslationUnitBaseTest {
} else {
// Failed test: Include.getIncludeName() always returns "";
// assertTrue
- assertTrue("PR:23478 Expected: an empty string. Got: "
- + include.getIncludeName(),
+ assertTrue("PR:23478 Expected: an empty string. Got: " + include.getIncludeName(),
includes[x].equals(include.getIncludeName()));
}
}
@@ -144,34 +141,34 @@ public class TranslationUnitTests extends TranslationUnitBaseTest {
* Simple sanity tests for the getElementAtLine() call.
*/
// This test is disabled due to consistent failure.
-// public void testGetElementAtLine() throws Exception {
-// Deque<String> missing = new ArrayDeque<String>();
-// ITranslationUnit tu = CProjectHelper.findTranslationUnit(testProject, "exetest.c");
-//
-// for (int x = 0; x < expectedStringList.length; x++) {
-// ICElement element = tu.getElementAtLine(expectedLines[x]);
-// if (element == null) {
-// missing.push(expectedStringList[x]);
-// } else {
-// if (expectedStringList[x].equals("mystruct_t")) {
-// assertTrue("PR:23603 expected: " + expectedStringList[x]
-// + ". Got: " + element.getElementName(),
-// expectedStringList[x].equals(element.getElementName()));
-// } else {
-// assertTrue("Expected: " + expectedStringList[x]
-// + ". Got: " + element.getElementName(),
-// expectedStringList[x].equals(element.getElementName()));
-// }
-// }
-// }
-// if (!missing.isEmpty()) {
-// StringBuilder output = new StringBuilder("PR:23603 Could not get elements:");
-// while (!missing.isEmpty()) {
-// output.append(" ").append(missing.pop());
-// }
-// assertTrue(output.toString(), false);
-// }
-// }
+ // public void testGetElementAtLine() throws Exception {
+ // Deque<String> missing = new ArrayDeque<String>();
+ // ITranslationUnit tu = CProjectHelper.findTranslationUnit(testProject, "exetest.c");
+ //
+ // for (int x = 0; x < expectedStringList.length; x++) {
+ // ICElement element = tu.getElementAtLine(expectedLines[x]);
+ // if (element == null) {
+ // missing.push(expectedStringList[x]);
+ // } else {
+ // if (expectedStringList[x].equals("mystruct_t")) {
+ // assertTrue("PR:23603 expected: " + expectedStringList[x]
+ // + ". Got: " + element.getElementName(),
+ // expectedStringList[x].equals(element.getElementName()));
+ // } else {
+ // assertTrue("Expected: " + expectedStringList[x]
+ // + ". Got: " + element.getElementName(),
+ // expectedStringList[x].equals(element.getElementName()));
+ // }
+ // }
+ // }
+ // if (!missing.isEmpty()) {
+ // StringBuilder output = new StringBuilder("PR:23603 Could not get elements:");
+ // while (!missing.isEmpty()) {
+ // output.append(" ").append(missing.pop());
+ // }
+ // assertTrue(output.toString(), false);
+ // }
+ // }
public void testIsValidSourceUnitName() {
assertTrue(CoreModel.isValidSourceUnitName(testProject.getProject(), "test.c"));
@@ -183,9 +180,9 @@ public class TranslationUnitTests extends TranslationUnitBaseTest {
// This test is disabled because it fails consistently due to a collision between content types
// "asmSource" defined in org.eclipse.cdt.core and
// "org.eclipse.cdt.managedbuilder.llvm.ui.llvmAssemblyCode" defined in
- // org.eclipse.cdt.managedbuilder.llvm.ui.
-// public void testAssemblyContentType_Bug186774() {
-// assertEquals(CCorePlugin.CONTENT_TYPE_ASMSOURCE, CoreModel.getRegistedContentTypeId(testProject.getProject(), "test.s"));
-// assertEquals(CCorePlugin.CONTENT_TYPE_ASMSOURCE, CoreModel.getRegistedContentTypeId(testProject.getProject(), "test.S"));
-// }
+ // org.eclipse.cdt.managedbuilder.llvm.ui.
+ // public void testAssemblyContentType_Bug186774() {
+ // assertEquals(CCorePlugin.CONTENT_TYPE_ASMSOURCE, CoreModel.getRegistedContentTypeId(testProject.getProject(), "test.s"));
+ // assertEquals(CCorePlugin.CONTENT_TYPE_ASMSOURCE, CoreModel.getRegistedContentTypeId(testProject.getProject(), "test.S"));
+ // }
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/WorkingCopyTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/WorkingCopyTests.java
index 949c4c3dda5..5aacabecbd0 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/WorkingCopyTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/WorkingCopyTests.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.core.model.tests;
-
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -39,38 +38,38 @@ import org.eclipse.core.runtime.Path;
* Contains unit test cases for Working Copies. Run using JUnit Plugin Test
* configuration launcher.
*/
-public class WorkingCopyTests extends TestCase {
+public class WorkingCopyTests extends TestCase {
private ICProject fCProject;
private IFile headerFile;
private NullProgressMonitor monitor;
-
+
public static void main(String[] args) {
TestPluginLauncher.run(TestPluginLauncher.getLocationFromProperties(), WorkingCopyTests.class, args);
}
-
+
public static Test suite() {
- TestSuite suite= new TestSuite(WorkingCopyTests.class.getName());
+ TestSuite suite = new TestSuite(WorkingCopyTests.class.getName());
suite.addTest(new WorkingCopyTests("testWorkingCopy"));
//suite.addTest(new WorkingCopyTests("testHashing"));
return suite;
- }
-
+ }
+
public WorkingCopyTests(String name) {
super(name);
}
-
+
@Override
protected void setUp() throws Exception {
monitor = new NullProgressMonitor();
-
- fCProject= CProjectHelper.createCCProject("TestProject1", "bin", IPDOMManager.ID_NO_INDEXER);
+
+ fCProject = CProjectHelper.createCCProject("TestProject1", "bin", IPDOMManager.ID_NO_INDEXER);
//Path filePath = new Path(ResourcesPlugin.getWorkspace().getRoot().getLocation().toString()+ fCProject.getPath().toString()+ "/WorkingCopyTest.h");
headerFile = fCProject.getProject().getFile("WorkingCopyTest.h");
if (!headerFile.exists()) {
- try{
+ try {
FileInputStream fileIn = new FileInputStream(
- CTestPlugin.getDefault().getFileInPlugin(new Path("resources/cfiles/WorkingCopyTestStart.h")));
- headerFile.create(fileIn,false, monitor);
+ CTestPlugin.getDefault().getFileInPlugin(new Path("resources/cfiles/WorkingCopyTestStart.h")));
+ headerFile.create(fileIn, false, monitor);
} catch (CoreException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
@@ -80,39 +79,38 @@ public class WorkingCopyTests extends TestCase {
}
@Override
- protected void tearDown() {
+ protected void tearDown() {
CProjectHelper.delete(fCProject);
- }
-
-
+ }
+
public void testWorkingCopy() throws Exception {
- ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(headerFile);
- // CreateWorkingCopy
- assertNotNull (tu);
+ ITranslationUnit tu = (ITranslationUnit) CoreModel.getDefault().create(headerFile);
+ // CreateWorkingCopy
+ assertNotNull(tu);
IWorkingCopy wc = tu.getWorkingCopy();
- assertNotNull (wc);
- assertNotNull (wc.getBuffer());
- assertTrue (wc.exists());
-
+ assertNotNull(wc);
+ assertNotNull(wc.getBuffer());
+ assertTrue(wc.exists());
+
// ModifyWorkingCopy
IBuffer wcBuf = wc.getBuffer();
wcBuf.append("\n class Hello{ int x; };");
- if (tu.getBuffer().getContents().equals(wc.getBuffer().getContents() ) )
- fail("Buffers should NOT be equal at this point!");
-
+ if (tu.getBuffer().getContents().equals(wc.getBuffer().getContents()))
+ fail("Buffers should NOT be equal at this point!");
+
// ReconcileWorkingCopy
wc.reconcile();
-
+
// CommitWorkingCopy
wc.commit(true, monitor);
-
- if(!tu.getBuffer().getContents().equals(wc.getBuffer().getContents()))
+
+ if (!tu.getBuffer().getContents().equals(wc.getBuffer().getContents()))
fail("Buffers should be equal at this point!");
-
+
// DestroyWorkingCopy
wc.destroy();
- assertFalse(wc.exists());
-
- Thread.sleep(1000);
+ assertFalse(wc.exists());
+
+ Thread.sleep(1000);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/AllCProjectDescriptionTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/AllCProjectDescriptionTests.java
index 278937a7c01..632ec266b32 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/AllCProjectDescriptionTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/AllCProjectDescriptionTests.java
@@ -17,15 +17,15 @@ import junit.framework.Test;
import junit.framework.TestSuite;
public class AllCProjectDescriptionTests {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
- public static Test suite() {
- TestSuite suite = new TestSuite(AllCProjectDescriptionTests.class.getName());
+ public static Test suite() {
+ TestSuite suite = new TestSuite(AllCProjectDescriptionTests.class.getName());
- // Just add more test cases here as you create them for
- // each class being tested
+ // Just add more test cases here as you create them for
+ // each class being tested
suite.addTest(CConfigurationDescriptionReferenceTests.suite());
suite.addTest(CConfigurationDescriptionExportSettings.suite());
suite.addTest(ExternalSettingsProviderTests.suite());
@@ -35,6 +35,6 @@ public class AllCProjectDescriptionTests {
suite.addTest(BackwardCompatibilityTests.suite());
suite.addTest(CProjectDescriptionBasicTests.suite());
suite.addTest(CProjectDescriptionStorageTests.suite());
- return suite;
- }
+ return suite;
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/BackwardCompatibilityTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/BackwardCompatibilityTests.java
index 08d1c4ca3b7..d3572e7c14d 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/BackwardCompatibilityTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/BackwardCompatibilityTests.java
@@ -37,11 +37,11 @@ import org.eclipse.core.runtime.Path;
public class BackwardCompatibilityTests extends BaseTestCase {
private static final String PROJ_NAME_PREFIX = "BackwardCompatibilityTests_";
ICProject p1, p2, p3;
-
+
public static TestSuite suite() {
return suite(BackwardCompatibilityTests.class, "_");
}
-
+
@Override
protected void setUp() throws Exception {
}
@@ -49,120 +49,123 @@ public class BackwardCompatibilityTests extends BaseTestCase {
@Override
protected void tearDown() throws Exception {
try {
- if(p1 != null){
+ if (p1 != null) {
p1.getProject().delete(true, null);
p1 = null;
}
- if(p2 != null){
+ if (p2 != null) {
p2.getProject().delete(true, null);
p2 = null;
}
- if(p3 != null){
+ if (p3 != null) {
p3.getProject().delete(true, null);
p3 = null;
}
- } catch (CoreException e){
+ } catch (CoreException e) {
}
}
public void testPathEntriesForNewStyle() throws Exception {
- p1 = CProjectHelper.createNewStyleCProject(PROJ_NAME_PREFIX + "a", TestUserAndDiscoveredEntriesCfgDataProvider.PROVIDER_ID, IPDOMManager.ID_NO_INDEXER);
+ p1 = CProjectHelper.createNewStyleCProject(PROJ_NAME_PREFIX + "a",
+ TestUserAndDiscoveredEntriesCfgDataProvider.PROVIDER_ID, IPDOMManager.ID_NO_INDEXER);
IProject project = p1.getProject();
-
+
IPathEntry[] entries = CoreModel.getRawPathEntries(p1);
IPathEntry[] resolvedentries = CoreModel.getResolvedPathEntries(p1);
- IPathEntry[] expectedRawEntries = new IPathEntry[]{
- CoreModel.newContainerEntry(new Path("org.eclipse.cdt.core.CFG_BASED_CONTAINER")),
- CoreModel.newSourceEntry(project.getFullPath()),
- CoreModel.newOutputEntry(project.getFullPath()),
- };
+ IPathEntry[] expectedRawEntries = new IPathEntry[] {
+ CoreModel.newContainerEntry(new Path("org.eclipse.cdt.core.CFG_BASED_CONTAINER")),
+ CoreModel.newSourceEntry(project.getFullPath()), CoreModel.newOutputEntry(project.getFullPath()), };
checkEntriesMatch(expectedRawEntries, entries);
-
- IPathEntry[] expectedResolvedEntries = new IPathEntry[]{
- CoreModel.newSourceEntry(project.getFullPath()),
+
+ IPathEntry[] expectedResolvedEntries = new IPathEntry[] { CoreModel.newSourceEntry(project.getFullPath()),
CoreModel.newOutputEntry(project.getFullPath()),
CoreModel.newIncludeEntry(project.getFullPath(), null, project.getLocation().append("a/b/c")),
CoreModel.newIncludeEntry(project.getFullPath(), null, new Path("/d/e/f")),
// Relative path with VALUE_WORKSPACE_PATH generates 2 entries, see MBSLanguageSettingsProvider
CoreModel.newIncludeEntry(project.getFullPath(), null, project.getLocation().append("g/h/i")),
- CoreModel.newIncludeEntry(project.getFullPath(), project.getFullPath().makeRelative(), new Path("g/h/i")),
+ CoreModel.newIncludeEntry(project.getFullPath(), project.getFullPath().makeRelative(),
+ new Path("g/h/i")),
CoreModel.newIncludeEntry(project.getFullPath(), new Path("j"), new Path("k/l")),
CoreModel.newMacroEntry(project.getFullPath(), "a", "b"),
- CoreModel.newMacroEntry(project.getFullPath(), "c", ""),
- };
+ CoreModel.newMacroEntry(project.getFullPath(), "c", ""), };
checkEntriesMatch(expectedResolvedEntries, resolvedentries);
IPathEntry[] newEntries = new IPathEntry[entries.length + 1];
System.arraycopy(entries, 0, newEntries, 0, entries.length);
- newEntries[entries.length] = CoreModel.newIncludeEntry(new Path("d"), null, new Path("/C/d/e"), true, new Path[]{new Path("a"), new Path("b")}, false);
+ newEntries[entries.length] = CoreModel.newIncludeEntry(new Path("d"), null, new Path("/C/d/e"), true,
+ new Path[] { new Path("a"), new Path("b") }, false);
IPathEntry[] newExpectedRawEntries = new IPathEntry[entries.length + 1];
System.arraycopy(entries, 0, newExpectedRawEntries, 0, entries.length);
- newExpectedRawEntries[entries.length] = CoreModel.newIncludeEntry(project.getFullPath().append("d"), null, new Path("/C/d/e"), true, new Path[]{new Path("a"), new Path("b")}, false);
+ newExpectedRawEntries[entries.length] = CoreModel.newIncludeEntry(project.getFullPath().append("d"), null,
+ new Path("/C/d/e"), true, new Path[] { new Path("a"), new Path("b") }, false);
CoreModel.setRawPathEntries(p1, newEntries, null);
-
+
entries = CoreModel.getRawPathEntries(p1);
checkEntriesMatch(entries, newExpectedRawEntries);
-
+
IPathEntry[] newExpectedResolved = new IPathEntry[resolvedentries.length + 1];
System.arraycopy(resolvedentries, 0, newExpectedResolved, 0, resolvedentries.length);
- newExpectedResolved[resolvedentries.length] = CoreModel.newIncludeEntry(project.getFullPath().append("d"), null, new Path("/C/d/e"), true, new Path[]{new Path("a"), new Path("b")}, false);
+ newExpectedResolved[resolvedentries.length] = CoreModel.newIncludeEntry(project.getFullPath().append("d"), null,
+ new Path("/C/d/e"), true, new Path[] { new Path("a"), new Path("b") }, false);
resolvedentries = CoreModel.getResolvedPathEntries(p1);
checkEntriesMatch(resolvedentries, newExpectedResolved);
-
- entries = concatEntries(entries, new IPathEntry[]{
- CoreModel.newSourceEntry(project.getFullPath().append("test_src")),
- CoreModel.newOutputEntry(project.getFullPath().append("test_out")),});
-
- newExpectedRawEntries = concatEntries(newExpectedRawEntries, new IPathEntry[]{
- CoreModel.newSourceEntry(project.getFullPath().append("test_src")),
- CoreModel.newOutputEntry(project.getFullPath().append("test_out")),});
-
- for(int i = 0; i < newExpectedRawEntries.length; i++){
+
+ entries = concatEntries(entries,
+ new IPathEntry[] { CoreModel.newSourceEntry(project.getFullPath().append("test_src")),
+ CoreModel.newOutputEntry(project.getFullPath().append("test_out")), });
+
+ newExpectedRawEntries = concatEntries(newExpectedRawEntries,
+ new IPathEntry[] { CoreModel.newSourceEntry(project.getFullPath().append("test_src")),
+ CoreModel.newOutputEntry(project.getFullPath().append("test_out")), });
+
+ for (int i = 0; i < newExpectedRawEntries.length; i++) {
IPathEntry entry = newExpectedRawEntries[i];
- if(entry.getEntryKind() == IPathEntry.CDT_SOURCE && entry.getPath().equals(project.getFullPath())){
- newExpectedRawEntries[i] = CoreModel.newSourceEntry(project.getFullPath(), new Path[]{new Path("test_src")});
+ if (entry.getEntryKind() == IPathEntry.CDT_SOURCE && entry.getPath().equals(project.getFullPath())) {
+ newExpectedRawEntries[i] = CoreModel.newSourceEntry(project.getFullPath(),
+ new Path[] { new Path("test_src") });
}
-// if(entry.getEntryKind() == IPathEntry.CDT_OUTPUT && entry.getPath().equals(project.getFullPath())){
-// newExpectedRawEntries[i] = CoreModel.newOutputEntry(project.getFullPath(), new Path[]{new Path("test_out")});
-// }
+ // if(entry.getEntryKind() == IPathEntry.CDT_OUTPUT && entry.getPath().equals(project.getFullPath())){
+ // newExpectedRawEntries[i] = CoreModel.newOutputEntry(project.getFullPath(), new Path[]{new Path("test_out")});
+ // }
}
-
- newExpectedResolved = concatEntries(newExpectedResolved, new IPathEntry[]{
- CoreModel.newSourceEntry(project.getFullPath().append("test_src")),
- CoreModel.newOutputEntry(project.getFullPath().append("test_out")),});
-
- for(int i = 0; i < newExpectedResolved.length; i++){
+
+ newExpectedResolved = concatEntries(newExpectedResolved,
+ new IPathEntry[] { CoreModel.newSourceEntry(project.getFullPath().append("test_src")),
+ CoreModel.newOutputEntry(project.getFullPath().append("test_out")), });
+
+ for (int i = 0; i < newExpectedResolved.length; i++) {
IPathEntry entry = newExpectedResolved[i];
- if(entry.getEntryKind() == IPathEntry.CDT_SOURCE && entry.getPath().equals(project.getFullPath())){
- newExpectedResolved[i] = CoreModel.newSourceEntry(project.getFullPath(), new Path[]{new Path("test_src")});
+ if (entry.getEntryKind() == IPathEntry.CDT_SOURCE && entry.getPath().equals(project.getFullPath())) {
+ newExpectedResolved[i] = CoreModel.newSourceEntry(project.getFullPath(),
+ new Path[] { new Path("test_src") });
}
-// if(entry.getEntryKind() == IPathEntry.CDT_OUTPUT && entry.getPath().equals(project.getFullPath())){
-// newExpectedResolved[i] = CoreModel.newOutputEntry(project.getFullPath(), new Path[]{new Path("test_out")});
-// }
+ // if(entry.getEntryKind() == IPathEntry.CDT_OUTPUT && entry.getPath().equals(project.getFullPath())){
+ // newExpectedResolved[i] = CoreModel.newOutputEntry(project.getFullPath(), new Path[]{new Path("test_out")});
+ // }
}
-
+
CoreModel.setRawPathEntries(p1, entries, null);
-
+
entries = CoreModel.getRawPathEntries(p1);
resolvedentries = CoreModel.getResolvedPathEntries(p1);
-
+
checkEntriesMatch(newExpectedRawEntries, entries);
checkEntriesMatch(newExpectedResolved, resolvedentries);
-
+
CoreModel.setRawPathEntries(p1, expectedRawEntries, null);
entries = CoreModel.getRawPathEntries(p1);
resolvedentries = CoreModel.getResolvedPathEntries(p1);
-
+
checkEntriesMatch(expectedRawEntries, entries);
checkEntriesMatch(expectedResolvedEntries, resolvedentries);
-
+
//check to see that setting the same entries do not give errors
CoreModel.setRawPathEntries(p1, expectedRawEntries, null);
entries = CoreModel.getRawPathEntries(p1);
resolvedentries = CoreModel.getResolvedPathEntries(p1);
-
+
checkEntriesMatch(expectedRawEntries, entries);
checkEntriesMatch(expectedResolvedEntries, resolvedentries);
}
@@ -176,29 +179,29 @@ public class BackwardCompatibilityTests extends BaseTestCase {
assertEquals(1, des.getConfigurations().length);
assertFalse(mngr.isNewStyleProject(des));
assertFalse(mngr.isNewStyleProject(project));
-
+
IPathEntry[] entries = CoreModel.getRawPathEntries(p2);
- entries = concatEntries(entries, new IPathEntry[]{
- CoreModel.newSourceEntry(project.getFullPath().append("test_src")),
- CoreModel.newOutputEntry(project.getFullPath().append("test_out")),});
+ entries = concatEntries(entries,
+ new IPathEntry[] { CoreModel.newSourceEntry(project.getFullPath().append("test_src")),
+ CoreModel.newOutputEntry(project.getFullPath().append("test_out")), });
CoreModel.setRawPathEntries(p2, entries, null);
-
- ICSourceEntry[] expectedSourceEntries = new ICSourceEntry[]{
- new CSourceEntry(project.getFullPath(), new IPath[] {new Path("test_src")}, ICSettingEntry.RESOLVED),
- new CSourceEntry(project.getFullPath().append("test_src"), null, ICSettingEntry.RESOLVED),
- };
- ICOutputEntry[] expectedOutputEntries = new ICOutputEntry[]{
- new COutputEntry(project.getFullPath(), null, ICSettingEntry.RESOLVED | ICSettingEntry.VALUE_WORKSPACE_PATH),
- new COutputEntry(project.getFullPath().append("test_out"), null, ICSettingEntry.RESOLVED | ICSettingEntry.VALUE_WORKSPACE_PATH),
- };
+ ICSourceEntry[] expectedSourceEntries = new ICSourceEntry[] {
+ new CSourceEntry(project.getFullPath(), new IPath[] { new Path("test_src") }, ICSettingEntry.RESOLVED),
+ new CSourceEntry(project.getFullPath().append("test_src"), null, ICSettingEntry.RESOLVED), };
+
+ ICOutputEntry[] expectedOutputEntries = new ICOutputEntry[] {
+ new COutputEntry(project.getFullPath(), null,
+ ICSettingEntry.RESOLVED | ICSettingEntry.VALUE_WORKSPACE_PATH),
+ new COutputEntry(project.getFullPath().append("test_out"), null,
+ ICSettingEntry.RESOLVED | ICSettingEntry.VALUE_WORKSPACE_PATH), };
des = mngr.getProjectDescription(project, false);
ICConfigurationDescription cfg = des.getDefaultSettingConfiguration();
ICSourceEntry[] sEntries = cfg.getSourceEntries();
ICOutputEntry[] oEntries = cfg.getBuildSetting().getOutputDirectories();
-
+
checkCEntriesMatch(expectedSourceEntries, sEntries);
checkCEntriesMatch(expectedOutputEntries, oEntries);
@@ -206,73 +209,73 @@ public class BackwardCompatibilityTests extends BaseTestCase {
cfg = des.getDefaultSettingConfiguration();
sEntries = cfg.getSourceEntries();
oEntries = cfg.getBuildSetting().getOutputDirectories();
-
+
checkCEntriesMatch(expectedSourceEntries, sEntries);
checkCEntriesMatch(expectedOutputEntries, oEntries);
}
-
+
public void testICDescriptorGetProjectData() throws Exception {
p3 = CProjectHelper.createCCProject(PROJ_NAME_PREFIX + "c", null, IPDOMManager.ID_NO_INDEXER);
IProject proj = p3.getProject();
-
+
doTestRm(proj);
doTestRm(proj);
doTestRm(proj);
doTestRm(proj);
doTestRm(proj);
}
-
- private void doTestRm(IProject proj) throws CoreException{
+
+ private void doTestRm(IProject proj) throws CoreException {
final String DATA_ID = "testICDescriptorGetProjectData";
- ICDescriptor dr = CCorePlugin.getDefault().getCProjectDescription(proj, false);
- dr.removeProjectStorageElement(DATA_ID);
- dr.saveProjectData();
+ ICDescriptor dr = CCorePlugin.getDefault().getCProjectDescription(proj, false);
+ dr.removeProjectStorageElement(DATA_ID);
+ dr.saveProjectData();
}
-
- public static IPathEntry[] concatEntries(IPathEntry[] entries1, IPathEntry[] entries2){
+
+ public static IPathEntry[] concatEntries(IPathEntry[] entries1, IPathEntry[] entries2) {
List list = new ArrayList(entries1.length + entries2.length);
list.addAll(Arrays.asList(entries1));
list.addAll(Arrays.asList(entries2));
- return (IPathEntry[])list.toArray(new IPathEntry[list.size()]);
+ return (IPathEntry[]) list.toArray(new IPathEntry[list.size()]);
}
-
- public static void checkCEntriesMatch(ICSettingEntry[] e1, ICSettingEntry[] e2){
- if(e1.length != e2.length)
+
+ public static void checkCEntriesMatch(ICSettingEntry[] e1, ICSettingEntry[] e2) {
+ if (e1.length != e2.length)
fail("entries num do not match");
-
+
Set set = new HashSet(Arrays.asList(e1));
set.removeAll(Arrays.asList(e2));
- if(set.size() != 0)
+ if (set.size() != 0)
fail("entries do not match");
}
-
- public static void checkEntriesMatch(IPathEntry[] e1, IPathEntry[] e2){
- if(e1.length != e2.length)
- fail("entries arrays have different length \ne1: " + dumpArray(e1) +"\ne2:" + dumpArray(e2) + "\n");
-
- for(int i = 0; i < e1.length; i++){
+
+ public static void checkEntriesMatch(IPathEntry[] e1, IPathEntry[] e2) {
+ if (e1.length != e2.length)
+ fail("entries arrays have different length \ne1: " + dumpArray(e1) + "\ne2:" + dumpArray(e2) + "\n");
+
+ for (int i = 0; i < e1.length; i++) {
IPathEntry entry = e1[i];
boolean found = false;
- for(int k = 0; k < e2.length; k++){
+ for (int k = 0; k < e2.length; k++) {
IPathEntry entry2 = e2[k];
- if(entry.equals(entry2)){
+ if (entry.equals(entry2)) {
found = true;
break;
}
}
- if(!found)
+ if (!found)
fail("unable to find entry " + entry.toString() + "\nin array \n" + dumpArray(e2) + "\n");
}
}
-
- public static String dumpArray(Object array[]){
- if(array == null)
+
+ public static String dumpArray(Object array[]) {
+ if (array == null)
return "null";
-
+
StringBuilder buf = new StringBuilder();
buf.append('[');
- for(int i = 0; i < array.length; i++){
- if(i != 0){
+ for (int i = 0; i < array.length; i++) {
+ if (i != 0) {
buf.append(",\n");
}
buf.append(array[i].toString());
@@ -280,5 +283,5 @@ public class BackwardCompatibilityTests extends BaseTestCase {
buf.append(']');
return buf.toString();
}
-
+
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionExportSettings.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionExportSettings.java
index f2d81dcd968..85817cde9b0 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionExportSettings.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionExportSettings.java
@@ -49,20 +49,12 @@ public class CConfigurationDescriptionExportSettings extends BaseTestCase {
}
// Setting entries 1
- final ICLanguageSettingEntry entries[] = new ICLanguageSettingEntry[]{
- new CMacroEntry("a", "b", 0),
- new CMacroEntry("c", "d", 0),
- new CIncludePathEntry("a/b/c", 0),
- new CIncludePathEntry("d/e/f", 0),
- };
+ final ICLanguageSettingEntry entries[] = new ICLanguageSettingEntry[] { new CMacroEntry("a", "b", 0),
+ new CMacroEntry("c", "d", 0), new CIncludePathEntry("a/b/c", 0), new CIncludePathEntry("d/e/f", 0), };
// Setting entries 2
- final ICLanguageSettingEntry entries2[] = new ICLanguageSettingEntry[]{
- new CMacroEntry("a2", "b2", 0),
- new CMacroEntry("c2", "d2", 0),
- new CIncludePathEntry("a/b/c/2", 0),
- new CIncludePathEntry("d/e/f/2", 0),
- };
+ final ICLanguageSettingEntry entries2[] = new ICLanguageSettingEntry[] { new CMacroEntry("a2", "b2", 0),
+ new CMacroEntry("c2", "d2", 0), new CIncludePathEntry("a/b/c/2", 0), new CIncludePathEntry("d/e/f/2", 0), };
/**
* This tests for simple reference propagation.
@@ -149,13 +141,17 @@ public class CConfigurationDescriptionExportSettings extends BaseTestCase {
coreModel.setProjectDescription(libProj, desLib);
// Main Project references lib project
- cfgMain.setReferenceInfo(new HashMap<String, String>() {{ put(libProj.getName(), ""); }});
+ cfgMain.setReferenceInfo(new HashMap<String, String>() {
+ {
+ put(libProj.getName(), "");
+ }
+ });
coreModel.setProjectDescription(mainProj, desMain);
// Referenced settings have been picked up
for (ICLanguageSettingEntry e : entries) {
- assertTrue(cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c").
- getSettingEntriesList(e.getKind()).contains(e));
+ assertTrue(cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c")
+ .getSettingEntriesList(e.getKind()).contains(e));
}
}
@@ -183,8 +179,8 @@ public class CConfigurationDescriptionExportSettings extends BaseTestCase {
checkEquivContents(cfgLib.getExternalSettings()[0].getEntries(), entries);
for (ICLanguageSettingEntry e : entries) {
- assertTrue(cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c").
- getSettingEntriesList(e.getKind()).contains(e));
+ assertTrue(cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c")
+ .getSettingEntriesList(e.getKind()).contains(e));
}
}
@@ -208,13 +204,17 @@ public class CConfigurationDescriptionExportSettings extends BaseTestCase {
coreModel.setProjectDescription(libProj, desLib);
// Main Project references lib project
- cfgMain.setReferenceInfo(new HashMap<String, String>() {{ put(libProj.getName(), ""); }});
+ cfgMain.setReferenceInfo(new HashMap<String, String>() {
+ {
+ put(libProj.getName(), "");
+ }
+ });
coreModel.setProjectDescription(mainProj, desMain);
// Referenced settings have been picked up
for (ICLanguageSettingEntry e : entries) {
- assertTrue(cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c").
- getSettingEntriesList(e.getKind()).contains(e));
+ assertTrue(cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c")
+ .getSettingEntriesList(e.getKind()).contains(e));
}
}
@@ -229,16 +229,17 @@ public class CConfigurationDescriptionExportSettings extends BaseTestCase {
// Check the exported settings is correct
checkEquivContents(entries2, cfgLib.getExternalSettings()[0].getEntries());
// Fetch the configuration a-fresh to pick up the settings
- ICConfigurationDescription cfgMain = coreModel.getProjectDescription(mainProj, false).getActiveConfiguration();
+ ICConfigurationDescription cfgMain = coreModel.getProjectDescription(mainProj, false)
+ .getActiveConfiguration();
assertTrue(cfgMain.getReferenceInfo().containsKey(libProj.getName()));
// Referenced settings have changed from entries -> entries2
for (ICLanguageSettingEntry e : entries)
- assertTrue(!cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c").
- getSettingEntriesList(e.getKind()).contains(e));
+ assertTrue(!cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c")
+ .getSettingEntriesList(e.getKind()).contains(e));
for (ICLanguageSettingEntry e : entries2)
- assertTrue(cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c").
- getSettingEntriesList(e.getKind()).contains(e));
+ assertTrue(cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c")
+ .getSettingEntriesList(e.getKind()).contains(e));
}
}
@@ -263,13 +264,17 @@ public class CConfigurationDescriptionExportSettings extends BaseTestCase {
coreModel.setProjectDescription(libProj, desLib);
// Main Project references lib project
- cfgMain.setReferenceInfo(new HashMap<String, String>() {{ put(libProj.getName(), cfgLib.getId()); }});
+ cfgMain.setReferenceInfo(new HashMap<String, String>() {
+ {
+ put(libProj.getName(), cfgLib.getId());
+ }
+ });
coreModel.setProjectDescription(mainProj, desMain);
// Referenced settings have been picked up
for (ICLanguageSettingEntry e : entries) {
- assertTrue(cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c").
- getSettingEntriesList(e.getKind()).contains(e));
+ assertTrue(cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c")
+ .getSettingEntriesList(e.getKind()).contains(e));
}
}
@@ -284,16 +289,17 @@ public class CConfigurationDescriptionExportSettings extends BaseTestCase {
// Check the exported settings is correct
checkEquivContents(entries2, cfgLib.getExternalSettings()[0].getEntries());
// Fetch the configuration a-fresh to pick up the settings
- ICConfigurationDescription cfgMain = coreModel.getProjectDescription(mainProj, false).getActiveConfiguration();
+ ICConfigurationDescription cfgMain = coreModel.getProjectDescription(mainProj, false)
+ .getActiveConfiguration();
assertTrue(cfgMain.getReferenceInfo().get(libProj.getName()).equals(cfgLib.getId()));
// Referenced settings have changed from entries -> entries2
for (ICLanguageSettingEntry e : entries)
- assertTrue(!cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c").
- getSettingEntriesList(e.getKind()).contains(e));
+ assertTrue(!cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c")
+ .getSettingEntriesList(e.getKind()).contains(e));
for (ICLanguageSettingEntry e : entries2)
- assertTrue(cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c").
- getSettingEntriesList(e.getKind()).contains(e));
+ assertTrue(cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c")
+ .getSettingEntriesList(e.getKind()).contains(e));
}
}
@@ -321,14 +327,18 @@ public class CConfigurationDescriptionExportSettings extends BaseTestCase {
coreModel.setProjectDescription(libProj, desLib);
// Main Project references lib project
- cfgMain.setReferenceInfo(new HashMap<String, String>() {{ put(libProj.getName(), cfgLib.getId()); }});
+ cfgMain.setReferenceInfo(new HashMap<String, String>() {
+ {
+ put(libProj.getName(), cfgLib.getId());
+ }
+ });
coreModel.setProjectDescription(mainProj, desMain);
checkEquivContents(entries, cfgLib.getExternalSettings()[0].getEntries());
// Referenced settings have been picked up
for (ICLanguageSettingEntry e : entries) {
- assertTrue(cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c").
- getSettingEntriesList(e.getKind()).contains(e));
+ assertTrue(cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c")
+ .getSettingEntriesList(e.getKind()).contains(e));
}
// Backup the .cproject
@@ -341,8 +351,8 @@ public class CConfigurationDescriptionExportSettings extends BaseTestCase {
checkEquivContents(entries2, cfgLib.getExternalSettings()[0].getEntries());
// Referenced settings have been picked up
for (ICLanguageSettingEntry e : entries2) {
- assertTrue(coreModel.getProjectDescription(mainProj).getActiveConfiguration().getRootFolderDescription().getLanguageSettingForFile("a.c").
- getSettingEntriesList(e.getKind()).contains(e));
+ assertTrue(coreModel.getProjectDescription(mainProj).getActiveConfiguration().getRootFolderDescription()
+ .getLanguageSettingForFile("a.c").getSettingEntriesList(e.getKind()).contains(e));
}
}
@@ -356,12 +366,12 @@ public class CConfigurationDescriptionExportSettings extends BaseTestCase {
checkEquivContents(entries, cfgLib.getExternalSettings()[0].getEntries());
// Referencing project contains entries and not entries2
for (ICLanguageSettingEntry e : entries) {
- assertTrue(cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c").
- getSettingEntriesList(e.getKind()).contains(e));
+ assertTrue(cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c")
+ .getSettingEntriesList(e.getKind()).contains(e));
}
for (ICLanguageSettingEntry e : entries2) {
- assertTrue(!cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c").
- getSettingEntriesList(e.getKind()).contains(e));
+ assertTrue(!cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c")
+ .getSettingEntriesList(e.getKind()).contains(e));
}
}
@@ -393,8 +403,16 @@ public class CConfigurationDescriptionExportSettings extends BaseTestCase {
cfgMain.createExternalSetting(null, null, null, entries2);
// Main Project references lib project
- cfgMain.setReferenceInfo(new HashMap<String, String>() {{ put(libProj.getName(), cfgLib.getId()); }});
- cfgLib.setReferenceInfo(new HashMap<String, String>() {{ put(mainProj.getName(), cfgMain.getId()); }});
+ cfgMain.setReferenceInfo(new HashMap<String, String>() {
+ {
+ put(libProj.getName(), cfgLib.getId());
+ }
+ });
+ cfgLib.setReferenceInfo(new HashMap<String, String>() {
+ {
+ put(mainProj.getName(), cfgMain.getId());
+ }
+ });
coreModel.setProjectDescription(libProj, desLib);
coreModel.setProjectDescription(mainProj, desMain);
@@ -422,16 +440,16 @@ public class CConfigurationDescriptionExportSettings extends BaseTestCase {
// Tests the exports are now the right way round
for (ICLanguageSettingEntry e : entries) {
- assertTrue(!cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c").
- getSettingEntriesList(e.getKind()).contains(e));
- assertTrue(cfgLib.getRootFolderDescription().getLanguageSettingForFile("a.c").
- getSettingEntriesList(e.getKind()).contains(e));
+ assertTrue(!cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c")
+ .getSettingEntriesList(e.getKind()).contains(e));
+ assertTrue(cfgLib.getRootFolderDescription().getLanguageSettingForFile("a.c")
+ .getSettingEntriesList(e.getKind()).contains(e));
}
for (ICLanguageSettingEntry e : entries2) {
- assertTrue(cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c").
- getSettingEntriesList(e.getKind()).contains(e));
- assertTrue(!cfgLib.getRootFolderDescription().getLanguageSettingForFile("a.c").
- getSettingEntriesList(e.getKind()).contains(e));
+ assertTrue(cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c")
+ .getSettingEntriesList(e.getKind()).contains(e));
+ assertTrue(!cfgLib.getRootFolderDescription().getLanguageSettingForFile("a.c")
+ .getSettingEntriesList(e.getKind()).contains(e));
}
// Now replace the .cproject with .cproject_back. The exported settings should be picked up in the referenced config
@@ -451,22 +469,21 @@ public class CConfigurationDescriptionExportSettings extends BaseTestCase {
checkEquivContents(entries2, cfgMain.getExternalSettings()[0].getEntries());
// Referencing project contains entries and not entries2
for (ICLanguageSettingEntry e : entries) {
- assertTrue(cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c").
- getSettingEntriesList(e.getKind()).contains(e));
- assertTrue(!cfgLib.getRootFolderDescription().getLanguageSettingForFile("a.c").
- getSettingEntriesList(e.getKind()).contains(e));
+ assertTrue(cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c")
+ .getSettingEntriesList(e.getKind()).contains(e));
+ assertTrue(!cfgLib.getRootFolderDescription().getLanguageSettingForFile("a.c")
+ .getSettingEntriesList(e.getKind()).contains(e));
}
for (ICLanguageSettingEntry e : entries2) {
- assertTrue(!cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c").
- getSettingEntriesList(e.getKind()).contains(e));
- assertTrue(cfgLib.getRootFolderDescription().getLanguageSettingForFile("a.c").
- getSettingEntriesList(e.getKind()).contains(e));
+ assertTrue(!cfgMain.getRootFolderDescription().getLanguageSettingForFile("a.c")
+ .getSettingEntriesList(e.getKind()).contains(e));
+ assertTrue(cfgLib.getRootFolderDescription().getLanguageSettingForFile("a.c")
+ .getSettingEntriesList(e.getKind()).contains(e));
}
}
-
private void checkEquivContents(Object[] expected, Object[] actual) {
- if(expected == null){
+ if (expected == null) {
assertTrue(actual == null);
return;
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionReferenceTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionReferenceTests.java
index cfd5329e358..59d47048cbf 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionReferenceTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionReferenceTests.java
@@ -31,7 +31,6 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.core.runtime.CoreException;
-
/**
* Test ICConfigurationDescription reference behaviours
*/
@@ -41,43 +40,43 @@ public class CConfigurationDescriptionReferenceTests extends BaseTestCase {
ICConfigurationDescription p2cd1, p2cd2, p2cd3;
ICConfigurationDescription p3cd1, p3cd2, p3cd3;
ICConfigurationDescription p4cd1, p4cd2, p4cd3;
-
+
public static TestSuite suite() {
return suite(CConfigurationDescriptionReferenceTests.class, "_");
}
-
+
@Override
protected void setUp() throws Exception {
p1 = CProjectHelper.createCCProject("p1", "bin");
p2 = CProjectHelper.createCCProject("p2", "bin");
p3 = CProjectHelper.createCCProject("p3", "bin");
p4 = CProjectHelper.createCCProject("p4", "bin");
-
+
CoreModel coreModel = CoreModel.getDefault();
ICProjectDescription des1 = coreModel.getProjectDescription(p1.getProject());
ICProjectDescription des2 = coreModel.getProjectDescription(p2.getProject());
ICProjectDescription des3 = coreModel.getProjectDescription(p3.getProject());
ICProjectDescription des4 = coreModel.getProjectDescription(p4.getProject());
-
+
p1cd1 = newCfg(des1, "p1", "cd1");
p1cd2 = newCfg(des1, "p1", "cd2");
p1cd3 = newCfg(des1, "p1", "cd3");
-
+
p2cd1 = newCfg(des2, "p2", "cd1");
p2cd2 = newCfg(des2, "p2", "cd2");
p2cd3 = newCfg(des2, "p2", "cd3");
-
+
p3cd1 = newCfg(des3, "p3", "cd1");
p3cd2 = newCfg(des3, "p3", "cd2");
p3cd3 = newCfg(des3, "p3", "cd3");
-
+
p4cd1 = newCfg(des4, "p4", "cd1");
p4cd2 = newCfg(des4, "p4", "cd2");
p4cd3 = newCfg(des4, "p4", "cd3");
-
+
/*
* Setup references:
- *
+ *
* p1: cd1 cd2 cd3
* \ | /
* \|/
@@ -91,19 +90,19 @@ public class CConfigurationDescriptionReferenceTests extends BaseTestCase {
* \|/
* p4: cd1 cd2 cd3
*/
-
- setRefs(p1cd1, new ICConfigurationDescription[] {p2cd3});
- setRefs(p1cd2, new ICConfigurationDescription[] {p2cd2});
- setRefs(p1cd3, new ICConfigurationDescription[] {p2cd1});
-
- setRefs(p2cd1, new ICConfigurationDescription[] {p3cd1});
- setRefs(p2cd2, new ICConfigurationDescription[] {p3cd2});
- setRefs(p2cd3, new ICConfigurationDescription[] {p3cd3});
-
- setRefs(p3cd1, new ICConfigurationDescription[] {p4cd2});
- setRefs(p3cd2, new ICConfigurationDescription[] {p4cd2});
- setRefs(p3cd3, new ICConfigurationDescription[] {p4cd2});
-
+
+ setRefs(p1cd1, new ICConfigurationDescription[] { p2cd3 });
+ setRefs(p1cd2, new ICConfigurationDescription[] { p2cd2 });
+ setRefs(p1cd3, new ICConfigurationDescription[] { p2cd1 });
+
+ setRefs(p2cd1, new ICConfigurationDescription[] { p3cd1 });
+ setRefs(p2cd2, new ICConfigurationDescription[] { p3cd2 });
+ setRefs(p2cd3, new ICConfigurationDescription[] { p3cd3 });
+
+ setRefs(p3cd1, new ICConfigurationDescription[] { p4cd2 });
+ setRefs(p3cd2, new ICConfigurationDescription[] { p4cd2 });
+ setRefs(p3cd3, new ICConfigurationDescription[] { p4cd2 });
+
coreModel.setProjectDescription(p1.getProject(), des1);
coreModel.setProjectDescription(p2.getProject(), des2);
coreModel.setProjectDescription(p3.getProject(), des3);
@@ -119,49 +118,51 @@ public class CConfigurationDescriptionReferenceTests extends BaseTestCase {
node.setReferenceInfo(p1RefData);
}
- private ICConfigurationDescription newCfg(ICProjectDescription des, String project, String config) throws CoreException {
- CDefaultConfigurationData data= new CDefaultConfigurationData(project+"."+config, project+" "+config+" name", null);
+ private ICConfigurationDescription newCfg(ICProjectDescription des, String project, String config)
+ throws CoreException {
+ CDefaultConfigurationData data = new CDefaultConfigurationData(project + "." + config,
+ project + " " + config + " name", null);
data.initEmptyData();
- return des.createConfiguration(CCorePlugin.DEFAULT_PROVIDER_ID, data);
+ return des.createConfiguration(CCorePlugin.DEFAULT_PROVIDER_ID, data);
}
-
+
public void testConfigurationDescriptionReference() throws CoreException {
// references
-
- assertEdges(p1cd1, new ICConfigurationDescription[] {p2cd3}, true);
- assertEdges(p1cd2, new ICConfigurationDescription[] {p2cd2}, true);
- assertEdges(p1cd3, new ICConfigurationDescription[] {p2cd1}, true);
-
- assertEdges(p2cd1, new ICConfigurationDescription[] {p3cd1}, true);
- assertEdges(p2cd2, new ICConfigurationDescription[] {p3cd2}, true);
- assertEdges(p2cd3, new ICConfigurationDescription[] {p3cd3}, true);
-
- assertEdges(p3cd1, new ICConfigurationDescription[] {p4cd2}, true);
- assertEdges(p3cd2, new ICConfigurationDescription[] {p4cd2}, true);
- assertEdges(p3cd3, new ICConfigurationDescription[] {p4cd2}, true);
-
+
+ assertEdges(p1cd1, new ICConfigurationDescription[] { p2cd3 }, true);
+ assertEdges(p1cd2, new ICConfigurationDescription[] { p2cd2 }, true);
+ assertEdges(p1cd3, new ICConfigurationDescription[] { p2cd1 }, true);
+
+ assertEdges(p2cd1, new ICConfigurationDescription[] { p3cd1 }, true);
+ assertEdges(p2cd2, new ICConfigurationDescription[] { p3cd2 }, true);
+ assertEdges(p2cd3, new ICConfigurationDescription[] { p3cd3 }, true);
+
+ assertEdges(p3cd1, new ICConfigurationDescription[] { p4cd2 }, true);
+ assertEdges(p3cd2, new ICConfigurationDescription[] { p4cd2 }, true);
+ assertEdges(p3cd3, new ICConfigurationDescription[] { p4cd2 }, true);
+
assertEdges(p4cd1, new ICConfigurationDescription[] {}, true);
assertEdges(p4cd2, new ICConfigurationDescription[] {}, true);
assertEdges(p4cd3, new ICConfigurationDescription[] {}, true);
}
-
+
public void testConfigurationDescriptionReferencing() throws CoreException {
// referencing
-
+
assertEdges(p1cd1, new ICConfigurationDescription[] {}, false);
assertEdges(p1cd2, new ICConfigurationDescription[] {}, false);
assertEdges(p1cd3, new ICConfigurationDescription[] {}, false);
-
- assertEdges(p2cd1, new ICConfigurationDescription[] {p1cd3}, false);
- assertEdges(p2cd2, new ICConfigurationDescription[] {p1cd2}, false);
- assertEdges(p2cd3, new ICConfigurationDescription[] {p1cd1}, false);
-
- assertEdges(p3cd1, new ICConfigurationDescription[] {p2cd1}, false);
- assertEdges(p3cd2, new ICConfigurationDescription[] {p2cd2}, false);
- assertEdges(p3cd3, new ICConfigurationDescription[] {p2cd3}, false);
-
+
+ assertEdges(p2cd1, new ICConfigurationDescription[] { p1cd3 }, false);
+ assertEdges(p2cd2, new ICConfigurationDescription[] { p1cd2 }, false);
+ assertEdges(p2cd3, new ICConfigurationDescription[] { p1cd1 }, false);
+
+ assertEdges(p3cd1, new ICConfigurationDescription[] { p2cd1 }, false);
+ assertEdges(p3cd2, new ICConfigurationDescription[] { p2cd2 }, false);
+ assertEdges(p3cd3, new ICConfigurationDescription[] { p2cd3 }, false);
+
assertEdges(p4cd1, new ICConfigurationDescription[] {}, false);
- assertEdges(p4cd2, new ICConfigurationDescription[] {p3cd1, p3cd2, p3cd3}, false);
+ assertEdges(p4cd2, new ICConfigurationDescription[] { p3cd1, p3cd2, p3cd3 }, false);
assertEdges(p4cd3, new ICConfigurationDescription[] {}, false);
}
@@ -196,7 +197,7 @@ public class CConfigurationDescriptionReferenceTests extends BaseTestCase {
* p2: cd1 \
* p3: cd1
*/
- setRefs(p1cd1, new ICConfigurationDescription[] {p2cd1, p3cd1});
+ setRefs(p1cd1, new ICConfigurationDescription[] { p2cd1, p3cd1 });
coreModel.setProjectDescription(p1.getProject(), des1);
coreModel.setProjectDescription(p2.getProject(), des2);
coreModel.setProjectDescription(p3.getProject(), des3);
@@ -209,7 +210,7 @@ public class CConfigurationDescriptionReferenceTests extends BaseTestCase {
assertEquals(cfgs[1].getId(), p3cd1.getId());
// Swap them round and check that the order is still persisted...
- setRefs(p1cd1, new ICConfigurationDescription[] {p3cd1, p2cd1});
+ setRefs(p1cd1, new ICConfigurationDescription[] { p3cd1, p2cd1 });
coreModel.setProjectDescription(p1.getProject(), des1);
cfgs = CoreModelUtil.getReferencedConfigurationDescriptions(p1cd1, false);
assertTrue(cfgs.length == 2);
@@ -219,46 +220,50 @@ public class CConfigurationDescriptionReferenceTests extends BaseTestCase {
if (p1 != null)
try {
p1.getProject().delete(true, npm());
- } catch (CoreException e){}
+ } catch (CoreException e) {
+ }
if (p2 != null)
try {
p2.getProject().delete(true, npm());
- } catch (CoreException e){}
+ } catch (CoreException e) {
+ }
if (p3 != null)
try {
p3.getProject().delete(true, npm());
- } catch (CoreException e){}
+ } catch (CoreException e) {
+ }
}
}
- protected void assertEdges(ICConfigurationDescription cfgDes, ICConfigurationDescription[] expected, boolean references) {
+ protected void assertEdges(ICConfigurationDescription cfgDes, ICConfigurationDescription[] expected,
+ boolean references) {
ICConfigurationDescription[] actual;
-
- if(references) {
- actual= CoreModelUtil.getReferencedConfigurationDescriptions(cfgDes, false);
+
+ if (references) {
+ actual = CoreModelUtil.getReferencedConfigurationDescriptions(cfgDes, false);
} else {
- actual= CoreModelUtil.getReferencingConfigurationDescriptions(cfgDes, false);
+ actual = CoreModelUtil.getReferencingConfigurationDescriptions(cfgDes, false);
}
-
+
assertEquals(expected.length, actual.length);
-
+
List actualIds = new ArrayList();
for (ICConfigurationDescription element : actual) {
actualIds.add(element.getId());
}
// check for each ID, don't use a Set so we detect duplicates
for (ICConfigurationDescription element : expected) {
- assertTrue(element.getId()+" is missing", actualIds.contains(element.getId()));
+ assertTrue(element.getId() + " is missing", actualIds.contains(element.getId()));
}
}
-
+
@Override
protected void tearDown() throws Exception {
- for (Object element : Arrays.asList(new ICProject[]{p1,p2,p3,p4})) {
+ for (Object element : Arrays.asList(new ICProject[] { p1, p2, p3, p4 })) {
ICProject project = (ICProject) element;
try {
project.getProject().delete(true, npm());
- } catch(CoreException ce) {
+ } catch (CoreException ce) {
// try next one..
}
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionBasicTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionBasicTests.java
index 0eaa280a240..9ebdacf1418 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionBasicTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionBasicTests.java
@@ -33,46 +33,46 @@ import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.jobs.IJobManager;
import org.eclipse.core.runtime.jobs.Job;
-public class CProjectDescriptionBasicTests extends BaseTestCase{
+public class CProjectDescriptionBasicTests extends BaseTestCase {
private static final String PROJ_NAME_PREFIX = "CProjectDescriptionBasicTests_";
IProject p1, p2, p3, p4;
-
+
public static TestSuite suite() {
return suite(CProjectDescriptionBasicTests.class, "_");
}
-
+
public void testSetInvalidDescription() throws Exception {
IWorkspace wsp = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = wsp.getRoot();
-
+
p1 = root.getProject(PROJ_NAME_PREFIX + "1");
p1.create(null);
p1.open(null);
-
+
CProjectHelper.addNatureToProject(p1, CProjectNature.C_NATURE_ID, null);
-
+
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
-
+
ICProjectDescription des = mngr.createProjectDescription(p1, false);
-
+
assertFalse(des.isValid());
-
+
boolean failed = false;
try {
mngr.setProjectDescription(p1, des);
- } catch (CoreException e){
+ } catch (CoreException e) {
failed = true;
}
-
+
assertTrue(failed);
}
-
+
public void testModulesCopiedOnCreateNewConfig() throws Exception {
ICProject p = CProjectHelper.createNewStyleCProject(PROJ_NAME_PREFIX + "c", IPDOMManager.ID_NO_INDEXER);
p3 = p.getProject();
-
+
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
-
+
ICProjectDescription des = mngr.getProjectDescription(p3);
ICConfigurationDescription baseCfg = des.getConfigurations()[0];
final String baseCfgId = baseCfg.getId();
@@ -82,7 +82,7 @@ public class CProjectDescriptionBasicTests extends BaseTestCase{
final String EL_NAME = "testElName";
final String ATTR2 = "testAttr2";
final String ATTR2_VALUE = "testAttr2Value";
-
+
ICStorageElement el = baseCfg.getStorage(STORAGE_ID, false);
assertNull(el);
el = baseCfg.getStorage(STORAGE_ID, true);
@@ -92,10 +92,10 @@ public class CProjectDescriptionBasicTests extends BaseTestCase{
assertEquals(0, el.getChildren().length);
ICStorageElement child = el.createChild(EL_NAME);
child.setAttribute(ATTR2, ATTR2_VALUE);
-
+
final String newCfgId1 = "cfg1.id";//CDataUtil.genId(null);
-// final String newCfgId2 = CDataUtil.genId(null);
-
+ // final String newCfgId2 = CDataUtil.genId(null);
+
ICConfigurationDescription cfg1 = des.createConfiguration(newCfgId1, newCfgId1 + ".name", baseCfg);
assertEquals(newCfgId1, cfg1.getId());
el = cfg1.getStorage(STORAGE_ID, false);
@@ -107,7 +107,7 @@ public class CProjectDescriptionBasicTests extends BaseTestCase{
assertEquals(ATTR2_VALUE, child.getAttribute(ATTR2));
mngr.setProjectDescription(p3, des);
-
+
des = mngr.getProjectDescription(p3, false);
cfg1 = des.getConfigurationById(newCfgId1);
el = cfg1.getStorage(STORAGE_ID, false);
@@ -155,55 +155,55 @@ public class CProjectDescriptionBasicTests extends BaseTestCase{
public void testSetInvalidCreatingDescription() throws Exception {
IWorkspace wsp = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = wsp.getRoot();
-
+
p2 = root.getProject(PROJ_NAME_PREFIX + "2");
p2.create(null);
p2.open(null);
-
+
CProjectHelper.addNatureToProject(p2, CProjectNature.C_NATURE_ID, null);
-
+
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
-
+
ICProjectDescription des = mngr.createProjectDescription(p2, false, true);
des.setSessionProperty(new QualifiedName(CTestPlugin.PLUGIN_ID, "tmp"), "tmp");
-
+
assertFalse(des.isValid());
-
+
boolean failed = false;
try {
mngr.setProjectDescription(p2, des);
- } catch (CoreException e){
+ } catch (CoreException e) {
failed = true;
}
-
+
assertFalse(failed);
-
+
assertNotNull(mngr.getProjectDescription(p2, false));
assertNotNull(mngr.getProjectDescription(p2, true));
-
+
des = mngr.getProjectDescription(p2, true);
ICConfigurationDescription cfg = mngr.getPreferenceConfiguration(TestCfgDataProvider.PROVIDER_ID, true);
cfg = des.createConfiguration(CDataUtil.genId(null), CDataUtil.genId(null), cfg);
mngr.setProjectDescription(p2, des);
-
+
}
-
+
public void testSetDescriptionWithRootIncompatibleRuleAquired() throws Exception {
ICProject p = CProjectHelper.createNewStyleCProject(PROJ_NAME_PREFIX + "4", IPDOMManager.ID_NO_INDEXER);
p4 = p.getProject();
-
+
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
-
+
ICProjectDescription des = mngr.getProjectDescription(p4);
ICConfigurationDescription baseCfg = des.getConfigurations()[0];
-
+
baseCfg.setName("qwertyuiop");
-
+
IJobManager jm = Job.getJobManager();
boolean failed = false;
try {
jm.beginRule(p4, null);
-
+
mngr.setProjectDescription(p4, des);
} catch (CoreException e) {
failed = true;
@@ -211,16 +211,15 @@ public class CProjectDescriptionBasicTests extends BaseTestCase{
} finally {
jm.endRule(p4);
}
-
+
assertTrue(failed);
}
-
public void testBug242955() throws Exception {
CoreModel coreModel = CoreModel.getDefault();
ICProjectDescriptionManager mngr = coreModel.getProjectDescriptionManager();
- String projectName = "testBug242955";
+ String projectName = "testBug242955";
String defaultConfigurationName = "Default";
String newConfigurationName = "NEW-NAME";
@@ -237,7 +236,8 @@ public class CProjectDescriptionBasicTests extends BaseTestCase{
assertEquals(1, initialProjectDescription.getConfigurations().length);
// Initial configuration description
- ICConfigurationDescription initialDefaultConfigurationDescription = initialProjectDescription.getConfigurations()[0];
+ ICConfigurationDescription initialDefaultConfigurationDescription = initialProjectDescription
+ .getConfigurations()[0];
initialDefaultConfigurationDescription.setName(defaultConfigurationName);
assertEquals(defaultConfigurationName, initialDefaultConfigurationDescription.getName());
mngr.setProjectDescription(project, initialProjectDescription);
@@ -247,28 +247,28 @@ public class CProjectDescriptionBasicTests extends BaseTestCase{
// Dialog Manage-configurations-New-"NEW-NAME", from "Default" configuration
final String newConfigurationId = newConfigurationName + ".id";
- ICConfigurationDescription propertyDefaultConfigurationDescription = propertyProjectDescription.getConfigurations()[0];
+ ICConfigurationDescription propertyDefaultConfigurationDescription = propertyProjectDescription
+ .getConfigurations()[0];
// creating new configuration in "Property" project description
ICConfigurationDescription propertyNewConfigurationDescription = propertyProjectDescription
- .createConfiguration(newConfigurationId, newConfigurationName, propertyDefaultConfigurationDescription);
+ .createConfiguration(newConfigurationId, newConfigurationName,
+ propertyDefaultConfigurationDescription);
assertNotNull(propertyNewConfigurationDescription);
- assertEquals(2,propertyProjectDescription.getConfigurations().length);
- assertEquals(defaultConfigurationName,propertyProjectDescription.getConfigurations()[0].getName());
- assertEquals(newConfigurationName,propertyProjectDescription.getConfigurations()[1].getName());
+ assertEquals(2, propertyProjectDescription.getConfigurations().length);
+ assertEquals(defaultConfigurationName, propertyProjectDescription.getConfigurations()[0].getName());
+ assertEquals(newConfigurationName, propertyProjectDescription.getConfigurations()[1].getName());
// Apply button, local_prjd: copy "Property" new configuration description to "Applied" project description
ICProjectDescription applyButtonProjectDescription = coreModel.getProjectDescription(project);
ICConfigurationDescription applyButtonNewConfigurationDescription = applyButtonProjectDescription
- .createConfiguration(
- propertyNewConfigurationDescription.getId(),
- propertyNewConfigurationDescription.getName(),
- propertyNewConfigurationDescription);
+ .createConfiguration(propertyNewConfigurationDescription.getId(),
+ propertyNewConfigurationDescription.getName(), propertyNewConfigurationDescription);
// OK button, persist the property project description prjd.
coreModel.setProjectDescription(project, propertyProjectDescription);
- assertEquals(2,propertyProjectDescription.getConfigurations().length);
- assertEquals(defaultConfigurationName,propertyProjectDescription.getConfigurations()[0].getName());
- assertEquals(newConfigurationName,propertyProjectDescription.getConfigurations()[1].getName());
+ assertEquals(2, propertyProjectDescription.getConfigurations().length);
+ assertEquals(defaultConfigurationName, propertyProjectDescription.getConfigurations()[0].getName());
+ assertEquals(newConfigurationName, propertyProjectDescription.getConfigurations()[1].getName());
// Close project
project.close(null);
@@ -290,9 +290,9 @@ public class CProjectDescriptionBasicTests extends BaseTestCase{
// project description after reopening the project
ICProjectDescription reopenedProjectDescription = coreModel.getProjectDescription(project, false);
- assertEquals(2,reopenedProjectDescription.getConfigurations().length);
- assertEquals(defaultConfigurationName,reopenedProjectDescription.getConfigurations()[0].getName());
- assertEquals(newConfigurationName,reopenedProjectDescription.getConfigurations()[1].getName());
+ assertEquals(2, reopenedProjectDescription.getConfigurations().length);
+ assertEquals(defaultConfigurationName, reopenedProjectDescription.getConfigurations()[0].getName());
+ assertEquals(newConfigurationName, reopenedProjectDescription.getConfigurations()[1].getName());
project.close(null);
}
@@ -301,24 +301,24 @@ public class CProjectDescriptionBasicTests extends BaseTestCase{
@Override
protected void tearDown() throws Exception {
try {
- if(p1 != null)
+ if (p1 != null)
p1.getProject().delete(true, null);
- } catch (CoreException e){
+ } catch (CoreException e) {
}
try {
- if(p2 != null)
+ if (p2 != null)
p2.getProject().delete(true, null);
- } catch (CoreException e){
+ } catch (CoreException e) {
}
try {
- if(p3 != null)
+ if (p3 != null)
p3.getProject().delete(true, null);
- } catch (CoreException e){
+ } catch (CoreException e) {
}
try {
- if(p4 != null)
+ if (p4 != null)
p4.getProject().delete(true, null);
- } catch (CoreException e){
+ } catch (CoreException e) {
}
super.tearDown();
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java
index 37c0df5656f..69cdfe6a038 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java
@@ -32,7 +32,7 @@ import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-public class CProjectDescriptionDeltaTests extends BaseTestCase{
+public class CProjectDescriptionDeltaTests extends BaseTestCase {
private MockListener listener;
@@ -41,7 +41,7 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
private String fProjName;
private ICDescriptionDelta fDelta;
- public MockListener(String projName){
+ public MockListener(String projName) {
fProjName = projName;
fIsNotified = false;
fDelta = null;
@@ -49,17 +49,17 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
@Override
public void handleEvent(CProjectDescriptionEvent event) {
- if(!event.getProject().getName().equals(fProjName))
+ if (!event.getProject().getName().equals(fProjName))
return;
fIsNotified = true;
fDelta = event.getProjectDelta();
}
- boolean isNotified(){
+ boolean isNotified() {
return fIsNotified;
}
- void clearNotified(){
+ void clearNotified() {
fIsNotified = false;
fDelta = null;
}
@@ -82,10 +82,9 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
ResourceHelper.cleanUp(getName());
}
-
- private void initListener(String projName){
+ private void initListener(String projName) {
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
- if(listener != null)
+ if (listener != null)
mngr.removeCProjectDescriptionListener(listener);
listener = new MockListener(projName);
mngr.addCProjectDescriptionListener(listener, CProjectDescriptionEvent.APPLIED);
@@ -96,7 +95,7 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
private static List<ICDescriptionDelta> findDeltas(ICDescriptionDelta delta, int type) {
List<ICDescriptionDelta> list = new ArrayList<ICDescriptionDelta>();
- if ((delta.getChangeFlags()&type)!=0) {
+ if ((delta.getChangeFlags() & type) != 0) {
list.add(delta);
}
@@ -113,7 +112,7 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
initListener(projName);
IProject project = ResourceHelper.createCDTProject(projName, null,
- new String[] {"test.configuration.1", "test.configuration.2"});
+ new String[] { "test.configuration.1", "test.configuration.2" });
// Get writable project description and its configurations
ICProjectDescription prjDescription = mngr.getProjectDescription(project, true);
@@ -146,12 +145,12 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Check old setting
assertTrue(delta.getOldSetting() instanceof ICProjectDescription);
- ICProjectDescription oldSetting = (ICProjectDescription)delta.getOldSetting();
+ ICProjectDescription oldSetting = (ICProjectDescription) delta.getOldSetting();
assertEquals(cfgDescription0.getName(), oldSetting.getActiveConfiguration().getName());
// Check new setting
assertTrue(delta.getNewSetting() instanceof ICProjectDescription);
- ICProjectDescription newSetting = (ICProjectDescription)delta.getNewSetting();
+ ICProjectDescription newSetting = (ICProjectDescription) delta.getNewSetting();
assertEquals(cfgDescription1.getName(), newSetting.getActiveConfiguration().getName());
}
@@ -189,12 +188,12 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Check old setting
assertTrue(delta.getOldSetting() instanceof ICConfigurationDescription);
- ICConfigurationDescription oldSetting = (ICConfigurationDescription)delta.getOldSetting();
+ ICConfigurationDescription oldSetting = (ICConfigurationDescription) delta.getOldSetting();
assertEquals(oldName, oldSetting.getName());
// Check new setting
assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription);
- ICConfigurationDescription newSetting = (ICConfigurationDescription)delta.getNewSetting();
+ ICConfigurationDescription newSetting = (ICConfigurationDescription) delta.getNewSetting();
assertEquals(newName, newSetting.getName());
}
@@ -231,12 +230,12 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Check old setting
assertTrue(delta.getOldSetting() instanceof ICConfigurationDescription);
- ICConfigurationDescription oldSetting = (ICConfigurationDescription)delta.getOldSetting();
+ ICConfigurationDescription oldSetting = (ICConfigurationDescription) delta.getOldSetting();
assertEquals(oldDescription, oldSetting.getDescription());
// Check new setting
assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription);
- ICConfigurationDescription newSetting = (ICConfigurationDescription)delta.getNewSetting();
+ ICConfigurationDescription newSetting = (ICConfigurationDescription) delta.getNewSetting();
assertEquals(cfgDescription.getDescription(), newSetting.getDescription());
}
@@ -278,12 +277,12 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Check old setting
assertTrue(delta.getOldSetting() instanceof ICLanguageSetting);
- ICLanguageSetting oldSetting = (ICLanguageSetting)delta.getOldSetting();
+ ICLanguageSetting oldSetting = (ICLanguageSetting) delta.getOldSetting();
assertEquals(oldLanguageId, oldSetting.getLanguageId());
// Check new setting
assertTrue(delta.getNewSetting() instanceof ICLanguageSetting);
- ICLanguageSetting newSetting = (ICLanguageSetting)delta.getNewSetting();
+ ICLanguageSetting newSetting = (ICLanguageSetting) delta.getNewSetting();
assertEquals(newLanguageId, newSetting.getLanguageId());
}
@@ -305,7 +304,7 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Modification SOURCE_CONTENT_TYPE
final String testContentType = "test.content.type";
ICLanguageSetting langSetting = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), false);
- langSetting.setSourceContentTypeIds(new String[] {testContentType});
+ langSetting.setSourceContentTypeIds(new String[] { testContentType });
// Write project description
listener.clearNotified();
@@ -322,13 +321,13 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Check old setting
assertTrue(delta.getOldSetting() instanceof ICLanguageSetting);
- ICLanguageSetting oldSetting = (ICLanguageSetting)delta.getOldSetting();
+ ICLanguageSetting oldSetting = (ICLanguageSetting) delta.getOldSetting();
List<String> oldContentTypes = Arrays.asList(oldSetting.getSourceContentTypeIds());
assertTrue(!oldContentTypes.contains(testContentType));
// Check new setting
assertTrue(delta.getNewSetting() instanceof ICLanguageSetting);
- ICLanguageSetting newSetting = (ICLanguageSetting)delta.getNewSetting();
+ ICLanguageSetting newSetting = (ICLanguageSetting) delta.getNewSetting();
List<String> newContentTypes = Arrays.asList(newSetting.getSourceContentTypeIds());
assertTrue(newContentTypes.contains(testContentType));
@@ -351,12 +350,11 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Modification SOURCE_EXTENSIONS
ICLanguageSetting langSetting = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), false);
final String testContentType = CCorePlugin.CONTENT_TYPE_ASMSOURCE;
- langSetting.setSourceContentTypeIds(new String[] {testContentType});
- String[] exts = CDataUtil.getExtensionsFromContentTypes(project, new String[] {testContentType});
- assertTrue(exts.length>0);
+ langSetting.setSourceContentTypeIds(new String[] { testContentType });
+ String[] exts = CDataUtil.getExtensionsFromContentTypes(project, new String[] { testContentType });
+ assertTrue(exts.length > 0);
final String testSourceExtension = exts[0];
-
// Write project description
listener.clearNotified();
mngr.setProjectDescription(project, prjDescription);
@@ -369,17 +367,17 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
assertEquals(1, deltas.size());
ICDescriptionDelta delta = deltas.get(0);
assertNotNull(delta);
-// assertEquals(ICDescriptionDelta.SOURCE_EXTENSIONS, delta.getChangeFlags());
+ // assertEquals(ICDescriptionDelta.SOURCE_EXTENSIONS, delta.getChangeFlags());
// Check old setting
assertTrue(delta.getOldSetting() instanceof ICLanguageSetting);
- ICLanguageSetting oldSetting = (ICLanguageSetting)delta.getOldSetting();
+ ICLanguageSetting oldSetting = (ICLanguageSetting) delta.getOldSetting();
List<String> oldSourceExtensions = Arrays.asList(oldSetting.getSourceExtensions());
assertTrue(!oldSourceExtensions.contains(testSourceExtension));
// Check new setting
assertTrue(delta.getNewSetting() instanceof ICLanguageSetting);
- ICLanguageSetting newSetting = (ICLanguageSetting)delta.getNewSetting();
+ ICLanguageSetting newSetting = (ICLanguageSetting) delta.getNewSetting();
List<String> newSourceExtensions = Arrays.asList(newSetting.getSourceExtensions());
assertTrue(newSourceExtensions.contains(testSourceExtension));
@@ -402,7 +400,7 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Modification SETTING_ENTRIES
ICLanguageSettingEntry testSettingEntry = new CIncludePathEntry("/path", 0);
ICLanguageSetting langSetting = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), false);
- ICLanguageSettingEntry[] entries = new ICLanguageSettingEntry[] {testSettingEntry};
+ ICLanguageSettingEntry[] entries = new ICLanguageSettingEntry[] { testSettingEntry };
langSetting.setSettingEntries(ICSettingEntry.INCLUDE_PATH, entries);
// Write project description
@@ -421,13 +419,13 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Check old setting
assertTrue(delta.getOldSetting() instanceof ICLanguageSetting);
- ICLanguageSetting oldSetting = (ICLanguageSetting)delta.getOldSetting();
+ ICLanguageSetting oldSetting = (ICLanguageSetting) delta.getOldSetting();
List<ICLanguageSettingEntry> oldSettingEntries = oldSetting.getSettingEntriesList(ICSettingEntry.INCLUDE_PATH);
assertTrue(!oldSettingEntries.contains(testSettingEntry));
// Check new setting
assertTrue(delta.getNewSetting() instanceof ICLanguageSetting);
- ICLanguageSetting newSetting = (ICLanguageSetting)delta.getNewSetting();
+ ICLanguageSetting newSetting = (ICLanguageSetting) delta.getNewSetting();
List<ICLanguageSettingEntry> newSettingEntries = newSetting.getSettingEntriesList(ICSettingEntry.INCLUDE_PATH);
assertTrue(newSettingEntries.contains(testSettingEntry));
}
@@ -448,7 +446,7 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Modification BINARY_PARSER_IDS
final String testBinaryParserId = "test.binary.parser.id";
ICTargetPlatformSetting targetPlatformSetting = cfgDescription.getTargetPlatformSetting();
- targetPlatformSetting.setBinaryParserIds(new String[] {testBinaryParserId});
+ targetPlatformSetting.setBinaryParserIds(new String[] { testBinaryParserId });
// Write project description
listener.clearNotified();
@@ -466,13 +464,13 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Check old setting
assertTrue(delta.getOldSetting() instanceof ICTargetPlatformSetting);
- ICTargetPlatformSetting oldSetting = (ICTargetPlatformSetting)delta.getOldSetting();
+ ICTargetPlatformSetting oldSetting = (ICTargetPlatformSetting) delta.getOldSetting();
List<String> oldBinaryParserIds = Arrays.asList(oldSetting.getBinaryParserIds());
assertTrue(!oldBinaryParserIds.contains(testBinaryParserId));
// Check new setting
assertTrue(delta.getNewSetting() instanceof ICTargetPlatformSetting);
- ICTargetPlatformSetting newSetting = (ICTargetPlatformSetting)delta.getNewSetting();
+ ICTargetPlatformSetting newSetting = (ICTargetPlatformSetting) delta.getNewSetting();
List<String> newBinaryParserIds = Arrays.asList(newSetting.getBinaryParserIds());
assertTrue(newBinaryParserIds.contains(testBinaryParserId));
@@ -493,7 +491,7 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Modification ERROR_PARSER_IDS
String testErrorParserId = "test.error.parser.id";
- cfgDescription.getBuildSetting().setErrorParserIDs(new String[] {testErrorParserId});
+ cfgDescription.getBuildSetting().setErrorParserIDs(new String[] { testErrorParserId });
// Write project description
listener.clearNotified();
@@ -511,13 +509,13 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Check old setting
assertTrue(delta.getOldSetting() instanceof ICBuildSetting);
- ICBuildSetting oldSetting = (ICBuildSetting)delta.getOldSetting();
+ ICBuildSetting oldSetting = (ICBuildSetting) delta.getOldSetting();
List<String> oldErrorParserIds = Arrays.asList(oldSetting.getErrorParserIDs());
assertTrue(!oldErrorParserIds.contains(testErrorParserId));
// Check new setting
assertTrue(delta.getNewSetting() instanceof ICBuildSetting);
- ICBuildSetting newSetting = (ICBuildSetting)delta.getNewSetting();
+ ICBuildSetting newSetting = (ICBuildSetting) delta.getNewSetting();
List<String> newErrorParserIds = Arrays.asList(newSetting.getErrorParserIDs());
assertTrue(newErrorParserIds.contains(testErrorParserId));
@@ -538,9 +536,10 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0];
assertNotNull(cfgDescription);
- cfgDescription.createFileDescription(file.getProjectRelativePath(),cfgDescription.getRootFolderDescription());
+ cfgDescription.createFileDescription(file.getProjectRelativePath(),
+ cfgDescription.getRootFolderDescription());
ICFileDescription[] fileDescriptions = cfgDescription.getFileDescriptions();
- assertTrue(fileDescriptions.length>0);
+ assertTrue(fileDescriptions.length > 0);
mngr.setProjectDescription(project, prjDescription);
}
@@ -554,7 +553,7 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Modification EXCLUDE
ICFileDescription[] fileDescriptions = cfgDescription.getFileDescriptions();
- assertTrue(fileDescriptions.length>0);
+ assertTrue(fileDescriptions.length > 0);
ICFileDescription fileDescription = fileDescriptions[0];
fileDescription.setExcluded(true);
@@ -574,12 +573,12 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Check old setting
assertTrue(delta.getOldSetting() instanceof ICFileDescription);
- ICFileDescription oldSetting = (ICFileDescription)delta.getOldSetting();
+ ICFileDescription oldSetting = (ICFileDescription) delta.getOldSetting();
assertTrue(!oldSetting.isExcluded());
// Check new setting
assertTrue(delta.getNewSetting() instanceof ICFileDescription);
- ICFileDescription newSetting = (ICFileDescription)delta.getNewSetting();
+ ICFileDescription newSetting = (ICFileDescription) delta.getNewSetting();
assertTrue(newSetting.isExcluded());
}
@@ -599,8 +598,10 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
assertNotNull(cfgDescription);
// Modification SOURCE_ADDED
- List<ICSourceEntry> sourceEntries = new ArrayList<ICSourceEntry>(Arrays.asList(cfgDescription.getSourceEntries()));
- ICSourceEntry testSourceEntry = new CSourceEntry(project.getFullPath().append("test_src"), null, ICSettingEntry.RESOLVED);
+ List<ICSourceEntry> sourceEntries = new ArrayList<ICSourceEntry>(
+ Arrays.asList(cfgDescription.getSourceEntries()));
+ ICSourceEntry testSourceEntry = new CSourceEntry(project.getFullPath().append("test_src"), null,
+ ICSettingEntry.RESOLVED);
sourceEntries.add(testSourceEntry);
cfgDescription.setSourceEntries(sourceEntries.toArray(new ICSourceEntry[0]));
@@ -616,17 +617,17 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
assertEquals(1, deltas.size());
ICDescriptionDelta delta = deltas.get(0);
assertNotNull(delta);
-// assertEquals(ICDescriptionDelta.SOURCE_ADDED, delta.getChangeFlags());
+ // assertEquals(ICDescriptionDelta.SOURCE_ADDED, delta.getChangeFlags());
// Check old setting
assertTrue(delta.getOldSetting() instanceof ICConfigurationDescription);
- ICConfigurationDescription oldSetting = (ICConfigurationDescription)delta.getOldSetting();
+ ICConfigurationDescription oldSetting = (ICConfigurationDescription) delta.getOldSetting();
List<ICSourceEntry> oldSourceEntries = Arrays.asList(oldSetting.getSourceEntries());
assertTrue(!oldSourceEntries.contains(testSourceEntry));
// Check new setting
assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription);
- ICConfigurationDescription newSetting = (ICConfigurationDescription)delta.getNewSetting();
+ ICConfigurationDescription newSetting = (ICConfigurationDescription) delta.getNewSetting();
List<ICSourceEntry> newSourceEntries = Arrays.asList(newSetting.getSourceEntries());
assertTrue(newSourceEntries.contains(testSourceEntry));
}
@@ -638,7 +639,8 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
initListener(projName);
IProject project = ResourceHelper.createCDTProjectWithConfig(projName);
- ICSourceEntry testSourceEntry = new CSourceEntry(project.getFullPath().append("test_src"), null, ICSettingEntry.RESOLVED);
+ ICSourceEntry testSourceEntry = new CSourceEntry(project.getFullPath().append("test_src"), null,
+ ICSettingEntry.RESOLVED);
{
// Add some source entry to remove it during the test
ICProjectDescription prjDescription = mngr.getProjectDescription(project, true);
@@ -646,7 +648,8 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0];
assertNotNull(cfgDescription);
- List<ICSourceEntry> sourceEntries = new ArrayList<ICSourceEntry>(Arrays.asList(cfgDescription.getSourceEntries()));
+ List<ICSourceEntry> sourceEntries = new ArrayList<ICSourceEntry>(
+ Arrays.asList(cfgDescription.getSourceEntries()));
sourceEntries.add(testSourceEntry);
cfgDescription.setSourceEntries(sourceEntries.toArray(new ICSourceEntry[0]));
@@ -675,17 +678,17 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
assertEquals(1, deltas.size());
ICDescriptionDelta delta = deltas.get(0);
assertNotNull(delta);
-// assertEquals(ICDescriptionDelta.SOURCE_REMOVED, delta.getChangeFlags());
+ // assertEquals(ICDescriptionDelta.SOURCE_REMOVED, delta.getChangeFlags());
// Check old setting
assertTrue(delta.getOldSetting() instanceof ICConfigurationDescription);
- ICConfigurationDescription oldSetting = (ICConfigurationDescription)delta.getOldSetting();
+ ICConfigurationDescription oldSetting = (ICConfigurationDescription) delta.getOldSetting();
List<ICSourceEntry> oldSourceEntries = Arrays.asList(oldSetting.getSourceEntries());
assertTrue(oldSourceEntries.contains(testSourceEntry));
// Check new setting
assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription);
- ICConfigurationDescription newSetting = (ICConfigurationDescription)delta.getNewSetting();
+ ICConfigurationDescription newSetting = (ICConfigurationDescription) delta.getNewSetting();
List<ICSourceEntry> newSourceEntries = Arrays.asList(newSetting.getSourceEntries());
assertTrue(!newSourceEntries.contains(testSourceEntry));
}
@@ -707,7 +710,8 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Modification EXTERNAL_SETTINGS_ADDED
ICSettingEntry testSettingEntry = new CIncludePathEntry("/path", 0);
- ICExternalSetting testExternalSetting = cfgDescription.createExternalSetting(null, null, null, new ICSettingEntry[] {testSettingEntry});
+ ICExternalSetting testExternalSetting = cfgDescription.createExternalSetting(null, null, null,
+ new ICSettingEntry[] { testSettingEntry });
// Write project description
listener.clearNotified();
@@ -725,13 +729,13 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Check old setting
assertTrue(delta.getOldSetting() instanceof ICConfigurationDescription);
- ICConfigurationDescription oldSetting = (ICConfigurationDescription)delta.getOldSetting();
+ ICConfigurationDescription oldSetting = (ICConfigurationDescription) delta.getOldSetting();
List<ICExternalSetting> oldExternalSettings = Arrays.asList(oldSetting.getExternalSettings());
assertEquals(0, oldExternalSettings.size());
// Check new setting
assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription);
- ICConfigurationDescription newSetting = (ICConfigurationDescription)delta.getNewSetting();
+ ICConfigurationDescription newSetting = (ICConfigurationDescription) delta.getNewSetting();
List<ICExternalSetting> newExternalSettings = Arrays.asList(newSetting.getExternalSettings());
assertEquals(1, newExternalSettings.size());
List<ICSettingEntry> newSettingEntries = Arrays.asList(newExternalSettings.get(0).getEntries());
@@ -753,7 +757,8 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0];
assertNotNull(cfgDescription);
- ICExternalSetting testExternalSetting = cfgDescription.createExternalSetting(null, null, null, new ICSettingEntry[] {testSettingEntry});
+ ICExternalSetting testExternalSetting = cfgDescription.createExternalSetting(null, null, null,
+ new ICSettingEntry[] { testSettingEntry });
mngr.setProjectDescription(project, prjDescription);
}
@@ -783,7 +788,7 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Check old setting
assertTrue(delta.getOldSetting() instanceof ICConfigurationDescription);
- ICConfigurationDescription oldSetting = (ICConfigurationDescription)delta.getOldSetting();
+ ICConfigurationDescription oldSetting = (ICConfigurationDescription) delta.getOldSetting();
List<ICExternalSetting> oldExternalSettings = Arrays.asList(oldSetting.getExternalSettings());
assertEquals(1, oldExternalSettings.size());
List<ICSettingEntry> oldSettingEntries = Arrays.asList(oldExternalSettings.get(0).getEntries());
@@ -791,7 +796,7 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Check new setting
assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription);
- ICConfigurationDescription newSetting = (ICConfigurationDescription)delta.getNewSetting();
+ ICConfigurationDescription newSetting = (ICConfigurationDescription) delta.getNewSetting();
List<ICExternalSetting> newExternalSettings = Arrays.asList(newSetting.getExternalSettings());
assertEquals(0, newExternalSettings.size());
}
@@ -834,13 +839,13 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Check old setting
assertTrue(delta.getOldSetting() instanceof ICConfigurationDescription);
- ICConfigurationDescription oldSetting = (ICConfigurationDescription)delta.getOldSetting();
+ ICConfigurationDescription oldSetting = (ICConfigurationDescription) delta.getOldSetting();
Map<String, String> oldReferenceInfo = oldSetting.getReferenceInfo();
assertEquals(0, oldReferenceInfo.size());
// Check new setting
assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription);
- ICConfigurationDescription newSetting = (ICConfigurationDescription)delta.getNewSetting();
+ ICConfigurationDescription newSetting = (ICConfigurationDescription) delta.getNewSetting();
Map<String, String> newReferenceInfo = newSetting.getReferenceInfo();
assertEquals(1, newReferenceInfo.size());
assertEquals(testValue, newReferenceInfo.get(testKey));
@@ -894,14 +899,14 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Check old setting
assertTrue(delta.getOldSetting() instanceof ICConfigurationDescription);
- ICConfigurationDescription oldSetting = (ICConfigurationDescription)delta.getOldSetting();
+ ICConfigurationDescription oldSetting = (ICConfigurationDescription) delta.getOldSetting();
Map<String, String> oldReferenceInfo = oldSetting.getReferenceInfo();
assertEquals(1, oldReferenceInfo.size());
assertEquals(testValue, oldReferenceInfo.get(testKey));
// Check new setting
assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription);
- ICConfigurationDescription newSetting = (ICConfigurationDescription)delta.getNewSetting();
+ ICConfigurationDescription newSetting = (ICConfigurationDescription) delta.getNewSetting();
Map<String, String> newReferenceInfo = newSetting.getReferenceInfo();
assertEquals(0, newReferenceInfo.size());
}
@@ -924,7 +929,7 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Modification EXT_REF, currently binary parsers are represented as CConfigExtensionReference
final String testBinaryParserId = "test.binary.parser.id";
ICTargetPlatformSetting targetPlatformSetting = cfgDescription.getTargetPlatformSetting();
- targetPlatformSetting.setBinaryParserIds(new String[] {testBinaryParserId});
+ targetPlatformSetting.setBinaryParserIds(new String[] { testBinaryParserId });
// Write project description
listener.clearNotified();
@@ -942,14 +947,14 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Check old setting
assertTrue(delta.getOldSetting() instanceof ICConfigurationDescription);
- ICConfigurationDescription oldSetting = (ICConfigurationDescription)delta.getOldSetting();
+ ICConfigurationDescription oldSetting = (ICConfigurationDescription) delta.getOldSetting();
ICTargetPlatformSetting oldTargetPlatformSetting = oldSetting.getTargetPlatformSetting();
List<String> oldBinaryParserIds = Arrays.asList(oldTargetPlatformSetting.getBinaryParserIds());
assertTrue(!oldBinaryParserIds.contains(testBinaryParserId));
// Check new setting
assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription);
- ICConfigurationDescription newSetting = (ICConfigurationDescription)delta.getNewSetting();
+ ICConfigurationDescription newSetting = (ICConfigurationDescription) delta.getNewSetting();
ICTargetPlatformSetting newTargetPlatformSetting = newSetting.getTargetPlatformSetting();
List<String> newBinaryParserIds = Arrays.asList(newTargetPlatformSetting.getBinaryParserIds());
assertTrue(newBinaryParserIds.contains(testBinaryParserId));
@@ -961,7 +966,7 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
initListener(projName);
IProject project = ResourceHelper.createCDTProject(projName, null,
- new String[] {"test.configuration.1", "test.configuration.2"});
+ new String[] { "test.configuration.1", "test.configuration.2" });
// Get writable project description and its configuration
ICProjectDescription prjDescription = mngr.getProjectDescription(project, true);
@@ -995,12 +1000,12 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Check old setting
assertTrue(delta.getOldSetting() instanceof ICProjectDescription);
- ICProjectDescription oldSetting = (ICProjectDescription)delta.getOldSetting();
+ ICProjectDescription oldSetting = (ICProjectDescription) delta.getOldSetting();
assertEquals(cfgDescription0.getName(), oldSetting.getDefaultSettingConfiguration().getName());
// Check new setting
assertTrue(delta.getNewSetting() instanceof ICProjectDescription);
- ICProjectDescription newSetting = (ICProjectDescription)delta.getNewSetting();
+ ICProjectDescription newSetting = (ICProjectDescription) delta.getNewSetting();
assertEquals(cfgDescription1.getName(), newSetting.getDefaultSettingConfiguration().getName());
}
@@ -1017,7 +1022,8 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0];
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
- List<ILanguageSettingsProvider> originalProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ List<ILanguageSettingsProvider> originalProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription)
+ .getLanguageSettingProviders();
// Modification LANGUAGE_SETTINGS_PROVIDERS
ILanguageSettingsProvider provider = new LanguageSettingsSerializableProvider("test.id", "test.name");
@@ -1042,14 +1048,14 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
// Check old setting
assertTrue(delta.getOldSetting() instanceof ICConfigurationDescription);
assertTrue(delta.getOldSetting() instanceof ILanguageSettingsProvidersKeeper);
- ILanguageSettingsProvidersKeeper oldSetting = (ILanguageSettingsProvidersKeeper)delta.getOldSetting();
+ ILanguageSettingsProvidersKeeper oldSetting = (ILanguageSettingsProvidersKeeper) delta.getOldSetting();
List<ILanguageSettingsProvider> oldProviders = oldSetting.getLanguageSettingProviders();
assertEquals(originalProviders, oldProviders);
// Check new setting
assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription);
assertTrue(delta.getNewSetting() instanceof ILanguageSettingsProvidersKeeper);
- ILanguageSettingsProvidersKeeper newSetting = (ILanguageSettingsProvidersKeeper)delta.getNewSetting();
+ ILanguageSettingsProvidersKeeper newSetting = (ILanguageSettingsProvidersKeeper) delta.getNewSetting();
List<ILanguageSettingsProvider> newProviders = newSetting.getLanguageSettingProviders();
assertEquals(providers, newProviders);
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionStorageTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionStorageTests.java
index 9d5f2a5ca50..41c8ae5fe9a 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionStorageTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionStorageTests.java
@@ -154,12 +154,14 @@ public class CProjectDescriptionStorageTests extends BaseTestCase {
// create testChildInStorage
projDesc = CoreModel.getDefault().getProjectDescription(project, true);
- ICStorageElement[] children = projDesc.getDefaultSettingConfiguration().getStorage(testingStorage, false).getChildrenByName(testChildInStorage);
+ ICStorageElement[] children = projDesc.getDefaultSettingConfiguration().getStorage(testingStorage, false)
+ .getChildrenByName(testChildInStorage);
assertTrue(children.length == 1);
projDesc.getDefaultSettingConfiguration().getStorage(testingStorage, false).removeChild(children[0]);
CoreModel.getDefault().setProjectDescription(project, projDesc);
projDesc = CoreModel.getDefault().getProjectDescription(project, false);
- assertTrue(projDesc.getDefaultSettingConfiguration().getStorage(testingStorage, false).getChildrenByName(testChildInStorage).length == 0);
+ assertTrue(projDesc.getDefaultSettingConfiguration().getStorage(testingStorage, false)
+ .getChildrenByName(testChildInStorage).length == 0);
project.refreshLocal(IResource.DEPTH_INFINITE, null);
// Restore from backup
@@ -170,7 +172,8 @@ public class CProjectDescriptionStorageTests extends BaseTestCase {
// Check that the project description no longer contains the testChildInStorage
projDesc = CoreModel.getDefault().getProjectDescription(project, false);
- assertTrue(projDesc.getDefaultSettingConfiguration().getStorage(testingStorage, false).getChildrenByName(testChildInStorage).length == 1);
+ assertTrue(projDesc.getDefaultSettingConfiguration().getStorage(testingStorage, false)
+ .getChildrenByName(testChildInStorage).length == 1);
refreshJob.cancel();
}
@@ -242,7 +245,6 @@ public class CProjectDescriptionStorageTests extends BaseTestCase {
refreshJob.cancel();
}
-
/**
* Tests that a read-only project description file is picked up
* @throws Exception
@@ -287,7 +289,8 @@ public class CProjectDescriptionStorageTests extends BaseTestCase {
* set files writable if no UI context has been provided.
*/
private void enableSetWritableWhenHeadless(boolean enable) {
- InstanceScope.INSTANCE.getNode("org.eclipse.team.ui").putBoolean("org.eclipse.team.ui.validate_edit_with_no_context", enable);
+ InstanceScope.INSTANCE.getNode("org.eclipse.team.ui")
+ .putBoolean("org.eclipse.team.ui.validate_edit_with_no_context", enable);
}
/**
@@ -357,13 +360,12 @@ public class CProjectDescriptionStorageTests extends BaseTestCase {
@Override
public boolean visit(IResource resource) throws CoreException {
assertTrue(resource instanceof IFile);
- csettings.getFile(resource.getName()).create(((IFile)resource).getContents(), false, null);
+ csettings.getFile(resource.getName()).create(((IFile) resource).getContents(), false, null);
return false;
}
});
}
-
private void backUpCProjectFile(String uniqueKey) {
File cproj = cProj.getProject().getFile(".cproject").getLocation().toFile();
File cprojback = cProj.getProject().getFile(".cproject_" + uniqueKey).getLocation().toFile();
@@ -406,9 +408,15 @@ public class CProjectDescriptionStorageTests extends BaseTestCase {
return true;
} finally {
if (in1 != null)
- try {in1.close();} catch (Exception e) {/*Don't care*/}
+ try {
+ in1.close();
+ } catch (Exception e) {
+ /*Don't care*/}
if (in2 != null)
- try {in2.close();} catch (Exception e) {/*Don't care*/}
+ try {
+ in2.close();
+ } catch (Exception e) {
+ /*Don't care*/}
}
}
@@ -427,9 +435,15 @@ public class CProjectDescriptionStorageTests extends BaseTestCase {
fail("Exception copyingFile: " + src.getAbsolutePath() + " -> " + dst.getAbsolutePath());
} finally {
if (in != null)
- try {in.close();} catch (Exception e) {/*Don't care*/}
+ try {
+ in.close();
+ } catch (Exception e) {
+ /*Don't care*/}
if (out != null)
- try {out.close();} catch (Exception e) {/*Don't care*/}
+ try {
+ out.close();
+ } catch (Exception e) {
+ /*Don't care*/}
}
while (dst.lastModified() - initModificationTime == 0) {
@@ -452,6 +466,7 @@ public class CProjectDescriptionStorageTests extends BaseTestCase {
private static class OurResourceChangeListener implements IResourceChangeListener {
boolean changeDetected;
private Set<IPath> filesToWatch = new HashSet<IPath>();
+
@Override
public synchronized void resourceChanged(IResourceChangeEvent event) {
IResourceDelta delta = event.getDelta();
@@ -464,12 +479,15 @@ public class CProjectDescriptionStorageTests extends BaseTestCase {
break;
}
}
+
public synchronized void addFileToWatch(IPath file) {
filesToWatch.add(file);
}
+
public synchronized void reset() {
changeDetected = false;
}
+
public synchronized void waitForChange() {
try {
if (!changeDetected)
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CfgSettingsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CfgSettingsTests.java
index 69a3a4daa2b..8e38d4d59e5 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CfgSettingsTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CfgSettingsTests.java
@@ -26,20 +26,20 @@ import org.eclipse.core.runtime.CoreException;
public class CfgSettingsTests extends BaseTestCase {
private static final String PROJ_NAME_PREFIX = "sfgst_";
ICProject p1;
-
+
public static TestSuite suite() {
return suite(CfgSettingsTests.class, "_");
}
-
+
@Override
protected void setUp() throws Exception {
}
-
+
public void testDefaultSettingConfig() throws Exception {
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
-
+
ICProjectDescriptionWorkspacePreferences prefs = mngr.getProjectDescriptionWorkspacePreferences(true);
-
+
int wspRel = prefs.getConfigurationRelations();
CoreModel model = CoreModel.getDefault();
p1 = CProjectHelper.createNewStyleCProject(PROJ_NAME_PREFIX + "a", IPDOMManager.ID_NO_INDEXER);
@@ -57,14 +57,14 @@ public class CfgSettingsTests extends BaseTestCase {
wspRel = getChangedConfigRelStatus(wspRel);
prefs.setConfigurationRelations(wspRel);
-
+
mngr.setProjectDescriptionWorkspacePreferences(prefs, true, null);
des = model.getProjectDescription(project, false);
prefs = mngr.getProjectDescriptionWorkspacePreferences(true);
assertEquals(wspRel, des.getConfigurationRelations());
assertEquals(wspRel, prefs.getConfigurationRelations());
assertTrue(des.isDefaultConfigurationRelations());
-
+
des = mngr.getProjectDescription(project);
assertTrue(des.isDefaultConfigurationRelations());
wspRel = prefs.getConfigurationRelations();
@@ -77,7 +77,7 @@ public class CfgSettingsTests extends BaseTestCase {
mngr.setProjectDescription(des.getProject(), des);
des = mngr.getProjectDescription(project, false);
assertEquals(wspRel, des.getConfigurationRelations());
-
+
des = mngr.getProjectDescription(project);
prefs = mngr.getProjectDescriptionWorkspacePreferences(false);
assertEquals(des.getConfigurationRelations(), prefs.getConfigurationRelations());
@@ -88,30 +88,30 @@ public class CfgSettingsTests extends BaseTestCase {
assertFalse(des.isDefaultConfigurationRelations());
assertEquals(projRel, des.getConfigurationRelations());
mngr.setProjectDescription(project, des);
-
+
des = mngr.getProjectDescription(project, false);
assertFalse(des.isDefaultConfigurationRelations());
assertEquals(projRel, des.getConfigurationRelations());
-
+
des = mngr.getProjectDescription(project, true);
assertFalse(des.isDefaultConfigurationRelations());
assertEquals(projRel, des.getConfigurationRelations());
- ICConfigurationDescription aCfg = des.getActiveConfiguration();
+ ICConfigurationDescription aCfg = des.getActiveConfiguration();
ICConfigurationDescription sCfg = des.getDefaultSettingConfiguration();
assertEquals(aCfg, sCfg);
-
+
des.createConfiguration("qq.2", "test2", des.getConfigurations()[0]);
assertEquals(aCfg, des.getActiveConfiguration());
assertEquals(sCfg, des.getActiveConfiguration());
-
+
projRel = getChangedConfigRelStatus(projRel);
des.setConfigurationRelations(projRel);
assertEquals(aCfg, des.getActiveConfiguration());
assertEquals(sCfg, des.getActiveConfiguration());
assertFalse(des.isDefaultConfigurationRelations());
-
+
projRel = ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE;
des.setConfigurationRelations(projRel);
ICConfigurationDescription cfg2 = des.getConfigurationById("qq.2");
@@ -135,7 +135,7 @@ public class CfgSettingsTests extends BaseTestCase {
assertEquals(cfg2, des.getDefaultSettingConfiguration());
mngr.setProjectDescription(project, des);
-
+
des = mngr.getProjectDescription(project, false);
assertEquals(aCfg.getId(), des.getActiveConfiguration().getId());
assertEquals(cfg2.getId(), des.getDefaultSettingConfiguration().getId());
@@ -144,21 +144,21 @@ public class CfgSettingsTests extends BaseTestCase {
assertEquals(aCfg.getId(), des.getActiveConfiguration().getId());
assertEquals(cfg2.getId(), des.getDefaultSettingConfiguration().getId());
}
-
- private int getChangedConfigRelStatus(int status){
- if(status == ICProjectDescriptionPreferences.CONFIGS_INDEPENDENT)
+
+ private int getChangedConfigRelStatus(int status) {
+ if (status == ICProjectDescriptionPreferences.CONFIGS_INDEPENDENT)
return ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE;
return ICProjectDescriptionPreferences.CONFIGS_INDEPENDENT;
}
-
+
@Override
protected void tearDown() throws Exception {
try {
- if(p1 != null){
+ if (p1 != null) {
p1.getProject().delete(true, null);
p1 = null;
}
- } catch (CoreException e){
+ } catch (CoreException e) {
}
}
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java
index f4fc6554fc5..eda6f82fe08 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java
@@ -34,7 +34,7 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
-public class ExternalSettingsProviderTests extends BaseTestCase{
+public class ExternalSettingsProviderTests extends BaseTestCase {
private static final String PROJ_NAME_PREFIX = "espt_";
ICProject p1, p2, p3, p4, p5, p6;
@@ -67,29 +67,25 @@ public class ExternalSettingsProviderTests extends BaseTestCase{
ICLanguageSettingEntry[] entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
assertEquals(0, entries.length);
ICSourceEntry[] sourceEntries = cfgDes.getSourceEntries();
- ICSourceEntry[] expectedSourceEntries = new ICSourceEntry[]{
- new CSourceEntry(project.getFullPath(), null, ICSettingEntry.RESOLVED)
- };
+ ICSourceEntry[] expectedSourceEntries = new ICSourceEntry[] {
+ new CSourceEntry(project.getFullPath(), null, ICSettingEntry.RESOLVED) };
assertEquals(1, sourceEntries.length);
assertTrue(Arrays.equals(expectedSourceEntries, sourceEntries));
- String[] extPIds = new String[]{CTestPlugin.PLUGIN_ID + ".testExtSettingsProvider"};
+ String[] extPIds = new String[] { CTestPlugin.PLUGIN_ID + ".testExtSettingsProvider" };
cfgDes.setExternalSettingsProviderIds(extPIds);
assertEquals(extPIds.length, cfgDes.getExternalSettingsProviderIds().length);
assertTrue(Arrays.equals(extPIds, cfgDes.getExternalSettingsProviderIds()));
entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
assertEquals(2, entries.length);
- ICLanguageSettingEntry[] expectedEntries = new ICLanguageSettingEntry[]{
- new CIncludePathEntry("ip_a", 0),
- new CIncludePathEntry("ip_b", 0),
- };
+ ICLanguageSettingEntry[] expectedEntries = new ICLanguageSettingEntry[] { new CIncludePathEntry("ip_a", 0),
+ new CIncludePathEntry("ip_b", 0), };
assertTrue(Arrays.equals(expectedEntries, entries));
sourceEntries = cfgDes.getSourceEntries();
assertEquals(2, sourceEntries.length);
- ICSourceEntry[] newExpectedSourceEntries = new ICSourceEntry[]{
+ ICSourceEntry[] newExpectedSourceEntries = new ICSourceEntry[] {
new CSourceEntry(project.getFullPath().append("sp_a"), null, 0),
- new CSourceEntry(project.getFullPath().append("sp_b"), null, 0),
- };
+ new CSourceEntry(project.getFullPath().append("sp_b"), null, 0), };
assertTrue(Arrays.equals(newExpectedSourceEntries, sourceEntries));
// insert entry into the mix; check that the new entry appears
@@ -118,7 +114,7 @@ public class ExternalSettingsProviderTests extends BaseTestCase{
assertEquals(0, entries.length);
- ls.setSettingEntries(ICSettingEntry.INCLUDE_PATH, (ICLanguageSettingEntry[])null);
+ ls.setSettingEntries(ICSettingEntry.INCLUDE_PATH, (ICLanguageSettingEntry[]) null);
entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
assertEquals(2, entries.length);
assertTrue(Arrays.equals(expectedEntries, entries));
@@ -135,12 +131,11 @@ public class ExternalSettingsProviderTests extends BaseTestCase{
ICLanguageSettingEntry[] entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
assertEquals(0, entries.length);
ICSourceEntry[] sourceEntries = cfgDes.getSourceEntries();
- ICSourceEntry[] expectedSourceEntries = new ICSourceEntry[]{
- new CSourceEntry(project.getFullPath(), null, ICSettingEntry.RESOLVED)
- };
+ ICSourceEntry[] expectedSourceEntries = new ICSourceEntry[] {
+ new CSourceEntry(project.getFullPath(), null, ICSettingEntry.RESOLVED) };
assertEquals(1, sourceEntries.length);
assertTrue(Arrays.equals(expectedSourceEntries, sourceEntries));
- String[] extPIds = new String[]{CTestPlugin.PLUGIN_ID + ".testExtSettingsProvider"};
+ String[] extPIds = new String[] { CTestPlugin.PLUGIN_ID + ".testExtSettingsProvider" };
cfgDes.setExternalSettingsProviderIds(extPIds);
model.setProjectDescription(project, des);
@@ -162,10 +157,8 @@ public class ExternalSettingsProviderTests extends BaseTestCase{
ls = cfgDes2.getLanguageSettingForFile(new Path("a.c"), true);
entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
- ICLanguageSettingEntry[] expectedEntries = new ICLanguageSettingEntry[]{
- new CIncludePathEntry("ip_a", 0),
- new CIncludePathEntry("ip_b", 0),
- };
+ ICLanguageSettingEntry[] expectedEntries = new ICLanguageSettingEntry[] { new CIncludePathEntry("ip_a", 0),
+ new CIncludePathEntry("ip_b", 0), };
assertTrue(Arrays.equals(expectedEntries, entries));
}
@@ -183,21 +176,17 @@ public class ExternalSettingsProviderTests extends BaseTestCase{
ICLanguageSettingEntry[] entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
assertEquals(0, entries.length);
ICSourceEntry[] sourceEntries = cfgDes.getSourceEntries();
- ICSourceEntry[] expectedSourceEntries = new ICSourceEntry[]{
- new CSourceEntry(project.getFullPath(), null, ICSettingEntry.RESOLVED)
- };
+ ICSourceEntry[] expectedSourceEntries = new ICSourceEntry[] {
+ new CSourceEntry(project.getFullPath(), null, ICSettingEntry.RESOLVED) };
assertEquals(1, sourceEntries.length);
assertTrue(Arrays.equals(expectedSourceEntries, sourceEntries));
- String[] extPIds = new String[]{CTestPlugin.PLUGIN_ID + ".testExtSettingsProvider"};
+ String[] extPIds = new String[] { CTestPlugin.PLUGIN_ID + ".testExtSettingsProvider" };
cfgDes.setExternalSettingsProviderIds(extPIds);
-
ls = cfgDes.getLanguageSettingForFile(new Path("a.c"), true);
entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
- ICLanguageSettingEntry[] expectedEntries = new ICLanguageSettingEntry[]{
- new CIncludePathEntry("ip_a", 0),
- new CIncludePathEntry("ip_b", 0),
- };
+ ICLanguageSettingEntry[] expectedEntries = new ICLanguageSettingEntry[] { new CIncludePathEntry("ip_a", 0),
+ new CIncludePathEntry("ip_b", 0), };
assertTrue(Arrays.equals(expectedEntries, entries));
model.setProjectDescription(project, des);
@@ -208,10 +197,8 @@ public class ExternalSettingsProviderTests extends BaseTestCase{
entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
assertTrue(Arrays.equals(expectedEntries, entries));
- ICLanguageSettingEntry[] expectedEntries2 = new ICLanguageSettingEntry[]{
- new CIncludePathEntry("ip_a2", 0),
- new CIncludePathEntry("ip_b2", 0),
- };
+ ICLanguageSettingEntry[] expectedEntries2 = new ICLanguageSettingEntry[] { new CIncludePathEntry("ip_a2", 0),
+ new CIncludePathEntry("ip_b2", 0), };
TestExtSettingsProvider.setVariantNum(1);
mngr.updateExternalSettingsProviders(extPIds, null);
@@ -235,21 +222,17 @@ public class ExternalSettingsProviderTests extends BaseTestCase{
ICLanguageSettingEntry[] entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
assertEquals(0, entries.length);
ICSourceEntry[] sourceEntries = cfgDes.getSourceEntries();
- ICSourceEntry[] expectedSourceEntries = new ICSourceEntry[]{
- new CSourceEntry(project.getFullPath(), null, ICSettingEntry.RESOLVED)
- };
+ ICSourceEntry[] expectedSourceEntries = new ICSourceEntry[] {
+ new CSourceEntry(project.getFullPath(), null, ICSettingEntry.RESOLVED) };
assertEquals(1, sourceEntries.length);
assertTrue(Arrays.equals(expectedSourceEntries, sourceEntries));
- String[] extPIds = new String[]{CTestPlugin.PLUGIN_ID + ".testExtSettingsProvider"};
+ String[] extPIds = new String[] { CTestPlugin.PLUGIN_ID + ".testExtSettingsProvider" };
cfgDes.setExternalSettingsProviderIds(extPIds);
-
ls = cfgDes.getLanguageSettingForFile(new Path("a.c"), true);
entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
- ICLanguageSettingEntry[] expectedEntries = new ICLanguageSettingEntry[]{
- new CIncludePathEntry("ip_a", 0),
- new CIncludePathEntry("ip_b", 0),
- };
+ ICLanguageSettingEntry[] expectedEntries = new ICLanguageSettingEntry[] { new CIncludePathEntry("ip_a", 0),
+ new CIncludePathEntry("ip_b", 0), };
assertTrue(Arrays.equals(expectedEntries, entries));
model.setProjectDescription(project, des);
@@ -260,39 +243,29 @@ public class ExternalSettingsProviderTests extends BaseTestCase{
entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
assertTrue(Arrays.equals(expectedEntries, entries));
- ls.setSettingEntries(ICSettingEntry.INCLUDE_PATH, (ICLanguageSettingEntry[])null);
+ ls.setSettingEntries(ICSettingEntry.INCLUDE_PATH, (ICLanguageSettingEntry[]) null);
entries = ls.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
assertTrue(Arrays.equals(expectedEntries, entries));
cfgDes.setSourceEntries(null);
- expectedSourceEntries = new ICSourceEntry[]{
- new CSourceEntry(project.getFullPath().append("sp_a"), null, 0),
- new CSourceEntry(project.getFullPath().append("sp_b"), null, 0),
- };
+ expectedSourceEntries = new ICSourceEntry[] { new CSourceEntry(project.getFullPath().append("sp_a"), null, 0),
+ new CSourceEntry(project.getFullPath().append("sp_b"), null, 0), };
sourceEntries = cfgDes.getSourceEntries();
assertEquals(2, sourceEntries.length);
assertTrue(Arrays.equals(expectedSourceEntries, sourceEntries));
cfgDes.getBuildSetting().setOutputDirectories(null);
- ICOutputEntry[] expectedOutputEntries = new ICOutputEntry[]{
+ ICOutputEntry[] expectedOutputEntries = new ICOutputEntry[] {
new COutputEntry(project.getFullPath().append("op_a"), null, 0),
- new COutputEntry(project.getFullPath().append("op_b"), null, 0),
- };
+ new COutputEntry(project.getFullPath().append("op_b"), null, 0), };
ICOutputEntry[] outputEntries = cfgDes.getBuildSetting().getOutputDirectories();
assertEquals(2, outputEntries.length);
assertTrue(Arrays.equals(expectedOutputEntries, outputEntries));
}
- private static final int[] ENTRY_KINDS = {
- ICSettingEntry.INCLUDE_PATH,
- ICSettingEntry.INCLUDE_FILE,
- ICSettingEntry.MACRO,
- ICSettingEntry.MACRO_FILE,
- ICSettingEntry.LIBRARY_PATH,
- ICSettingEntry.LIBRARY_FILE,
- ICSettingEntry.OUTPUT_PATH ,
- ICSettingEntry.SOURCE_PATH ,
- };
+ private static final int[] ENTRY_KINDS = { ICSettingEntry.INCLUDE_PATH, ICSettingEntry.INCLUDE_FILE,
+ ICSettingEntry.MACRO, ICSettingEntry.MACRO_FILE, ICSettingEntry.LIBRARY_PATH, ICSettingEntry.LIBRARY_FILE,
+ ICSettingEntry.OUTPUT_PATH, ICSettingEntry.SOURCE_PATH, };
/**
* Test that all entries are present
@@ -306,7 +279,7 @@ public class ExternalSettingsProviderTests extends BaseTestCase{
ICConfigurationDescription cfgDes = des.getConfigurations()[0];
TestExtSettingsProvider.setVariantNum(0);
- String[] extPIds = new String[]{TestExtSettingsProvider.TEST_EXTERNAL_PROVIDER_ID};
+ String[] extPIds = new String[] { TestExtSettingsProvider.TEST_EXTERNAL_PROVIDER_ID };
cfgDes.setExternalSettingsProviderIds(extPIds);
assertEquals(extPIds.length, cfgDes.getExternalSettingsProviderIds().length);
@@ -317,19 +290,20 @@ public class ExternalSettingsProviderTests extends BaseTestCase{
ICSettingEntry[] provided = TestExtSettingsProvider.SETTINGS_VARIANTS[0][0].getEntries(kind);
switch (kind) {
// Language setting kinds: see KindBasedStore
- case ICSettingEntry.INCLUDE_PATH :
- case ICSettingEntry.INCLUDE_FILE :
- case ICSettingEntry.LIBRARY_PATH :
- case ICSettingEntry.LIBRARY_FILE :
- case ICSettingEntry.MACRO :
- case ICSettingEntry.MACRO_FILE :
+ case ICSettingEntry.INCLUDE_PATH:
+ case ICSettingEntry.INCLUDE_FILE:
+ case ICSettingEntry.LIBRARY_PATH:
+ case ICSettingEntry.LIBRARY_FILE:
+ case ICSettingEntry.MACRO:
+ case ICSettingEntry.MACRO_FILE:
assertTrue(Arrays.equals(langSettings.getSettingEntries(kind), provided));
break;
// All settings kind
- case ICSettingEntry.OUTPUT_PATH :
- assertTrue(Arrays.equals(cfgDes.getBuildSetting().getOutputDirectories(), makeProjectRelativePath(project, provided)));
+ case ICSettingEntry.OUTPUT_PATH:
+ assertTrue(Arrays.equals(cfgDes.getBuildSetting().getOutputDirectories(),
+ makeProjectRelativePath(project, provided)));
break;
- case ICSettingEntry.SOURCE_PATH :
+ case ICSettingEntry.SOURCE_PATH:
assertTrue(Arrays.equals(cfgDes.getSourceEntries(), makeProjectRelativePath(project, provided)));
break;
default:
@@ -346,15 +320,15 @@ public class ExternalSettingsProviderTests extends BaseTestCase{
*/
private ICSettingEntry[] makeProjectRelativePath(IProject project, ICSettingEntry[] input) {
ICSettingEntry[] out = new ICSettingEntry[input.length];
- for (int i = 0; i < input.length; i ++) {
+ for (int i = 0; i < input.length; i++) {
switch (input[i].getKind()) {
case ICSettingEntry.OUTPUT_PATH:
out[i] = new COutputEntry(project.getFullPath().append(input[i].getValue()),
- ((ICOutputEntry)input[i]).getExclusionPatterns(), input[i].getFlags());
+ ((ICOutputEntry) input[i]).getExclusionPatterns(), input[i].getFlags());
break;
case ICSettingEntry.SOURCE_PATH:
out[i] = new CSourceEntry(project.getFullPath().append(input[i].getValue()),
- ((ICSourceEntry)input[i]).getExclusionPatterns(), input[i].getFlags());
+ ((ICSourceEntry) input[i]).getExclusionPatterns(), input[i].getFlags());
break;
}
}
@@ -374,7 +348,7 @@ public class ExternalSettingsProviderTests extends BaseTestCase{
// add external settings provider
ICProjectDescription des = model.getProjectDescription(project);
ICConfigurationDescription cfgDes = des.getConfigurations()[0];
- String[] extPIds = new String[]{TestExtSettingsProvider.TEST_EXTERNAL_PROVIDER_ID};
+ String[] extPIds = new String[] { TestExtSettingsProvider.TEST_EXTERNAL_PROVIDER_ID };
cfgDes.setExternalSettingsProviderIds(extPIds);
model.setProjectDescription(project, des);
@@ -383,15 +357,14 @@ public class ExternalSettingsProviderTests extends BaseTestCase{
cfgDes = des.getConfigurations()[0];
ICFolderDescription root = cfgDes.getRootFolderDescription();
HashMap<String, ICLanguageSetting> languageSettingsById = new HashMap<String, ICLanguageSetting>();
- for (ICLanguageSetting s: root.getLanguageSettings()) {
+ for (ICLanguageSetting s : root.getLanguageSettings()) {
languageSettingsById.put(s.getLanguageId(), s);
}
ICLanguageSetting ls;
ICLanguageSettingEntry[] entries;
- ICLanguageSettingEntry[] expectedEntriesSet = new ICLanguageSettingEntry[]{
- new CMacroEntry("m_c", "mv_c", 0)
- };
+ ICLanguageSettingEntry[] expectedEntriesSet = new ICLanguageSettingEntry[] {
+ new CMacroEntry("m_c", "mv_c", 0) };
ICLanguageSettingEntry[] expectedEntriesUnset = new ICLanguageSettingEntry[] {};
// setting should be present for assembly but not for C
@@ -416,7 +389,7 @@ public class ExternalSettingsProviderTests extends BaseTestCase{
cfgDes = des.getConfigurations()[0];
root = cfgDes.getRootFolderDescription();
languageSettingsById = new HashMap<String, ICLanguageSetting>();
- for (ICLanguageSetting s: root.getLanguageSettings()) {
+ for (ICLanguageSetting s : root.getLanguageSettings()) {
languageSettingsById.put(s.getLanguageId(), s);
}
@@ -448,7 +421,7 @@ public class ExternalSettingsProviderTests extends BaseTestCase{
// add external settings provider
ICProjectDescription des = model.getProjectDescription(project);
ICConfigurationDescription cfgDes = des.getConfigurations()[0];
- String[] extPIds = new String[]{TestExtSettingsProvider.TEST_EXTERNAL_PROVIDER_ID};
+ String[] extPIds = new String[] { TestExtSettingsProvider.TEST_EXTERNAL_PROVIDER_ID };
cfgDes.setExternalSettingsProviderIds(extPIds);
ICFolderDescription root = cfgDes.getRootFolderDescription();
model.setProjectDescription(project, des);
@@ -457,11 +430,12 @@ public class ExternalSettingsProviderTests extends BaseTestCase{
des = model.getProjectDescription(project, false);
cfgDes = des.getConfigurations()[0];
root = cfgDes.getRootFolderDescription();
- for (ICLanguageSetting s: root.getLanguageSettings()) {
- if( s.getLanguageId().equals("org.eclipse.cdt.core.assembly") ) {
+ for (ICLanguageSetting s : root.getLanguageSettings()) {
+ if (s.getLanguageId().equals("org.eclipse.cdt.core.assembly")) {
assertEquals(1, s.getSettingEntries(ICSettingEntry.MACRO).length);
assertEquals("TheValue", s.getSettingEntries(4)[0].getValue());
- } if( s.getLanguageId().equals("org.eclipse.cdt.core.g++") ) {
+ }
+ if (s.getLanguageId().equals("org.eclipse.cdt.core.g++")) {
assertEquals(1, s.getSettingEntries(ICSettingEntry.MACRO).length);
assertEquals("", s.getSettingEntries(ICSettingEntry.MACRO)[0].getValue());
}
@@ -472,27 +446,27 @@ public class ExternalSettingsProviderTests extends BaseTestCase{
protected void tearDown() throws Exception {
try {
p1.getProject().delete(true, null);
- } catch (CoreException e){
+ } catch (CoreException e) {
}
try {
p2.getProject().delete(true, null);
- } catch (CoreException e){
+ } catch (CoreException e) {
}
try {
p3.getProject().delete(true, null);
- } catch (CoreException e){
+ } catch (CoreException e) {
}
try {
p4.getProject().delete(true, null);
- } catch (CoreException e){
+ } catch (CoreException e) {
}
try {
p5.getProject().delete(true, null);
- } catch (CoreException e){
+ } catch (CoreException e) {
}
try {
p6.getProject().delete(true, null);
- } catch (CoreException e){
+ } catch (CoreException e) {
}
}
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/PathSettingsContainerTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/PathSettingsContainerTests.java
index 0f7443ee8ec..bb4360e942a 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/PathSettingsContainerTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/PathSettingsContainerTests.java
@@ -28,26 +28,26 @@ public class PathSettingsContainerTests extends BaseTestCase {
public static TestSuite suite() {
return suite(PathSettingsContainerTests.class, "_");
}
-
+
@Override
protected void setUp() throws Exception {
}
-
+
@Override
protected void tearDown() throws Exception {
}
public void testPathSettingsContainerCreate() {
- final PathSettingsContainer root= PathSettingsContainer.createRootContainer();
+ final PathSettingsContainer root = PathSettingsContainer.createRootContainer();
assertNull(root.getValue());
assertNull(root.getParentContainer());
assertTrue(root.isRoot());
assertTrue(root.isValid());
assertEquals(0, root.getChildren(false).length);
assertEquals(1, root.getChildren(true).length);
-
- final IPath level1= new Path("level1");
- final PathSettingsContainer child1= root.getChildContainer(level1, true, true);
+
+ final IPath level1 = new Path("level1");
+ final PathSettingsContainer child1 = root.getChildContainer(level1, true, true);
assertNotNull(child1);
assertNull(child1.getValue());
assertSame(root, child1.getParentContainer());
@@ -56,12 +56,12 @@ public class PathSettingsContainerTests extends BaseTestCase {
assertEquals(1, root.getChildren(false).length);
assertEquals(0, child1.getChildren(false).length);
assertEquals(1, child1.getChildren(true).length);
- final String value1= "child1";
+ final String value1 = "child1";
child1.setValue(value1);
assertSame(value1, child1.getValue());
-
- final IPath level2= level1.append("level2");
- final PathSettingsContainer child2= root.getChildContainer(level2, true, true);
+
+ final IPath level2 = level1.append("level2");
+ final PathSettingsContainer child2 = root.getChildContainer(level2, true, true);
assertNotNull(child2);
assertNull(child2.getValue());
assertSame(child1, child2.getParentContainer());
@@ -70,12 +70,12 @@ public class PathSettingsContainerTests extends BaseTestCase {
assertEquals(1, child1.getChildren(false).length);
assertEquals(0, child2.getChildren(false).length);
assertEquals(1, child2.getChildren(true).length);
- final String value2= "child2";
+ final String value2 = "child2";
child2.setValue(value2);
assertSame(value2, child2.getValue());
- final IPath level3= level2.append("level3");
- final PathSettingsContainer child3= root.getChildContainer(level3, true, true);
+ final IPath level3 = level2.append("level3");
+ final PathSettingsContainer child3 = root.getChildContainer(level3, true, true);
assertNotNull(child3);
assertNull(child3.getValue());
assertSame(child2, child3.getParentContainer());
@@ -84,26 +84,26 @@ public class PathSettingsContainerTests extends BaseTestCase {
assertEquals(1, child2.getChildren(false).length);
assertEquals(0, child3.getChildren(false).length);
assertEquals(1, child3.getChildren(true).length);
- final String value3= "child3";
+ final String value3 = "child3";
child3.setValue(value3);
assertSame(value3, child3.getValue());
-
+
assertSame(child1, root.getChildContainer(level1, true, true));
assertSame(child2, root.getChildContainer(level2, true, true));
assertSame(child3, root.getChildContainer(level3, true, true));
}
public void testPathSettingsContainerRemove() {
- final PathSettingsContainer root= PathSettingsContainer.createRootContainer();
- final IPath level1= new Path("level1");
- final PathSettingsContainer child1= root.getChildContainer(level1, true, true);
- final IPath level2= level1.append("level2");
- final PathSettingsContainer child2= root.getChildContainer(level2, true, true);
- final IPath level3= level2.append("level3");
- final PathSettingsContainer child3= root.getChildContainer(level3, true, true);
- final IPath level31= level2.append("level31");
- final PathSettingsContainer child31= root.getChildContainer(level31, true, true);
-
+ final PathSettingsContainer root = PathSettingsContainer.createRootContainer();
+ final IPath level1 = new Path("level1");
+ final PathSettingsContainer child1 = root.getChildContainer(level1, true, true);
+ final IPath level2 = level1.append("level2");
+ final PathSettingsContainer child2 = root.getChildContainer(level2, true, true);
+ final IPath level3 = level2.append("level3");
+ final PathSettingsContainer child3 = root.getChildContainer(level3, true, true);
+ final IPath level31 = level2.append("level31");
+ final PathSettingsContainer child31 = root.getChildContainer(level31, true, true);
+
child3.remove();
assertEquals(1, child2.getChildren(false).length);
assertFalse(child3.isValid());
@@ -118,7 +118,7 @@ public class PathSettingsContainerTests extends BaseTestCase {
}
public void testPathSettingsContainer_Bug208765() {
- final PathSettingsContainer root= PathSettingsContainer.createRootContainer();
+ final PathSettingsContainer root = PathSettingsContainer.createRootContainer();
try {
root.removeChildContainer(new Path(""));
} catch (NullPointerException npe) {
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ProjectCreationStateTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ProjectCreationStateTests.java
index d42cbc1ffdb..cad4255c901 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ProjectCreationStateTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ProjectCreationStateTests.java
@@ -28,96 +28,97 @@ import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-public class ProjectCreationStateTests extends BaseTestCase{
+public class ProjectCreationStateTests extends BaseTestCase {
private static final String PROJ_NAME_PREFIX = "ProjectCreationStateTests_";
private IProject p1, p2, p3, p4;
private Listener listener;
-
+
private class Listener implements ICProjectDescriptionListener {
private boolean fIsCreationCompletedNotified;
private boolean fIsCreating;
private boolean fIsNotified;
private String fProjName;
-
- Listener(String projName){
+
+ Listener(String projName) {
init();
fProjName = projName;
}
-
+
@Override
public void handleEvent(CProjectDescriptionEvent event) {
- if(!event.getProject().getName().equals(fProjName))
+ if (!event.getProject().getName().equals(fProjName))
return;
fIsNotified = true;
boolean creating = event.getNewCProjectDescription().isCdtProjectCreating();
ICDescriptionDelta delta = event.getProjectDelta();
- boolean notified = delta != null ? (delta.getChangeFlags() & ICDescriptionDelta.PROJECT_CREAION_COMPLETED) != 0 : false;
-
- if(creating)
+ boolean notified = delta != null
+ ? (delta.getChangeFlags() & ICDescriptionDelta.PROJECT_CREAION_COMPLETED) != 0
+ : false;
+
+ if (creating)
assertTrue(fIsCreating);
- if(notified)
+ if (notified)
assertFalse(fIsCreationCompletedNotified);
-
+
fIsCreating = creating;
fIsCreationCompletedNotified = notified;
}
-
- void init(){
+
+ void init() {
fIsCreating = true;
fIsCreationCompletedNotified = false;
resetNotified();
}
-
- boolean isCreating(){
+
+ boolean isCreating() {
return fIsCreating;
}
-
- boolean isCreationCompletedNotified(){
+
+ boolean isCreationCompletedNotified() {
return fIsCreationCompletedNotified;
}
- boolean isNotified(){
+ boolean isNotified() {
boolean notified = fIsNotified;
resetNotified();
return notified;
}
- void resetNotified(){
+ void resetNotified() {
fIsNotified = false;
}
}
-
+
public static TestSuite suite() {
return suite(ProjectCreationStateTests.class, "_");
}
@Override
protected void setUp() throws Exception {
-// p1 = CProjectHelper.createNewStileCProject(PROJ_NAME_PREFIX + "a", IPDOMManager.ID_NO_INDEXER);
+ // p1 = CProjectHelper.createNewStileCProject(PROJ_NAME_PREFIX + "a", IPDOMManager.ID_NO_INDEXER);
}
-
- private void initListener(String projName){
+
+ private void initListener(String projName) {
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
- if(listener != null)
+ if (listener != null)
mngr.removeCProjectDescriptionListener(listener);
listener = new Listener(projName);
mngr.addCProjectDescriptionListener(listener, CProjectDescriptionEvent.APPLIED);
-
+
assertFalse(listener.isNotified());
assertFalse(listener.isCreationCompletedNotified());
assertTrue(listener.isCreating());
}
-
+
public void testProjectCreatingState() throws Exception {
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
String projName = PROJ_NAME_PREFIX + "a";
-
+
initListener(projName);
-
-
+
ICProject cp1 = CProjectHelper.createNewStyleCProject(projName, IPDOMManager.ID_NO_INDEXER, true);
IProject project = cp1.getProject();
p1 = project;
@@ -125,7 +126,7 @@ public class ProjectCreationStateTests extends BaseTestCase{
assertFalse(listener.isCreationCompletedNotified());
assertTrue(listener.isCreating());
listener.resetNotified();
-
+
ICProjectDescription des = mngr.getProjectDescription(project, false);
assertTrue(des.isCdtProjectCreating());
des = mngr.getProjectDescription(project, true);
@@ -133,7 +134,7 @@ public class ProjectCreationStateTests extends BaseTestCase{
assertFalse(listener.isNotified());
assertFalse(listener.isCreationCompletedNotified());
assertTrue(listener.isCreating());
-
+
ICProjectDescription des2 = mngr.getProjectDescription(project, true);
des2.createConfiguration(CDataUtil.genId(null), CDataUtil.genId(null), des2.getConfigurations()[0]);
mngr.setProjectDescription(project, des2);
@@ -145,7 +146,7 @@ public class ProjectCreationStateTests extends BaseTestCase{
assertFalse(listener.isCreationCompletedNotified());
assertTrue(listener.isCreating());
listener.resetNotified();
-
+
des.createConfiguration(CDataUtil.genId(null), CDataUtil.genId(null), des.getConfigurations()[0]);
des.setCdtProjectCreated();
des2.createConfiguration(CDataUtil.genId(null), CDataUtil.genId(null), des2.getConfigurations()[0]);
@@ -169,7 +170,7 @@ public class ProjectCreationStateTests extends BaseTestCase{
assertFalse(listener.isNotified());
assertFalse(listener.isCreationCompletedNotified());
assertFalse(listener.isCreating());
-
+
des2.createConfiguration(CDataUtil.genId(null), CDataUtil.genId(null), des2.getConfigurations()[0]);
mngr.setProjectDescription(project, des2);
assertTrue(listener.isNotified());
@@ -177,7 +178,7 @@ public class ProjectCreationStateTests extends BaseTestCase{
assertFalse(listener.isCreating());
listener.resetNotified();
}
-
+
public void testCreateProjectDescriptionForInexistingDes() throws Exception {
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
String projName = PROJ_NAME_PREFIX + "b";
@@ -190,12 +191,11 @@ public class ProjectCreationStateTests extends BaseTestCase{
project.create(null);
project.open(null);
CProjectHelper.addNatureToProject(project, CProjectNature.C_NATURE_ID, null);
-
+
assertFalse(listener.isNotified());
assertFalse(listener.isCreationCompletedNotified());
assertTrue(listener.isCreating());
-
ICProjectDescription des = mngr.getProjectDescription(project, false);
assertNull(des);
des = mngr.getProjectDescription(project, true);
@@ -210,7 +210,7 @@ public class ProjectCreationStateTests extends BaseTestCase{
assertFalse(listener.isNotified());
assertFalse(listener.isCreationCompletedNotified());
assertTrue(listener.isCreating());
-
+
des = mngr.createProjectDescription(project, false);
assertFalse(des.isCdtProjectCreating());
des = mngr.getProjectDescription(project, false);
@@ -241,19 +241,17 @@ public class ProjectCreationStateTests extends BaseTestCase{
assertFalse(listener.isCreationCompletedNotified());
assertTrue(listener.isCreating());
}
-
+
public void testCreateProjectDescriptionForCreatingDes() throws Exception {
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
String projName = PROJ_NAME_PREFIX + "c";
-
+
initListener(projName);
-
-
+
ICProject cp3 = CProjectHelper.createNewStyleCProject(projName, IPDOMManager.ID_NO_INDEXER, true);
IProject project = cp3.getProject();
p3 = project;
-
assertTrue(listener.isNotified());
assertFalse(listener.isCreationCompletedNotified());
assertTrue(listener.isCreating());
@@ -272,7 +270,7 @@ public class ProjectCreationStateTests extends BaseTestCase{
assertFalse(listener.isNotified());
assertFalse(listener.isCreationCompletedNotified());
assertTrue(listener.isCreating());
-
+
des = mngr.createProjectDescription(project, false);
assertFalse(des.isCdtProjectCreating());
des = mngr.getProjectDescription(project, false);
@@ -303,19 +301,17 @@ public class ProjectCreationStateTests extends BaseTestCase{
assertFalse(listener.isCreationCompletedNotified());
assertTrue(listener.isCreating());
}
-
+
public void testCreateProjectDescriptionForCreatedDes() throws Exception {
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
String projName = PROJ_NAME_PREFIX + "d";
-
+
initListener(projName);
-
-
+
ICProject cp4 = CProjectHelper.createNewStyleCProject(projName, IPDOMManager.ID_NO_INDEXER, false);
IProject project = cp4.getProject();
p4 = project;
-
assertTrue(listener.isNotified());
assertFalse(listener.isCreationCompletedNotified());
assertFalse(listener.isCreating());
@@ -334,7 +330,7 @@ public class ProjectCreationStateTests extends BaseTestCase{
assertFalse(listener.isNotified());
assertFalse(listener.isCreationCompletedNotified());
assertFalse(listener.isCreating());
-
+
des = mngr.createProjectDescription(project, false);
assertFalse(des.isCdtProjectCreating());
des = mngr.getProjectDescription(project, false);
@@ -366,40 +362,39 @@ public class ProjectCreationStateTests extends BaseTestCase{
assertFalse(listener.isCreating());
}
-
@Override
protected void tearDown() throws Exception {
- if(listener != null){
+ if (listener != null) {
CoreModel.getDefault().getProjectDescriptionManager().removeCProjectDescriptionListener(listener);
listener = null;
}
try {
- if(p1 != null){
+ if (p1 != null) {
p1.getProject().delete(true, null);
p1 = null;
}
- } catch (CoreException e){
+ } catch (CoreException e) {
}
try {
- if(p2 != null){
+ if (p2 != null) {
p2.getProject().delete(true, null);
p2 = null;
}
- } catch (CoreException e){
+ } catch (CoreException e) {
}
try {
- if(p3 != null){
+ if (p3 != null) {
p3.getProject().delete(true, null);
p3 = null;
}
- } catch (CoreException e){
+ } catch (CoreException e) {
}
try {
- if(p4 != null){
+ if (p4 != null) {
p4.getProject().delete(true, null);
p4 = null;
}
- } catch (CoreException e){
+ } catch (CoreException e) {
}
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestCfgDataProvider.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestCfgDataProvider.java
index 32948513884..a406b96db84 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestCfgDataProvider.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestCfgDataProvider.java
@@ -24,7 +24,7 @@ import org.eclipse.cdt.core.testplugin.CTestPlugin;
/**
* Basic CDefaultConfigurationDataProvider
- *
+ *
* This is extended to allow persisting Library path + Library file language
* settings which aren't supported by the base default configuration data provider
* i.e. cdt.core without managedbuild...
@@ -32,39 +32,29 @@ import org.eclipse.cdt.core.testplugin.CTestPlugin;
public class TestCfgDataProvider extends CDefaultConfigurationDataProvider {
public static final String PROVIDER_ID = CTestPlugin.PLUGIN_ID + ".testCfgDataProvider";
-
// Overriden so it supports saving Library file and Library path entries
private static final class TestDataFactory extends CDataFactory {
@Override
- public CLanguageData createLanguageData(CConfigurationData cfg,
- CResourceData rcBase,
- CLanguageData base,
- String id,
- boolean clone){
- if(id == null)
- id = clone ? base.getId() : CDataUtil.genId(rcBase.getId());
+ public CLanguageData createLanguageData(CConfigurationData cfg, CResourceData rcBase, CLanguageData base,
+ String id, boolean clone) {
+ if (id == null)
+ id = clone ? base.getId() : CDataUtil.genId(rcBase.getId());
return new CDefaultLanguageData(id, base);
}
@Override
- public CLanguageData createLanguageData(CConfigurationData cfg,
- CResourceData rcBase,
- String id,
- String name,
- String languageId,
- int supportedEntryKinds,
- String[] rcTypes,
- boolean isContentTypes) {
- return super.createLanguageData(cfg, rcBase, id, name, languageId,
- supportedEntryKinds | ICSettingEntry.LIBRARY_FILE | ICSettingEntry.LIBRARY_PATH,
- rcTypes, isContentTypes);
+ public CLanguageData createLanguageData(CConfigurationData cfg, CResourceData rcBase, String id, String name,
+ String languageId, int supportedEntryKinds, String[] rcTypes, boolean isContentTypes) {
+ return super.createLanguageData(cfg, rcBase, id, name, languageId,
+ supportedEntryKinds | ICSettingEntry.LIBRARY_FILE | ICSettingEntry.LIBRARY_PATH, rcTypes,
+ isContentTypes);
}
}
@Override
- protected CDataFactory getDataFactory(){
+ protected CDataFactory getDataFactory() {
return new TestDataFactory();
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestExtSettingsProvider.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestExtSettingsProvider.java
index c0464a9f703..7fa6afa9d09 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestExtSettingsProvider.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestExtSettingsProvider.java
@@ -25,120 +25,61 @@ public class TestExtSettingsProvider extends CExternalSettingProvider {
public static final String TEST_EXTERNAL_PROVIDER_ID = CTestPlugin.PLUGIN_ID + ".testExtSettingsProvider";
- private static CExternalSetting[] SETTINGS_1 = new CExternalSetting[]{
- new CExternalSetting(null, null, null, new ICSettingEntry[]{
- new CIncludePathEntry("ip_a", 0),
- new CIncludePathEntry("ip_b", 0),
- new CIncludeFileEntry("if_a", 0),
- new CIncludeFileEntry("if_b", 0),
- new CMacroEntry("m_a", "mv_a", 0),
- new CMacroEntry("m_b", "mv_b", 0),
- new CMacroFileEntry("mf_a", 0),
- new CMacroFileEntry("mf_b", 0),
- new CLibraryPathEntry("lp_a", 0),
- new CLibraryPathEntry("lp_b", 0),
- new CLibraryFileEntry("lf_a", 0),
- new CLibraryFileEntry("lf_b", 0),
- new CSourceEntry("sp_a", null, 0),
- new CSourceEntry("sp_b", null, 0),
- new COutputEntry("op_a", null, 0),
- new COutputEntry("op_b", null, 0),
- })
- };
+ private static CExternalSetting[] SETTINGS_1 = new CExternalSetting[] { new CExternalSetting(null, null, null,
+ new ICSettingEntry[] { new CIncludePathEntry("ip_a", 0), new CIncludePathEntry("ip_b", 0),
+ new CIncludeFileEntry("if_a", 0), new CIncludeFileEntry("if_b", 0),
+ new CMacroEntry("m_a", "mv_a", 0), new CMacroEntry("m_b", "mv_b", 0),
+ new CMacroFileEntry("mf_a", 0), new CMacroFileEntry("mf_b", 0), new CLibraryPathEntry("lp_a", 0),
+ new CLibraryPathEntry("lp_b", 0), new CLibraryFileEntry("lf_a", 0),
+ new CLibraryFileEntry("lf_b", 0), new CSourceEntry("sp_a", null, 0),
+ new CSourceEntry("sp_b", null, 0), new COutputEntry("op_a", null, 0),
+ new COutputEntry("op_b", null, 0), }) };
- private static CExternalSetting[] SETTINGS_2 = new CExternalSetting[]{
- new CExternalSetting(null, null, null, new ICSettingEntry[]{
- new CIncludePathEntry("ip_a2", 0),
- new CIncludePathEntry("ip_b2", 0),
- new CIncludeFileEntry("if_a2", 0),
- new CIncludeFileEntry("if_b2", 0),
- new CMacroEntry("m_a2", "mv_a2", 0),
- new CMacroEntry("m_b2", "mv_b2", 0),
- new CMacroFileEntry("mf_a2", 0),
- new CMacroFileEntry("mf_b2", 0),
- new CLibraryPathEntry("lp_a2", 0),
- new CLibraryPathEntry("lp_b2", 0),
- new CLibraryFileEntry("lf_a2", 0),
- new CLibraryFileEntry("lf_b2", 0),
- new CSourceEntry("sp_a2", null, 0),
- new CSourceEntry("sp_b2", null, 0),
- new COutputEntry("op_a2", null, 0),
- new COutputEntry("op_b2", null, 0),
- })
- };
+ private static CExternalSetting[] SETTINGS_2 = new CExternalSetting[] { new CExternalSetting(null, null, null,
+ new ICSettingEntry[] { new CIncludePathEntry("ip_a2", 0), new CIncludePathEntry("ip_b2", 0),
+ new CIncludeFileEntry("if_a2", 0), new CIncludeFileEntry("if_b2", 0),
+ new CMacroEntry("m_a2", "mv_a2", 0), new CMacroEntry("m_b2", "mv_b2", 0),
+ new CMacroFileEntry("mf_a2", 0), new CMacroFileEntry("mf_b2", 0), new CLibraryPathEntry("lp_a2", 0),
+ new CLibraryPathEntry("lp_b2", 0), new CLibraryFileEntry("lf_a2", 0),
+ new CLibraryFileEntry("lf_b2", 0), new CSourceEntry("sp_a2", null, 0),
+ new CSourceEntry("sp_b2", null, 0), new COutputEntry("op_a2", null, 0),
+ new COutputEntry("op_b2", null, 0), }) };
- private static CExternalSetting[] SETTINGS_3 = new CExternalSetting[]{
- new CExternalSetting(
- new String[]{
- "org.eclipse.cdt.core.assembly"
- },
- null, null,
- new ICSettingEntry[]{
- new CMacroEntry("m_c", "mv_c", 0)
- }
- )
- };
+ private static CExternalSetting[] SETTINGS_3 = new CExternalSetting[] {
+ new CExternalSetting(new String[] { "org.eclipse.cdt.core.assembly" }, null, null,
+ new ICSettingEntry[] { new CMacroEntry("m_c", "mv_c", 0) }) };
- private static CExternalSetting[] SETTINGS_4 = new CExternalSetting[]{
- new CExternalSetting(
- new String[]{
- "org.eclipse.cdt.core.assembly",
- "org.eclipse.cdt.core.gcc"
- },
- null, null,
- new ICSettingEntry[]{
- new CMacroEntry("m_c", "mv_c", 0)
- }
- )
- };
+ private static CExternalSetting[] SETTINGS_4 = new CExternalSetting[] {
+ new CExternalSetting(new String[] { "org.eclipse.cdt.core.assembly", "org.eclipse.cdt.core.gcc" }, null,
+ null, new ICSettingEntry[] { new CMacroEntry("m_c", "mv_c", 0) }) };
- private static CExternalSetting[] SETTINGS_5 = new CExternalSetting[]{
- new CExternalSetting(
- new String[]{
- "org.eclipse.cdt.core.g++"
- },
- null, null,
- new ICSettingEntry[]{
- new CMacroEntry("THE_MACRO", "", 0)
- }
- ),
- new CExternalSetting(
- new String[]{
- "org.eclipse.cdt.core.assembly"
- },
- null, null,
- new ICSettingEntry[]{
- new CMacroEntry("THE_MACRO", "TheValue", 0)
- }
- )
- };
+ private static CExternalSetting[] SETTINGS_5 = new CExternalSetting[] {
+ new CExternalSetting(new String[] { "org.eclipse.cdt.core.g++" }, null, null,
+ new ICSettingEntry[] { new CMacroEntry("THE_MACRO", "", 0) }),
+ new CExternalSetting(new String[] { "org.eclipse.cdt.core.assembly" }, null, null,
+ new ICSettingEntry[] { new CMacroEntry("THE_MACRO", "TheValue", 0) }) };
- public static final CExternalSetting[][] SETTINGS_VARIANTS = new CExternalSetting[][]{
- SETTINGS_1,
- SETTINGS_2,
- SETTINGS_3,
- SETTINGS_4,
- SETTINGS_5};
+ public static final CExternalSetting[][] SETTINGS_VARIANTS = new CExternalSetting[][] { SETTINGS_1, SETTINGS_2,
+ SETTINGS_3, SETTINGS_4, SETTINGS_5 };
private static int variantNum;
@Override
- public CExternalSetting[] getSettings(IProject project,
- ICConfigurationDescription cfg) {
+ public CExternalSetting[] getSettings(IProject project, ICConfigurationDescription cfg) {
return SETTINGS_VARIANTS[variantNum].clone();
}
- public static void setVariantNum(int num){
- if(num < 0 || num >= SETTINGS_VARIANTS.length)
+ public static void setVariantNum(int num) {
+ if (num < 0 || num >= SETTINGS_VARIANTS.length)
throw new IllegalArgumentException();
variantNum = num;
}
- public static int getVariantNum(){
+ public static int getVariantNum() {
return variantNum;
}
- public static int getMaxVariantNum(){
+ public static int getMaxVariantNum() {
return SETTINGS_VARIANTS.length - 1;
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestUserAndDiscoveredEntriesCfgDataProvider.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestUserAndDiscoveredEntriesCfgDataProvider.java
index b87dfcec13a..a89dc957fe6 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestUserAndDiscoveredEntriesCfgDataProvider.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestUserAndDiscoveredEntriesCfgDataProvider.java
@@ -17,20 +17,20 @@ import org.eclipse.cdt.core.settings.model.extension.impl.UserAndDiscoveredEntry
import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
import org.eclipse.cdt.core.testplugin.CTestPlugin;
-public class TestUserAndDiscoveredEntriesCfgDataProvider extends UserAndDiscoveredEntryConfigurationDataProvider{
+public class TestUserAndDiscoveredEntriesCfgDataProvider extends UserAndDiscoveredEntryConfigurationDataProvider {
public static final String PROVIDER_ID = CTestPlugin.PLUGIN_ID + ".testUserAndDiscoveredCfgDataProvider";
-
- private static final KindBasedStore[] ENTRIES_STORES = new KindBasedStore[]{new KindBasedStore(false)};
-
+
+ private static final KindBasedStore[] ENTRIES_STORES = new KindBasedStore[] { new KindBasedStore(false) };
+
static {
ICLanguageSettingEntry[] entries = new ICLanguageSettingEntry[4];
entries[0] = new CIncludePathEntry("a/b/c", 0);
entries[1] = new CIncludePathEntry("/d/e/f", 0);
entries[2] = new CIncludePathEntry("g/h/i", ICSettingEntry.VALUE_WORKSPACE_PATH);
entries[3] = new CIncludePathEntry("/j/k/l", ICSettingEntry.VALUE_WORKSPACE_PATH);
-
+
ENTRIES_STORES[0].put(ICSettingEntry.INCLUDE_PATH, entries);
-
+
entries = new ICLanguageSettingEntry[2];
entries[0] = new CMacroEntry("a", "b", 0);
entries[1] = new CMacroEntry("c", null, 0);
@@ -38,10 +38,9 @@ public class TestUserAndDiscoveredEntriesCfgDataProvider extends UserAndDiscover
}
@Override
- protected ICLanguageSettingEntry[] getAllDiscoveredEntries(
- LanguageData data, int kind) {
- ICLanguageSettingEntry entries[] = (ICLanguageSettingEntry[])ENTRIES_STORES[0].get(kind);
- return entries != null ? (ICLanguageSettingEntry[])entries.clone() : new ICLanguageSettingEntry[0];
+ protected ICLanguageSettingEntry[] getAllDiscoveredEntries(LanguageData data, int kind) {
+ ICLanguageSettingEntry entries[] = (ICLanguageSettingEntry[]) ENTRIES_STORES[0].get(kind);
+ return entries != null ? (ICLanguageSettingEntry[]) entries.clone() : new ICLanguageSettingEntry[0];
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ASTComparer.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ASTComparer.java
index 0c1e7a98cc3..2357ebd77a3 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ASTComparer.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ASTComparer.java
@@ -31,48 +31,31 @@ import org.junit.Assert;
public class ASTComparer extends Assert {
private static Set<String> methodsToIgnore = new HashSet<>(Arrays.asList(
- // Prevent infinite recursion
- "getParent",
- "getTranslationUnit",
- "getLastName",
-
- // Exponential complexity
- "getOperand2", // duplicates getInitOperand2()
- "getChildren",
- "getAllSegments", // duplicates getQualifier()
-
- // Can be different in copy
- "isFrozen",
- "getContainingFilename",
- "getOriginalNode",
-
- // These methods are problematic
- "getProblem",
-
- // Ignore preprocessor nodes
- "getMacroDefinitions",
- "getBuiltinMacroDefinitions",
- "getIncludeDirectives",
- "getAllPreprocessorStatements",
- "getMacroExpansions",
- "getPreprocessorProblems",
- "getComments",
-
- // Avoid name resolution
- "isDeclaration",
- "isDefinition",
- "isReference",
- "isAssociatedWithLastName",
- "getNestingLevel",
- "getImplicitNames",
- "getImplicitDestructorNames",
- "isLValue",
-
- // These methods can return a special constant value, such as
- // ICPPASTFunctionDecalarator.NOEXCEPT_DEFAULT, which does not
- // get cloned when the node is copied.
- "getNoexceptExpression"
- ));
+ // Prevent infinite recursion
+ "getParent", "getTranslationUnit", "getLastName",
+
+ // Exponential complexity
+ "getOperand2", // duplicates getInitOperand2()
+ "getChildren", "getAllSegments", // duplicates getQualifier()
+
+ // Can be different in copy
+ "isFrozen", "getContainingFilename", "getOriginalNode",
+
+ // These methods are problematic
+ "getProblem",
+
+ // Ignore preprocessor nodes
+ "getMacroDefinitions", "getBuiltinMacroDefinitions", "getIncludeDirectives", "getAllPreprocessorStatements",
+ "getMacroExpansions", "getPreprocessorProblems", "getComments",
+
+ // Avoid name resolution
+ "isDeclaration", "isDefinition", "isReference", "isAssociatedWithLastName", "getNestingLevel",
+ "getImplicitNames", "getImplicitDestructorNames", "isLValue",
+
+ // These methods can return a special constant value, such as
+ // ICPPASTFunctionDecalarator.NOEXCEPT_DEFAULT, which does not
+ // get cloned when the node is copied.
+ "getNoexceptExpression"));
public static void assertCopy(IASTNode node1, IASTNode node2) {
try {
@@ -81,7 +64,7 @@ public class ASTComparer extends Assert {
throw new RuntimeException(e);
}
}
-
+
private static void assertCopy(IASTNode node1, IASTNode node2, int n) throws Exception {
if (node1 == null && node2 == null)
return;
@@ -93,9 +76,9 @@ public class ASTComparer extends Assert {
Class klass2 = node2.getClass();
assertTrue(klass1.equals(klass2)); // nodes must be the same concrete type
//System.out.println(spaces(n) + klass1.getSimpleName());
-
+
BeanInfo beanInfo = Introspector.getBeanInfo(klass1);
-
+
for (PropertyDescriptor property : beanInfo.getPropertyDescriptors()) {
Method getter = property.getReadMethod();
if (getter == null)
@@ -105,10 +88,10 @@ public class ASTComparer extends Assert {
if (getter.getAnnotation(Deprecated.class) != null)
continue;
-
+
try {
Class returnType = getter.getReturnType();
-
+
if (IASTNode.class.isAssignableFrom(returnType)) {
//System.out.println(spaces(n) + "Testing1: " + getter.getName());
IASTNode result1 = (IASTNode) getter.invoke(node1);
@@ -123,29 +106,27 @@ public class ASTComparer extends Assert {
assertNotNull(result1);
assertNotNull(result2);
assertEquals(result1.length, result2.length);
- for(int i = 0; i < result1.length; i++)
+ for (int i = 0; i < result1.length; i++)
assertCopy(result1[i], result2[i], n + 1);
- } else if ((returnType.isPrimitive() || returnType.equals(String.class)) && !returnType.equals(Void.class)) {
+ } else if ((returnType.isPrimitive() || returnType.equals(String.class))
+ && !returnType.equals(Void.class)) {
//System.out.println(spaces(n) + "Testing3: " + getter.getName());
Object result1 = getter.invoke(node1);
Object result2 = getter.invoke(node2);
assertEquals(result1, result2);
}
} catch (AssertionFailedError e) {
- System.out.printf("Failure when calling %s.%s() @(%d,%d)\n",
- node1.getClass().getSimpleName(),
- getter.getName(),
- ((ASTNode) node1).getOffset(),
- ((ASTNode) node1).getLength());
+ System.out.printf("Failure when calling %s.%s() @(%d,%d)\n", node1.getClass().getSimpleName(),
+ getter.getName(), ((ASTNode) node1).getOffset(), ((ASTNode) node1).getLength());
throw e;
- }
+ }
}
-
+
}
-
-// private static String spaces(int n) {
-// char[] spaces = new char[n*2];
-// Arrays.fill(spaces, ' ');
-// return new String(spaces);
-// }
+
+ // private static String spaces(int n) {
+ // char[] spaces = new char[n*2];
+ // Arrays.fill(spaces, ' ');
+ // return new String(spaces);
+ // }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ArrayUtilTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ArrayUtilTest.java
index 3b6a46d6c18..6b364c92ee6 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ArrayUtilTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ArrayUtilTest.java
@@ -11,7 +11,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.core.parser.tests;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
@@ -19,66 +19,66 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
import junit.framework.TestCase;
public class ArrayUtilTest extends TestCase {
- private final Object o1= new Object();
- private final Object o2= new Object();
- private final Object o3= new Object();
- private final Object o4= new Object();
-
+ private final Object o1 = new Object();
+ private final Object o2 = new Object();
+ private final Object o3 = new Object();
+ private final Object o4 = new Object();
+
public void testAppend() {
- Object[] array= null;
- array= ArrayUtil.append(array, o1);
- array= ArrayUtil.append(array, o2);
- array= ArrayUtil.append(array, o3);
+ Object[] array = null;
+ array = ArrayUtil.append(array, o1);
+ array = ArrayUtil.append(array, o2);
+ array = ArrayUtil.append(array, o3);
assertEquals(o1, array[0]);
assertEquals(o2, array[1]);
assertEquals(o3, array[2]);
- array= ArrayUtil.appendAt(Object.class, null, 0, o1);
- array= ArrayUtil.appendAt(Object.class, array, 1, o2);
- array= ArrayUtil.appendAt(Object.class, array, 2, o3);
+ array = ArrayUtil.appendAt(Object.class, null, 0, o1);
+ array = ArrayUtil.appendAt(Object.class, array, 1, o2);
+ array = ArrayUtil.appendAt(Object.class, array, 2, o3);
assertEquals(o1, array[0]);
assertEquals(o2, array[1]);
assertEquals(o3, array[2]);
}
public void testPrepend() {
- Object[] array= null;
- array= ArrayUtil.prepend(Object.class, array, o1);
- array= ArrayUtil.prepend(Object.class, array, o2);
- array= ArrayUtil.prepend(Object.class, array, o3);
+ Object[] array = null;
+ array = ArrayUtil.prepend(Object.class, array, o1);
+ array = ArrayUtil.prepend(Object.class, array, o2);
+ array = ArrayUtil.prepend(Object.class, array, o3);
assertEquals(o3, array[0]);
assertEquals(o2, array[1]);
assertEquals(o1, array[2]);
}
public void testTrim() {
- Object[] array= new Object[] {null, null};
- array= ArrayUtil.trim(Object.class, array);
+ Object[] array = new Object[] { null, null };
+ array = ArrayUtil.trim(Object.class, array);
assertEquals(0, array.length);
- array= new Object[] {o1, null};
- array= ArrayUtil.trim(Object.class, array);
+ array = new Object[] { o1, null };
+ array = ArrayUtil.trim(Object.class, array);
assertEquals(1, array.length);
assertEquals(o1, array[0]);
- array= new Object[] {o1, o2};
- Object[] array2= ArrayUtil.trim(Object.class, array);
+ array = new Object[] { o1, o2 };
+ Object[] array2 = ArrayUtil.trim(Object.class, array);
assertEquals(2, array2.length);
assertSame(o1, array2[0]);
assertSame(o2, array2[1]);
assertSame(array, array2);
- array= new Object[] {null, null};
- array= ArrayUtil.trim(Object.class, array, true);
+ array = new Object[] { null, null };
+ array = ArrayUtil.trim(Object.class, array, true);
assertEquals(0, array.length);
- array= new Object[] {o1, null};
- array= ArrayUtil.trim(Object.class, array, true);
+ array = new Object[] { o1, null };
+ array = ArrayUtil.trim(Object.class, array, true);
assertEquals(1, array.length);
assertEquals(o1, array[0]);
-
- array= new Object[] {o1, o2};
- array2= ArrayUtil.trim(Object.class, array, true);
+
+ array = new Object[] { o1, o2 };
+ array2 = ArrayUtil.trim(Object.class, array, true);
assertEquals(2, array2.length);
assertSame(o1, array2[0]);
assertSame(o2, array2[1]);
@@ -86,72 +86,72 @@ public class ArrayUtilTest extends TestCase {
}
public void testAddAll() {
- Object[] array1= {o1, o2, null};
- Object[] array2= {o3, null};
+ Object[] array1 = { o1, o2, null };
+ Object[] array2 = { o3, null };
Object[] result;
-
- result= ArrayUtil.addAll(Object.class, array2, array1);
+
+ result = ArrayUtil.addAll(Object.class, array2, array1);
assertEquals(o3, result[0]);
assertEquals(o1, result[1]);
assertEquals(o2, result[2]);
-
- result= ArrayUtil.addAll(Object.class, array1, array2);
+
+ result = ArrayUtil.addAll(Object.class, array1, array2);
assertEquals(o1, result[0]);
assertEquals(o2, result[1]);
assertEquals(o3, result[2]);
assertSame(array1, result);
-
- array1= new Object[] {o1, o2};
- array2= new Object[] {o3, null};
-
- result= ArrayUtil.addAll(Object.class, array2, array1);
+
+ array1 = new Object[] { o1, o2 };
+ array2 = new Object[] { o3, null };
+
+ result = ArrayUtil.addAll(Object.class, array2, array1);
assertEquals(o3, result[0]);
assertEquals(o1, result[1]);
assertEquals(o2, result[2]);
-
- result= ArrayUtil.addAll(Object.class, array1, array2);
+
+ result = ArrayUtil.addAll(Object.class, array1, array2);
assertEquals(o1, result[0]);
assertEquals(o2, result[1]);
assertEquals(o3, result[2]);
- array1= new Object[] {o1, o2};
- array2= new Object[] {o3};
-
- result= ArrayUtil.addAll(Object.class, array2, array1);
+ array1 = new Object[] { o1, o2 };
+ array2 = new Object[] { o3 };
+
+ result = ArrayUtil.addAll(Object.class, array2, array1);
assertEquals(o3, result[0]);
assertEquals(o1, result[1]);
assertEquals(o2, result[2]);
-
- result= ArrayUtil.addAll(Object.class, array1, array2);
+
+ result = ArrayUtil.addAll(Object.class, array1, array2);
assertEquals(o1, result[0]);
assertEquals(o2, result[1]);
assertEquals(o3, result[2]);
-
- array1= new Object[] {o1, o2};
- array2= new Object[] {};
- result= ArrayUtil.addAll(Object.class, array2, array1);
+
+ array1 = new Object[] { o1, o2 };
+ array2 = new Object[] {};
+ result = ArrayUtil.addAll(Object.class, array2, array1);
assertEquals(o1, result[0]);
assertEquals(o2, result[1]);
assertNotSame(array1, result);
- result= ArrayUtil.addAll(Object.class, array1, array2);
+ result = ArrayUtil.addAll(Object.class, array1, array2);
assertEquals(o1, result[0]);
assertEquals(o2, result[1]);
assertSame(array1, result);
// Check that mismatched array types don't cause an ArrayStoreException.
// See http://bugs.eclipse.org/481274
- array1= new Integer[] {1, 2};
- array2= new String[] {"s"};
- result= ArrayUtil.addAll(Object.class, array1, array2);
+ array1 = new Integer[] { 1, 2 };
+ array2 = new String[] { "s" };
+ result = ArrayUtil.addAll(Object.class, array1, array2);
assertEquals(3, result.length);
assertEquals(1, result[0]);
assertEquals(2, result[1]);
assertEquals("s", result[2]);
}
-
+
public void testRemove() {
- Object[] array= new Object[] {o1, o2, o3, o4, null};
+ Object[] array = new Object[] { o1, o2, o3, o4, null };
ArrayUtil.remove(array, o3);
assertSame(o1, array[0]);
assertSame(o2, array[1]);
@@ -170,7 +170,7 @@ public class ArrayUtilTest extends TestCase {
ArrayUtil.remove(array, o2);
assertNull(array[0]);
- array= new Object[] {o1, o2, o3, o4};
+ array = new Object[] { o1, o2, o3, o4 };
ArrayUtil.remove(array, o3);
assertSame(o1, array[0]);
assertSame(o2, array[1]);
@@ -189,56 +189,56 @@ public class ArrayUtilTest extends TestCase {
ArrayUtil.remove(array, o2);
assertNull(array[0]);
}
-
+
public void testRemoveNulls() {
- Object[] array= new Object[0];
+ Object[] array = new Object[0];
Object[] result;
-
- result= ArrayUtil.removeNulls(Object.class, array);
+
+ result = ArrayUtil.removeNulls(Object.class, array);
assertEquals(0, result.length);
assertSame(result, array);
-
- array= new Object[]{null};
- result= ArrayUtil.removeNulls(Object.class, array);
+
+ array = new Object[] { null };
+ result = ArrayUtil.removeNulls(Object.class, array);
assertEquals(0, result.length);
- array= new Object[]{o1};
- result= ArrayUtil.removeNulls(Object.class, array);
+ array = new Object[] { o1 };
+ result = ArrayUtil.removeNulls(Object.class, array);
assertEquals(1, result.length);
assertSame(result[0], o1);
assertSame(result, array);
- array= new Object[]{o1, null};
- result= ArrayUtil.removeNulls(Object.class, array);
+ array = new Object[] { o1, null };
+ result = ArrayUtil.removeNulls(Object.class, array);
assertEquals(1, result.length);
assertSame(result[0], o1);
- array= new Object[]{null, o1};
- result= ArrayUtil.removeNulls(Object.class, array);
+ array = new Object[] { null, o1 };
+ result = ArrayUtil.removeNulls(Object.class, array);
assertEquals(1, result.length);
assertSame(result[0], o1);
- array= new Object[]{o1, o2};
- result= ArrayUtil.removeNulls(Object.class, array);
+ array = new Object[] { o1, o2 };
+ result = ArrayUtil.removeNulls(Object.class, array);
assertEquals(2, result.length);
assertSame(result[0], o1);
assertSame(result[1], o2);
assertSame(result, array);
- array= new Object[]{null, o1, o2};
- result= ArrayUtil.removeNulls(Object.class, array);
+ array = new Object[] { null, o1, o2 };
+ result = ArrayUtil.removeNulls(Object.class, array);
assertEquals(2, result.length);
assertSame(result[0], o1);
assertSame(result[1], o2);
- array= new Object[]{o1, null, o2};
- result= ArrayUtil.removeNulls(Object.class, array);
+ array = new Object[] { o1, null, o2 };
+ result = ArrayUtil.removeNulls(Object.class, array);
assertEquals(2, result.length);
assertSame(result[0], o1);
assertSame(result[1], o2);
- array= new Object[]{o1, o2, null};
- result= ArrayUtil.removeNulls(Object.class, array);
+ array = new Object[] { o1, o2, null };
+ result = ArrayUtil.removeNulls(Object.class, array);
assertEquals(2, result.length);
assertSame(result[0], o1);
assertSame(result[1], o2);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/AutomatedFramework.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/AutomatedFramework.java
index 7fdf5dec98c..f0e72eeb02c 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/AutomatedFramework.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/AutomatedFramework.java
@@ -11,7 +11,7 @@
* Contributors:
* IBM Corp. - Rational Software - initial implementation
*******************************************************************************/
-
+
package org.eclipse.cdt.core.parser.tests;
import java.io.File;
@@ -43,72 +43,72 @@ public abstract class AutomatedFramework extends TestCase {
super(name);
}
- protected abstract AutomatedFramework newTest( String name );
+ protected abstract AutomatedFramework newTest(String name);
+
protected abstract void loadProperties() throws Exception;
- public abstract void doFile() throws Throwable;
- private void fillSuite( TestSuite suite, File path ){
+ public abstract void doFile() throws Throwable;
+
+ private void fillSuite(TestSuite suite, File path) {
File files[] = null;
- if( path.isFile() ){
- files = new File[ 1 ];
+ if (path.isFile()) {
+ files = new File[1];
files[0] = path;
- }
- else
+ } else
files = path.listFiles();
-
+
File file = null;
String filePath = null;
int i = 0;
- try{
- file = files[ i++ ];
- while( file != null )
- {
- if( file.isDirectory() )
- fillSuite( suite, file );
- else if( file.isFile() && nameFilter.accept( file.getParentFile(), file.getName() ) ){
- try{
+ try {
+ file = files[i++];
+ while (file != null) {
+ if (file.isDirectory())
+ fillSuite(suite, file);
+ else if (file.isFile() && nameFilter.accept(file.getParentFile(), file.getName())) {
+ try {
filePath = file.getCanonicalPath();
- } catch ( Exception e ){
+ } catch (Exception e) {
continue;
}
-
- if( filePath.endsWith(".cpp") || filePath.endsWith(".hpp") || //$NON-NLS-1$ //$NON-NLS-2$
- filePath.endsWith(".cc") || filePath.endsWith(".CC") || //$NON-NLS-1$ //$NON-NLS-2$
- filePath.endsWith(".C") || //$NON-NLS-1$
- filePath.endsWith(".hxx") || filePath.endsWith(".hh") ) //$NON-NLS-1$ //$NON-NLS-2$
+
+ if (filePath.endsWith(".cpp") || filePath.endsWith(".hpp") || //$NON-NLS-1$ //$NON-NLS-2$
+ filePath.endsWith(".cc") || filePath.endsWith(".CC") || //$NON-NLS-1$ //$NON-NLS-2$
+ filePath.endsWith(".C") || //$NON-NLS-1$
+ filePath.endsWith(".hxx") || filePath.endsWith(".hh")) //$NON-NLS-1$ //$NON-NLS-2$
{
- AutomatedFramework.natures.put( filePath, "cpp" ); //$NON-NLS-1$
- } else if( filePath.endsWith(".c") ){ //$NON-NLS-1$
- AutomatedFramework.natures.put( filePath, "c" ); //$NON-NLS-1$
+ AutomatedFramework.natures.put(filePath, "cpp"); //$NON-NLS-1$
+ } else if (filePath.endsWith(".c")) { //$NON-NLS-1$
+ AutomatedFramework.natures.put(filePath, "c"); //$NON-NLS-1$
} else {
- AutomatedFramework.natures.put( filePath, AutomatedFramework.defaultNature );
+ AutomatedFramework.natures.put(filePath, AutomatedFramework.defaultNature);
}
-
- AutomatedFramework.fileList.add( file );
- suite.addTest( newTest( file.getName().replace(',', '_') ) );
- }
- file = files[ i++ ];
+
+ AutomatedFramework.fileList.add(file);
+ suite.addTest(newTest(file.getName().replace(',', '_')));
+ }
+ file = files[i++];
}
- } catch( ArrayIndexOutOfBoundsException e ){
+ } catch (ArrayIndexOutOfBoundsException e) {
//done
}
}
public void reportFailed() {
- fail( "Unable to open " + outputFile + "for output of results." ); //$NON-NLS-1$ //$NON-NLS-2$
+ fail("Unable to open " + outputFile + "for output of results."); //$NON-NLS-1$ //$NON-NLS-2$
}
public void propertiesFailed() {
- fail( "Unable to load properties file." ); //$NON-NLS-1$
+ fail("Unable to load properties file."); //$NON-NLS-1$
}
-
+
@Override
protected void runTest() throws Throwable {
String name = getName();
-
- if( name.equals("propertiesFailed") ) //$NON-NLS-1$
+
+ if (name.equals("propertiesFailed")) //$NON-NLS-1$
propertiesFailed();
- else if ( name.equals("reportFailed") ) //$NON-NLS-1$
+ else if (name.equals("reportFailed")) //$NON-NLS-1$
reportFailed();
else
doFile();
@@ -116,45 +116,44 @@ public abstract class AutomatedFramework extends TestCase {
public Test createSuite() {
TestSuite suite = new TestSuite();
-
- try{
+
+ try {
loadProperties();
- } catch( Exception e ){
- suite.addTest( newTest( "propertiesFailed") ); //$NON-NLS-1$
+ } catch (Exception e) {
+ suite.addTest(newTest("propertiesFailed")); //$NON-NLS-1$
}
-
- if( outputFile != null && !outputFile.isEmpty() ){
- try{
-
- File output = new File( outputFile );
-
- if( output.exists() ){
+
+ if (outputFile != null && !outputFile.isEmpty()) {
+ try {
+
+ File output = new File(outputFile);
+
+ if (output.exists()) {
output.delete();
}
-
+
output.createNewFile();
-
- report = new FileOutputStream( output );
-
- } catch( Exception e ) {
- suite.addTest( newTest( "reportFailed" ) ); //$NON-NLS-1$
+
+ report = new FileOutputStream(output);
+
+ } catch (Exception e) {
+ suite.addTest(newTest("reportFailed")); //$NON-NLS-1$
}
}
-
+
Set keys = testSources.keySet();
Iterator iter = keys.iterator();
int size = keys.size();
String item = null;
- for( int i = size; i > 0; i-- )
- {
+ for (int i = size; i > 0; i--) {
item = (String) iter.next();
- File file = new File( item );
- if( file.exists() ){
- defaultNature = (String) testSources.get( item );
- fillSuite( suite, file );
+ File file = new File(item);
+ if (file.exists()) {
+ defaultNature = (String) testSources.get(item);
+ fillSuite(suite, file);
}
}
-
+
return suite;
}
@@ -166,24 +165,22 @@ public abstract class AutomatedFramework extends TestCase {
protected static LinkedList fileList = new LinkedList();
private static FilenameFilter nameFilter = new Filter();
protected static FileOutputStream report = null;
-
- static private class Filter implements FilenameFilter
- {
+
+ static private class Filter implements FilenameFilter {
@Override
public boolean accept(File dir, String name) {
- if( name.endsWith(".cpp") || //$NON-NLS-1$
- name.endsWith(".c") || //$NON-NLS-1$
- name.endsWith(".cc") || //$NON-NLS-1$
- name.endsWith(".CC") || //$NON-NLS-1$
- name.endsWith(".C") || //$NON-NLS-1$
- name.endsWith(".h") || //$NON-NLS-1$
- name.endsWith(".hh") || //$NON-NLS-1$
- name.endsWith(".hpp") || //$NON-NLS-1$
- name.endsWith(".hxx")) //$NON-NLS-1$
+ if (name.endsWith(".cpp") || //$NON-NLS-1$
+ name.endsWith(".c") || //$NON-NLS-1$
+ name.endsWith(".cc") || //$NON-NLS-1$
+ name.endsWith(".CC") || //$NON-NLS-1$
+ name.endsWith(".C") || //$NON-NLS-1$
+ name.endsWith(".h") || //$NON-NLS-1$
+ name.endsWith(".hh") || //$NON-NLS-1$
+ name.endsWith(".hpp") || //$NON-NLS-1$
+ name.endsWith(".hxx")) //$NON-NLS-1$
{
return true;
- }
- else
+ } else
return false;
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CharArrayObjectMapTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CharArrayObjectMapTest.java
index cb1f5a2f609..10804f9ac62 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CharArrayObjectMapTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CharArrayObjectMapTest.java
@@ -46,10 +46,9 @@ public class CharArrayObjectMapTest extends TestCase {
public void testDuplicates() {
CharArrayObjectMap map = new CharArrayObjectMap(4);
- String[] keys = new String[] {
- "a", "b", "c", "c", "value", "value", "context", "context", "result", "d", "e", "f", "g", "h", "i", "j",
- "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "z"
- };
+ String[] keys = new String[] { "a", "b", "c", "c", "value", "value", "context", "context", "result", "d", "e",
+ "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
+ "z" };
for (int i = 0; i < keys.length; i++) {
String key = keys[i];
map.put(key.toCharArray(), key + i);
@@ -70,8 +69,8 @@ public class CharArrayObjectMapTest extends TestCase {
int r = random.nextInt();
map.put(("key" + Integer.toUnsignedString(i)).toCharArray(), i);
double collisionRatio = (double) map.countCollisions() / map.size();
- assertTrue(String.format("Collision ratio %.3f is unexpectedly high for map size of %d.", collisionRatio, map.size()),
- collisionRatio <= 0.4);
+ assertTrue(String.format("Collision ratio %.3f is unexpectedly high for map size of %d.", collisionRatio,
+ map.size()), collisionRatio <= 0.4);
}
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CharArrayUtilsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CharArrayUtilsTest.java
index a05efd61d69..914a80005ca 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CharArrayUtilsTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CharArrayUtilsTest.java
@@ -48,21 +48,20 @@ public class CharArrayUtilsTest extends TestCase {
assertEquals(-1, CharArrayUtils.lastIndexOf('a', "array".toCharArray(), 4));
assertEquals(3, CharArrayUtils.lastIndexOf('a', "array".toCharArray(), 3));
- assertEquals(8, CharArrayUtils.lastIndexOf("aaabbbaa".toCharArray(),
- "aaabbbaaaaabbbaabbbaa".toCharArray()));
- assertEquals(-1, CharArrayUtils.lastIndexOf("aaabbbaa".toCharArray(),
- "aabbbaabbbaa".toCharArray()));
+ assertEquals(8, CharArrayUtils.lastIndexOf("aaabbbaa".toCharArray(), "aaabbbaaaaabbbaabbbaa".toCharArray()));
+ assertEquals(-1, CharArrayUtils.lastIndexOf("aaabbbaa".toCharArray(), "aabbbaabbbaa".toCharArray()));
assertEquals(6, CharArrayUtils.lastIndexOf("".toCharArray(), "123456".toCharArray()));
assertEquals(4, CharArrayUtils.lastIndexOf("56".toCharArray(), "123456".toCharArray()));
assertEquals(-1, CharArrayUtils.lastIndexOf("123".toCharArray(), "".toCharArray()));
char[] buffer = "A::B::C".toCharArray();
- assertEquals(CharArrayUtils.lastIndexOf("::".toCharArray(), buffer), 4);
- assertTrue(CharArrayUtils.equals(CharArrayUtils.lastSegment(buffer, "::".toCharArray()), "C".toCharArray()));
+ assertEquals(CharArrayUtils.lastIndexOf("::".toCharArray(), buffer), 4);
+ assertTrue(CharArrayUtils.equals(CharArrayUtils.lastSegment(buffer, "::".toCharArray()), "C".toCharArray()));
- buffer = "A::B::C:foo".toCharArray();
- assertEquals(CharArrayUtils.lastIndexOf("::".toCharArray(), buffer), 4);
- assertTrue(CharArrayUtils.equals(CharArrayUtils.lastSegment(buffer, "::".toCharArray()), "C:foo".toCharArray()));
+ buffer = "A::B::C:foo".toCharArray();
+ assertEquals(CharArrayUtils.lastIndexOf("::".toCharArray(), buffer), 4);
+ assertTrue(
+ CharArrayUtils.equals(CharArrayUtils.lastSegment(buffer, "::".toCharArray()), "C:foo".toCharArray()));
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ContentAssistMatcherFactoryTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ContentAssistMatcherFactoryTest.java
index 3db157b78a6..3d7a439e7e2 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ContentAssistMatcherFactoryTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ContentAssistMatcherFactoryTest.java
@@ -46,8 +46,7 @@ public class ContentAssistMatcherFactoryTest extends TestCase {
public void testCamelCaseMatcher() {
setShowCamelCaseMatches(true);
- IContentAssistMatcher matcher = ContentAssistMatcherFactory
- .getInstance().createMatcher("fB");
+ IContentAssistMatcher matcher = ContentAssistMatcherFactory.getInstance().createMatcher("fB");
assertEquals("f", String.valueOf(matcher.getPrefixForBinarySearch()));
assertTrue(matcher.matchRequiredAfterBinarySearch());
@@ -55,8 +54,7 @@ public class ContentAssistMatcherFactoryTest extends TestCase {
public void testPrefixMatcher() {
setShowCamelCaseMatches(true);
- IContentAssistMatcher matcher = ContentAssistMatcherFactory
- .getInstance().createMatcher("foo");
+ IContentAssistMatcher matcher = ContentAssistMatcherFactory.getInstance().createMatcher("foo");
assertEquals("foo", String.valueOf(matcher.getPrefixForBinarySearch()));
assertFalse(matcher.matchRequiredAfterBinarySearch());
@@ -67,7 +65,6 @@ public class ContentAssistMatcherFactoryTest extends TestCase {
}
private boolean match(String pattern, String name) {
- return ContentAssistMatcherFactory.getInstance().match(
- pattern.toCharArray(), name.toCharArray());
+ return ContentAssistMatcherFactory.getInstance().match(pattern.toCharArray(), name.toCharArray());
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FileBasePluginTestCase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FileBasePluginTestCase.java
index 3dbdf1e022d..183e4cb41d6 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FileBasePluginTestCase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FileBasePluginTestCase.java
@@ -36,15 +36,15 @@ import org.eclipse.core.runtime.NullProgressMonitor;
* @author dsteffle
*/
public class FileBasePluginTestCase extends TestCase {
- static NullProgressMonitor monitor;
- static IWorkspace workspace;
- static IProject project;
- static FileManager fileManager;
- static int numProjects;
- static Class className;
+ static NullProgressMonitor monitor;
+ static IWorkspace workspace;
+ static IProject project;
+ static FileManager fileManager;
+ static int numProjects;
+ static Class className;
static ICProject cPrj;
- public FileBasePluginTestCase() {
+ public FileBasePluginTestCase() {
}
public FileBasePluginTestCase(String name) {
@@ -52,87 +52,87 @@ public class FileBasePluginTestCase extends TestCase {
}
private void initialize(Class aClassName) {
- if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null) {
+ if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null) {
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
monitor = new NullProgressMonitor();
workspace = ResourcesPlugin.getWorkspace();
- try {
- cPrj = CProjectHelper.createCCProject("ParserTestProject", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
- project = cPrj.getProject();
-
- // ugly
- if (className == null || !className.equals(aClassName)) {
- className = aClassName;
- numProjects++;
- }
- } catch (CoreException e) {
- // Ignore
- }
+ try {
+ cPrj = CProjectHelper.createCCProject("ParserTestProject", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
+ project = cPrj.getProject();
+
+ // ugly
+ if (className == null || !className.equals(aClassName)) {
+ className = aClassName;
+ numProjects++;
+ }
+ } catch (CoreException e) {
+ // Ignore
+ }
if (project == null)
throw new NullPointerException("Unable to create project"); //$NON-NLS-1$
//Create file manager
fileManager = new FileManager();
- }
- }
-
- public FileBasePluginTestCase(String name, Class className) {
- super(name);
- initialize(className);
- }
-
- public void cleanupProject() throws Exception {
- numProjects--;
-
- try {
- if (numProjects == 0) {
- project.delete(true, false, monitor);
- project = null;
- }
- } catch (Throwable e) {
- // Ignore
- }
- }
-
- @Override
+ }
+ }
+
+ public FileBasePluginTestCase(String name, Class className) {
+ super(name);
+ initialize(className);
+ }
+
+ public void cleanupProject() throws Exception {
+ numProjects--;
+
+ try {
+ if (numProjects == 0) {
+ project.delete(true, false, monitor);
+ project = null;
+ }
+ } catch (Throwable e) {
+ // Ignore
+ }
+ }
+
+ @Override
protected void tearDown() throws Exception {
- if (project == null || !project.exists())
- return;
-
- IResource [] members = project.members();
- for (int i = 0; i < members.length; i++) {
- if (members[i].getName().equals(".project") || members[i].getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
- continue;
- if (members[i].getName().equals(".settings"))
- continue;
- try {
- members[i].delete(false, monitor);
- } catch (Throwable e) {
- // Ignore
- }
- }
+ if (project == null || !project.exists())
+ return;
+
+ IResource[] members = project.members();
+ for (int i = 0; i < members.length; i++) {
+ if (members[i].getName().equals(".project") || members[i].getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
+ continue;
+ if (members[i].getName().equals(".settings"))
+ continue;
+ try {
+ members[i].delete(false, monitor);
+ } catch (Throwable e) {
+ // Ignore
+ }
+ }
}
- protected IFolder importFolder(String folderName) throws Exception {
- IFolder folder = project.getProject().getFolder(folderName);
+ protected IFolder importFolder(String folderName) throws Exception {
+ IFolder folder = project.getProject().getFolder(folderName);
// Create file input stream
if (!folder.exists())
folder.create(false, false, monitor);
return folder;
- }
+ }
- public IFile importFile(String fileName, String contents) throws Exception {
+ public IFile importFile(String fileName, String contents) throws Exception {
// Obtain file handle
IFile file = project.getProject().getFile(fileName);
InputStream stream = new ByteArrayInputStream(contents.getBytes());
// Create file input stream
if (file.exists()) {
- file.setContents(stream, false, false, monitor);
+ file.setContents(stream, false, false, monitor);
} else {
file.create(stream, false, monitor);
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ObjectMapTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ObjectMapTest.java
index 241a4b24ceb..963eb2d6886 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ObjectMapTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ObjectMapTest.java
@@ -26,116 +26,104 @@ import junit.framework.TestCase;
*/
public class ObjectMapTest extends TestCase {
- private static class HashObject {
- final public int hash;
+ private static class HashObject {
+ final public int hash;
- HashObject(int h) {
- hash = h;
- }
+ HashObject(int h) {
+ hash = h;
+ }
- @Override
+ @Override
public int hashCode() {
- return hash;
- }
- }
+ return hash;
+ }
+ }
- public void insertContents(ObjectMap map, Object[][] contents) throws Exception {
- for (int i = 0; i < contents.length; i++) {
- map.put(contents[i][0], contents[i][1]);
- }
- }
+ public void insertContents(ObjectMap map, Object[][] contents) throws Exception {
+ for (int i = 0; i < contents.length; i++) {
+ map.put(contents[i][0], contents[i][1]);
+ }
+ }
- public void assertContents(ObjectMap map, Object[][] contents) throws Exception {
- for (int i = 0; i < contents.length; i++) {
- assertEquals(map.keyAt(i), contents[i][0]);
- assertEquals(map.getAt(i), contents[i][1]);
- assertEquals(map.get(contents[i][0]), contents[i][1]);
- }
- assertEquals(map.size(), contents.length);
- }
+ public void assertContents(ObjectMap map, Object[][] contents) throws Exception {
+ for (int i = 0; i < contents.length; i++) {
+ assertEquals(map.keyAt(i), contents[i][0]);
+ assertEquals(map.getAt(i), contents[i][1]);
+ assertEquals(map.get(contents[i][0]), contents[i][1]);
+ }
+ assertEquals(map.size(), contents.length);
+ }
- public void testSimpleAdd() throws Exception{
- ObjectMap map = new ObjectMap(2);
+ public void testSimpleAdd() throws Exception {
+ ObjectMap map = new ObjectMap(2);
- Object[][] contents = new Object[][] { {"1", "ob" } };
+ Object[][] contents = new Object[][] { { "1", "ob" } };
- insertContents(map, contents);
- assertContents(map, contents);
+ insertContents(map, contents);
+ assertContents(map, contents);
- assertEquals(map.size(), 1);
- assertEquals(map.capacity(), 8);
- }
+ assertEquals(map.size(), 1);
+ assertEquals(map.capacity(), 8);
+ }
- public void testSimpleCollision() throws Exception{
- ObjectMap map = new ObjectMap(2);
+ public void testSimpleCollision() throws Exception {
+ ObjectMap map = new ObjectMap(2);
- HashObject key1 = new HashObject(1);
- HashObject key2 = new HashObject(1);
+ HashObject key1 = new HashObject(1);
+ HashObject key2 = new HashObject(1);
- Object[][] contents = new Object[][] { {key1, "1" },
- {key2, "2" } };
+ Object[][] contents = new Object[][] { { key1, "1" }, { key2, "2" } };
- insertContents(map, contents);
+ insertContents(map, contents);
- assertEquals(map.size(), 2);
- assertEquals(map.capacity(), 8);
+ assertEquals(map.size(), 2);
+ assertEquals(map.capacity(), 8);
- assertContents(map, contents);
- }
+ assertContents(map, contents);
+ }
- public void testResize() throws Exception{
- ObjectMap map = new ObjectMap(1);
+ public void testResize() throws Exception {
+ ObjectMap map = new ObjectMap(1);
- assertEquals(map.size(), 0);
- assertEquals(map.capacity(), 8);
+ assertEquals(map.size(), 0);
+ assertEquals(map.capacity(), 8);
- Object[][] res = new Object[][] { { "0", "o0" },
- { "1", "o1" },
- { "2", "o2" },
- { "3", "o3" },
- { "4", "o4" } };
+ Object[][] res = new Object[][] { { "0", "o0" }, { "1", "o1" }, { "2", "o2" }, { "3", "o3" }, { "4", "o4" } };
- insertContents(map, res);
- assertEquals(map.capacity(), 8);
- assertContents(map, res);
- }
+ insertContents(map, res);
+ assertEquals(map.capacity(), 8);
+ assertContents(map, res);
+ }
- public void testCollisionResize() throws Exception{
- ObjectMap map = new ObjectMap(1);
+ public void testCollisionResize() throws Exception {
+ ObjectMap map = new ObjectMap(1);
- assertEquals(map.size(), 0);
- assertEquals(map.capacity(), 8);
+ assertEquals(map.size(), 0);
+ assertEquals(map.capacity(), 8);
- Object[][] res = new Object[][] { { new HashObject(0), "o0" },
- { new HashObject(1), "o1" },
- { new HashObject(0), "o2" },
- { new HashObject(1), "o3" },
- { new HashObject(0), "o4" } };
+ Object[][] res = new Object[][] { { new HashObject(0), "o0" }, { new HashObject(1), "o1" },
+ { new HashObject(0), "o2" }, { new HashObject(1), "o3" }, { new HashObject(0), "o4" } };
- insertContents(map, res);
- assertEquals(map.capacity(), 8);
- assertContents(map, res);
- }
+ insertContents(map, res);
+ assertEquals(map.capacity(), 8);
+ assertContents(map, res);
+ }
- public void testReAdd() throws Exception{
- ObjectMap map = new ObjectMap(1);
+ public void testReAdd() throws Exception {
+ ObjectMap map = new ObjectMap(1);
- assertEquals(map.size(), 0);
- assertEquals(map.capacity(), 8);
+ assertEquals(map.size(), 0);
+ assertEquals(map.capacity(), 8);
- Object[][] res = new Object[][] { { "0", "o0" },
- { "1", "o1" } };
+ Object[][] res = new Object[][] { { "0", "o0" }, { "1", "o1" } };
- insertContents(map, res);
- assertEquals(map.capacity(), 8);
- assertContents(map, res);
+ insertContents(map, res);
+ assertEquals(map.capacity(), 8);
+ assertContents(map, res);
- res = new Object[][]{ { "0", "o00" },
- { "1", "o01" },
- { "10", "o10" },
- { "11", "o11" } };
+ res = new Object[][] { { "0", "o00" }, { "1", "o01" }, { "10", "o10" }, { "11", "o11" } };
- insertContents(map, res);
- assertContents(map, res);
- }
+ insertContents(map, res);
+ assertContents(map, res);
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserTestSuite.java
index 0b52ff7f164..f74906d08d7 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserTestSuite.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserTestSuite.java
@@ -30,7 +30,7 @@ import junit.framework.TestSuite;
*/
public class ParserTestSuite extends TestCase {
public static Test suite() {
- TestSuite suite= new TestSuite(ParserTestSuite.class.getName());
+ TestSuite suite = new TestSuite(ParserTestSuite.class.getName());
suite.addTestSuite(ArrayUtilTest.class);
suite.addTestSuite(CharArrayUtilsTest.class);
suite.addTestSuite(SegmentMatcherTest.class);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/SegmentMatcherTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/SegmentMatcherTest.java
index 4a27263330d..066e2e0af1d 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/SegmentMatcherTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/SegmentMatcherTest.java
@@ -11,7 +11,7 @@
* Contributors:
* Tomasz Wesolowski - initial API and implementation
* Jens Elmenthaler - further tweaking
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.core.parser.tests;
@@ -20,7 +20,6 @@ import junit.framework.TestCase;
import org.eclipse.cdt.core.parser.util.SegmentMatcher;
public class SegmentMatcherTest extends TestCase {
-
public void testSimple() {
@@ -53,17 +52,17 @@ public class SegmentMatcherTest extends TestCase {
assertFalse(matchSegments("fBBBarBaz", "fooBarBaz"));
assertFalse(matchSegments("foooBarBaz", "fooBarBaz"));
assertFalse(matchSegments("foBrBaz", "fooBarBaz"));
-
+
}
-
+
public void testSuffix() {
assertTrue(matchSegments("fooBar", "fooBar123"));
assertTrue(matchSegments("fooBar", "fooBarrr"));
assertTrue(matchSegments("fooBar", "fooBarr__"));
-
+
}
-
+
public void testNumeric() {
assertTrue(matchSegments("fBBaz", "foo29BarBaz"));
@@ -71,14 +70,14 @@ public class SegmentMatcherTest extends TestCase {
assertTrue(matchSegments("fB100Baz1", "fooBar100Baz10"));
assertTrue(matchSegments("fB100Baz10", "fooBar100Baz10"));
assertTrue(matchSegments("fooBar100Baz10", "fooBar100Baz10"));
-
+
assertFalse(matchSegments("fBar100Ba", "fooBarBaz"));
assertTrue(matchSegments("f100Baz", "fooBar100Baz10"));
assertFalse(matchSegments("fB1000Baz", "fooBar100Baz"));
assertFalse(matchSegments("sV", "seed48"));
-
+
}
-
+
public void testSeparator() {
assertTrue(matchSegments("fBB", "foo_Bar_Baz"));
@@ -95,23 +94,23 @@ public class SegmentMatcherTest extends TestCase {
assertFalse(matchSegments("fB_B", "foo__bar__baz"));
assertFalse(matchSegments("f___b", "foo__bar"));
assertFalse(matchSegments("f__bb", "foo__bar__baz"));
-
+
assertFalse(matchSegments("f_B_B", "fooBarBaz"));
assertFalse(matchSegments("f_B", "foo_bar"));
assertFalse(matchSegments("foo_B", "foo_bar"));
assertFalse(matchSegments("foo_Bar", "foo_bar"));
assertFalse(matchSegments("fO_bar", "foo_bar"));
assertFalse(matchSegments("f__b", "foo_bar"));
-
+
}
-
+
public void testPrefixChars() {
- assertFalse(matchSegments("$asd","_asd"));
- assertFalse(matchSegments("_$$","__"));
- assertFalse(matchSegments("__$","__"));
+ assertFalse(matchSegments("$asd", "_asd"));
+ assertFalse(matchSegments("_$$", "__"));
+ assertFalse(matchSegments("__$", "__"));
- // require everything to be exactly the same from start up until the first section
+ // require everything to be exactly the same from start up until the first section
assertTrue(matchSegments("__f", "__fooBar"));
assertTrue(matchSegments("__fooB", "__fooBar"));
assertFalse(matchSegments("_fooB", "__fooBar"));
@@ -154,7 +153,7 @@ public class SegmentMatcherTest extends TestCase {
assertEquals("$__foo", getPrefixForBinarySearch("$__foo3"));
assertEquals("$__foo", getPrefixForBinarySearch("$__foo_"));
}
-
+
/**
* Only checks segment matching (i.e. without case-insensitive prefix matching)
*/
@@ -162,7 +161,7 @@ public class SegmentMatcherTest extends TestCase {
SegmentMatcher matcher = new SegmentMatcher(pattern.toCharArray());
return matcher.matchSegments(name.toCharArray());
}
-
+
private String getPrefixForBinarySearch(String pattern) {
SegmentMatcher matcher = new SegmentMatcher(pattern.toCharArray());
return String.valueOf(matcher.getPrefixForBinarySearch());
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/XMLDumper.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/XMLDumper.java
index 7c319ee19da..7d3dc6e1111 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/XMLDumper.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/XMLDumper.java
@@ -38,25 +38,25 @@ public class XMLDumper {
public static class Test {
private String msg = "hi"; //$NON-NLS-1$
-
+
public String getMsg() {
return msg;
}
-
+
public Test self = this;
}
-
- public static void main(String [] args) {
+
+ public static void main(String[] args) {
Test test = new Test();
try {
XMLDumper dumper = new XMLDumper(test);
Document document = dumper.getDocument();
StringWriter writer = new StringWriter();
-
+
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(new DOMSource(document), new StreamResult(writer));
- System.out.println( "STRXML = " + writer.toString() ); //Spit out DOM as a String //$NON-NLS-1$
+ System.out.println("STRXML = " + writer.toString()); //Spit out DOM as a String //$NON-NLS-1$
} catch (TransformerException e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
@@ -64,44 +64,44 @@ public class XMLDumper {
}
}
-
+
private int id = 0;
private HashMap map = new HashMap();
private Document document;
-
+
public Document getDocument() {
return document;
}
-
+
public XMLDumper(Object obj) throws ParserConfigurationException {
document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
document.appendChild(createObject(obj));
}
-
+
private Element createObject(Object obj) {
Class cls = obj.getClass();
String clsName = cls.getName();
clsName = clsName.replace('$', '.');
-
+
Element element = document.createElement(clsName);
map.put(obj, Integer.valueOf(id));
- element.setAttribute("id",Integer.toString(id++)); //$NON-NLS-1$
-
- Field [] fields = cls.getDeclaredFields();
+ element.setAttribute("id", Integer.toString(id++)); //$NON-NLS-1$
+
+ Field[] fields = cls.getDeclaredFields();
for (int i = 0; i < fields.length; ++i) {
Field field = fields[i];
int modifiers = field.getModifiers();
-
+
// Skip over static fields
if (Modifier.isStatic(modifiers))
continue;
-
+
// Skip fields that start with an underscore
if (field.getName().charAt(0) == '_')
continue;
-
+
Object value = null;
-
+
String fieldName = field.getName();
if (Modifier.isPublic(modifiers)) {
try {
@@ -111,34 +111,33 @@ public class XMLDumper {
}
} else {
String methodName = "get" + //$NON-NLS-1$
- fieldName.substring(0, 1).toUpperCase() +
- fieldName.substring(1);
-
+ fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
+
Method method = null;
try {
- method = cls.getMethod(methodName, (Class []) null);
+ method = cls.getMethod(methodName, (Class[]) null);
} catch (NoSuchMethodException e) {
continue;
}
-
+
try {
- value = method.invoke(obj, (Object []) null);
+ value = method.invoke(obj, (Object[]) null);
} catch (Exception e) {
value = e;
}
}
-
+
Element fieldElement = document.createElement(fieldName);
element.appendChild(fieldElement);
-
+
if (value == null)
return element;
-
+
Class type = field.getType();
if (String.class.isAssignableFrom(type))
- fieldElement.appendChild(document.createTextNode((String)value));
+ fieldElement.appendChild(document.createTextNode((String) value));
else if (Integer.class.isAssignableFrom(type))
- fieldElement.appendChild(document.createTextNode(((Integer)value).toString()));
+ fieldElement.appendChild(document.createTextNode(((Integer) value).toString()));
else if (Exception.class.isAssignableFrom(type))
fieldElement.appendChild(document.createTextNode(value.toString()));
else {
@@ -148,9 +147,9 @@ public class XMLDumper {
else
fieldElement.appendChild(createObject(value));
}
-
+
}
-
+
return element;
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java
index 1ed102a602e..d64b48a1a45 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java
@@ -140,7 +140,8 @@ public class AST2CPPAttributeTests extends AST2TestBase {
return specifier.getAttributes();
}
- private void checkAttributeRelations(List<IASTAttributeSpecifier> specifiers, Class<? extends IASTAttributeOwner>... parentType) {
+ private void checkAttributeRelations(List<IASTAttributeSpecifier> specifiers,
+ Class<? extends IASTAttributeOwner>... parentType) {
assertEquals(parentType.length, specifiers.size());
for (int i = 0; i < specifiers.size(); i++) {
IASTAttributeSpecifier specifier = specifiers.get(i);
@@ -487,9 +488,8 @@ public class AST2CPPAttributeTests extends AST2TestBase {
IASTAttribute attribute = attributes[0];
IASTToken argumentClause = attribute.getArgumentClause();
final int startOffset = 8;
- final String[] tokenImages = new String[] { "this", "(", "is", ")", "{", "[",
- "my", "]", "}", "(", "argument", "[", "with", "]", "{", "some",
- "}", ",", "parentheses", ")"};
+ final String[] tokenImages = new String[] { "this", "(", "is", ")", "{", "[", "my", "]", "}", "(", "argument",
+ "[", "with", "]", "{", "some", "}", ",", "parentheses", ")" };
argumentClause.accept(new TokenPositionCheckVisitor(startOffset, tokenImages));
}
@@ -526,7 +526,6 @@ public class AST2CPPAttributeTests extends AST2TestBase {
checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTFunctionDeclarator.class);
}
-
// enum E {
// value1 [[attr1]], value2 [[attr2]] = 1
// };
@@ -539,7 +538,8 @@ public class AST2CPPAttributeTests extends AST2TestBase {
//}
public void testAttributedFunctionParameter_Bug535275() throws Exception {
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, true);
- checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTParameterDeclaration.class, ICPPASTSimpleDeclSpecifier.class);
+ checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTParameterDeclaration.class,
+ ICPPASTSimpleDeclSpecifier.class);
}
//namespace [[attr]] NS {}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPImplicitNameTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPImplicitNameTests.java
index 5276fa4b5e6..3f3b11961a8 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPImplicitNameTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPImplicitNameTests.java
@@ -52,7 +52,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
}
protected BindingAssertionHelper getAssertionHelper() throws ParserException, IOException {
- String code= getAboveComment();
+ String code = getAboveComment();
return new AST2AssertionHelper(code, ParserLanguage.CPP);
}
@@ -104,7 +104,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// +p;
// }
public void testBinaryExpressions() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTTranslationUnit tu = ba.getTranslationUnit();
NameCollector col = new NameCollector();
tu.accept(col);
@@ -148,7 +148,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// *y; //2
// }
public void testPointerDereference() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertImplicitName("*x;", 1, ICPPFunction.class);
ba.assertNoImplicitName("*y; //2", 1);
}
@@ -166,7 +166,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// X* px2 = &y; // overloaded
// }
public void testPointerToMember() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTTranslationUnit tu = ba.getTranslationUnit();
NameCollector col = new NameCollector();
tu.accept(col);
@@ -227,7 +227,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// (++p1).x; //2
// }
public void testUnaryPrefixAndPostfix() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertImplicitName("++).x; //1", 2, ICPPFunction.class);
ba.assertImplicitName("++p1).x; //2", 2, ICPPMethod.class);
}
@@ -253,7 +253,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// test(a, b, c, d); // func
// }
public void testCommaOperator1() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
// expression lists are used in function calls but they should not resolve to the comma operator
ba.assertNoImplicitName(", b, c, d); // func", 1);
ba.assertNoImplicitName(", c, d); // func", 1);
@@ -319,7 +319,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// x(1, 2); // 3
// }
public void testFunctionCallOperator() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTTranslationUnit tu = ba.getTranslationUnit();
NameCollector col = new NameCollector();
tu.accept(col);
@@ -360,7 +360,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// b = a; // should not resolve
// }
public void testCopyAssignmentOperator() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNoImplicitName("= a;", 1);
}
@@ -378,7 +378,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// func(y[q]); //2
// }
public void testArraySubscript() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTTranslationUnit tu = ba.getTranslationUnit();
NameCollector col = new NameCollector();
tu.accept(col);
@@ -413,7 +413,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// delete 1;
// }
public void testDelete() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTImplicitName[] names = ba.getImplicitNames("delete x;", 6);
assertEquals(2, names.length);
IASTImplicitName destructor = names[0];
@@ -447,9 +447,9 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// delete b;
// }
public void testOverloadedDelete_Bug351547() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
- IBinding m= bh.assertNonProblem("operator delete(void * a)", 15);
- IBinding f= bh.assertNonProblem("operator delete(void * b)", 15);
+ BindingAssertionHelper bh = getAssertionHelper();
+ IBinding m = bh.assertNonProblem("operator delete(void * a)", 15);
+ IBinding f = bh.assertNonProblem("operator delete(void * b)", 15);
IASTImplicitName[] names = bh.getImplicitNames("delete a;", 6);
assertEquals(2, names.length);
@@ -474,9 +474,9 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// B* b = new B;
// }
public void testOverloadedNew_Bug354585() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
- IBinding m= bh.assertNonProblem("operator new(size_t a)", 12);
- IBinding f= bh.assertNonProblem("operator new(size_t b)", 12);
+ BindingAssertionHelper bh = getAssertionHelper();
+ IBinding m = bh.assertNonProblem("operator new(size_t a)", 12);
+ IBinding f = bh.assertNonProblem("operator new(size_t b)", 12);
IASTImplicitName[] names = bh.getImplicitNames("new A;", 3);
assertEquals(2, names.length);
@@ -512,7 +512,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// int* p2 = new (5, 6) int[5];
// }
public void testNew() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTImplicitName n1 = ba.assertImplicitName("new (nothrow) X", 3, ICPPFunction.class);
IASTImplicitName n2 = ba.assertImplicitName("new (nothrow) int", 3, ICPPFunction.class);
IASTImplicitName n3 = ba.assertImplicitName("new (5, 6) int", 3, ICPPFunction.class);
@@ -530,7 +530,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// throw;
// }
public void testEmptyThrow() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNoImplicitName("throw;", 5);
}
@@ -559,7 +559,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// };
// B C::t = 1;
public void testConstructorCall() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTTranslationUnit tu = ba.getTranslationUnit();
ICPPConstructor ctor0 = ba.assertNonProblem("A()", 1, ICPPConstructor.class);
ICPPConstructor ctor1 = ba.assertNonProblem("A(int)", 1, ICPPConstructor.class);
@@ -596,7 +596,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// }
// }
public void testBuiltinOperators_294543() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTTranslationUnit tu = ba.getTranslationUnit();
ICPPFunction op = ba.assertNonProblem("operator==", 0);
IASTImplicitName a = ba.assertImplicitName("==b", 2, ICPPFunction.class);
@@ -612,7 +612,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// x = A().a;
// }
public void testTemporaryDestruction() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTImplicitDestructorName[] names = ba.getImplicitDestructorNames("x = A().a");
assertEquals(1, names.length);
assertEquals("~A", names[0].resolveBinding().getName());
@@ -627,7 +627,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// x = A();
// }
public void testTemporaryNotCreatedWhenBoundToVariable() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTImplicitDestructorName[] names = ba.getImplicitDestructorNames("x = A()");
assertEquals(0, names.length);
}
@@ -640,7 +640,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// return (new A())->a;
// }
public void testTemporaryNotCreatesInNewExpression() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTImplicitDestructorName[] names = ba.getImplicitDestructorNames("(new A())->a");
assertEquals(0, names.length);
}
@@ -653,7 +653,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// A& x = A();
// }
public void testTemporaryBoundToReference() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTImplicitDestructorName[] names = ba.getImplicitDestructorNames("A()");
assertEquals(0, names.length);
}
@@ -670,7 +670,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
// S s3;
// }//1
public void testOrderOfDestruction() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IASTImplicitDestructorName[] names = ba.getImplicitDestructorNames("}//1", 1);
assertEquals(3, names.length);
assertEquals("~S", names[0].resolveBinding().getName());
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java
index 4d889618d21..dcc6441edac 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java
@@ -396,8 +396,8 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// // resolution chooses Z::h(double)
// }
public void test3_4_3_2s2() throws Exception {
- String[] problems= {"AB::x", "x", "AB::i", "i"};
- parse(getAboveComment(), ParserLanguage.CPP, problems); // qualified names are counted double, so 4
+ String[] problems = { "AB::x", "x", "AB::i", "i" };
+ parse(getAboveComment(), ParserLanguage.CPP, problems); // qualified names are counted double, so 4
}
// namespace A {
@@ -529,7 +529,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// struct Base::Datum; // error: Datum undefined
// struct Base::Data* pBase; // OK: refers to nested Data
public void test3_4_4s3() throws Exception {
- String[] problems= {"::Glob", "Glob", "Base::Datum", "Datum"};
+ String[] problems = { "::Glob", "Glob", "Base::Datum", "Datum" };
parse(getAboveComment(), ParserLanguage.CPP, problems);
}
@@ -799,15 +799,15 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// new (int (*[10])());
// };
public void test5_3_4s3() throws Exception {
- IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 0);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- IASTExpression expr= getExpressionOfStatement(fdef, 0);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, 0);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ IASTExpression expr = getExpressionOfStatement(fdef, 0);
assertInstance(expr, ICPPASTNewExpression.class);
- ICPPASTNewExpression newExpr= (ICPPASTNewExpression) expr;
+ ICPPASTNewExpression newExpr = (ICPPASTNewExpression) expr;
assertNull(newExpr.getNewPlacement());
assertNull(newExpr.getNewInitializer());
- IASTTypeId typeid= newExpr.getTypeId();
+ IASTTypeId typeid = newExpr.getTypeId();
isTypeEqual(CPPVisitor.createType(typeid), "int (* [10])()");
}
@@ -821,37 +821,37 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
public void test5_3_4s12() throws Exception {
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=236856
- IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 0);
- IASTFunctionDefinition fdef= getDeclaration(tu, 1);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, 0);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 1);
// new T;
- IASTExpression expr= getExpressionOfStatement(fdef, 0);
+ IASTExpression expr = getExpressionOfStatement(fdef, 0);
assertInstance(expr, ICPPASTNewExpression.class);
- ICPPASTNewExpression newExpr= (ICPPASTNewExpression) expr;
+ ICPPASTNewExpression newExpr = (ICPPASTNewExpression) expr;
assertNull(newExpr.getNewPlacement());
assertNull(newExpr.getNewInitializer());
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int");
// new(2,f) T;
- expr= getExpressionOfStatement(fdef, 1);
+ expr = getExpressionOfStatement(fdef, 1);
assertInstance(expr, ICPPASTNewExpression.class);
- newExpr= (ICPPASTNewExpression) expr;
+ newExpr = (ICPPASTNewExpression) expr;
assertInstance(newExpr.getNewPlacement(), IASTExpressionList.class);
assertNull(newExpr.getNewInitializer());
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int");
// new T[5];
- expr= getExpressionOfStatement(fdef, 2);
+ expr = getExpressionOfStatement(fdef, 2);
assertInstance(expr, ICPPASTNewExpression.class);
- newExpr= (ICPPASTNewExpression) expr;
+ newExpr = (ICPPASTNewExpression) expr;
assertNull(newExpr.getNewPlacement());
assertNull(newExpr.getNewInitializer());
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int [5]");
// new (2,f) T[5];
- expr= getExpressionOfStatement(fdef, 3);
+ expr = getExpressionOfStatement(fdef, 3);
assertInstance(expr, ICPPASTNewExpression.class);
- newExpr= (ICPPASTNewExpression) expr;
+ newExpr = (ICPPASTNewExpression) expr;
assertInstance(newExpr.getNewPlacement(), IASTExpressionList.class);
assertNull(newExpr.getNewInitializer());
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int [5]");
@@ -1160,7 +1160,6 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
-
// class complex { //
// };
// typedef int complex; // error: redefinition
@@ -1196,9 +1195,9 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// // an ordinary member function, not a constructor
// } S;
public void test7_1_3s5b() throws Exception {
- IASTTranslationUnit tu= parseWithErrors(getAboveComment(), ParserLanguage.CPP);
- IASTCompositeTypeSpecifier comp= getCompositeType(tu, 0);
- IASTDeclaration d= getDeclaration(comp, 0);
+ IASTTranslationUnit tu = parseWithErrors(getAboveComment(), ParserLanguage.CPP);
+ IASTCompositeTypeSpecifier comp = getCompositeType(tu, 0);
+ IASTDeclaration d = getDeclaration(comp, 0);
assertInstance(d, IASTProblemDeclaration.class);
}
@@ -1335,7 +1334,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// j++; // A::unique::j
// }
public void test7_3_1_1s1() throws Exception {
- String[] problems= {"i"};
+ String[] problems = { "i" };
parse(getAboveComment(), ParserLanguage.CPP, problems);
}
@@ -1659,7 +1658,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// i = 5; // illformed; neither i is visible
// }
public void test7_3_4s1() throws Exception {
- String[] problems= {"i", "i"};
+ String[] problems = { "i", "i" };
parse(getAboveComment(), ParserLanguage.CPP, problems);
}
@@ -1676,7 +1675,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// i = 7; // error: both M::i and N::i are visible
// }
public void test7_3_4s2a() throws Exception {
- String[] problems= {"i"};
+ String[] problems = { "i" };
parse(getAboveComment(), ParserLanguage.CPP, problems);
}
@@ -1701,7 +1700,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// }
// }
public void test7_3_4s2b() throws Exception {
- String[] problems= {"k"};
+ String[] problems = { "k" };
parse(getAboveComment(), ParserLanguage.CPP, problems);
}
@@ -1731,7 +1730,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// f('a'); //OK: D::f(char)
// }
public void test7_3_4s5() throws Exception {
- String[] problems= {"d1", "f"};
+ String[] problems = { "d1", "f" };
parse(getAboveComment(), ParserLanguage.CPP, problems);
}
@@ -1855,16 +1854,16 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// S<int()> x; // typeid
// S<int(1)> y; // expression (illformed)
public void test8_2s4() throws Exception {
- IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 1);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, 1);
NameCollector col = new NameCollector();
tu.accept(col);
assertInstance(col.getName(4), ICPPASTTemplateId.class);
- assertInstance(((ICPPASTTemplateId)col.getName(4)).getTemplateArguments()[0], IASTTypeId.class);
+ assertInstance(((ICPPASTTemplateId) col.getName(4)).getTemplateArguments()[0], IASTTypeId.class);
final IASTName S_int_1 = col.getName(7);
assertInstance(S_int_1, ICPPASTTemplateId.class);
- assertInstance(((ICPPASTTemplateId)S_int_1).getTemplateArguments()[0], IASTExpression.class);
+ assertInstance(((ICPPASTTemplateId) S_int_1).getTemplateArguments()[0], IASTExpression.class);
assertInstance(S_int_1.getBinding(), IProblemBinding.class);
}
@@ -1898,8 +1897,8 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
final String code = getAboveComment();
parse(code, ParserLanguage.CPP, true, 1);
- BindingAssertionHelper ba= new AST2AssertionHelper(code, true);
- IFunction f= ba.assertNonProblem("f", 1, IFunction.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, true);
+ IFunction f = ba.assertNonProblem("f", 1, IFunction.class);
isTypeEqual(f.getType(), "void (int (*)(C))");
}
@@ -1909,8 +1908,8 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
public void test8_2s7b() throws Exception {
final String code = getAboveComment();
parse(code, ParserLanguage.CPP, true, 0);
- BindingAssertionHelper ba= new AST2AssertionHelper(code, true);
- IFunction f= ba.assertNonProblem("h", 1, IFunction.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, true);
+ IFunction f = ba.assertNonProblem("h", 1, IFunction.class);
isTypeEqual(f.getType(), "void (int * (*)(C *))");
}
@@ -2251,7 +2250,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
//
// void c() const& {}
// void d() const&& {}
- //
+ //
// void e() volatile & {}
// void f() volatile && {}
//
@@ -2261,7 +2260,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
public void test8s4() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
-
+
// void print(int a, int)
// {
// //printf("a = %d",a);
@@ -2397,7 +2396,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// demonstrate the rules with variable initialiation, but CDT doesn't
// currently issue problem bindings for variable initialization,
// so in the tests the examples are rewritten to use function calls.
-
+
// void f1(double);
// void f2(double&);
// void f3(const double&);
@@ -2653,10 +2652,10 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// y.g(); //error
// }
public void test9_3_2s4() throws Exception {
- String[] problems= {"g"};
+ String[] problems = { "g" };
final String code = getAboveComment();
- IASTTranslationUnit tu= parse(code, ParserLanguage.CPP, problems);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP, problems);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("g();", 1);
bh.assertProblem("g(); //error", 1);
}
@@ -3675,16 +3674,16 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
public void test12_4s12() throws Exception {
final String code = getAboveComment();
parse(code, ParserLanguage.CPP, false, 0);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- ICPPFunction dtor= bh.assertNonProblem("~B() {", 2);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ ICPPFunction dtor = bh.assertNonProblem("~B() {", 2);
- ICPPFunction d= bh.assertNonProblem("~B(); //1", 2);
+ ICPPFunction d = bh.assertNonProblem("~B(); //1", 2);
assertSame(dtor, d);
- d= bh.assertNonProblem("~B(); //2", 2);
+ d = bh.assertNonProblem("~B(); //2", 2);
assertSame(dtor, d);
- d= bh.assertNonProblem("~B_alias(); //3", 8);
+ d = bh.assertNonProblem("~B_alias(); //3", 8);
assertSame(dtor, d);
- d= bh.assertNonProblem("~B(); //4", 2);
+ d = bh.assertNonProblem("~B(); //4", 2);
assertSame(dtor, d);
bh.assertProblem("~B_alias(); //5", 8);
@@ -4142,7 +4141,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// int f (int) { } // definition of f(int)
// int f (cInt) { } // error: redefinition of f(int)
public void test12_8s3e() throws Exception {
- String[] problems= {"f"};
+ String[] problems = { "f" };
parse(getAboveComment(), ParserLanguage.CPP, problems);
}
@@ -4367,7 +4366,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// b.f(); //Calls X::f()
// }
public void test13_3_3_2s3b() throws Exception {
- String[] problems= {"g"};
+ String[] problems = { "g" };
parse(getAboveComment(), ParserLanguage.CPP, problems);
}
@@ -4687,7 +4686,6 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
-
// void error(const char*);
// template<class T> class Array {
// T* v;
@@ -4741,8 +4739,6 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
-
-
// class B {
// virtual void f(int);
// };
@@ -4951,6 +4947,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
public void test14_5_6_1s1a() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
+
// // file2.c
// template<class T>
// void f(T);
@@ -4969,12 +4966,12 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// // Guaranteed to be different
// template <int I> void f/*3*/(A<I>, A<I+11>);
public void test14_5_6_1s8a() throws Exception {
- final String content= getAboveComment();
- IASTTranslationUnit tu= parse(content, ParserLanguage.CPP, true, 0);
- BindingAssertionHelper bh= new AST2AssertionHelper(content, true);
- ICPPFunctionTemplate f1= bh.assertNonProblem("f/*1*/", 1);
- ICPPFunctionTemplate f2= bh.assertNonProblem("f/*2*/", 1);
- ICPPFunctionTemplate f3= bh.assertNonProblem("f/*3*/", 1);
+ final String content = getAboveComment();
+ IASTTranslationUnit tu = parse(content, ParserLanguage.CPP, true, 0);
+ BindingAssertionHelper bh = new AST2AssertionHelper(content, true);
+ ICPPFunctionTemplate f1 = bh.assertNonProblem("f/*1*/", 1);
+ ICPPFunctionTemplate f2 = bh.assertNonProblem("f/*2*/", 1);
+ ICPPFunctionTemplate f3 = bh.assertNonProblem("f/*3*/", 1);
assertSame(f1, f2);
assertNotSame(f1, f3);
}
@@ -5000,11 +4997,11 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// b * a; // calls #1a
// }
public void test14_5_6_2s3() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IBinding op1= bh.assertNonProblem("operator*(R&)", -4);
- IASTImplicitName name= bh.assertImplicitName("* a", 1, ICPPFunction.class);
- ICPPTemplateInstance inst= (ICPPTemplateInstance) name.resolveBinding();
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IBinding op1 = bh.assertNonProblem("operator*(R&)", -4);
+ IASTImplicitName name = bh.assertImplicitName("* a", 1, ICPPFunction.class);
+ ICPPTemplateInstance inst = (ICPPTemplateInstance) name.resolveBinding();
ICPPSpecialization templateSpecialization = (ICPPSpecialization) inst.getTemplateDefinition();
assertSame(op1, templateSpecialization.getSpecializedBinding());
}
@@ -5242,11 +5239,11 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
public void test14_6_2s2() throws Exception {
final String code = getAboveComment();
parse(code, ParserLanguage.CPP, true, 0);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- ICPPUnknownBinding unknown= bh.assertNonProblem("B<T>", 4);
- unknown= bh.assertNonProblem("T::A", 4);
- unknown= bh.assertNonProblem("B<T>::i", 7);
- unknown= bh.assertNonProblem("j", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ ICPPUnknownBinding unknown = bh.assertNonProblem("B<T>", 4);
+ unknown = bh.assertNonProblem("T::A", 4);
+ unknown = bh.assertNonProblem("B<T>::i", 7);
+ unknown = bh.assertNonProblem("j", 1);
}
// typedef double A;
@@ -5257,13 +5254,13 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// A a; // a has type double
// };
public void test14_6_2s3() throws Exception {
- final String content= getAboveComment();
- IASTTranslationUnit tu= parse(content, ParserLanguage.CPP, true, 0);
- BindingAssertionHelper bh= new AST2AssertionHelper(content, true);
- IVariable v= bh.assertNonProblem("a;", 1);
- IType t= v.getType();
+ final String content = getAboveComment();
+ IASTTranslationUnit tu = parse(content, ParserLanguage.CPP, true, 0);
+ BindingAssertionHelper bh = new AST2AssertionHelper(content, true);
+ IVariable v = bh.assertNonProblem("a;", 1);
+ IType t = v.getType();
assertInstance(t, ITypedef.class);
- t= ((ITypedef) t).getType();
+ t = ((ITypedef) t).getType();
assertInstance(t, IBasicType.class);
assertEquals(IBasicType.t_double, ((IBasicType) t).getType());
}
@@ -5282,12 +5279,12 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// };
// Y<A> ya;
public void test14_6_2s4() throws Exception {
- final String content= getAboveComment();
+ final String content = getAboveComment();
parse(content, ParserLanguage.CPP, true, 0);
- BindingAssertionHelper bh= new AST2AssertionHelper(content, true);
- IBinding b= bh.assertNonProblem("b;", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(content, true);
+ IBinding b = bh.assertNonProblem("b;", 1);
assertEquals("Y", b.getOwner().getName());
- b= bh.assertNonProblem("a = i", 1);
+ b = bh.assertNonProblem("a = i", 1);
assertNull(b.getOwner());
}
@@ -5565,7 +5562,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// // with deduces templateargument of type int
// template<> void sort(Array<int>&);
public void test14_7_3s11() throws Exception {
- parse(getAboveComment(), ParserLanguage.CPP, true, 0 );
+ parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// template<class T1> class A {
@@ -5578,6 +5575,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
public void test14_7_3s17() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
+
// template<class T> class X; // X is a class template
// template<> class X<int>;
// X<int>* p; // OK: pointer to declared class X<int>
@@ -5773,17 +5771,17 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// f<int,char>(); // f<int,char>(0,0)
// }
public void test14_8_2s5() throws Exception {
- final String content= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(content, true);
+ final String content = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(content, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f(1, 'c')", 1);
+ inst = bh.assertNonProblem("f(1, 'c')", 1);
assertEquals("<int,char>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
- inst= bh.assertNonProblem("f(1)", 1);
+ inst = bh.assertNonProblem("f(1)", 1);
assertEquals("<int,double>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
bh.assertProblem("f()", 1);
- inst= bh.assertNonProblem("f<int>()", -2);
+ inst = bh.assertNonProblem("f<int>()", -2);
assertEquals("<int,double>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
- inst= bh.assertNonProblem("f<int,char>()", -2);
+ inst = bh.assertNonProblem("f<int,char>()", -2);
assertEquals("<int,char>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
@@ -5803,8 +5801,8 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// int I = f<int>(0);
// int j = f<void>(0); // invalid array
public void _test14_8_2s8b() throws Exception {
- final String content= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(content, true);
+ final String content = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(content, true);
bh.assertNonProblem("f<int>(0)", -3);
bh.assertProblem("f<void>(0)", -3);
}
@@ -5812,9 +5810,9 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// template <class T> int f(typename T::B*);
// int i = f<int>(0);
public void test14_8_2s8c() throws Exception {
- final String content= getAboveComment();
- IASTTranslationUnit tu= parse(content, ParserLanguage.CPP, true, 2);
- BindingAssertionHelper bh= new AST2AssertionHelper(content, true);
+ final String content = getAboveComment();
+ IASTTranslationUnit tu = parse(content, ParserLanguage.CPP, true, 2);
+ BindingAssertionHelper bh = new AST2AssertionHelper(content, true);
bh.assertProblem("f<", 1);
bh.assertProblem("f<int>", 6);
}
@@ -5840,8 +5838,8 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// h<D>(0); // The TT member of D is not a template
// }
public void test14_8_2s8d() throws Exception {
- final String content= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(content, true);
+ final String content = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(content, true);
bh.assertProblem("f<A>", 0);
bh.assertProblem("f<B>", 0);
bh.assertProblem("g<C>", 0);
@@ -5853,7 +5851,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
public void test14_8_2s8e() throws Exception {
final String code = getAboveComment();
parse(code, ParserLanguage.CPP, true, 2);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertProblem("f<int>", 0);
}
@@ -5864,7 +5862,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
public void test14_8_2s8f() throws Exception {
final String code = getAboveComment();
parse(code, ParserLanguage.CPP, true, 2);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertProblem("f<X>", 0);
}
@@ -5893,11 +5891,11 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// g({1,2,3}); // error: no argument deduced for T
// }
public void test14_8_2_1s1a() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f({1,2,3})", 1);
+ inst = bh.assertNonProblem("f({1,2,3})", 1);
assertEquals("<int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
bh.assertProblem("f({1,\"asdf\"})", 1);
bh.assertProblem("g({1,2,3})", 1);
@@ -5911,13 +5909,13 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// g(x, y, z); // T1 is deduced to int; Types is deduced to float, int
// }
public void test14_8_2_1s1b() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f(x, y, z)", 1);
+ inst = bh.assertNonProblem("f(x, y, z)", 1);
assertEquals("<int,float,const int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
- inst= bh.assertNonProblem("g(x, y, z)", 1);
+ inst = bh.assertNonProblem("g(x, y, z)", 1);
assertEquals("<int,float,int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
@@ -5929,12 +5927,12 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// int n3 = g(i); // error: would call g<int>(const int&&), which
// // would bind an rvalue reference to an lvalue
public void test14_8_2_1s3() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f(i)", 1);
+ inst = bh.assertNonProblem("f(i)", 1);
assertEquals("<int &>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
- inst= bh.assertNonProblem("f(0)", 1);
+ inst = bh.assertNonProblem("f(0)", 1);
assertEquals("<int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
bh.assertProblem("g(i)", 1);
}
@@ -5946,10 +5944,10 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// int g(char);
// int i = f(g); // calls f(int (*)(int))
public void test14_8_2_1s7() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f(g)", 1);
+ inst = bh.assertNonProblem("f(g)", 1);
assertEquals("<int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
@@ -5960,10 +5958,10 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// char g(char);
// int i = f(1, g); // calls f(int, int (*)(int))
public void test14_8_2_1s8() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f(1, g)", 1);
+ inst = bh.assertNonProblem("f(1, g)", 1);
assertEquals("<int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
@@ -5974,10 +5972,10 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// template <class T> T g(T);
// int i = f(1, g); // calls f(int, int (*)(int))
public void test14_8_2_1s9() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f(1, g)", 1);
+ inst = bh.assertNonProblem("f(1, g)", 1);
assertEquals("<int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
@@ -6012,21 +6010,21 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// g(Tuple<int>()); // calls #3
// }
public void test14_8_2_4s12() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parse(code, ParserLanguage.CPP, true, 0);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- ICPPFunction g1= bh.assertNonProblem("g(Tuple<Types...>)", 1);
- ICPPFunction g2= bh.assertNonProblem("g(Tuple<T1, Types...>)", 1);
- ICPPFunction g3= bh.assertNonProblem("g(Tuple<T1, Types&...>)", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ ICPPFunction g1 = bh.assertNonProblem("g(Tuple<Types...>)", 1);
+ ICPPFunction g2 = bh.assertNonProblem("g(Tuple<T1, Types...>)", 1);
+ ICPPFunction g3 = bh.assertNonProblem("g(Tuple<T1, Types&...>)", 1);
- ICPPTemplateInstance x= bh.assertNonProblem("g(Tuple<>())", 1);
+ ICPPTemplateInstance x = bh.assertNonProblem("g(Tuple<>())", 1);
assertSame(g1, x.getTemplateDefinition());
- x= bh.assertNonProblem("g(Tuple<int, float>())", 1);
+ x = bh.assertNonProblem("g(Tuple<int, float>())", 1);
assertSame(g2, x.getTemplateDefinition());
- x= bh.assertNonProblem("g(Tuple<int, float&>())", 1);
+ x = bh.assertNonProblem("g(Tuple<int, float&>())", 1);
assertSame(g3, x.getTemplateDefinition());
- x= bh.assertNonProblem("g(Tuple<int>())", 1);
+ x = bh.assertNonProblem("g(Tuple<int>())", 1);
assertSame(g3, x.getTemplateDefinition());
}
@@ -6035,8 +6033,8 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// g({1,2,3}); // error: no argument deduced for T
// }
public void test14_8_2_5s5() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertProblem("g({1,2,3})", 1);
}
@@ -6065,10 +6063,10 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// f(g3); //error: U could be char or float
// }
public void test14_8_2_5s7b() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f(g1)", 1);
+ inst = bh.assertNonProblem("f(g1)", 1);
assertEquals("<int,float>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
bh.assertProblem("f(g2)", 1);
bh.assertProblem("f(g3)", 1);
@@ -6107,12 +6105,12 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// f(0); // calls f<int>(int&&), i.e., #2
// }
public void test14_8_2_5s10() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f(i)", 1);
+ inst = bh.assertNonProblem("f(i)", 1);
assertEquals("<int &>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
- inst= bh.assertNonProblem("f(0)", 1);
+ inst = bh.assertNonProblem("f(0)", 1);
assertEquals("<int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
@@ -6123,8 +6121,8 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// //T cannot be deduced
// }
public void test14_8_2_5s14() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertProblem("f(v)", 1);
}
@@ -6141,17 +6139,17 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// f3(v); //OK: i deduced to be 10
// }
public void test14_8_2_5s15() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f1(v)", 2);
+ inst = bh.assertNonProblem("f1(v)", 2);
assertEquals("<int20>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
- inst= bh.assertNonProblem("f1<20>(v)", -3);
+ inst = bh.assertNonProblem("f1<20>(v)", -3);
assertEquals("<int20>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
bh.assertProblem("f2(v)", 2);
- inst= bh.assertNonProblem("f2<10>(v)", -3);
+ inst = bh.assertNonProblem("f2<10>(v)", -3);
assertEquals("<int10>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
- inst= bh.assertNonProblem("f3(v)", 2);
+ inst = bh.assertNonProblem("f3(v)", 2);
assertEquals("<int10>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
@@ -6166,13 +6164,13 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// f(a1, a2); // OK
// }
public void test14_8_2_5s16a() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
bh.assertProblem("g(a1)", 1);
- inst= bh.assertNonProblem("g<0>(a1)", -4);
+ inst = bh.assertNonProblem("g<0>(a1)", -4);
assertEquals("<int0>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
- inst= bh.assertNonProblem("f(a1, a2)", 1);
+ inst = bh.assertNonProblem("f(a1, a2)", 1);
assertEquals("<int1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
@@ -6199,7 +6197,6 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
-
// template<int i> class A {};
// template<short s> void f(A<s>);
// void k1() {
@@ -6214,13 +6211,13 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// g(b); // OK: cv-qualifiers are ignored on template parameter types
// }
public void test14_8_2_5s17() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
bh.assertProblem("f(a)", 1);
- inst= bh.assertNonProblem("f<1>(a)", -3);
+ inst = bh.assertNonProblem("f<1>(a)", -3);
assertEquals("<short int1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
- inst= bh.assertNonProblem("g(b)", 1);
+ inst = bh.assertNonProblem("g(b)", 1);
assertEquals("<short int1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
@@ -6236,11 +6233,11 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// f(&foo); // error: type deduction fails because foo is a template
// }
public void test14_8_2_5s18() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
bh.assertProblem("f(&g)", 1);
- inst= bh.assertNonProblem("f(&h)", 1);
+ inst = bh.assertNonProblem("f(&h)", 1);
assertEquals("<char>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
bh.assertProblem("f(&foo)", 1);
}
@@ -6252,13 +6249,13 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// f<int>(); // OK: call f<int>(5,7)
// }
public void test14_8_2_5s19() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f(1)", 1);
+ inst = bh.assertNonProblem("f(1)", 1);
assertEquals("<int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
bh.assertProblem("f()", 1);
- inst= bh.assertNonProblem("f<int>()", -2);
+ inst = bh.assertNonProblem("f<int>()", -2);
assertEquals("<int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
@@ -6300,18 +6297,18 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// // specialized than the variadic templates #1 and #2
// }
public void test14_8_2_5s22() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- ICPPFunctionTemplate f1= bh.assertNonProblem("f(Args ... args)", 1);
- ICPPFunctionTemplate f2= bh.assertNonProblem("f(T1 a1, Args ... args)", 1);
- ICPPFunctionTemplate f3= bh.assertNonProblem("f(T1 a1, T2 a2)", 1);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ ICPPFunctionTemplate f1 = bh.assertNonProblem("f(Args ... args)", 1);
+ ICPPFunctionTemplate f2 = bh.assertNonProblem("f(T1 a1, Args ... args)", 1);
+ ICPPFunctionTemplate f3 = bh.assertNonProblem("f(T1 a1, T2 a2)", 1);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f()", 1);
+ inst = bh.assertNonProblem("f()", 1);
assertSame(f1, inst.getTemplateDefinition());
- inst= bh.assertNonProblem("f(1, 2, 3)", 1);
+ inst = bh.assertNonProblem("f(1, 2, 3)", 1);
assertSame(f2, inst.getTemplateDefinition());
- inst= bh.assertNonProblem("f(1, 2)", 1);
+ inst = bh.assertNonProblem("f(1, 2)", 1);
assertSame(f3, inst.getTemplateDefinition());
}
@@ -6813,7 +6810,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// void f(int);
// template<void (*pf)(int)> struct A { };
// A<&f> a; // selects f(int)
- public void test14_3_2s5() throws Exception {
+ public void test14_3_2s5() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@@ -6831,7 +6828,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// ac.f<>(1); //template
// }
public void test14_5_2s2() throws Exception {
- parse(getAboveComment(), ParserLanguage.CPP, true, 0); //should be 0
+ parse(getAboveComment(), ParserLanguage.CPP, true, 0); //should be 0
}
// template<class T1, class T2, int I> class A<T1, T2, I> { }; // error
@@ -6877,12 +6874,12 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// template <int K, int L> A<K+L> f/*2*/(A<K>, A<L>); // same as #1
// template <int I, int J> A<I-J> f/*3*/(A<I>, A<J>); // different from #1
public void test14_5_6_1s5() throws Exception {
- final String content= getAboveComment();
- IASTTranslationUnit tu= parse(content, ParserLanguage.CPP, true, 0);
- BindingAssertionHelper bh= new AST2AssertionHelper(content, true);
- ICPPFunctionTemplate f1= bh.assertNonProblem("f/*1*/", 1);
- ICPPFunctionTemplate f2= bh.assertNonProblem("f/*2*/", 1);
- ICPPFunctionTemplate f3= bh.assertNonProblem("f/*3*/", 1);
+ final String content = getAboveComment();
+ IASTTranslationUnit tu = parse(content, ParserLanguage.CPP, true, 0);
+ BindingAssertionHelper bh = new AST2AssertionHelper(content, true);
+ ICPPFunctionTemplate f1 = bh.assertNonProblem("f/*1*/", 1);
+ ICPPFunctionTemplate f2 = bh.assertNonProblem("f/*2*/", 1);
+ ICPPFunctionTemplate f3 = bh.assertNonProblem("f/*3*/", 1);
assertSame(f1, f2);
assertNotSame(f1, f3);
}
@@ -6891,11 +6888,11 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// template <int I, int J> void f/*1*/(A<I+J>); // #1
// template <int K, int L> void f/*2*/(A<K+L>); // same as #1
public void test14_5_6_1s6() throws Exception {
- final String content= getAboveComment();
- IASTTranslationUnit tu= parse(content, ParserLanguage.CPP, true, 0);
- BindingAssertionHelper bh= new AST2AssertionHelper(content, true);
- ICPPFunctionTemplate f1= bh.assertNonProblem("f/*1*/", 1);
- ICPPFunctionTemplate f2= bh.assertNonProblem("f/*2*/", 1);
+ final String content = getAboveComment();
+ IASTTranslationUnit tu = parse(content, ParserLanguage.CPP, true, 0);
+ BindingAssertionHelper bh = new AST2AssertionHelper(content, true);
+ ICPPFunctionTemplate f1 = bh.assertNonProblem("f/*1*/", 1);
+ ICPPFunctionTemplate f2 = bh.assertNonProblem("f/*2*/", 1);
assertSame(f1, f2);
}
@@ -6927,7 +6924,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// int (&ra)[3] = a; // ra refers to the array a
// ra[1] = i; // modifies a[1]
// }
- public void test8_5_3s1() throws Exception { // TODO raised bug 90648
+ public void test8_5_3s1() throws Exception { // TODO raised bug 90648
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@@ -6939,7 +6936,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// this->A::operator=(s); // wellformed
// return *this;
// }
- public void test12s1() throws Exception {
+ public void test12s1() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@@ -6960,7 +6957,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// // C/B/D/A sublattice is fully constructed
// { }
// };
- public void test12_7s2() throws Exception {
+ public void test12_7s2() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@@ -6996,7 +6993,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// void g() {
// (int (*)(int))&f; // cast expression as selector
// }
- public void test13_4s5a() throws Exception { // bug 90674
+ public void test13_4s5a() throws Exception { // bug 90674
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
}
@@ -7032,9 +7029,9 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// int ef(D&);
// int ff(X&);
public void test11_3s2() throws Exception { //bug 92793
- IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 0);
- IASTCompositeTypeSpecifier D= getCompositeType(tu, 2);
- IASTDeclaration accessDecl= getDeclaration(D, 2);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, 0);
+ IASTCompositeTypeSpecifier D = getCompositeType(tu, 2);
+ IASTDeclaration accessDecl = getDeclaration(D, 2);
assertInstance(accessDecl, ICPPASTUsingDeclaration.class);
}
@@ -7044,7 +7041,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// int b = f(a);
// int c(b);
// }
- public void test8_5s2() throws Exception { // 90641
+ public void test8_5s2() throws Exception { // 90641
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@@ -7066,7 +7063,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// {
// f<int()>(); // int() is a typeid:call the first f()
// }
- public void test14_3s2() throws Exception {
+ public void test14_3s2() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTestBase.java
index a9130252cd4..f8c07d3b8b0 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTestBase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTestBase.java
@@ -20,17 +20,17 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
public class AST2CPPTestBase extends AST2TestBase {
public AST2CPPTestBase() {
}
-
+
public AST2CPPTestBase(String name) {
super(name);
}
-
+
protected IASTTranslationUnit parseAndCheckBindings(String code) throws Exception {
return parseAndCheckBindings(code, CPP);
}
protected IASTTranslationUnit parseAndCheckBindings() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
return parseAndCheckBindings(code);
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
index cb85c0d289d..3ec4cf786d3 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
@@ -200,12 +200,13 @@ public class AST2CPPTests extends AST2CPPTestBase {
return (ICPPClassType) bindings[0];
}
- private void checkNewExpression(IASTFunctionDefinition fdef, int i_expr, Class<?> placement, String type, Class<?> init) {
+ private void checkNewExpression(IASTFunctionDefinition fdef, int i_expr, Class<?> placement, String type,
+ Class<?> init) {
IASTExpression expr;
ICPPASTNewExpression newExpr;
- expr= getExpressionOfStatement(fdef, i_expr);
+ expr = getExpressionOfStatement(fdef, i_expr);
assertInstance(expr, ICPPASTNewExpression.class);
- newExpr= (ICPPASTNewExpression) expr;
+ newExpr = (ICPPASTNewExpression) expr;
if (placement == null) {
assertNull(newExpr.getNewPlacement());
} else {
@@ -220,10 +221,10 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
private void checkDeclDef(String[] declNames, String[] defNames, IASTDeclaration[] decls) {
- int i= 0, j= 0;
+ int i = 0, j = 0;
for (IASTDeclaration decl : decls) {
if (decl instanceof ICPPASTLinkageSpecification) {
- decl= ((ICPPASTLinkageSpecification) decl).getDeclarations()[0];
+ decl = ((ICPPASTLinkageSpecification) decl).getDeclarations()[0];
}
final IASTDeclarator[] dtors = ((IASTSimpleDeclaration) decl).getDeclarators();
for (IASTDeclarator dtor : dtors) {
@@ -246,23 +247,24 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertEquals(defNames.length, j);
}
- protected static void assertSameType(IType first, IType second){
+ protected static void assertSameType(IType first, IType second) {
assertNotNull(first);
assertNotNull(second);
- assertTrue("Expected types to be the same, but first was: '" + first.toString() + "' and second was: '" + second + "'", first.isSameType(second));
+ assertTrue("Expected types to be the same, but first was: '" + first.toString() + "' and second was: '" + second
+ + "'", first.isSameType(second));
}
-
+
private void checkUserDefinedLiteralIsType(String code, String type_name) throws Exception {
IASTTranslationUnit tu = parseAndCheckBindings(code, CPP);
IASTDeclaration[] declarations = tu.getDeclarations();
IASTDeclaration declaration = declarations[declarations.length - 1];
-
+
IASTInitializer init = ((IASTSimpleDeclaration) declaration).getDeclarators()[0].getInitializer();
- IType type = ((IASTExpression)((IASTEqualsInitializer) init).getInitializerClause()).getExpressionType();
-
+ IType type = ((IASTExpression) ((IASTEqualsInitializer) init).getInitializerClause()).getExpressionType();
+
assertEquals(type_name, type.toString());
}
-
+
private void checkUserDefinedLiteralIsRet(String code) throws Exception {
checkUserDefinedLiteralIsType(code, "Ret");
}
@@ -407,7 +409,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
public void testBug95424() throws Exception {
- IASTTranslationUnit tu = parse("void f(){ traits_type::copy(__r->_M_refdata(), __buf, __i); }", CPP, true, true);
+ IASTTranslationUnit tu = parse("void f(){ traits_type::copy(__r->_M_refdata(), __buf, __i); }", CPP, true,
+ true);
tu = parse("void f(){ traits_type::copy(__r->_M_refdata(), __buf, __i); }", CPP, false, true);
IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
IASTCompoundStatement cs = (IASTCompoundStatement) f.getBody();
@@ -456,8 +459,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testSimpleClass() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTCompositeTypeSpecifier compTypeSpec =
- (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
+ IASTCompositeTypeSpecifier compTypeSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
IASTName name_A = compTypeSpec.getName();
IASTDeclarator dtor = decl.getDeclarators()[0];
@@ -748,7 +750,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// class A a;
// }
public void testNameHiding() throws Exception {
- String content= getAboveComment();
+ String content = getAboveComment();
IASTTranslationUnit tu = parse(content, CPP);
NameCollector collector = new NameCollector();
@@ -1024,8 +1026,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
IPointerType pt = (IPointerType) pf.getType();
assertTrue(pt.getType() instanceof IFunctionType);
- tu = parse(
- "struct A; int (*pfi)(int, struct A *);", CPP);
+ tu = parse("struct A; int (*pfi)(int, struct A *);", CPP);
collector = new NameCollector();
tu.accept(collector);
ICPPClassType A = (ICPPClassType) collector.getName(0).resolveBinding();
@@ -1055,13 +1056,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
IFunction f = (IFunction) decl.getDeclarators()[0].getName().resolveBinding();
decl = (IASTSimpleDeclaration) tu.getDeclarations()[2];
- IVariable g =
- (IVariable) decl.getDeclarators()[0].getNestedDeclarator().getName().resolveBinding();
+ IVariable g = (IVariable) decl.getDeclarators()[0].getNestedDeclarator().getName().resolveBinding();
decl = (IASTSimpleDeclaration) tu.getDeclarations()[3];
- IVariable h =
- (IVariable) decl.getDeclarators()[0].getNestedDeclarator().getNestedDeclarator()
- .getName().resolveBinding();
+ IVariable h = (IVariable) decl.getDeclarators()[0].getNestedDeclarator().getNestedDeclarator().getName()
+ .resolveBinding();
IFunctionType t_f = f.getType();
IType t_f_return = t_f.getReturnType();
@@ -1112,8 +1111,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
public void testFnReturningPtrToFn() throws Exception {
- IASTTranslationUnit tu = parse(
- "void (* f(int))(){}", CPP);
+ IASTTranslationUnit tu = parse("void (* f(int))(){}", CPP);
IASTFunctionDefinition def = (IASTFunctionDefinition) tu.getDeclarations()[0];
IFunction f = (IFunction) def.getDeclarator().getName().resolveBinding();
@@ -1175,20 +1173,20 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testUsingDeclaration_86368() throws Exception {
BindingAssertionHelper bh = getAssertionHelper();
- IFunction f1= bh.assertNonProblem("f(int)", 1);
- IFunction f2= bh.assertNonProblem("f('i')", 1);
+ IFunction f1 = bh.assertNonProblem("f(int)", 1);
+ IFunction f2 = bh.assertNonProblem("f('i')", 1);
assertSame(f1, f2);
- IFunction g1= bh.assertNonProblem("f(char)", 1);
- IFunction g2= bh.assertNonProblem("f('c')", 1);
+ IFunction g1 = bh.assertNonProblem("f(char)", 1);
+ IFunction g2 = bh.assertNonProblem("f('c')", 1);
assertSame(g1, g2);
// Alternative binding resolution order.
bh = getAssertionHelper();
- f2= bh.assertNonProblem("f('i')", 1);
- f1= bh.assertNonProblem("f(int)", 1);
+ f2 = bh.assertNonProblem("f('i')", 1);
+ f1 = bh.assertNonProblem("f(int)", 1);
assertSame(f1, f2);
- g2= bh.assertNonProblem("f('c')", 1);
- g1= bh.assertNonProblem("f(char)", 1);
+ g2 = bh.assertNonProblem("f('c')", 1);
+ g1 = bh.assertNonProblem("f(char)", 1);
assertSame(g1, g2);
}
@@ -1377,18 +1375,18 @@ public class AST2CPPTests extends AST2CPPTestBase {
// typedef E F;
// F::E() {}
public void testImplicitConstructors_360223() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
- ICPPClassType c= bh.assertNonProblem("C", 0);
+ BindingAssertionHelper bh = getAssertionHelper();
+ ICPPClassType c = bh.assertNonProblem("C", 0);
ICPPConstructor[] ctors = c.getConstructors();
assertEquals(1, ctors.length);
assertFalse(ctors[0].isImplicit());
- c= bh.assertNonProblem("D", 0);
+ c = bh.assertNonProblem("D", 0);
ctors = c.getConstructors();
assertEquals(1, ctors.length);
assertFalse(ctors[0].isImplicit());
- IBinding ctor= bh.assertNonProblem("E() {}", 1);
+ IBinding ctor = bh.assertNonProblem("E() {}", 1);
assertTrue(ctor instanceof ICPPConstructor);
}
@@ -1465,7 +1463,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testInheritedTemplateConstructor() throws Exception {
parseAndCheckBindings();
}
-
+
// struct base {};
//
// struct derived : public base {
@@ -1482,8 +1480,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// class F { (~)F(); };
// class G { (~)G(void); };
- BufferedReader br= new BufferedReader(new StringReader(getAboveComment()));
- for (String line= br.readLine(); line != null; line= br.readLine()) {
+ BufferedReader br = new BufferedReader(new StringReader(getAboveComment()));
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
IASTTranslationUnit tu = parse(line, CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
@@ -1491,14 +1489,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
ICPPMethod[] methods = ((ICPPClassScope) A.getCompositeScope()).getImplicitMethods();
assertNotNull(methods);
- int count= 0;
+ int count = 0;
for (ICPPMethod method : methods)
count += method.getName().startsWith("~") ? 1 : 0;
assertEquals(line, 0, count);
methods = A.getDeclaredMethods();
assertNotNull(methods);
- count= 0;
+ count = 0;
for (ICPPMethod method : methods)
count += method.getName().startsWith("~") ? 1 : 0;
assertEquals(line, 1, count);
@@ -1509,8 +1507,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// class D {D();};
// class E {E(void);};
public void testImplicitDestructor_183160() throws Exception {
- BufferedReader br= new BufferedReader(new StringReader(getAboveComment()));
- for (String line= br.readLine(); line != null; line= br.readLine()) {
+ BufferedReader br = new BufferedReader(new StringReader(getAboveComment()));
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
IASTTranslationUnit tu = parse(line, CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
@@ -1518,14 +1516,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
ICPPMethod[] methods = ((ICPPClassScope) A.getCompositeScope()).getImplicitMethods();
assertNotNull(methods);
- int count= 0;
+ int count = 0;
for (ICPPMethod method : methods)
count += method.getName().startsWith("~") ? 1 : 0;
assertEquals(line, 1, count);
methods = A.getDeclaredMethods();
assertNotNull(methods);
- count= 0;
+ count = 0;
for (ICPPMethod method : methods)
count += method.getName().startsWith("~") ? 1 : 0;
assertEquals(line, 0, count);
@@ -1553,8 +1551,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// class S {public: S(int k=5, int* ip= 0);};
// class T {public: T(int k=5, int* ip= 0, T* t= 0);};
public void testExplicitDefaultConstructor_183160() throws Exception {
- BufferedReader br= new BufferedReader(new StringReader(getAboveComment()));
- for (String line= br.readLine(); line != null; line= br.readLine()) {
+ BufferedReader br = new BufferedReader(new StringReader(getAboveComment()));
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
IASTTranslationUnit tu = parse(line, CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
@@ -1571,8 +1569,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// class S {public: S(int k=5, int* ip);};
// class T {public: T(int k, int* ip= 0, T* t= 0);};
public void testExplicitNonDefaultConstructor_183160() throws Exception {
- BufferedReader br= new BufferedReader(new StringReader(getAboveComment()));
- for (String line= br.readLine(); line != null; line= br.readLine()) {
+ BufferedReader br = new BufferedReader(new StringReader(getAboveComment()));
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
IASTTranslationUnit tu = parse(line, CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
@@ -1593,8 +1591,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// class G {protected: G(volatile G &, int i=4, int l=2);};
// class H {H(const volatile H &, int i=1, long k=2) {}};
public void testExplicitCopyConstructor_183160() throws Exception {
- BufferedReader br= new BufferedReader(new StringReader(getAboveComment()));
- for (String line= br.readLine(); line != null; line= br.readLine()) {
+ BufferedReader br = new BufferedReader(new StringReader(getAboveComment()));
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
IASTTranslationUnit tu = parse(line, CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
@@ -1612,8 +1610,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// class K {protected: K(volatile K *, int i=4, int l=2);}; // K * rather than K &
// class L {L(const volatile L &, int i=1, long k=2, int* x) {}}; // param int* x has no initializer
public void testNotExplicitCopyConstructor_183160() throws Exception {
- BufferedReader br= new BufferedReader(new StringReader(getAboveComment()));
- for (String line= br.readLine(); line != null; line= br.readLine()) {
+ BufferedReader br = new BufferedReader(new StringReader(getAboveComment()));
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
IASTTranslationUnit tu = parse(line, CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
@@ -1631,17 +1629,17 @@ public class AST2CPPTests extends AST2CPPTestBase {
// class C {public: void operator=(C &c, int k=5) {} }; // compile error
// class D {public: void operator=(const D &, const D &); }; // compile error
public void testNotExplicitCopyAssignmentOperator_183160() throws Exception {
- BufferedReader br= new BufferedReader(new StringReader(getAboveComment()));
- for (String line= br.readLine(); line != null; line= br.readLine()) {
+ BufferedReader br = new BufferedReader(new StringReader(getAboveComment()));
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
IASTTranslationUnit tu = parse(line, CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
ICPPClassType A = (ICPPClassType) compSpec.getName().resolveBinding();
- ICPPMethod[] methods = ((ICPPClassScope)A.getCompositeScope()).getImplicitMethods();
+ ICPPMethod[] methods = ((ICPPClassScope) A.getCompositeScope()).getImplicitMethods();
assertNotNull(methods);
- int count= 0;
+ int count = 0;
for (ICPPMethod method : methods) {
- boolean eq= Arrays.equals(method.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray());
+ boolean eq = Arrays.equals(method.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray());
count += eq ? 1 : 0;
}
@@ -1649,9 +1647,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
methods = A.getDeclaredMethods();
assertNotNull(methods);
- count= 0;
+ count = 0;
for (ICPPMethod method : methods) {
- boolean eq= Arrays.equals(method.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray());
+ boolean eq = Arrays.equals(method.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray());
count += eq ? 1 : 0;
}
@@ -1664,17 +1662,17 @@ public class AST2CPPTests extends AST2CPPTestBase {
// class C {private: void operator=(volatile C &) {} };
// class D {D& operator=(volatile const D &); };
public void testExplicitCopyAssignmentOperator_183160() throws Exception {
- BufferedReader br= new BufferedReader(new StringReader(getAboveComment()));
- for (String line= br.readLine(); line != null; line= br.readLine()) {
+ BufferedReader br = new BufferedReader(new StringReader(getAboveComment()));
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
IASTTranslationUnit tu = parse(line, CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
ICPPClassType A = (ICPPClassType) compSpec.getName().resolveBinding();
- ICPPMethod[] methods = ((ICPPClassScope)A.getCompositeScope()).getImplicitMethods();
+ ICPPMethod[] methods = ((ICPPClassScope) A.getCompositeScope()).getImplicitMethods();
assertNotNull(methods);
- int count= 0;
+ int count = 0;
for (ICPPMethod method : methods) {
- boolean eq= Arrays.equals(method.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray());
+ boolean eq = Arrays.equals(method.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray());
count += eq ? 1 : 0;
}
@@ -1682,9 +1680,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
methods = A.getDeclaredMethods();
assertNotNull(methods);
- count= 0;
+ count = 0;
for (ICPPMethod method : methods) {
- boolean eq= Arrays.equals(method.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray());
+ boolean eq = Arrays.equals(method.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray());
count += eq ? 1 : 0;
}
@@ -1740,14 +1738,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
// This assertion fails because conv is the copy ctor A(const A&), not the conversion operator B::operator A()
assertSame(oper, conv);
}
-
+
// struct S {
// operator int() &;
// operator int() &&;
// };
- //
+ //
// void waldo(int);
- //
+ //
// int main() {
// S s;
// waldo(s); // ERROR
@@ -1927,8 +1925,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// AB::f(`c`);
// }
public void testBug84679() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), CPP,
- false, false);
+ IASTTranslationUnit tu = parse(getAboveComment(), CPP, false, false);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -1958,7 +1955,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// };
public void testBug84692() throws Exception {
// also tests bug 234042.
- CPPASTNameBase.sAllowRecursionBindings= false;
+ CPPASTNameBase.sAllowRecursionBindings = false;
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
NameCollector col = new NameCollector();
@@ -2033,12 +2030,12 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- ICPPClassType A =
- (ICPPClassType) ((IASTCompositeTypeSpecifier) decl.getDeclSpecifier()).getName().resolveBinding();
+ ICPPClassType A = (ICPPClassType) ((IASTCompositeTypeSpecifier) decl.getDeclSpecifier()).getName()
+ .resolveBinding();
IASTFunctionDefinition def = (IASTFunctionDefinition) tu.getDeclarations()[1];
- IASTExpressionStatement expStatement =
- (IASTExpressionStatement) ((IASTCompoundStatement) def.getBody()).getStatements()[0];
+ IASTExpressionStatement expStatement = (IASTExpressionStatement) ((IASTCompoundStatement) def.getBody())
+ .getStatements()[0];
assertTrue(expStatement.getExpression() instanceof IASTLiteralExpression);
IType type = expStatement.getExpression().getExpressionType();
@@ -2046,8 +2043,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertSame(((IPointerType) type).getType(), A);
def = (IASTFunctionDefinition) tu.getDeclarations()[2];
- expStatement =
- (IASTExpressionStatement) ((IASTCompoundStatement) def.getBody()).getStatements()[0];
+ expStatement = (IASTExpressionStatement) ((IASTCompoundStatement) def.getBody()).getStatements()[0];
IASTUnaryExpression ue = (IASTUnaryExpression) expStatement.getExpression();
type = ue.getExpressionType();
@@ -2061,8 +2057,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
NameCollector col = new NameCollector();
tu.accept(col);
ICPPConstructor T = (ICPPConstructor) col.getName(1).resolveBinding();
- assertTrue(CharArrayUtils.equals(T.getNameCharArray(),
- "T".toCharArray()));
+ assertTrue(CharArrayUtils.equals(T.getNameCharArray(), "T".toCharArray()));
assertEquals(T.getName(), "T");
}
@@ -2186,8 +2181,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
public void testPointerToMemberType() throws Exception {
- IASTTranslationUnit tu = parse("struct S; int S::* pm;",
- CPP);
+ IASTTranslationUnit tu = parse("struct S; int S::* pm;", CPP);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -2432,7 +2426,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// };
public void testFriend_275358() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPClassType A = bh.assertNonProblem("A", 1);
IFunction set = bh.assertNonProblem("set()", 3);
IFunction m = bh.assertNonProblem("Other::m()", 8);
@@ -2442,9 +2436,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertSame(friends[0], set);
assertSame(friends[1], m);
- IBinding[] declaredMethods= A.getAllDeclaredMethods();
+ IBinding[] declaredMethods = A.getAllDeclaredMethods();
assertEquals(0, declaredMethods.length);
- declaredMethods= A.getDeclaredMethods();
+ declaredMethods = A.getDeclaredMethods();
assertEquals(0, declaredMethods.length);
}
@@ -2625,7 +2619,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
IBinding[] bs = CPPSemantics.findBindingsForContentAssist(name, true, null);
// check the result
- HashSet result= new HashSet();
+ HashSet result = new HashSet();
for (IBinding binding : bs) {
result.add(binding.getName());
}
@@ -2653,10 +2647,10 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTName name = col.getName(5);
assertEquals("v_", name.toString());
- IBinding[] bs = CPPSemantics.findBindingsForContentAssist(name, true, new String[] {"ns::inner"});
+ IBinding[] bs = CPPSemantics.findBindingsForContentAssist(name, true, new String[] { "ns::inner" });
// check the result
- HashSet result= new HashSet();
+ HashSet result = new HashSet();
for (IBinding binding : bs) {
result.add(binding.getName());
}
@@ -2794,8 +2788,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
String code = "int *foo(int *b) { return (int *)(b); }";
IASTTranslationUnit tu = parse(code, CPP);
IASTFunctionDefinition function = (IASTFunctionDefinition) tu.getDeclarations()[0];
- IASTReturnStatement r =
- (IASTReturnStatement) ((IASTCompoundStatement) function.getBody()).getStatements()[0];
+ IASTReturnStatement r = (IASTReturnStatement) ((IASTCompoundStatement) function.getBody()).getStatements()[0];
assertTrue(r.getReturnValue() instanceof IASTCastExpression);
}
@@ -2807,10 +2800,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testBug84476() throws Exception {
String code = getAboveComment();
- IASTFunctionDefinition foo = (IASTFunctionDefinition) parse(code,
- CPP).getDeclarations()[0];
- IASTDeclarationStatement decl =
- (IASTDeclarationStatement) ((IASTCompoundStatement) foo.getBody()).getStatements()[1];
+ IASTFunctionDefinition foo = (IASTFunctionDefinition) parse(code, CPP).getDeclarations()[0];
+ IASTDeclarationStatement decl = (IASTDeclarationStatement) ((IASTCompoundStatement) foo.getBody())
+ .getStatements()[1];
IASTSimpleDeclaration pb = (IASTSimpleDeclaration) decl.getDeclaration();
IASTDeclarator d = pb.getDeclarators()[0];
assertEquals(d.getNestedDeclarator().getPointerOperators().length, 1);
@@ -2931,10 +2923,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
// }
public void testBug84478() throws Exception {
- IASTFunctionDefinition foo = (IASTFunctionDefinition) parse(
- getAboveComment(), CPP).getDeclarations()[0];
- ICPPASTWhileStatement whileStatement =
- (ICPPASTWhileStatement) ((IASTCompoundStatement) foo.getBody()).getStatements()[2];
+ IASTFunctionDefinition foo = (IASTFunctionDefinition) parse(getAboveComment(), CPP).getDeclarations()[0];
+ ICPPASTWhileStatement whileStatement = (ICPPASTWhileStatement) ((IASTCompoundStatement) foo.getBody())
+ .getStatements()[2];
assertNull(whileStatement.getCondition());
assertNotNull(whileStatement.getConditionDeclaration());
}
@@ -3147,7 +3138,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
ICPPUsingDeclaration u = (ICPPUsingDeclaration) col.getName(7).resolveBinding();
IASTName[] decls = tu.getDeclarationsInAST(u);
- assertEquals(3, decls.length); // 2 function-decls + using-decl
+ assertEquals(3, decls.length); // 2 function-decls + using-decl
assertSame(decls[0], col.getName(1));
assertSame(decls[1], col.getName(3));
@@ -3155,12 +3146,12 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertEquals(delegates.length, 2);
decls = tu.getDeclarationsInAST(delegates[0]);
- assertEquals(2, decls.length); // function-decl + using-decl
+ assertEquals(2, decls.length); // function-decl + using-decl
assertSame(decls[0], col.getName(1));
assertSame(decls[1], col.getName(7));
decls = tu.getDeclarationsInAST(delegates[0]);
- assertEquals(2, decls.length); // function-decl + using-decl
+ assertEquals(2, decls.length); // function-decl + using-decl
assertSame(decls[0], col.getName(1));
}
@@ -3208,12 +3199,12 @@ public class AST2CPPTests extends AST2CPPTestBase {
ICPPClassType g_struct = (ICPPClassType) col.getName(1).resolveBinding();
IFunction g_func = (IFunction) col.getName(2).resolveBinding();
- assertSame(g_struct,ref2);
+ assertSame(g_struct, ref2);
assertSame(g_func, ref1);
ICPPUsingDeclaration comp = (ICPPUsingDeclaration) col.getName(7).resolveBinding();
IASTName[] decls = tu.getDeclarationsInAST(comp);
- assertEquals(3, decls.length); // struct, func and using-decl
+ assertEquals(3, decls.length); // struct, func and using-decl
assertSame(decls[0], col.getName(1));
assertSame(decls[1], col.getName(2));
assertSame(decls[2], col.getName(7));
@@ -3246,7 +3237,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertSame(x_var, ref1);
IASTName[] refs = tu.getReferences(x_struct);
- assertEquals(2, refs.length); // 1 ref + using-decl
+ assertEquals(2, refs.length); // 1 ref + using-decl
assertSame(refs[0], col.getName(10));
assertSame(refs[1], col.getName(12));
@@ -3527,11 +3518,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertSame(bs[1], f1);
assertSame(bs[2], f2);
- String[] s = ((ICPPBinding) bs[1]).getQualifiedName();
+ String[] s = ((ICPPBinding) bs[1]).getQualifiedName();
assertEquals(2, s.length);
assertEquals("A", s[0]);
assertEquals("f", s[1]);
- assertTrue(((ICPPBinding) bs[1]).isGloballyQualified());
+ assertTrue(((ICPPBinding) bs[1]).isGloballyQualified());
}
// namespace A {
@@ -3582,22 +3573,22 @@ public class AST2CPPTests extends AST2CPPTestBase {
tu.accept(col);
IFunction f1 = (IFunction) col.getName(6).resolveBinding();
- IScope classScope= f1.getScope();
+ IScope classScope = f1.getScope();
assertTrue(classScope instanceof ICPPClassScope);
IBinding[] bindings = classScope.find("bf", tu);
- ICPPMethod method= extractSingleMethod(bindings);
+ ICPPMethod method = extractSingleMethod(bindings);
assertEquals("B", method.getQualifiedName()[0]);
- bindings= classScope.find("f", tu);
- method= extractSingleMethod(bindings);
+ bindings = classScope.find("f", tu);
+ method = extractSingleMethod(bindings);
assertEquals("A", method.getQualifiedName()[0]);
- bindings= classScope.find("B", tu);
- ICPPClassType classType= extractSingleClass(bindings);
+ bindings = classScope.find("B", tu);
+ ICPPClassType classType = extractSingleClass(bindings);
assertEquals("B", classType.getQualifiedName()[0]);
- bindings= classScope.find("A", tu);
- classType= extractSingleClass(bindings);
+ bindings = classScope.find("A", tu);
+ classType = extractSingleClass(bindings);
assertEquals("A", classType.getQualifiedName()[0]);
}
@@ -3781,7 +3772,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// B () : A() {}
// };
public void testBug89539() throws Exception {
- String content= getAboveComment();
+ String content = getAboveComment();
IASTTranslationUnit tu = parse(content, CPP);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -3817,8 +3808,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
public void testBug89828() throws Exception {
- IASTTranslationUnit tu = parse(
- "class B * b; void f(); void f(int);", CPP);
+ IASTTranslationUnit tu = parse("class B * b; void f(); void f(int);", CPP);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -3890,8 +3880,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTTypeId typeId = ((ICPPASTConversionName) name1).getTypeId();
assertNotNull(typeId);
- assertEquals(((IASTSimpleDeclSpecifier) typeId.getDeclSpecifier()).getType(),
- IASTSimpleDeclSpecifier.t_int);
+ assertEquals(((IASTSimpleDeclSpecifier) typeId.getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_int);
}
@@ -3912,13 +3901,13 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertTrue(int1 instanceof ICPPASTConversionName);
assertNotNull(((ICPPASTConversionName) int1).getTypeId());
- IASTFunctionDefinition fdef= getDeclaration(tu, 1);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 1);
final IASTName x_int = fdef.getDeclarator().getName();
assertNotNull(x_int);
assertTrue(x_int instanceof ICPPASTQualifiedName);
assertTrue(((ICPPASTQualifiedName) x_int).isConversionOrOperator());
- final IASTName int2= ((ICPPASTQualifiedName)x_int).getLastName();
+ final IASTName int2 = ((ICPPASTQualifiedName) x_int).getLastName();
assertNotNull(int2);
assertTrue(int2 instanceof ICPPASTConversionName);
assertNotNull(((ICPPASTConversionName) int2).getTypeId());
@@ -3928,33 +3917,31 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertTrue(int3 instanceof ICPPASTConversionName);
assertNotNull(((ICPPASTConversionName) int3).getTypeId());
- ICPPASTTemplateDeclaration tdef= getDeclaration(tu, 3);
- fdef= (IASTFunctionDefinition) tdef.getDeclaration();
+ ICPPASTTemplateDeclaration tdef = getDeclaration(tu, 3);
+ fdef = (IASTFunctionDefinition) tdef.getDeclaration();
final IASTName x_ac_int = fdef.getDeclarator().getName();
assertNotNull(x_ac_int);
assertTrue(x_ac_int instanceof ICPPASTQualifiedName);
assertTrue(((ICPPASTQualifiedName) x_ac_int).isConversionOrOperator());
- final IASTName int4= ((ICPPASTQualifiedName)x_ac_int).getLastName();
+ final IASTName int4 = ((ICPPASTQualifiedName) x_ac_int).getLastName();
assertNotNull(int4);
assertTrue(int4 instanceof ICPPASTConversionName);
assertNotNull(((ICPPASTConversionName) int4).getTypeId());
}
public void testBug88662() throws Exception {
- IASTTranslationUnit tu = parse(
- "int foo() { return int();}", CPP);
- IASTReturnStatement returnStatement =
- (IASTReturnStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[0]).getBody()).getStatements()[0];
- ICPPASTSimpleTypeConstructorExpression expression =
- (ICPPASTSimpleTypeConstructorExpression) returnStatement.getReturnValue();
+ IASTTranslationUnit tu = parse("int foo() { return int();}", CPP);
+ IASTReturnStatement returnStatement = (IASTReturnStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
+ .getDeclarations()[0]).getBody()).getStatements()[0];
+ ICPPASTSimpleTypeConstructorExpression expression = (ICPPASTSimpleTypeConstructorExpression) returnStatement
+ .getReturnValue();
assertEquals(expression.getInitialValue(), null);
assertEquals(expression.getSimpleType(), ICPPASTSimpleTypeConstructorExpression.t_int);
}
public void testBug90498a() throws Exception {
- IASTTranslationUnit tu = parse(
- "typedef int INT;\ntypedef INT (FOO) (INT);", CPP);
+ IASTTranslationUnit tu = parse("typedef int INT;\ntypedef INT (FOO) (INT);", CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
IASTDeclSpecifier declSpec = decl.getDeclSpecifier();
@@ -3969,8 +3956,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
public void testBug90498b() throws Exception {
- IASTTranslationUnit tu = parse(
- "int (* foo) (int) (0);", CPP);
+ IASTTranslationUnit tu = parse("int (* foo) (int) (0);", CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTDeclSpecifier declSpec = decl.getDeclSpecifier();
@@ -3998,8 +3984,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTCompoundStatement cs = (IASTCompoundStatement) foo.getBody();
IASTStatement[] subs = cs.getStatements();
for (int i = 0; i < subs.length; ++i) {
- IASTBinaryExpression be =
- (IASTBinaryExpression) ((IASTExpressionStatement) subs[i]).getExpression();
+ IASTBinaryExpression be = (IASTBinaryExpression) ((IASTExpressionStatement) subs[i]).getExpression();
if (i == 1) {
IASTTypeIdExpression expression = (IASTTypeIdExpression) be.getOperand1();
IASTTypeId typeId = expression.getTypeId();
@@ -4059,8 +4044,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
public void testBug90603() throws Exception {
- IASTTranslationUnit tu = parse(
- "class X { void f(){} };", CPP);
+ IASTTranslationUnit tu = parse("class X { void f(){} };", CPP);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -4091,8 +4075,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
IVariable x = (IVariable) col.getName(2).resolveBinding();
IProblemBinding problem = (IProblemBinding) col.getName(3).resolveBinding();
assertSame(x.getType(), X);
- assertEquals(problem.getID(),
- IProblemBinding.SEMANTIC_INVALID_REDEFINITION);
+ assertEquals(problem.getID(), IProblemBinding.SEMANTIC_INVALID_REDEFINITION);
}
// struct C {
@@ -4379,8 +4362,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
IVariable a1 = (IVariable) col.getName(1).resolveBinding();
IVariable a2 = (IVariable) col.getName(2).resolveBinding();
- IBinding[] bs = col.getName(3).getCompletionContext().findBindings(
- col.getName(3), true);
+ IBinding[] bs = col.getName(3).getCompletionContext().findBindings(col.getName(3), true);
assertEquals(bs.length, 2);
assertSame(bs[0], a1);
assertSame(bs[1], a2);
@@ -4434,8 +4416,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
public void testBug90648() throws ParserException {
- IASTTranslationUnit tu = parse(
- "int f() { int (&ra)[3] = a; }", CPP);
+ IASTTranslationUnit tu = parse("int f() { int (&ra)[3] = a; }", CPP);
IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
IASTCompoundStatement body = (IASTCompoundStatement) f.getBody();
final IASTDeclarationStatement statement = (IASTDeclarationStatement) body.getStatements()[0];
@@ -4482,8 +4463,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
public void testBug90647() throws Exception {
- parse(
- "char msg[] = \"Syntax error on line %s\\n\";", CPP);
+ parse("char msg[] = \"Syntax error on line %s\\n\";", CPP);
}
// int main(int argc, char **argv)
@@ -4520,16 +4500,15 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
public void testBug83997() throws Exception {
- IASTTranslationUnit tu = parse(
- "namespace { int x; }", CPP);
+ IASTTranslationUnit tu = parse("namespace { int x; }", CPP);
NameCollector col = new NameCollector();
tu.accept(col);
assertNoProblemBindings(col);
}
public void testBug85786() throws Exception {
- IASTTranslationUnit tu = parse(
- "void f(int); void foo () { void * p = &f; ((void (*) (int)) p) (1); }", ParserLanguage.C);
+ IASTTranslationUnit tu = parse("void f(int); void foo () { void * p = &f; ((void (*) (int)) p) (1); }",
+ ParserLanguage.C);
NameCollector nameResolver = new NameCollector();
tu.accept(nameResolver);
assertNoProblemBindings(nameResolver);
@@ -4653,8 +4632,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTCompoundStatement body = (IASTCompoundStatement) f.getBody();
for (int i = 0; i < 2; ++i) {
IASTDeclarationStatement ds = (IASTDeclarationStatement) body.getStatements()[i];
- String s1 = ((IASTNamedTypeSpecifier) ((IASTSimpleDeclaration) ds.getDeclaration())
- .getDeclSpecifier()).getName().toString();
+ String s1 = ((IASTNamedTypeSpecifier) ((IASTSimpleDeclaration) ds.getDeclaration()).getDeclSpecifier())
+ .getName().toString();
String s2 = ((IASTCompositeTypeSpecifier) A.getDeclSpecifier()).getName().toString();
assertEquals(s1, s2);
}
@@ -4705,7 +4684,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
ICPPASTPointerToMember po = (ICPPASTPointerToMember) d.getPointerOperators()[0];
assertEquals("X::", po.getName().toString());
}
-
+
// struct cat {
// void meow();
// };
@@ -4726,14 +4705,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testBug84466() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
- ICPPASTCastExpression dynamic_cast =
- (ICPPASTCastExpression) ((IASTEqualsInitializer) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
- .getDeclarations()[2]).getBody()).getStatements()[0])
- .getDeclaration()).getDeclarators()[0].getInitializer())
- .getInitializerClause();
+ ICPPASTCastExpression dynamic_cast = (ICPPASTCastExpression) ((IASTEqualsInitializer) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
+ .getDeclarations()[2]).getBody()).getStatements()[0]).getDeclaration()).getDeclarators()[0]
+ .getInitializer()).getInitializerClause();
- assertEquals(dynamic_cast.getOperator(),
- ICPPASTCastExpression.op_dynamic_cast);
+ assertEquals(dynamic_cast.getOperator(), ICPPASTCastExpression.op_dynamic_cast);
}
public void testBug88338_CPP() throws Exception {
@@ -4801,10 +4777,10 @@ public class AST2CPPTests extends AST2CPPTestBase {
// };
// Sub::Sub(Other * b) : Base(b) {}
public void testBug95673() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
- ICPPConstructor ctor= ba.assertNonProblem("Base(Other", 4, ICPPConstructor.class);
- ICPPConstructor ctor2= ba.assertNonProblem("Base(b)", 4, ICPPConstructor.class);
+ ICPPConstructor ctor = ba.assertNonProblem("Base(Other", 4, ICPPConstructor.class);
+ ICPPConstructor ctor2 = ba.assertNonProblem("Base(b)", 4, ICPPConstructor.class);
assertSame(ctor, ctor2);
}
@@ -4920,8 +4896,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testBug94779() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
- IASTDeclarationStatement ds =
- (IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
+ IASTDeclarationStatement ds = (IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
.getDeclarations()[0]).getBody()).getStatements()[0];
IASTDeclarator d = ((IASTSimpleDeclaration) ds.getDeclaration()).getDeclarators()[0];
assertTrue(d.getName().resolveBinding() instanceof IVariable);
@@ -4959,10 +4934,12 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
IASTDeclaration[] decls = tu.getDeclarations();
- assertTrue(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).isComplex());
- assertEquals(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_float);
- assertTrue(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).isComplex());
- assertEquals(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double);
+ assertTrue(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration) decls[0]).getDeclSpecifier()).isComplex());
+ assertEquals(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration) decls[0]).getDeclSpecifier()).getType(),
+ IASTSimpleDeclSpecifier.t_float);
+ assertTrue(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration) decls[1]).getDeclSpecifier()).isComplex());
+ assertEquals(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration) decls[1]).getDeclSpecifier()).getType(),
+ IASTSimpleDeclSpecifier.t_double);
}
// class _A {
@@ -5039,7 +5016,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
ICPPConstructor ctor = (ICPPConstructor) col.getName(1).resolveBinding();
- ICPPConstructor [] cs = A.getConstructors();
+ ICPPConstructor[] cs = A.getConstructors();
assertTrue(cs.length == 2);
assertSame(cs[1], ctor);
}
@@ -5080,7 +5057,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
ICPPClassType B = (ICPPClassType) col.getName(2).resolveBinding();
ICPPClassType C = (ICPPClassType) col.getName(3).resolveBinding();
- ICPPClassType [] classes = A.getNestedClasses();
+ ICPPClassType[] classes = A.getNestedClasses();
assertEquals(classes.length, 2);
assertSame(classes[0], B);
assertSame(classes[1], C);
@@ -5096,7 +5073,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
tu.accept(col);
ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
- IBinding [] bindings = A.getMemberBindings();
+ IBinding[] bindings = A.getMemberBindings();
assertEquals(bindings.length, 3);
assertSame(bindings[0], col.getName(1).resolveBinding());
assertSame(bindings[1], col.getName(2).resolveBinding());
@@ -5164,32 +5141,32 @@ public class AST2CPPTests extends AST2CPPTestBase {
// i(&a); // i(int * const &)
// }
public void testRankingQualificationConversions_c() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
-
- ICPPFunction f1= bh.assertNonProblem("f(const int&)", 1);
- ICPPFunction f2= bh.assertNonProblem("f(int&)", 1);
- ICPPFunction g1= bh.assertNonProblem("g(const int&)", 1);
- ICPPFunction g2= bh.assertNonProblem("g(int)", 1);
- ICPPFunction h1= bh.assertNonProblem("h(const int * const&)", 1);
- ICPPFunction h2= bh.assertNonProblem("h(int *)", 1);
- ICPPFunction i1= bh.assertNonProblem("i(int * const &)", 1);
- ICPPFunction i2= bh.assertNonProblem("i(const int *)", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+
+ ICPPFunction f1 = bh.assertNonProblem("f(const int&)", 1);
+ ICPPFunction f2 = bh.assertNonProblem("f(int&)", 1);
+ ICPPFunction g1 = bh.assertNonProblem("g(const int&)", 1);
+ ICPPFunction g2 = bh.assertNonProblem("g(int)", 1);
+ ICPPFunction h1 = bh.assertNonProblem("h(const int * const&)", 1);
+ ICPPFunction h2 = bh.assertNonProblem("h(int *)", 1);
+ ICPPFunction i1 = bh.assertNonProblem("i(int * const &)", 1);
+ ICPPFunction i2 = bh.assertNonProblem("i(const int *)", 1);
ICPPFunction ref;
- ref= bh.assertNonProblem("f(ca)", 1);
+ ref = bh.assertNonProblem("f(ca)", 1);
assertSame(f1, ref);
- ref= bh.assertNonProblem("f(a)", 1);
+ ref = bh.assertNonProblem("f(a)", 1);
assertSame(f2, ref);
bh.assertProblem("g(ca)", 1);
bh.assertProblem("g(a)", 1);
- ref= bh.assertNonProblem("h(&ca)", 1);
+ ref = bh.assertNonProblem("h(&ca)", 1);
assertSame(h1, ref);
- ref= bh.assertNonProblem("h(&a)", 1);
+ ref = bh.assertNonProblem("h(&a)", 1);
assertSame(h2, ref);
- ref= bh.assertNonProblem("i(&ca)", 1);
+ ref = bh.assertNonProblem("i(&ca)", 1);
assertSame(i2, ref);
- ref= bh.assertNonProblem("i(&a)", 1);
+ ref = bh.assertNonProblem("i(&a)", 1);
assertSame(i1, ref);
}
@@ -5256,7 +5233,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f1(__null);
// }
public void testBug240567() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
bh.assertNonProblem("f1(__null", 2, ICPPFunction.class);
}
@@ -5405,7 +5382,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
}
public void testBug78800() throws Exception {
- parseAndCheckBindings("class Matrix { public: Matrix & operator *(Matrix &); }; Matrix rotate, translate; Matrix transform = rotate * translate;");
+ parseAndCheckBindings(
+ "class Matrix { public: Matrix & operator *(Matrix &); }; Matrix rotate, translate; Matrix transform = rotate * translate;");
}
// struct U { static int i; };
@@ -5435,7 +5413,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testBug1043290() throws Exception {
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment());
IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[0];
- IASTStatement [] statements = ((IASTCompoundStatement)fd.getBody()).getStatements();
+ IASTStatement[] statements = ((IASTCompoundStatement) fd.getBody()).getStatements();
IASTWhileStatement whileStmt = (IASTWhileStatement) statements[1];
IASTLabelStatement labelStmt = (IASTLabelStatement) whileStmt.getBody();
assertTrue(labelStmt.getNestedStatement() instanceof IASTExpressionStatement);
@@ -5541,9 +5519,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// check class
IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[2];
- IASTDeclarator fdecl= fd.getDeclarator();
- IASTName name= fdecl.getName();
- IBinding binding= name.resolveBinding();
+ IASTDeclarator fdecl = fd.getDeclarator();
+ IASTName name = fdecl.getName();
+ IBinding binding = name.resolveBinding();
assertTrue(binding instanceof IFunction);
assertFalse(binding instanceof IProblemBinding);
}
@@ -5605,21 +5583,21 @@ public class AST2CPPTests extends AST2CPPTestBase {
// problem5(ptm);
// }
public void testBug214335() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
-
- IBinding b00= bh.assertProblem("problem1(\"", 8);
- IBinding b01= bh.assertProblem("problem2(\"", 8);
- IBinding b02= bh.assertProblem("problem3(\"", 8);
- IBinding b03= bh.assertNonProblem("nonproblem1(\"", 11);
- IBinding b04= bh.assertProblem("problem4(\"", 8);
- IBinding b05= bh.assertProblem("problem5(\"", 8);
-
- IBinding b06= bh.assertProblem("problem1(ptm", 8);
- IBinding b07= bh.assertProblem("problem2(ptm", 8);
- IBinding b08= bh.assertProblem("problem3(ptm", 8);
- IBinding b09= bh.assertNonProblem("nonproblem1(ptm", 11);
- IBinding b10= bh.assertProblem("problem4(ptm", 8);
- IBinding b11= bh.assertProblem("problem5(ptm", 8);
+ BindingAssertionHelper bh = getAssertionHelper();
+
+ IBinding b00 = bh.assertProblem("problem1(\"", 8);
+ IBinding b01 = bh.assertProblem("problem2(\"", 8);
+ IBinding b02 = bh.assertProblem("problem3(\"", 8);
+ IBinding b03 = bh.assertNonProblem("nonproblem1(\"", 11);
+ IBinding b04 = bh.assertProblem("problem4(\"", 8);
+ IBinding b05 = bh.assertProblem("problem5(\"", 8);
+
+ IBinding b06 = bh.assertProblem("problem1(ptm", 8);
+ IBinding b07 = bh.assertProblem("problem2(ptm", 8);
+ IBinding b08 = bh.assertProblem("problem3(ptm", 8);
+ IBinding b09 = bh.assertNonProblem("nonproblem1(ptm", 11);
+ IBinding b10 = bh.assertProblem("problem4(ptm", 8);
+ IBinding b11 = bh.assertProblem("problem5(ptm", 8);
assertInstance(b03, ICPPFunction.class);
assertInstance(b09, ICPPFunction.class);
@@ -5662,64 +5640,70 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
IASTDeclaration[] decls = tu.getDeclarations();
- ICPPASTNamespaceDefinition nsdef= (ICPPASTNamespaceDefinition) decls[0];
- ICPPASTUsingDeclaration udcl= (ICPPASTUsingDeclaration) decls[2];
- ICPPASTUsingDeclaration udf= (ICPPASTUsingDeclaration) decls[3];
- IASTFunctionDefinition fdef= (IASTFunctionDefinition) decls[4];
-
- IASTDeclaration[] nsdecls= nsdef.getDeclarations();
- ICPPASTCompositeTypeSpecifier cldef= (ICPPASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) nsdecls[0]).getDeclSpecifier();
- ICPPASTFunctionDeclarator fdecl1= (ICPPASTFunctionDeclarator) ((IASTSimpleDeclaration) nsdecls[1]).getDeclarators()[0];
- ICPPASTFunctionDeclarator fdecl2= (ICPPASTFunctionDeclarator) ((IASTSimpleDeclaration) nsdecls[2]).getDeclarators()[0];
-
- IASTStatement[] stmts= ((IASTCompoundStatement) fdef.getBody()).getStatements();
- IASTName clname= ((IASTNamedTypeSpecifier) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) stmts[0]).getDeclaration()).getDeclSpecifier()).getName();
- IASTName fnname1= ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTExpressionStatement) stmts[1]).getExpression()).getFunctionNameExpression()).getName();
- IASTName fnname2= ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTExpressionStatement) stmts[2]).getExpression()).getFunctionNameExpression()).getName();
+ ICPPASTNamespaceDefinition nsdef = (ICPPASTNamespaceDefinition) decls[0];
+ ICPPASTUsingDeclaration udcl = (ICPPASTUsingDeclaration) decls[2];
+ ICPPASTUsingDeclaration udf = (ICPPASTUsingDeclaration) decls[3];
+ IASTFunctionDefinition fdef = (IASTFunctionDefinition) decls[4];
+
+ IASTDeclaration[] nsdecls = nsdef.getDeclarations();
+ ICPPASTCompositeTypeSpecifier cldef = (ICPPASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) nsdecls[0])
+ .getDeclSpecifier();
+ ICPPASTFunctionDeclarator fdecl1 = (ICPPASTFunctionDeclarator) ((IASTSimpleDeclaration) nsdecls[1])
+ .getDeclarators()[0];
+ ICPPASTFunctionDeclarator fdecl2 = (ICPPASTFunctionDeclarator) ((IASTSimpleDeclaration) nsdecls[2])
+ .getDeclarators()[0];
+
+ IASTStatement[] stmts = ((IASTCompoundStatement) fdef.getBody()).getStatements();
+ IASTName clname = ((IASTNamedTypeSpecifier) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) stmts[0])
+ .getDeclaration()).getDeclSpecifier()).getName();
+ IASTName fnname1 = ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTExpressionStatement) stmts[1])
+ .getExpression()).getFunctionNameExpression()).getName();
+ IASTName fnname2 = ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTExpressionStatement) stmts[2])
+ .getExpression()).getFunctionNameExpression()).getName();
// check class
- IBinding b= cldef.getName().resolveBinding();
- assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
- assertEquals(1, tu.getDefinitionsInAST(b).length); // class-def
- assertEquals(2, tu.getDeclarationsInAST(b).length); // class-def + using-decl
+ IBinding b = cldef.getName().resolveBinding();
+ assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
+ assertEquals(1, tu.getDefinitionsInAST(b).length); // class-def
+ assertEquals(2, tu.getDeclarationsInAST(b).length); // class-def + using-decl
// check functions
- b= fdecl1.getName().resolveBinding();
- assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
- assertEquals(0, tu.getDefinitionsInAST(b).length); // function is not defined
- assertEquals(2, tu.getDeclarationsInAST(b).length); // func-decl + using-decl
- b= fdecl2.getName().resolveBinding();
- assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
- assertEquals(0, tu.getDefinitionsInAST(b).length); // function is not defined
- assertEquals(2, tu.getDeclarationsInAST(b).length); // func-decl + using-decl
+ b = fdecl1.getName().resolveBinding();
+ assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
+ assertEquals(0, tu.getDefinitionsInAST(b).length); // function is not defined
+ assertEquals(2, tu.getDeclarationsInAST(b).length); // func-decl + using-decl
+ b = fdecl2.getName().resolveBinding();
+ assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
+ assertEquals(0, tu.getDefinitionsInAST(b).length); // function is not defined
+ assertEquals(2, tu.getDeclarationsInAST(b).length); // func-decl + using-decl
// check using declaration class
- b= udcl.getName().resolveBinding();
- assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
- assertEquals(1, tu.getDefinitionsInAST(b).length); // class-def
- assertEquals(2, tu.getDeclarationsInAST(b).length); // class-def + using-decl
+ b = udcl.getName().resolveBinding();
+ assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
+ assertEquals(1, tu.getDefinitionsInAST(b).length); // class-def
+ assertEquals(2, tu.getDeclarationsInAST(b).length); // class-def + using-decl
// check using declaration function
- b= udf.getName().resolveBinding();
- assertEquals(5, tu.getReferences(b).length); // 4 refs + using-decl
- assertEquals(0, tu.getDefinitionsInAST(b).length); // function is not defined
- assertEquals(3, tu.getDeclarationsInAST(b).length); // using-decl + 2 func-decls
+ b = udf.getName().resolveBinding();
+ assertEquals(5, tu.getReferences(b).length); // 4 refs + using-decl
+ assertEquals(0, tu.getDefinitionsInAST(b).length); // function is not defined
+ assertEquals(3, tu.getDeclarationsInAST(b).length); // using-decl + 2 func-decls
// check class reference
- b= clname.resolveBinding();
- assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
- assertEquals(1, tu.getDefinitionsInAST(b).length); // class-def
- assertEquals(2, tu.getDeclarationsInAST(b).length); // class-def + using-decl
+ b = clname.resolveBinding();
+ assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
+ assertEquals(1, tu.getDefinitionsInAST(b).length); // class-def
+ assertEquals(2, tu.getDeclarationsInAST(b).length); // class-def + using-decl
// check function references
- b= fnname1.resolveBinding();
- assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
- assertEquals(0, tu.getDefinitionsInAST(b).length); // function is not defined
- assertEquals(2, tu.getDeclarationsInAST(b).length); // using-decl + func-decl
- b= fnname2.resolveBinding();
- assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
- assertEquals(0, tu.getDefinitionsInAST(b).length); // function is not defined
- assertEquals(2, tu.getDeclarationsInAST(b).length); // using-decl + func-decl
+ b = fnname1.resolveBinding();
+ assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
+ assertEquals(0, tu.getDefinitionsInAST(b).length); // function is not defined
+ assertEquals(2, tu.getDeclarationsInAST(b).length); // using-decl + func-decl
+ b = fnname2.resolveBinding();
+ assertEquals(3, tu.getReferences(b).length); // 2 refs + using-decl
+ assertEquals(0, tu.getDefinitionsInAST(b).length); // function is not defined
+ assertEquals(2, tu.getDeclarationsInAST(b).length); // using-decl + func-decl
}
// namespace x {
@@ -5735,9 +5719,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// a=0;
// }
public void testUsingDirectiveWithNestedClass_209582() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
- IBinding b= bh.assertNonProblem("a=", 1);
+ IBinding b = bh.assertNonProblem("a=", 1);
assertEquals("x", b.getScope().getScopeName().toString());
}
@@ -5754,7 +5738,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// Test foo3 (&bar);
// }
public void testCastAmbiguity_211756() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
bh.assertNonProblem("foo1", 4);
bh.assertNonProblem("foo2", 4);
@@ -5768,7 +5752,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// return 0;
// }
public void testTemplateIDAmbiguity_104706() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
bh.assertNonProblem("relayIndex <", 10);
bh.assertNonProblem("relayIndex >", 10);
@@ -5806,7 +5790,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// func(unqualified);
// }
public void testScopeOfUsingDelegates_219424() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
bh.assertNonProblem("cl c", 2);
bh.assertNonProblem("func(qualified)", 4);
@@ -5822,40 +5806,40 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testQualifiedMemberDeclaration_222026() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
- IBinding b= bh.assertNonProblem("member1", 7);
- IBinding b2= bh.assertNonProblem("member1(){", 7);
+ IBinding b = bh.assertNonProblem("member1", 7);
+ IBinding b2 = bh.assertNonProblem("member1(){", 7);
assertTrue(b instanceof ICPPMethod);
- ICPPMethod m1= (ICPPMethod) b;
+ ICPPMethod m1 = (ICPPMethod) b;
assertEquals("member1", m1.getName());
assertEquals("Test", m1.getScope().getScopeName().toString());
assertSame(b, b2);
- bh= new AST2AssertionHelper(code, true);
- b= bh.assertNonProblem("member2", 7);
- b2= bh.assertNonProblem("member2();", 7);
+ bh = new AST2AssertionHelper(code, true);
+ b = bh.assertNonProblem("member2", 7);
+ b2 = bh.assertNonProblem("member2();", 7);
assertTrue(b instanceof ICPPMethod);
- m1= (ICPPMethod) b;
+ m1 = (ICPPMethod) b;
assertEquals("member2", m1.getName());
assertEquals("Test", m1.getScope().getScopeName().toString());
assertSame(b, b2);
// different resolution order
- bh= new AST2AssertionHelper(code, true);
- b2= bh.assertNonProblem("member1(){", 7);
- b= bh.assertNonProblem("member1", 7);
+ bh = new AST2AssertionHelper(code, true);
+ b2 = bh.assertNonProblem("member1(){", 7);
+ b = bh.assertNonProblem("member1", 7);
assertTrue(b instanceof ICPPMethod);
- m1= (ICPPMethod) b;
+ m1 = (ICPPMethod) b;
assertEquals("member1", m1.getName());
assertEquals("Test", m1.getScope().getScopeName().toString());
assertSame(b, b2);
- bh= new AST2AssertionHelper(code, true);
- b2= bh.assertNonProblem("member2();", 7);
- b= bh.assertNonProblem("member2", 7);
+ bh = new AST2AssertionHelper(code, true);
+ b2 = bh.assertNonProblem("member2();", 7);
+ b = bh.assertNonProblem("member2", 7);
assertTrue(b instanceof ICPPMethod);
- m1= (ICPPMethod) b;
+ m1 = (ICPPMethod) b;
assertEquals("member2", m1.getName());
assertEquals("Test", m1.getScope().getScopeName().toString());
assertSame(b, b2);
@@ -5870,49 +5854,49 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testQualifiedMemberDeclarationInNamespace_222026() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
- IBinding b= bh.assertNonProblem("member1", 7);
- IBinding b2= bh.assertNonProblem("member1(){", 7);
+ IBinding b = bh.assertNonProblem("member1", 7);
+ IBinding b2 = bh.assertNonProblem("member1(){", 7);
assertTrue(b instanceof ICPPFunction);
- ICPPFunction m1= (ICPPFunction) b;
+ ICPPFunction m1 = (ICPPFunction) b;
assertEquals("member1", m1.getName());
assertEquals("Test", m1.getScope().getScopeName().toString());
assertSame(b, b2);
- bh= new AST2AssertionHelper(code, true);
- b= bh.assertNonProblem("member2", 7);
- b2= bh.assertNonProblem("member2();", 7);
+ bh = new AST2AssertionHelper(code, true);
+ b = bh.assertNonProblem("member2", 7);
+ b2 = bh.assertNonProblem("member2();", 7);
assertTrue(b instanceof ICPPFunction);
- m1= (ICPPFunction) b;
+ m1 = (ICPPFunction) b;
assertEquals("member2", m1.getName());
assertEquals("Test", m1.getScope().getScopeName().toString());
assertSame(b, b2);
// different resolution order
- bh= new AST2AssertionHelper(code, true);
- b2= bh.assertNonProblem("member1(){", 7);
- b= bh.assertNonProblem("member1", 7);
+ bh = new AST2AssertionHelper(code, true);
+ b2 = bh.assertNonProblem("member1(){", 7);
+ b = bh.assertNonProblem("member1", 7);
assertTrue(b instanceof ICPPFunction);
- m1= (ICPPFunction) b;
+ m1 = (ICPPFunction) b;
assertEquals("member1", m1.getName());
assertEquals("Test", m1.getScope().getScopeName().toString());
assertSame(b, b2);
- bh= new AST2AssertionHelper(code, true);
- b2= bh.assertNonProblem("member2();", 7);
- b= bh.assertNonProblem("member2", 7);
+ bh = new AST2AssertionHelper(code, true);
+ b2 = bh.assertNonProblem("member2();", 7);
+ b = bh.assertNonProblem("member2", 7);
assertTrue(b instanceof ICPPFunction);
- m1= (ICPPFunction) b;
+ m1 = (ICPPFunction) b;
assertEquals("member2", m1.getName());
assertEquals("Test", m1.getScope().getScopeName().toString());
assertSame(b, b2);
}
// namespace ns { typedef int ns::TINT; } // illegal, still no CCE is expected.
- public void testQualifiedTypedefs_222093() throws Exception{
- BindingAssertionHelper bh= getAssertionHelper();
- IBinding td= bh.assertProblem("TINT", 4);
+ public void testQualifiedTypedefs_222093() throws Exception {
+ BindingAssertionHelper bh = getAssertionHelper();
+ IBinding td = bh.assertProblem("TINT", 4);
bh.assertProblem("ns::", 2);
}
@@ -5922,17 +5906,17 @@ public class AST2CPPTests extends AST2CPPTestBase {
// if (a > b) {
// }
// }
- public void testResettingTemplateIdScopesStack_223777() throws Exception{
+ public void testResettingTemplateIdScopesStack_223777() throws Exception {
parseAndCheckBindings(getAboveComment());
}
// long x= 10L;
public void testLongLiteral_225534() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
- IASTDeclarator decltor= ((IASTSimpleDeclaration)tu.getDeclarations()[0]).getDeclarators()[0];
- IASTEqualsInitializer init= (IASTEqualsInitializer) decltor.getInitializer();
- ICPPASTLiteralExpression exp= (ICPPASTLiteralExpression) init.getInitializerClause();
- ICPPBasicType type= (ICPPBasicType) exp.getExpressionType();
+ IASTDeclarator decltor = ((IASTSimpleDeclaration) tu.getDeclarations()[0]).getDeclarators()[0];
+ IASTEqualsInitializer init = (IASTEqualsInitializer) decltor.getInitializer();
+ ICPPASTLiteralExpression exp = (ICPPASTLiteralExpression) init.getInitializerClause();
+ ICPPBasicType type = (ICPPBasicType) exp.getExpressionType();
assertTrue(type.isLong());
}
@@ -5995,13 +5979,13 @@ public class AST2CPPTests extends AST2CPPTestBase {
// foo/*k2*/(11.1E1L);
// }
public void testLiteralsViaOverloads_225534() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
- char[] cs= {'a','b','e','f','g','h','i','j','k'};
+ BindingAssertionHelper ba = getAssertionHelper();
+ char[] cs = { 'a', 'b', 'e', 'f', 'g', 'h', 'i', 'j', 'k' };
for (char c : cs) {
- for (int i=1; i<(c < 'i' ? 4 : 3); i++) {
- ICPPFunction def= ba.assertNonProblem("foo/*_"+c+"*/", 3, ICPPFunction.class);
- ICPPFunction ref= ba.assertNonProblem("foo/*"+c+""+i+"*/", 3, ICPPFunction.class);
- assertSame("function ref: "+c+""+i, def, ref);
+ for (int i = 1; i < (c < 'i' ? 4 : 3); i++) {
+ ICPPFunction def = ba.assertNonProblem("foo/*_" + c + "*/", 3, ICPPFunction.class);
+ ICPPFunction ref = ba.assertNonProblem("foo/*" + c + "" + i + "*/", 3, ICPPFunction.class);
+ assertSame("function ref: " + c + "" + i, def, ref);
}
}
}
@@ -6055,7 +6039,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// X::operator int() {}
// X::xtint(a); // 2
public void testEmptyDeclSpecifier() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("X {", 1, ICPPClassType.class);
ba.assertNonProblem("X()", 1, ICPPConstructor.class);
ba.assertNonProblem("~X", 2, ICPPMethod.class);
@@ -6090,8 +6074,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// new (p) (T[f][f]);
// };
public void testNewPlacement() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment());
- IASTFunctionDefinition fdef= getDeclaration(tu, 3);
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment());
+ IASTFunctionDefinition fdef = getDeclaration(tu, 3);
checkNewExpression(fdef, 0, null, "int", null);
checkNewExpression(fdef, 1, null, "int", IASTExpressionList.class);
@@ -6117,11 +6101,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
// +
// }
public void testTrailingSyntaxErrorInNamespace() throws Exception {
- final String comment= getAboveComment();
- IASTTranslationUnit tu= parse(comment, CPP, false, false);
- ICPPASTNamespaceDefinition ns= getDeclaration(tu, 0);
- IASTDeclaration decl= getDeclaration(ns, 0);
- IASTProblemDeclaration pdecl= getDeclaration(ns, 1);
+ final String comment = getAboveComment();
+ IASTTranslationUnit tu = parse(comment, CPP, false, false);
+ ICPPASTNamespaceDefinition ns = getDeclaration(tu, 0);
+ IASTDeclaration decl = getDeclaration(ns, 0);
+ IASTProblemDeclaration pdecl = getDeclaration(ns, 1);
assertEquals("+", pdecl.getRawSignature());
}
@@ -6130,23 +6114,23 @@ public class AST2CPPTests extends AST2CPPTestBase {
// +
// }
public void testTrailingSyntaxErrorInLinkageSpec() throws Exception {
- final String comment= getAboveComment();
- IASTTranslationUnit tu= parse(comment, CPP, false, false);
- ICPPASTLinkageSpecification ls= getDeclaration(tu, 0);
- IASTDeclaration decl= getDeclaration(ls, 0);
- IASTProblemDeclaration pdecl= getDeclaration(ls, 1);
+ final String comment = getAboveComment();
+ IASTTranslationUnit tu = parse(comment, CPP, false, false);
+ ICPPASTLinkageSpecification ls = getDeclaration(tu, 0);
+ IASTDeclaration decl = getDeclaration(ls, 0);
+ IASTProblemDeclaration pdecl = getDeclaration(ls, 1);
assertEquals("+", pdecl.getRawSignature());
}
// class C;
// void func(void (C::*m)(int) const);
public void test233889_a() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
- ICPPFunction func= bh.assertNonProblem("func(", 4, ICPPFunction.class);
- assertEquals(1,func.getParameters().length);
- IType type= func.getParameters()[0].getType();
- ICPPPointerToMemberType ptm= assertInstance(type, ICPPPointerToMemberType.class);
- ICPPFunctionType t= ((ICPPFunctionType)ptm.getType());
+ BindingAssertionHelper bh = getAssertionHelper();
+ ICPPFunction func = bh.assertNonProblem("func(", 4, ICPPFunction.class);
+ assertEquals(1, func.getParameters().length);
+ IType type = func.getParameters()[0].getType();
+ ICPPPointerToMemberType ptm = assertInstance(type, ICPPPointerToMemberType.class);
+ ICPPFunctionType t = ((ICPPFunctionType) ptm.getType());
assertTrue(t.isConst());
}
@@ -6163,9 +6147,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// func(&C::m2);
// }
public void testBug233889_b() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
- ICPPFunction fn1= bh.assertNonProblem("func(&C::m1", 4, ICPPFunction.class);
- ICPPFunction fn2= bh.assertNonProblem("func(&C::m2", 4, ICPPFunction.class);
+ BindingAssertionHelper bh = getAssertionHelper();
+ ICPPFunction fn1 = bh.assertNonProblem("func(&C::m1", 4, ICPPFunction.class);
+ ICPPFunction fn2 = bh.assertNonProblem("func(&C::m2", 4, ICPPFunction.class);
assertNotSame(fn1, fn2);
}
@@ -6184,21 +6168,24 @@ public class AST2CPPTests extends AST2CPPTestBase {
// void member4() const volatile { foo(this);/*4*/ }
// };
public void testThisType() throws Exception {
- BindingAssertionHelper ba=getAssertionHelper();
- ICPPFunction pt1= ba.assertNonProblem("foo(this);/*1*/", 3, ICPPFunction.class);
- ICPPFunction pt2= ba.assertNonProblem("foo(this);/*2*/", 3, ICPPFunction.class);
- ICPPFunction pt3= ba.assertNonProblem("foo(this);/*3*/", 3, ICPPFunction.class);
- ICPPFunction pt4= ba.assertNonProblem("foo(this);/*4*/", 3, ICPPFunction.class);
+ BindingAssertionHelper ba = getAssertionHelper();
+ ICPPFunction pt1 = ba.assertNonProblem("foo(this);/*1*/", 3, ICPPFunction.class);
+ ICPPFunction pt2 = ba.assertNonProblem("foo(this);/*2*/", 3, ICPPFunction.class);
+ ICPPFunction pt3 = ba.assertNonProblem("foo(this);/*3*/", 3, ICPPFunction.class);
+ ICPPFunction pt4 = ba.assertNonProblem("foo(this);/*4*/", 3, ICPPFunction.class);
- IType t1= ((IPointerType)pt1.getType().getParameterTypes()[0]).getType();
- IQualifierType t2= (IQualifierType) ((IPointerType) pt2.getType().getParameterTypes()[0]).getType();
- IQualifierType t3= (IQualifierType) ((IPointerType) pt3.getType().getParameterTypes()[0]).getType();
- IQualifierType t4= (IQualifierType) ((IPointerType) pt4.getType().getParameterTypes()[0]).getType();
+ IType t1 = ((IPointerType) pt1.getType().getParameterTypes()[0]).getType();
+ IQualifierType t2 = (IQualifierType) ((IPointerType) pt2.getType().getParameterTypes()[0]).getType();
+ IQualifierType t3 = (IQualifierType) ((IPointerType) pt3.getType().getParameterTypes()[0]).getType();
+ IQualifierType t4 = (IQualifierType) ((IPointerType) pt4.getType().getParameterTypes()[0]).getType();
assertTrue(!(t1 instanceof IQualifierType));
- assertTrue(t2.isConst()); assertTrue(!t2.isVolatile());
- assertTrue(!t3.isConst()); assertTrue(t3.isVolatile());
- assertTrue(t4.isConst()); assertTrue(t4.isVolatile());
+ assertTrue(t2.isConst());
+ assertTrue(!t2.isVolatile());
+ assertTrue(!t3.isConst());
+ assertTrue(t3.isVolatile());
+ assertTrue(t4.isConst());
+ assertTrue(t4.isVolatile());
}
// class A {
@@ -6213,7 +6200,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// a2->foo();/*2*/
// }
public void testMemberAccessOperator_a() throws Exception {
- BindingAssertionHelper ba=getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertProblem("foo();/*1*/", 3);
ba.assertNonProblem("foo();/*2*/", 3);
}
@@ -6236,9 +6223,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// b2->foo();/*2*/
// }
public void testMemberAccessOperator_b() throws Exception {
- BindingAssertionHelper ba=getAssertionHelper();
- ICPPMethod m1= ba.assertNonProblem("foo();/*1*/", 3, ICPPMethod.class);
- ICPPMethod m2= ba.assertNonProblem("foo();/*2*/", 3, ICPPMethod.class);
+ BindingAssertionHelper ba = getAssertionHelper();
+ ICPPMethod m1 = ba.assertNonProblem("foo();/*1*/", 3, ICPPMethod.class);
+ ICPPMethod m2 = ba.assertNonProblem("foo();/*2*/", 3, ICPPMethod.class);
assertEquals(m1.getClassOwner().getName(), "A");
assertEquals(m2.getClassOwner().getName(), "B");
}
@@ -6252,7 +6239,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// c->foo();/**/ // refers to A::foo
// }
public void testMemberAccessOperator_c() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("foo();/**/", 3);
}
@@ -6265,7 +6252,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// c->foo();/**/ // expect problem - foo is not in B
// }
public void testMemberAccessOperator_d() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertProblem("foo();/**/", 3);
}
@@ -6281,7 +6268,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// c->foo();/**/ // refers to A::foo
// }
public void testMemberAccessOperator_e() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("foo();/**/", 3);
}
@@ -6309,7 +6296,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f4(s);
// }
public void testArrayToPointerConversion() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("f1(p)", 2, ICPPFunction.class);
ba.assertProblem("f2(q)", 2);
ba.assertNonProblem("f3(r)", 2, ICPPFunction.class);
@@ -6364,30 +6351,30 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testRestrictIsNoCPPKeyword_228826() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code, CPP, false);
- parseAndCheckBindings(getAboveComment(), CPP, true); // even with gnu extensions
+ parseAndCheckBindings(getAboveComment(), CPP, true); // even with gnu extensions
}
// void test1();
// void test2() throw ();
// void test3() throw (int);
public void testEmptyExceptionSpecification_86943() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), CPP);
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), CPP);
- IASTSimpleDeclaration d= getDeclaration(tu, 0);
- ICPPASTFunctionDeclarator fdtor= (ICPPASTFunctionDeclarator) d.getDeclarators()[0];
- IASTTypeId[] specs= fdtor.getExceptionSpecification();
+ IASTSimpleDeclaration d = getDeclaration(tu, 0);
+ ICPPASTFunctionDeclarator fdtor = (ICPPASTFunctionDeclarator) d.getDeclarators()[0];
+ IASTTypeId[] specs = fdtor.getExceptionSpecification();
assertEquals(0, specs.length);
assertSame(ICPPASTFunctionDeclarator.NO_EXCEPTION_SPECIFICATION, specs);
- d= getDeclaration(tu, 1);
- fdtor= (ICPPASTFunctionDeclarator) d.getDeclarators()[0];
- specs= fdtor.getExceptionSpecification();
+ d = getDeclaration(tu, 1);
+ fdtor = (ICPPASTFunctionDeclarator) d.getDeclarators()[0];
+ specs = fdtor.getExceptionSpecification();
assertEquals(0, specs.length);
assertNotSame(ICPPASTFunctionDeclarator.NO_EXCEPTION_SPECIFICATION, specs);
- d= getDeclaration(tu, 2);
- fdtor= (ICPPASTFunctionDeclarator) d.getDeclarators()[0];
- specs= fdtor.getExceptionSpecification();
+ d = getDeclaration(tu, 2);
+ fdtor = (ICPPASTFunctionDeclarator) d.getDeclarators()[0];
+ specs = fdtor.getExceptionSpecification();
assertEquals(1, specs.length);
}
@@ -6409,9 +6396,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// func(y);
// }
public void testOverloadedFunction_248774() throws Exception {
- BindingAssertionHelper helper= getAssertionHelper();
- ICPPFunction func1= helper.assertNonProblem("func(x)", 4, ICPPFunction.class);
- ICPPFunction func2= helper.assertNonProblem("func(y)", 4, ICPPFunction.class);
+ BindingAssertionHelper helper = getAssertionHelper();
+ ICPPFunction func1 = helper.assertNonProblem("func(x)", 4, ICPPFunction.class);
+ ICPPFunction func2 = helper.assertNonProblem("func(y)", 4, ICPPFunction.class);
assertNotSame(func1, func2);
}
@@ -6428,9 +6415,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// func(y[0]);
// }
public void testOverloadedOperator_248803() throws Exception {
- BindingAssertionHelper helper= getAssertionHelper();
- ICPPFunction func1= helper.assertNonProblem("func(x[0])", 4, ICPPFunction.class);
- ICPPFunction func2= helper.assertNonProblem("func(y[0])", 4, ICPPFunction.class);
+ BindingAssertionHelper helper = getAssertionHelper();
+ ICPPFunction func1 = helper.assertNonProblem("func(x[0])", 4, ICPPFunction.class);
+ ICPPFunction func2 = helper.assertNonProblem("func(y[0])", 4, ICPPFunction.class);
assertNotSame(func1, func2);
}
@@ -6453,13 +6440,13 @@ public class AST2CPPTests extends AST2CPPTestBase {
// void m();//5
// };
public void testOverridden_248846() throws Exception {
- BindingAssertionHelper helper= getAssertionHelper();
- ICPPMethod m0= helper.assertNonProblem("m();//0", 1, ICPPMethod.class);
- ICPPMethod m1= helper.assertNonProblem("m();//1", 1, ICPPMethod.class);
- ICPPMethod m2= helper.assertNonProblem("m();//2", 1, ICPPMethod.class);
- ICPPMethod m3= helper.assertNonProblem("m(int);", 1, ICPPMethod.class);
- ICPPMethod m4= helper.assertNonProblem("m();//4", 1, ICPPMethod.class);
- ICPPMethod m5= helper.assertNonProblem("m();//5", 1, ICPPMethod.class);
+ BindingAssertionHelper helper = getAssertionHelper();
+ ICPPMethod m0 = helper.assertNonProblem("m();//0", 1, ICPPMethod.class);
+ ICPPMethod m1 = helper.assertNonProblem("m();//1", 1, ICPPMethod.class);
+ ICPPMethod m2 = helper.assertNonProblem("m();//2", 1, ICPPMethod.class);
+ ICPPMethod m3 = helper.assertNonProblem("m(int);", 1, ICPPMethod.class);
+ ICPPMethod m4 = helper.assertNonProblem("m();//4", 1, ICPPMethod.class);
+ ICPPMethod m5 = helper.assertNonProblem("m();//5", 1, ICPPMethod.class);
assertFalse(ClassTypeHelper.isVirtual(m0));
assertFalse(ClassTypeHelper.isVirtual(m3));
@@ -6489,20 +6476,20 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertFalse(ClassTypeHelper.isOverrider(m5, m2));
assertTrue(ClassTypeHelper.isOverrider(m4, m2));
- ICPPMethod[] ors= ClassTypeHelper.findOverridden(m0);
+ ICPPMethod[] ors = ClassTypeHelper.findOverridden(m0);
assertEquals(0, ors.length);
- ors= ClassTypeHelper.findOverridden(m1);
+ ors = ClassTypeHelper.findOverridden(m1);
assertEquals(0, ors.length);
- ors= ClassTypeHelper.findOverridden(m2);
+ ors = ClassTypeHelper.findOverridden(m2);
assertEquals(1, ors.length);
assertEquals(ors[0], m1);
- ors= ClassTypeHelper.findOverridden(m3);
+ ors = ClassTypeHelper.findOverridden(m3);
assertEquals(0, ors.length);
- ors= ClassTypeHelper.findOverridden(m4);
+ ors = ClassTypeHelper.findOverridden(m4);
assertEquals(2, ors.length);
assertEquals(ors[0], m2);
assertEquals(ors[1], m1);
- ors= ClassTypeHelper.findOverridden(m5);
+ ors = ClassTypeHelper.findOverridden(m5);
assertEquals(1, ors.length);
assertEquals(ors[0], m1);
}
@@ -6515,10 +6502,10 @@ public class AST2CPPTests extends AST2CPPTestBase {
// p.a; // should not resolve
// }
public void testPointerMemberAccess_245068() throws Exception {
- final String comment= getAboveComment();
- final boolean[] isCpps= {false, true};
+ final String comment = getAboveComment();
+ final boolean[] isCpps = { false, true };
for (boolean isCpp : isCpps) {
- BindingAssertionHelper ba= new AST2AssertionHelper(comment, isCpp);
+ BindingAssertionHelper ba = new AST2AssertionHelper(comment, isCpp);
ba.assertProblem("a; // should not resolve", 1);
}
}
@@ -6540,7 +6527,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// };
public void testNamespaceQualifiedOperator_256840() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("operator ns::A", 14);
parseAndCheckBindings(code, CPP);
}
@@ -6551,7 +6538,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(p);
// }
public void testFunctionExtraArgument() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertProblem("f(p)", 1);
}
@@ -6561,10 +6548,10 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(p);
// }
public void testVariadicFunction_2500582() throws Exception {
- final String comment= getAboveComment();
- final boolean[] isCpps= {false, true};
+ final String comment = getAboveComment();
+ final boolean[] isCpps = { false, true };
for (boolean isCpp : isCpps) {
- BindingAssertionHelper ba= new AST2AssertionHelper(comment, isCpp);
+ BindingAssertionHelper ba = new AST2AssertionHelper(comment, isCpp);
ba.assertNonProblem("f(p)", 1, IFunction.class);
}
}
@@ -6579,12 +6566,12 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(0);
// }
public void testVariadicFunction_2500583() throws Exception {
- final String comment= getAboveComment();
- final boolean[] isCpps= {false, true};
+ final String comment = getAboveComment();
+ final boolean[] isCpps = { false, true };
for (boolean isCpp : isCpps) {
- BindingAssertionHelper ba= new AST2AssertionHelper(comment, isCpp);
- IFunction decl= ba.assertNonProblem("f(Incomplete* p)", 1, IFunction.class);
- IFunction func= ba.assertNonProblem("f(0)", 1, IFunction.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(comment, isCpp);
+ IFunction decl = ba.assertNonProblem("f(Incomplete* p)", 1, IFunction.class);
+ IFunction func = ba.assertNonProblem("f(0)", 1, IFunction.class);
assertSame(decl, func);
}
}
@@ -6602,11 +6589,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testFunctionCallOnLHS_252695() throws Exception {
final String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code, CPP, true);
- IASTFunctionDefinition fdef= getDeclaration(tu, 1);
- IASTExpressionStatement exstmt= getStatement(fdef, 0);
+ IASTTranslationUnit tu = parseAndCheckBindings(code, CPP, true);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 1);
+ IASTExpressionStatement exstmt = getStatement(fdef, 0);
assertInstance(exstmt.getExpression(), IASTBinaryExpression.class);
- exstmt= getStatement(fdef, 1);
+ exstmt = getStatement(fdef, 1);
assertInstance(exstmt.getExpression(), IASTBinaryExpression.class);
}
@@ -6618,8 +6605,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// template <int E> class B {};
public void testInvalidClassRedeclaration_254961() throws Exception {
final String code = getAboveComment();
- IASTTranslationUnit tu= parse(code, CPP, true, false);
- NameCollector nc= new NameCollector();
+ IASTTranslationUnit tu = parse(code, CPP, true, false);
+ NameCollector nc = new NameCollector();
tu.accept(nc);
assertProblemBindings(nc, 4);
assertProblemBinding(IProblemBinding.SEMANTIC_INVALID_REDEFINITION, nc.getName(2).resolveBinding());
@@ -6636,8 +6623,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// template <typename T> class B {};
public void testInvalidClassRedeclaration_364226() throws Exception {
final String code = getAboveComment();
- IASTTranslationUnit tu= parse(code, CPP, true, false);
- NameCollector nc= new NameCollector();
+ IASTTranslationUnit tu = parse(code, CPP, true, false);
+ NameCollector nc = new NameCollector();
tu.accept(nc);
assertProblemBindings(nc, 4);
assertProblemBinding(IProblemBinding.SEMANTIC_INVALID_REDEFINITION, nc.getName(4).resolveBinding());
@@ -6694,7 +6681,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// int y;
// };
public void testScopeOfClassMember_259460() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("B b", 1, ICPPClassType.class);
ba.assertProblem("B p", 1);
ba.assertProblem("B method", 1);
@@ -6713,7 +6700,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// };
// };
public void testScopeOfClassMember_259648() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("GREEN)", 5, IEnumerator.class);
ba.assertNonProblem("RED;", 3, IEnumerator.class);
ba.assertProblem("GREEN;", 5);
@@ -6731,9 +6718,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// func(*b);
// }
public void testSmartPointerReference_259680() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
- ICPPFunction f1= ba.assertNonProblem("func(*a)", 4, ICPPFunction.class);
- ICPPFunction f2= ba.assertNonProblem("func(*b)", 4, ICPPFunction.class);
+ BindingAssertionHelper ba = getAssertionHelper();
+ ICPPFunction f1 = ba.assertNonProblem("func(*a)", 4, ICPPFunction.class);
+ ICPPFunction f2 = ba.assertNonProblem("func(*b)", 4, ICPPFunction.class);
assertNotSame(f1, f2);
}
@@ -6748,7 +6735,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// ))))))))))))))))))))))))))))));
// }
public void testNestedTemplateIDAmbiguity_259501() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code);
}
@@ -6772,7 +6759,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// (p1 % p2).a; //5
// }
public void testOverloadedBinaryOperator_259927a() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("a; //1", 1, ICPPField.class);
ba.assertNonProblem("a; //2", 1, ICPPField.class);
ba.assertNonProblem("a; //3", 1, ICPPField.class);
@@ -6801,7 +6788,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// (b + i).a; //6
// }
public void testOverloadedBinaryOperator_259927b() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("a; //1", 1, ICPPField.class);
ba.assertNonProblem("a; //2", 1, ICPPField.class);
ba.assertNonProblem("a; //3", 1, ICPPField.class);
@@ -6824,7 +6811,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// (++p1).x; //2
// }
public void testOverloadedUnaryOperator_259927c() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("x; //1", 1, ICPPField.class);
ba.assertNonProblem("x; //2", 1, ICPPField.class);
}
@@ -6841,7 +6828,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// (++p1).x; //2
// }
public void testOverloadedUnaryOperator_259927d() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("x; //1", 1, ICPPField.class);
ba.assertNonProblem("x; //2", 1, ICPPField.class);
}
@@ -6871,9 +6858,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// (~b).xx; // 6
// }
public void testOverloadedUnaryOperator_259927e() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
- for (int i = 1; i <=6; i++)
- ba.assertNonProblem("xx; // "+i, 2, ICPPField.class);
+ BindingAssertionHelper ba = getAssertionHelper();
+ for (int i = 1; i <= 6; i++)
+ ba.assertNonProblem("xx; // " + i, 2, ICPPField.class);
}
// struct A {
@@ -6902,9 +6889,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// (~b).xx; // 6
//}
public void testOverloadedUnaryOperator_259927f() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
for (int i = 1; i <= 6; i++)
- ba.assertNonProblem("xx; // "+i, 2, ICPPField.class);
+ ba.assertNonProblem("xx; // " + i, 2, ICPPField.class);
}
// int a,b,c,d ;
@@ -6921,18 +6908,18 @@ public class AST2CPPTests extends AST2CPPTestBase {
// typedef int S2 (int(t)); // resolve this ambiguity first
// };
public void testOrderOfAmbiguityResolution_259373() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
- ICPPVariable a= ba.assertNonProblem("a;", 1);
+ BindingAssertionHelper ba = getAssertionHelper();
+ ICPPVariable a = ba.assertNonProblem("a;", 1);
assertInstance(a.getType(), IPointerType.class);
- ICPPVariable b= ba.assertNonProblem("b;", 1);
+ ICPPVariable b = ba.assertNonProblem("b;", 1);
assertInstance(b.getType(), IBasicType.class);
- ICPPVariable c= ba.assertNonProblem("c;", 1);
+ ICPPVariable c = ba.assertNonProblem("c;", 1);
assertInstance(c.getType(), IPointerType.class);
- ITypedef s1= (ITypedef) ((IPointerType) c.getType()).getType();
+ ITypedef s1 = (ITypedef) ((IPointerType) c.getType()).getType();
assertInstance(((IFunctionType) s1.getType()).getParameterTypes()[0], IPointerType.class);
- ICPPVariable d= ba.assertNonProblem("d;", 1);
+ ICPPVariable d = ba.assertNonProblem("d;", 1);
assertInstance(d.getType(), IPointerType.class);
- ITypedef s2= (ITypedef) ((IPointerType) d.getType()).getType();
+ ITypedef s2 = (ITypedef) ((IPointerType) d.getType()).getType();
assertInstance(((IFunctionType) s2.getType()).getParameterTypes()[0], IBasicType.class);
}
@@ -6950,20 +6937,20 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testFriendFunctionResolution_86368() throws Exception {
BindingAssertionHelper bh = getAssertionHelper();
- IFunction f1= bh.assertNonProblem("f(int)", 1);
- IFunction f2= bh.assertNonProblem("f(1)", 1);
+ IFunction f1 = bh.assertNonProblem("f(int)", 1);
+ IFunction f2 = bh.assertNonProblem("f(1)", 1);
assertSame(f1, f2);
- IFunction g1= bh.assertNonProblem("g(int)", 1);
- IFunction g2= bh.assertNonProblem("g(1)", 1);
+ IFunction g1 = bh.assertNonProblem("g(int)", 1);
+ IFunction g2 = bh.assertNonProblem("g(1)", 1);
assertSame(g1, g2);
// Alternative binding resolution order.
bh = getAssertionHelper();
- f2= bh.assertNonProblem("f(1)", 1);
- f1= bh.assertNonProblem("f(int)", 1);
+ f2 = bh.assertNonProblem("f(1)", 1);
+ f1 = bh.assertNonProblem("f(int)", 1);
assertSame(f1, f2);
- g2= bh.assertNonProblem("g(1)", 1);
- g1= bh.assertNonProblem("g(int)", 1);
+ g2 = bh.assertNonProblem("g(1)", 1);
+ g1 = bh.assertNonProblem("g(int)", 1);
assertSame(g1, g2);
}
@@ -6980,9 +6967,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// int func(int i) { return i; }
public void testFriendFunction_438114() throws Exception {
BindingAssertionHelper bh = getAssertionHelper();
- ICPPFunction f1= bh.assertNonProblemOnFirstIdentifier("func(int i);");
- ICPPFunction f2= bh.assertNonProblemOnFirstIdentifier("func(int i = 0);");
- ICPPFunction f3= bh.assertNonProblemOnFirstIdentifier("func(int i) {");
+ ICPPFunction f1 = bh.assertNonProblemOnFirstIdentifier("func(int i);");
+ ICPPFunction f2 = bh.assertNonProblemOnFirstIdentifier("func(int i = 0);");
+ ICPPFunction f3 = bh.assertNonProblemOnFirstIdentifier("func(int i) {");
assertSame(f1, f2);
assertSame(f2, f3);
assertEquals(0, f1.getRequiredArgumentCount());
@@ -7014,36 +7001,44 @@ public class AST2CPPTests extends AST2CPPTestBase {
// a.bar();/*8*/
// }
public void testMemberFunctionDisambiguationByCVness_238409() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
-
- ICPPMethod bar_cv= bh.assertNonProblem("bar();/*1*/", 3, ICPPMethod.class);
- ICPPMethod bar_v= bh.assertNonProblem("bar();/*2*/", 3, ICPPMethod.class);
- ICPPMethod bar_c= bh.assertNonProblem("bar();/*3*/", 3, ICPPMethod.class);
- ICPPMethod bar= bh.assertNonProblem("bar();/*4*/", 3, ICPPMethod.class);
- ICPPFunctionType bar_cv_ft= bar_cv.getType();
- ICPPFunctionType bar_v_ft= bar_v.getType();
- ICPPFunctionType bar_c_ft= bar_c.getType();
- ICPPFunctionType bar_ft= bar.getType();
-
- assertTrue(bar_cv_ft.isConst()); assertTrue(bar_cv_ft.isVolatile());
- assertTrue(!bar_v_ft.isConst()); assertTrue(bar_v_ft.isVolatile());
- assertTrue(bar_c_ft.isConst()); assertTrue(!bar_c_ft.isVolatile());
- assertTrue(!bar_ft.isConst()); assertTrue(!bar_ft.isVolatile());
-
- bar_cv= bh.assertNonProblem("bar();/*5*/", 3, ICPPMethod.class);
- bar_v= bh.assertNonProblem("bar();/*6*/", 3, ICPPMethod.class);
- bar_c= bh.assertNonProblem("bar();/*7*/", 3, ICPPMethod.class);
- bar= bh.assertNonProblem("bar();/*8*/", 3, ICPPMethod.class);
- bar_cv_ft= bar_cv.getType();
- bar_v_ft= bar_v.getType();
- bar_c_ft= bar_c.getType();
- bar_ft= bar.getType();
-
- assertTrue(bar_cv_ft.isConst()); assertTrue(bar_cv_ft.isVolatile());
- assertTrue(!bar_v_ft.isConst()); assertTrue(bar_v_ft.isVolatile());
- assertTrue(bar_c_ft.isConst()); assertTrue(!bar_c_ft.isVolatile());
- assertTrue(!bar_ft.isConst()); assertTrue(!bar_ft.isVolatile());
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+
+ ICPPMethod bar_cv = bh.assertNonProblem("bar();/*1*/", 3, ICPPMethod.class);
+ ICPPMethod bar_v = bh.assertNonProblem("bar();/*2*/", 3, ICPPMethod.class);
+ ICPPMethod bar_c = bh.assertNonProblem("bar();/*3*/", 3, ICPPMethod.class);
+ ICPPMethod bar = bh.assertNonProblem("bar();/*4*/", 3, ICPPMethod.class);
+ ICPPFunctionType bar_cv_ft = bar_cv.getType();
+ ICPPFunctionType bar_v_ft = bar_v.getType();
+ ICPPFunctionType bar_c_ft = bar_c.getType();
+ ICPPFunctionType bar_ft = bar.getType();
+
+ assertTrue(bar_cv_ft.isConst());
+ assertTrue(bar_cv_ft.isVolatile());
+ assertTrue(!bar_v_ft.isConst());
+ assertTrue(bar_v_ft.isVolatile());
+ assertTrue(bar_c_ft.isConst());
+ assertTrue(!bar_c_ft.isVolatile());
+ assertTrue(!bar_ft.isConst());
+ assertTrue(!bar_ft.isVolatile());
+
+ bar_cv = bh.assertNonProblem("bar();/*5*/", 3, ICPPMethod.class);
+ bar_v = bh.assertNonProblem("bar();/*6*/", 3, ICPPMethod.class);
+ bar_c = bh.assertNonProblem("bar();/*7*/", 3, ICPPMethod.class);
+ bar = bh.assertNonProblem("bar();/*8*/", 3, ICPPMethod.class);
+ bar_cv_ft = bar_cv.getType();
+ bar_v_ft = bar_v.getType();
+ bar_c_ft = bar_c.getType();
+ bar_ft = bar.getType();
+
+ assertTrue(bar_cv_ft.isConst());
+ assertTrue(bar_cv_ft.isVolatile());
+ assertTrue(!bar_v_ft.isConst());
+ assertTrue(bar_v_ft.isVolatile());
+ assertTrue(bar_c_ft.isConst());
+ assertTrue(!bar_c_ft.isVolatile());
+ assertTrue(!bar_ft.isConst());
+ assertTrue(!bar_ft.isVolatile());
}
// void test1(float f);
@@ -7059,7 +7054,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// test2(e1);
// }
public void testOverloadResolution_262191() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code);
}
@@ -7073,7 +7068,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// select (int (h) + 1);
// }
public void testSimpleTypeConstructorExpressions() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code);
}
@@ -7086,7 +7081,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(a());
// }
public void testBug263152a() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertProblem("f(a())", 1);
}
@@ -7102,7 +7097,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// p.m(a());
// }
public void testBug263152b() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("m(a())", 1, ICPPMethod.class);
}
@@ -7113,7 +7108,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
// };
public void _testInstanceMemberInStaticMethod_263154() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertProblem("a =", 1);
}
@@ -7132,28 +7127,28 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testAmbiguityResolutionInCondition_263158() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper ba= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, true);
ba.assertNonProblem("A*", 1, ICPPClassType.class);
ba.assertNonProblem("a", 1, ICPPVariable.class);
ba.assertNonProblem("B*", 1, ICPPVariable.class);
parseAndCheckBindings(code, CPP);
}
-
+
// typedef struct xx{} type;
// void test(void* ptr) {
// delete (type)(ptr);
// }
public void testAmbiguityResolutionInDeleteExpression_428922() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper ba= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, true);
ba.assertNonProblem("type)", 4, ITypedef.class);
ba.assertNonProblem("ptr);", 3, ICPPVariable.class);
IASTTranslationUnit tu = parseAndCheckBindings(code, CPP);
- ICPPASTFunctionDefinition test= getDeclaration(tu, 1);
- IASTExpressionStatement stmt= getStatement(test, 0);
- ICPPASTDeleteExpression dexpr= (ICPPASTDeleteExpression) stmt.getExpression();
+ ICPPASTFunctionDefinition test = getDeclaration(tu, 1);
+ IASTExpressionStatement stmt = getStatement(test, 0);
+ ICPPASTDeleteExpression dexpr = (ICPPASTDeleteExpression) stmt.getExpression();
assertTrue(dexpr.getOperand() instanceof ICPPASTCastExpression);
}
@@ -7166,7 +7161,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(s);
// }
public void testPointerToNonPointerConversion_263159() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertProblem("f(p)", 1);
ba.assertProblem("f(q)", 1);
ba.assertProblem("f(r)", 1);
@@ -7183,7 +7178,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// fia(0);
// }
public void testNonPointerToPointerConversion_263707() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertProblem("fip(1)", 3);
ba.assertProblem("fia(1)", 3);
ba.assertNonProblem("fip(0)", 3, ICPPFunction.class);
@@ -7199,7 +7194,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// reset(new cl[1]);
// }
public void testTypeOfNewExpression_264163() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code, CPP);
}
@@ -7214,7 +7209,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testConstructorTemplateInImplicitConversion_264314() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper ba= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, true);
ba.assertNonProblem("onRange(ir)", 7);
parseAndCheckBindings(code, CPP);
}
@@ -7234,10 +7229,10 @@ public class AST2CPPTests extends AST2CPPTestBase {
// CT<pcpi2> ct2;
public void testConstTypedef_264474() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper ba= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, true);
ba.assertNonProblem("check(p2)", 5);
- IBinding ct1= ba.assertNonProblem("CT<pcpi>", 8);
- IBinding ct2= ba.assertNonProblem("CT<pcpi2>", 9);
+ IBinding ct1 = ba.assertNonProblem("CT<pcpi>", 8);
+ IBinding ct2 = ba.assertNonProblem("CT<pcpi2>", 9);
assertSame(ct1, ct2);
parseAndCheckBindings(code, CPP);
@@ -7281,7 +7276,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testMemberPtrs_264479() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper ba= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, true);
ba.assertNonProblem("mpr(&X::f)", 3);
ba.assertNonProblem("mpr(&X::m)", 3);
ba.assertNonProblem("mprc(&X::cm)", 4);
@@ -7305,7 +7300,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(!p);
// }
public void testTypeOfNotExpression_265779() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("f(!p)", 1);
}
@@ -7458,14 +7453,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testPointerToArrayWithDefaultVal_267184() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper ba= new AST2AssertionHelper(code, true);
- ICPPParameter p= ba.assertNonProblem("names", 5);
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, true);
+ ICPPParameter p = ba.assertNonProblem("names", 5);
assertTrue(p.hasDefaultValue());
- IType t= p.getType();
- assertInstance(t, IPointerType.class); // parameter of type array is converted to pointer
- t= ((IPointerType) t).getType();
+ IType t = p.getType();
+ assertInstance(t, IPointerType.class); // parameter of type array is converted to pointer
+ t = ((IPointerType) t).getType();
assertInstance(t, IPointerType.class);
- t= ((IPointerType) t).getType();
+ t = ((IPointerType) t).getType();
assertInstance(t, IBasicType.class);
parseAndCheckBindings(code, CPP);
@@ -7477,15 +7472,15 @@ public class AST2CPPTests extends AST2CPPTestBase {
// };
public void testPureVirtualVsInitDeclarator_267184() throws Exception {
final String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code, CPP);
- ICPPASTCompositeTypeSpecifier ct= getCompositeType(tu, 0);
- IASTSimpleDeclaration sdecl= getDeclaration(ct, 0);
- ICPPASTFunctionDeclarator dtor= (ICPPASTFunctionDeclarator) sdecl.getDeclarators()[0];
+ IASTTranslationUnit tu = parseAndCheckBindings(code, CPP);
+ ICPPASTCompositeTypeSpecifier ct = getCompositeType(tu, 0);
+ IASTSimpleDeclaration sdecl = getDeclaration(ct, 0);
+ ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) sdecl.getDeclarators()[0];
assertTrue(dtor.isPureVirtual());
assertNull(dtor.getInitializer());
- sdecl= getDeclaration(ct, 1);
- dtor= (ICPPASTFunctionDeclarator) sdecl.getDeclarators()[0];
+ sdecl = getDeclaration(ct, 1);
+ dtor = (ICPPASTFunctionDeclarator) sdecl.getDeclarators()[0];
assertFalse(dtor.isPureVirtual());
assertNotNull(dtor.getInitializer());
@@ -7553,7 +7548,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// (x + 1.0).b; //3
// }
public void testOverloadResolutionForOperators_266211() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("a; //1", 1, ICPPField.class);
ba.assertNonProblem("a; //2", 1, ICPPField.class);
ba.assertNonProblem("b; //3", 1, ICPPField.class);
@@ -7573,7 +7568,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// (x + 1.0).a; //2
// }
public void testOverloadResolutionForOperators_268534() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("a; //1", 1, ICPPField.class);
ba.assertNonProblem("a; //2", 1, ICPPField.class);
}
@@ -7587,7 +7582,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// test(c);
// }
public void testInvalidUserDefinedConversion_269729() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertProblem("test(c)", 4);
}
@@ -7612,7 +7607,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertSame(col.getName(4).resolveBinding(), col.getName(11).resolveBinding());
assertSame(col.getName(6).resolveBinding(), col.getName(12).resolveBinding());
}
-
+
// auto L = L"";
// auto u8 = u8"";
// auto u = u"";
@@ -7651,16 +7646,16 @@ public class AST2CPPTests extends AST2CPPTestBase {
// struct A;
// A a;
public void testForwardDeclarationAfterUsing_271236() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertNonProblem("A a;", 1, ICPPClassType.class);
}
// template <class T> class Moo;
// bool getFile(Moo <class Foo> & res);
public void testScopeOfClassFwdDecl_270831() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
- ICPPClassType t= ba.assertNonProblem("Foo", 3, ICPPClassType.class);
- IScope scope= t.getScope();
+ BindingAssertionHelper ba = getAssertionHelper();
+ ICPPClassType t = ba.assertNonProblem("Foo", 3, ICPPClassType.class);
+ IScope scope = t.getScope();
assertEquals(EScopeKind.eGlobal, scope.getKind());
}
@@ -7680,13 +7675,13 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testDerivedToBaseConversion_269318() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper ba= new AST2AssertionHelper(code, true);
- ICPPFunction t= ba.assertNonProblem("test(d1);", 4, ICPPFunction.class);
- ICPPClassType ct= (ICPPClassType) t.getParameters()[0].getType();
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, true);
+ ICPPFunction t = ba.assertNonProblem("test(d1);", 4, ICPPFunction.class);
+ ICPPClassType ct = (ICPPClassType) t.getParameters()[0].getType();
assertEquals("C", ct.getName());
- t= ba.assertNonProblem("test(d2);", 4, ICPPFunction.class);
- ct= (ICPPClassType) t.getParameters()[0].getType();
+ t = ba.assertNonProblem("test(d2);", 4, ICPPFunction.class);
+ ct = (ICPPClassType) t.getParameters()[0].getType();
assertEquals("C", ct.getName());
parseAndCheckBindings(code, CPP);
@@ -7713,15 +7708,15 @@ public class AST2CPPTests extends AST2CPPTestBase {
// };
public void testDeclarationAmbiguity_269953() throws Exception {
final String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code, CPP);
- ICPPASTCompositeTypeSpecifier ct= getCompositeType(tu, 1);
- ICPPClassType c= (ICPPClassType) ct.getName().resolveBinding();
+ IASTTranslationUnit tu = parseAndCheckBindings(code, CPP);
+ ICPPASTCompositeTypeSpecifier ct = getCompositeType(tu, 1);
+ ICPPClassType c = (ICPPClassType) ct.getName().resolveBinding();
- ICPPMethod[] methods= c.getDeclaredMethods();
+ ICPPMethod[] methods = c.getDeclaredMethods();
assertEquals(1, methods.length);
assertEquals("C", methods[0].getName());
- ICPPField[] fields= c.getDeclaredFields();
+ ICPPField[] fields = c.getDeclaredFields();
assertEquals(1, fields.length);
assertEquals("s", fields[0].getName());
}
@@ -7785,11 +7780,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testNestedOverloadedFunctionCalls_283324() throws Exception {
final String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code, CPP);
- IASTFunctionDefinition test= getDeclaration(tu, 1);
- IASTExpressionStatement stmt= getStatement(test, 1);
- long now= System.currentTimeMillis();
- IType t= stmt.getExpression().getExpressionType();
+ IASTTranslationUnit tu = parseAndCheckBindings(code, CPP);
+ IASTFunctionDefinition test = getDeclaration(tu, 1);
+ IASTExpressionStatement stmt = getStatement(test, 1);
+ long now = System.currentTimeMillis();
+ IType t = stmt.getExpression().getExpressionType();
assertInstance(t, ICPPClassType.class);
assertTrue(stmt.getExpression().isLValue());
final long time = System.currentTimeMillis() - now;
@@ -7821,7 +7816,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(l1);
// }
public void testEnumToIntConversion_285368() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ICPPFunction f1 = ba.assertNonProblem("f(i1)", 1, ICPPFunction.class);
IType t1 = f1.getType().getParameterTypes()[0];
assertTrue(t1 instanceof ICPPBasicType);
@@ -7852,7 +7847,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(i3);
// }
public void testCastInEnumeratorValue_446380() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
IEnumerator i2 = ba.assertNonProblem("i2", IEnumerator.class);
Number v2 = i2.getValue().numberValue();
assertNotNull(v2);
@@ -7861,7 +7856,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
Number v3 = i3.getValue().numberValue();
assertNotNull(v3);
assertEquals(2, v3.intValue());
- ICPPFunction f = ba.assertNonProblemOnFirstIdentifier("f(i3)",ICPPFunction.class);
+ ICPPFunction f = ba.assertNonProblemOnFirstIdentifier("f(i3)", ICPPFunction.class);
IType t = f.getType().getParameterTypes()[0];
// The declared types of the enum values don't affect the underlying type of the enum,
// only the values themselves do.
@@ -7870,7 +7865,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// typedef enum enum_name enum_name;
public void testTypedefRecursion_285457() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ba.assertProblem("enum_name", 9);
}
@@ -7908,7 +7903,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testTypeLookupWithMultipleInheritance_286213() throws Exception {
parseAndCheckBindings();
}
-
+
// template<class>
// struct ContainerOf {
// int numParts;
@@ -7938,14 +7933,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
// };
// const int X::v7= 1;
public void testVariableDefVsDecl_286259() throws Exception {
- String[] declNames= {"v3"};
- String[] defNames= {"v1", "v2", "v4", "v5", "X::v7"};
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), CPP);
+ String[] declNames = { "v3" };
+ String[] defNames = { "v1", "v2", "v4", "v5", "X::v7" };
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), CPP);
checkDeclDef(declNames, defNames, tu.getDeclarations());
- declNames= new String[] {"v7", "v8"};
- defNames= new String[] {"v6"};
- IASTCompositeTypeSpecifier cls= getCompositeType(tu, 5);
+ declNames = new String[] { "v7", "v8" };
+ defNames = new String[] { "v6" };
+ IASTCompositeTypeSpecifier cls = getCompositeType(tu, 5);
checkDeclDef(declNames, defNames, cls.getMembers());
}
@@ -7955,14 +7950,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
// };
// const int X::v2;
public void testVariableDefVsDecl_292635() throws Exception {
- String[] declNames= {"v1"};
- String[] defNames= {"X::v2"};
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), CPP);
+ String[] declNames = { "v1" };
+ String[] defNames = { "X::v2" };
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), CPP);
checkDeclDef(declNames, defNames, tu.getDeclarations());
- declNames= new String[] {"v2"};
- defNames= new String[] {};
- IASTCompositeTypeSpecifier cls= getCompositeType(tu, 1);
+ declNames = new String[] { "v2" };
+ defNames = new String[] {};
+ IASTCompositeTypeSpecifier cls = getCompositeType(tu, 1);
checkDeclDef(declNames, defNames, cls.getMembers());
}
@@ -7975,22 +7970,22 @@ public class AST2CPPTests extends AST2CPPTestBase {
final String code = getAboveComment();
parseAndCheckBindings(code, CPP);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- ICPPClassType S= bh.assertNonProblem("S*", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ ICPPClassType S = bh.assertNonProblem("S*", 1);
assertNull(S.getOwner());
- ICPPClassType X= bh.assertNonProblem("X {", 1);
- ICPPClassType T= bh.assertNonProblem("T;", 1);
+ ICPPClassType X = bh.assertNonProblem("X {", 1);
+ ICPPClassType T = bh.assertNonProblem("T;", 1);
assertSame(X, T.getOwner());
- T= bh.assertNonProblem("T* m2", 1);
+ T = bh.assertNonProblem("T* m2", 1);
assertSame(X, T.getOwner());
}
// class ULONGLONG {
// public :
// ULONGLONG (unsigned long long val) {}
- // friend ULONGLONG operator ~ (const ULONGLONG &) { return 0; }
+ // friend ULONGLONG operator ~ (const ULONGLONG &) { return 0; }
// };
//
// int main() {
@@ -7998,10 +7993,10 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testNonUserdefinedOperator_291409b() throws Exception {
final String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code, CPP);
- IASTFunctionDefinition def= getDeclaration(tu, 1);
- IASTReturnStatement rstmt= getStatement(def, 0);
- IASTImplicitNameOwner expr= (IASTImplicitNameOwner) rstmt.getReturnValue();
+ IASTTranslationUnit tu = parseAndCheckBindings(code, CPP);
+ IASTFunctionDefinition def = getDeclaration(tu, 1);
+ IASTReturnStatement rstmt = getStatement(def, 0);
+ IASTImplicitNameOwner expr = (IASTImplicitNameOwner) rstmt.getReturnValue();
assertEquals(0, expr.getImplicitNames().length);
}
@@ -8016,8 +8011,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testMethodTemplateWithSameName_292051() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code, CPP);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- ICPPMethod m= bh.assertNonProblem("t<1>", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ ICPPMethod m = bh.assertNonProblem("t<1>", 1);
assertTrue(m.isInline());
}
@@ -8086,7 +8081,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testUserDefinedConversion_222444c() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("foo(c);", 3);
bh.assertProblem("foo(cc);", 3);
}
@@ -8102,10 +8097,10 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testInvalidOverload_291409() throws Exception {
final String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code, CPP);
- IASTFunctionDefinition fdef= getDeclaration(tu, 2);
- IASTReturnStatement stmt= getStatement(fdef, 0);
- IASTImplicitNameOwner no= (IASTImplicitNameOwner) stmt.getReturnValue();
+ IASTTranslationUnit tu = parseAndCheckBindings(code, CPP);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 2);
+ IASTReturnStatement stmt = getStatement(fdef, 0);
+ IASTImplicitNameOwner no = (IASTImplicitNameOwner) stmt.getReturnValue();
assertEquals(0, no.getImplicitNames().length);
}
@@ -8135,7 +8130,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testLookupInConstructorChainInitializer_293566() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("B>(1)", 1);
parseAndCheckBindings(code, CPP);
}
@@ -8165,21 +8160,21 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testFunctionDeclViaTypedef_86495() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code, CPP);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
- ICPPFunctionTemplate template= bh.assertNonProblem("functionTemplate", 16);
+ ICPPFunctionTemplate template = bh.assertNonProblem("functionTemplate", 16);
assertNotNull(template.getType());
assertEquals(1, template.getParameters().length);
- ICPPMethod method= bh.assertNonProblem("method", 6);
+ ICPPMethod method = bh.assertNonProblem("method", 6);
assertNotNull(method.getType());
assertEquals(1, method.getParameters().length);
- ICPPFunction friendFunction= bh.assertNonProblem("friendFunction", 14);
+ ICPPFunction friendFunction = bh.assertNonProblem("friendFunction", 14);
assertNotNull(friendFunction.getType());
assertEquals(1, friendFunction.getParameters().length);
- ICPPMethod methodTemplate= bh.assertNonProblem("methodTemplate", 14);
+ ICPPMethod methodTemplate = bh.assertNonProblem("methodTemplate", 14);
assertTrue(methodTemplate instanceof ICPPFunctionTemplate);
assertNotNull(methodTemplate.getType());
assertEquals(1, methodTemplate.getParameters().length);
@@ -8308,34 +8303,34 @@ public class AST2CPPTests extends AST2CPPTestBase {
// foo(source_const_rvalue_ref()); // #1
// }
public void testRValueReference_294730() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IBinding foo1= bh.assertNonProblem("foo(const A&)", 3);
- IBinding foo2= bh.assertNonProblem("foo(A&&)", 3);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IBinding foo1 = bh.assertNonProblem("foo(const A&)", 3);
+ IBinding foo2 = bh.assertNonProblem("foo(A&&)", 3);
IBinding b;
- b= bh.assertNonProblem("foo(a)", 3);
+ b = bh.assertNonProblem("foo(a)", 3);
assertSame(b, foo1);
- b= bh.assertNonProblem("foo(ra)", 3);
+ b = bh.assertNonProblem("foo(ra)", 3);
assertSame(b, foo1);
- b= bh.assertNonProblem("foo(rra)", 3);
+ b = bh.assertNonProblem("foo(rra)", 3);
assertSame(b, foo1);
- b= bh.assertNonProblem("foo(ca)", 3);
+ b = bh.assertNonProblem("foo(ca)", 3);
assertSame(b, foo1);
- b= bh.assertNonProblem("foo(rca)", 3);
+ b = bh.assertNonProblem("foo(rca)", 3);
assertSame(b, foo1);
- b= bh.assertNonProblem("foo(rrca)", 3);
+ b = bh.assertNonProblem("foo(rrca)", 3);
assertSame(b, foo1);
- b= bh.assertNonProblem("foo(source_rvalue())", 3);
+ b = bh.assertNonProblem("foo(source_rvalue())", 3);
assertSame(b, foo2);
- b= bh.assertNonProblem("foo(source_ref())", 3);
+ b = bh.assertNonProblem("foo(source_ref())", 3);
assertSame(b, foo1);
- b= bh.assertNonProblem("foo(source_rvalue_ref())", 3);
+ b = bh.assertNonProblem("foo(source_rvalue_ref())", 3);
assertSame(b, foo2);
- b= bh.assertNonProblem("foo(source_const_rvalue())", 3);
+ b = bh.assertNonProblem("foo(source_const_rvalue())", 3);
assertSame(b, foo1);
- b= bh.assertNonProblem("foo(source_const_ref())", 3);
+ b = bh.assertNonProblem("foo(source_const_ref())", 3);
assertSame(b, foo1);
- b= bh.assertNonProblem("foo(source_const_rvalue_ref())", 3);
+ b = bh.assertNonProblem("foo(source_const_rvalue_ref())", 3);
assertSame(b, foo1);
}
@@ -8348,18 +8343,18 @@ public class AST2CPPTests extends AST2CPPTestBase {
// RRI& r4 = i; // r4 has the type int&
// RRI&& r5 = i; // r5 has the type int&&
public void testRValueReferenceTypedefs_294730() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
IVariable v;
- v= bh.assertNonProblem("r1", 2);
+ v = bh.assertNonProblem("r1", 2);
assertEquals("int &", ASTTypeUtil.getType(v.getType()));
- v= bh.assertNonProblem("r2", 2);
+ v = bh.assertNonProblem("r2", 2);
assertEquals("int &", ASTTypeUtil.getType(v.getType()));
- v= bh.assertNonProblem("r3", 2);
+ v = bh.assertNonProblem("r3", 2);
assertEquals("int &", ASTTypeUtil.getType(v.getType()));
- v= bh.assertNonProblem("r4", 2);
+ v = bh.assertNonProblem("r4", 2);
assertEquals("int &", ASTTypeUtil.getType(v.getType()));
- v= bh.assertNonProblem("r5", 2);
+ v = bh.assertNonProblem("r5", 2);
assertEquals("int &&", ASTTypeUtil.getType(v.getType()));
}
@@ -8395,8 +8390,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// cdref(cvd); // error: type qualifiers dropped
// }
public void testDirectBinding_294730() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("dref(d)", 4);
bh.assertNonProblem("cdref(d)", 5);
bh.assertNonProblem("aref(b)", 4);
@@ -8420,7 +8415,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// test(s());
// }
public void testSpecialRuleForImplicitObjectType_294730() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code, CPP);
}
@@ -8477,10 +8472,10 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testInitOfClassObjectsByRValues_294730() throws Exception {
final CharSequence[] contents = getContents(3);
- final String code= contents[0].toString();
- final String end= contents[2].toString();
+ final String code = contents[0].toString();
+ final String end = contents[2].toString();
parseAndCheckBindings(code + end, CPP);
- BindingAssertionHelper bh= new AST2AssertionHelper(code + contents[1] + end, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code + contents[1] + end, true);
bh.assertProblem("sink3(source())", 5);
bh.assertProblem("sink3(csource())", 5);
bh.assertProblem("sink3(z7)", 5);
@@ -8502,7 +8497,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// check(c+a);
// }
public void testADLForOperators_296906() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code, CPP);
}
@@ -8518,16 +8513,16 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(a, 1); // calls ns::f(ns::A, char)
// }
public void testADL_299101() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code, CPP);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction inns= bh.assertNonProblem("f(ns::A, char)", 1);
- IFunction glob= bh.assertNonProblem("f(ns::A, int)", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction inns = bh.assertNonProblem("f(ns::A, char)", 1);
+ IFunction glob = bh.assertNonProblem("f(ns::A, int)", 1);
- IBinding b= bh.assertNonProblem("f(a, '1')", 1);
+ IBinding b = bh.assertNonProblem("f(a, '1')", 1);
assertSame(b, inns);
- b= bh.assertNonProblem("f(a, 1)", 1);
+ b = bh.assertNonProblem("f(a, 1)", 1);
assertSame(b, glob);
}
@@ -8545,25 +8540,25 @@ public class AST2CPPTests extends AST2CPPTestBase {
// __typeof((a->x)) t8(); // type is const double
public void testDecltype_294730() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code, CPP);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction f= bh.assertNonProblem("t1", 2);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction f = bh.assertNonProblem("t1", 2);
assertEquals("const int &&", ASTTypeUtil.getType(f.getType().getReturnType()));
- f= bh.assertNonProblem("t2", 2);
+ f = bh.assertNonProblem("t2", 2);
assertEquals("int", ASTTypeUtil.getType(f.getType().getReturnType()));
- f= bh.assertNonProblem("t3", 2);
+ f = bh.assertNonProblem("t3", 2);
assertEquals("double", ASTTypeUtil.getType(f.getType().getReturnType()));
- f= bh.assertNonProblem("t4", 2);
+ f = bh.assertNonProblem("t4", 2);
assertEquals("const double &", ASTTypeUtil.getType(f.getType().getReturnType()));
- f= bh.assertNonProblem("t5", 2);
+ f = bh.assertNonProblem("t5", 2);
assertEquals("const int", ASTTypeUtil.getType(f.getType().getReturnType()));
- f= bh.assertNonProblem("t6", 2);
+ f = bh.assertNonProblem("t6", 2);
assertEquals("int", ASTTypeUtil.getType(f.getType().getReturnType()));
- f= bh.assertNonProblem("t7", 2);
+ f = bh.assertNonProblem("t7", 2);
assertEquals("const double", ASTTypeUtil.getType(f.getType().getReturnType()));
- f= bh.assertNonProblem("t8", 2);
+ f = bh.assertNonProblem("t8", 2);
assertEquals("const double", ASTTypeUtil.getType(f.getType().getReturnType()));
}
@@ -8580,7 +8575,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testDecltypeInNameQualifier_380751() throws Exception {
parseAndCheckBindings();
}
-
+
// struct Base {};
// struct Derived : decltype(Base()) {};
public void testDecltypeInBaseSpecifier_438348() throws Exception {
@@ -8623,8 +8618,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// auto bar = [foo] { return foo; };
public void testLambdaWithCapture_446225() throws Exception {
BindingAssertionHelper bh = getAssertionHelper();
- ICPPVariable foo1= bh.assertNonProblemOnFirstIdentifier("foo =", ICPPVariable.class);
- ICPPVariable foo2= bh.assertNonProblemOnFirstIdentifier("[foo]", ICPPVariable.class);
+ ICPPVariable foo1 = bh.assertNonProblemOnFirstIdentifier("foo =", ICPPVariable.class);
+ ICPPVariable foo2 = bh.assertNonProblemOnFirstIdentifier("[foo]", ICPPVariable.class);
assertTrue(foo1 == foo2);
assertEquals(2, bh.getTranslationUnit().getReferences(foo1).length);
}
@@ -8741,8 +8736,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// g({ "foo", "bar" }); // OK, uses #3
// }
public void testListInitialization_302412b() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("f({1,2,3})", 1);
bh.assertNonProblem("f({'a','b'})", 1);
bh.assertProblem("f({1.0})", 1);
@@ -8791,8 +8786,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// x({x1}); // no matching constructor
// }
public void testListInitialization_302412c() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("e({ 'a', 'b' })", 1);
bh.assertNonProblem("g({ 'a', 'b' })", 1);
bh.assertProblem("g({ 1.0, 1.0 })", 1);
@@ -8815,8 +8810,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f({1.0}); // narrowing not detected by cdt.
// }
public void testListInitialization_302412d() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("f({'a', 'b'})", 1);
// not detected by CDT
// bh.assertProblem("f({1.0})", 1);
@@ -8835,8 +8830,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// h({ }); // OK: identity conversion
// }
public void testListInitialization_302412e() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
// not detected by CDT
// bh.assertProblem("g({1})", 1);
bh.assertNonProblem("h({'a'})", 1);
@@ -8871,7 +8866,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// fH({1}); // H(G(1))
// }
public void testListInitialization_302412f() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
bh.assertProblem("f({1,1})", 1);
bh.assertImplicitName("F({1,1})", 1, ICPPConstructor.class);
bh.assertNonProblem("fF({1,1})", 2);
@@ -8880,8 +8875,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
bh.assertNonProblem("fG({1})", 2);
bh.assertImplicitName("H(1)", 1, ICPPConstructor.class);
- IASTImplicitName n= bh.assertImplicitName("H({1})", 1, IProblemBinding.class);
- IProblemBinding problem= (IProblemBinding) n.resolveBinding();
+ IASTImplicitName n = bh.assertImplicitName("H({1})", 1, IProblemBinding.class);
+ IProblemBinding problem = (IProblemBinding) n.resolveBinding();
assertEquals(IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, problem.getID());
bh.assertProblem("fH(1)", 2);
bh.assertNonProblem("fH({1})", 2);
@@ -8901,7 +8896,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testListInitialization_439477a() throws Exception {
parseAndCheckBindings();
}
-
+
// void waldo(int const (&)[2]);
// void waldo(int const (&)[3]);
// void foo1() {
@@ -8911,19 +8906,19 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testListInitialization_439477b() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
-
+
ICPPFunction def1 = helper.assertNonProblem("waldo(int const (&)[2])", "waldo");
ICPPFunction def2 = helper.assertNonProblem("waldo(int const (&)[3])", "waldo");
-
+
ICPPFunction call1 = helper.assertNonProblem("waldo({1, 2})", "waldo");
ICPPFunction call2 = helper.assertNonProblem("waldo({1, 2, 3})", "waldo");
-
+
assertEquals(call1, def1);
assertEquals(call2, def2);
-
+
helper.assertProblem("waldo({1, 2, 3, 4})", "waldo", IProblemBinding.SEMANTIC_NAME_NOT_FOUND);
}
-
+
// namespace std {
// template<class E>
// class initializer_list {
@@ -8943,7 +8938,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// int b;
// };
//
- // A<B> waldo({{0}, {0}});
+ // A<B> waldo({{0}, {0}});
public void testListInitialization_458679() throws Exception {
parseAndCheckImplicitNameBindings();
}
@@ -8991,7 +8986,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertTrue(binding instanceof ICPPConstructor);
assertEquals(2, ((ICPPConstructor) binding).getType().getParameterTypes().length);
}
-
+
// struct S {
// int a;
// float b;
@@ -9028,29 +9023,29 @@ public class AST2CPPTests extends AST2CPPTestBase {
// auto x; // Error - missing initializer.
// auto y = { 1.0, 5 }; // Error - inconsistent types in the array initializer.
public void testAutoType_289542() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- ICPPVariable b= bh.assertNonProblem("b =", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ ICPPVariable b = bh.assertNonProblem("b =", 1);
assertEquals("A", ASTTypeUtil.getType(b.getType()));
- ICPPVariable c= bh.assertNonProblem("c(a)", "c");
+ ICPPVariable c = bh.assertNonProblem("c(a)", "c");
assertEquals("A", ASTTypeUtil.getType(c.getType()));
- ICPPVariable p= bh.assertNonProblem("p =", 1);
+ ICPPVariable p = bh.assertNonProblem("p =", 1);
assertEquals("const A *", ASTTypeUtil.getType(p.getType()));
- ICPPVariable q= bh.assertNonProblem("q =", 1);
+ ICPPVariable q = bh.assertNonProblem("q =", 1);
assertEquals("const char * const", ASTTypeUtil.getType(q.getType()));
- ICPPVariable d= bh.assertNonProblem("d =", 1);
+ ICPPVariable d = bh.assertNonProblem("d =", 1);
assertEquals("double", ASTTypeUtil.getType(d.getType()));
- ICPPVariable r= bh.assertNonProblem("r =", 1);
+ ICPPVariable r = bh.assertNonProblem("r =", 1);
assertEquals("std::initializer_list<char>", ASTTypeUtil.getType(r.getType()));
- ICPPVariable s= bh.assertNonProblem("s =", 1);
+ ICPPVariable s = bh.assertNonProblem("s =", 1);
assertEquals("long int *", ASTTypeUtil.getType(s.getType()));
- ICPPVariable t= bh.assertNonProblem("t =", 1);
+ ICPPVariable t = bh.assertNonProblem("t =", 1);
assertEquals("std::initializer_list<double> *", ASTTypeUtil.getType(t.getType()));
- ICPPVariable x= bh.assertNonProblem("x;", 1);
- IProblemType pt= (IProblemType) x.getType();
+ ICPPVariable x = bh.assertNonProblem("x;", 1);
+ IProblemType pt = (IProblemType) x.getType();
assertEquals(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE, pt.getID());
- ICPPVariable y= bh.assertNonProblem("y =", 1);
- pt= (IProblemType) y.getType();
+ ICPPVariable y = bh.assertNonProblem("y =", 1);
+ pt = (IProblemType) y.getType();
assertEquals(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE, pt.getID());
}
@@ -9062,35 +9057,35 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testAutoType_305970() throws Exception {
BindingAssertionHelper bh = getAssertionHelper();
- ICPPVariable x= bh.assertNonProblem("x =", 1, ICPPVariable.class);
- IProblemType xt= (IProblemType) x.getType();
+ ICPPVariable x = bh.assertNonProblem("x =", 1, ICPPVariable.class);
+ IProblemType xt = (IProblemType) x.getType();
assertEquals(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE, xt.getID());
- ICPPVariable a= bh.assertNonProblem("a :", "a", ICPPVariable.class);
- IProblemType at= (IProblemType) a.getType();
+ ICPPVariable a = bh.assertNonProblem("a :", "a", ICPPVariable.class);
+ IProblemType at = (IProblemType) a.getType();
assertEquals(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE, at.getID());
}
// struct A { auto a = 1; }; // Auto-typed non-static fields are not allowed.
// struct B { static auto b = 1; }; // Auto-typed static fields are ok.
public void testAutoType_305987() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- ICPPVariable a= bh.assertNonProblem("a =", 1);
- IProblemType pt= (IProblemType) a.getType();
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ ICPPVariable a = bh.assertNonProblem("a =", 1);
+ IProblemType pt = (IProblemType) a.getType();
assertEquals(ISemanticProblem.TYPE_AUTO_FOR_NON_STATIC_FIELD, pt.getID());
- ICPPVariable b= bh.assertNonProblem("b =", 1);
+ ICPPVariable b = bh.assertNonProblem("b =", 1);
}
// auto fpif1(int)->int(*)(int)
// auto fpif2(int)->int(*)(int) {}
public void testNewFunctionDeclaratorSyntax_305972() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
- ICPPFunction f= bh.assertNonProblem("fpif1", 0);
+ ICPPFunction f = bh.assertNonProblem("fpif1", 0);
assertEquals("int (* (int))(int)", ASTTypeUtil.getType(f.getType()));
- f= bh.assertNonProblem("fpif2", 0);
+ f = bh.assertNonProblem("fpif2", 0);
assertEquals("int (* (int))(int)", ASTTypeUtil.getType(f.getType()));
}
@@ -9101,49 +9096,49 @@ public class AST2CPPTests extends AST2CPPTestBase {
// enum EUnscoped2 : long {b2};
// enum EUnscoped3 : int;
public void testScopedEnums_305975a() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPEnumeration e;
ICPPBinding ei;
- e= bh.assertNonProblem("EScoped1", 0);
+ e = bh.assertNonProblem("EScoped1", 0);
assertTrue(e.isScoped());
assertEquals("int", ASTTypeUtil.getType(e.getFixedType()));
assertDefinition(e);
- ei= bh.assertNonProblem("a1", 0);
+ ei = bh.assertNonProblem("a1", 0);
assertSame(e, ei.getOwner());
assertEquals(2, ei.getQualifiedName().length);
- e= bh.assertNonProblem("EScoped2", 0);
+ e = bh.assertNonProblem("EScoped2", 0);
assertTrue(e.isScoped());
assertEquals("short int", ASTTypeUtil.getType(e.getFixedType()));
assertDefinition(e);
- ei= bh.assertNonProblem("a2", 0);
+ ei = bh.assertNonProblem("a2", 0);
assertSame(e, ei.getOwner());
assertEquals(2, ei.getQualifiedName().length);
- e= bh.assertNonProblem("EScoped3", 0);
+ e = bh.assertNonProblem("EScoped3", 0);
assertTrue(e.isScoped());
assertEquals("int", ASTTypeUtil.getType(e.getFixedType()));
assertDeclaration(e);
- e= bh.assertNonProblem("EUnscoped1", 0);
+ e = bh.assertNonProblem("EUnscoped1", 0);
assertFalse(e.isScoped());
assertNull(e.getFixedType());
assertDefinition(e);
- ei= bh.assertNonProblem("b1", 0);
+ ei = bh.assertNonProblem("b1", 0);
assertSame(e, ei.getOwner());
assertEquals(1, ei.getQualifiedName().length);
- e= bh.assertNonProblem("EUnscoped2", 0);
+ e = bh.assertNonProblem("EUnscoped2", 0);
assertFalse(e.isScoped());
assertEquals("long int", ASTTypeUtil.getType(e.getFixedType()));
assertDefinition(e);
- ei= bh.assertNonProblem("b2", 0);
+ ei = bh.assertNonProblem("b2", 0);
assertSame(e, ei.getOwner());
assertEquals(1, ei.getQualifiedName().length);
- e= bh.assertNonProblem("EUnscoped3", 0);
+ e = bh.assertNonProblem("EUnscoped3", 0);
assertFalse(e.isScoped());
assertEquals("int", ASTTypeUtil.getType(e.getFixedType()));
assertDeclaration(e);
@@ -9156,7 +9151,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// enum E1 : int; // OK: E1 is un-scoped, underlying type is int
// enum class F1; // OK: F1 is scoped, underlying type is int
public void testScopedEnums_305975b() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code);
}
@@ -9164,8 +9159,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// enum class F y2 = a; // illegal
// enum E; // illegal
public void testScopedEnums_305975c() throws Exception {
- String code= getAboveComment();
- IASTTranslationUnit tu= parse(code, CPP, true, false);
+ String code = getAboveComment();
+ IASTTranslationUnit tu = parse(code, CPP, true, false);
IASTDeclaration[] decls = tu.getDeclarations();
assertEquals(3, decls.length);
assertInstance(decls[0], IASTProblemDeclaration.class);
@@ -9184,8 +9179,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// fbool(Col::red); // error: no Col to bool conversion
// }
public void testScopedEnums_305975d() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("fCol(Col::red)", 4);
bh.assertProblem("fint(Col::red)", 4);
@@ -9229,8 +9224,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// xl; // error: not in scope
// }
public void testScopedEnums_305975f() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertProblem("high;", -1);
bh.assertProblem("xdir d", -2);
@@ -9243,10 +9238,10 @@ public class AST2CPPTests extends AST2CPPTestBase {
// enum A {e1, e2= e1+2, e3};
// enum B {e1, e2= f(e1)+2, e3};
public void testScopedEnums_305975g() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code);
}
-
+
// typedef int Int;
// struct S {
// enum waldo1 : int;
@@ -9284,12 +9279,12 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testSizeofReference_397342() throws Exception {
parseAndCheckBindings();
}
-
+
// constexpr int waldo = sizeof("cat\b\\\n");
public void testSizeofStringLiteralWithEscapeCharacters_459279() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
ICPPVariable waldo = helper.assertNonProblem("waldo");
- assertConstantValue(7, waldo); // "cat" + backspace + slash + newline + null terminator
+ assertConstantValue(7, waldo); // "cat" + backspace + slash + newline + null terminator
}
// struct A {
@@ -9309,7 +9304,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
long BSize = getSizeAndAlignment(B, nameB).size;
assertEquals(pointerSize, BSize);
}
-
+
// struct waldo {};
public void testSizeofEmptyStruct_457770() throws Exception {
BindingAssertionHelper bh = getAssertionHelper();
@@ -9342,13 +9337,13 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(c32);
// }
public void testNewCharacterTypes_305976() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction f1= bh.assertNonProblem("f(int)", 1);
- IFunction f2= bh.assertNonProblem("f(unsigned int)", 1);
- IBinding b= bh.assertNonProblem("f(c16)", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction f1 = bh.assertNonProblem("f(int)", 1);
+ IFunction f2 = bh.assertNonProblem("f(unsigned int)", 1);
+ IBinding b = bh.assertNonProblem("f(c16)", 1);
assertSame(f1, b);
- b= bh.assertNonProblem("f(c32)", 1);
+ b = bh.assertNonProblem("f(c32)", 1);
assertSame(f2, b);
}
@@ -9380,11 +9375,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(c+1); // converts c to a char and calls operator+(int, int)
// }
public void testBuiltinOperators_294543a() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction fint= bh.assertNonProblem("f(int)", 1);
- IFunction f= bh.assertNonProblem("f(c+1)", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction fint = bh.assertNonProblem("f(int)", 1);
+ IFunction f = bh.assertNonProblem("f(c+1)", 1);
assertSame(fint, f);
}
@@ -9398,11 +9393,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(a= 1); // A cannot be converted to long& here
// }
public void testBuiltinOperators_294543b() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction fA= bh.assertNonProblem("f(A)", 1);
- IFunction f= bh.assertNonProblem("f(a= 1)", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction fA = bh.assertNonProblem("f(A)", 1);
+ IFunction f = bh.assertNonProblem("f(a= 1)", 1);
assertSame(fA, f);
}
@@ -9417,11 +9412,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
// Y* m(Y*);//3
// };
public void testOverrideSimpleCovariance_321617() throws Exception {
- BindingAssertionHelper helper= getAssertionHelper();
- ICPPMethod m0= helper.assertNonProblem("m();//0", 1, ICPPMethod.class);
- ICPPMethod m1= helper.assertNonProblem("m(X*);//1", 1, ICPPMethod.class);
- ICPPMethod m2= helper.assertNonProblem("m();//2", 1, ICPPMethod.class);
- ICPPMethod m3= helper.assertNonProblem("m(Y*);//3", 1, ICPPMethod.class);
+ BindingAssertionHelper helper = getAssertionHelper();
+ ICPPMethod m0 = helper.assertNonProblem("m();//0", 1, ICPPMethod.class);
+ ICPPMethod m1 = helper.assertNonProblem("m(X*);//1", 1, ICPPMethod.class);
+ ICPPMethod m2 = helper.assertNonProblem("m();//2", 1, ICPPMethod.class);
+ ICPPMethod m3 = helper.assertNonProblem("m(Y*);//3", 1, ICPPMethod.class);
assertTrue(ClassTypeHelper.isVirtual(m0));
assertTrue(ClassTypeHelper.isVirtual(m1));
@@ -9440,14 +9435,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertFalse(ClassTypeHelper.isOverrider(m3, m0));
assertFalse(ClassTypeHelper.isOverrider(m3, m1));
- ICPPMethod[] ors= ClassTypeHelper.findOverridden(m0);
+ ICPPMethod[] ors = ClassTypeHelper.findOverridden(m0);
assertEquals(0, ors.length);
- ors= ClassTypeHelper.findOverridden(m1);
+ ors = ClassTypeHelper.findOverridden(m1);
assertEquals(0, ors.length);
- ors= ClassTypeHelper.findOverridden(m2);
+ ors = ClassTypeHelper.findOverridden(m2);
assertEquals(1, ors.length);
assertSame(ors[0], m0);
- ors= ClassTypeHelper.findOverridden(m3);
+ ors = ClassTypeHelper.findOverridden(m3);
assertEquals(0, ors.length);
}
@@ -9470,11 +9465,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testResolutionToFinalOverrider_86654() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
-
+
ICPPMethod actual = helper.assertNonProblem("c.f()", "f");
ICPPMethod expected = helper.assertNonProblem("virtual void f(); // B", "f");
assertEquals(expected, actual);
-
+
actual = helper.assertNonProblem("c.C::f()", "f");
expected = helper.assertNonProblem("virtual void f(); // A", "f");
assertEquals(expected, actual);
@@ -9487,36 +9482,36 @@ public class AST2CPPTests extends AST2CPPTestBase {
// int f(int) = delete;
// auto g() -> int = delete;
public void testDefaultedAndDeletedFunctions_305978() throws Exception {
- String code= getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code);
+ String code = getAboveComment();
+ IASTTranslationUnit tu = parseAndCheckBindings(code);
- ICPPASTFunctionDefinition f= getDeclaration(tu, 1);
+ ICPPASTFunctionDefinition f = getDeclaration(tu, 1);
assertTrue(f.isDefaulted());
assertFalse(f.isDeleted());
- f= getDeclaration(tu, 2);
+ f = getDeclaration(tu, 2);
assertFalse(f.isDefaulted());
assertTrue(f.isDeleted());
- f= getDeclaration(tu, 3);
+ f = getDeclaration(tu, 3);
assertFalse(f.isDefaulted());
assertTrue(f.isDeleted());
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- ICPPFunction fb= bh.assertNonProblem("X() =", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ ICPPFunction fb = bh.assertNonProblem("X() =", 1);
assertFalse(fb.isDeleted());
- fb= bh.assertNonProblem("f(int)", 1);
+ fb = bh.assertNonProblem("f(int)", 1);
assertTrue(fb.isDeleted());
- fb= bh.assertNonProblem("g()", 1);
+ fb = bh.assertNonProblem("g()", 1);
assertTrue(fb.isDeleted());
}
// const int b=12;
// void f(int a= b) = delete ;
public void testDefaultedAndDeletedFunctions_305978b() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code);
}
@@ -9591,17 +9586,17 @@ public class AST2CPPTests extends AST2CPPTestBase {
// ::g(1);
// }
public void testInlineNamespace_305980c() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction fo= bh.assertNonProblem("f(int)", 1);
- IFunction g= bh.assertNonProblem("g(int)", 1);
- IFunction fi= bh.assertNonProblem("f(char)", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction fo = bh.assertNonProblem("f(int)", 1);
+ IFunction g = bh.assertNonProblem("g(int)", 1);
+ IFunction fi = bh.assertNonProblem("f(char)", 1);
- IFunction ref= bh.assertNonProblem("f(1)", 1);
+ IFunction ref = bh.assertNonProblem("f(1)", 1);
assertSame(fi, ref);
- ref= bh.assertNonProblem("g(1)", 1);
+ ref = bh.assertNonProblem("g(1)", 1);
assertSame(g, ref);
}
@@ -9612,12 +9607,12 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
// void ns::f() {}
public void testInlineNamespace_305980d() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction f1= bh.assertNonProblem("f();", 1);
- IFunction f2= bh.assertNonProblem("f() {", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction f1 = bh.assertNonProblem("f();", 1);
+ IFunction f2 = bh.assertNonProblem("f() {", 1);
assertSame(f1, f2);
}
@@ -9643,7 +9638,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
// };
public void testLambdaExpression_316307a() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code);
}
@@ -9658,7 +9653,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testLambdaExpression_316307b() throws Exception {
parseAndCheckBindings();
}
-
+
// struct function {
// template <typename T>
// function(T);
@@ -9676,13 +9671,13 @@ public class AST2CPPTests extends AST2CPPTestBase {
// void f(const MyType& val);
// void g(MyType& val);
public void testTypeString_323596() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction f= bh.assertNonProblem("f(", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction f = bh.assertNonProblem("f(", 1);
assertEquals("const MyType &", ASTTypeUtil.getType(f.getType().getParameterTypes()[0], false));
assertEquals("const int &", ASTTypeUtil.getType(f.getType().getParameterTypes()[0], true));
- IFunction g= bh.assertNonProblem("g(", 1);
+ IFunction g = bh.assertNonProblem("g(", 1);
assertEquals("MyType &", ASTTypeUtil.getType(g.getType().getParameterTypes()[0], false));
assertEquals("int &", ASTTypeUtil.getType(g.getType().getParameterTypes()[0], true));
}
@@ -9700,9 +9695,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// container cnt;
// };
public void testConstMember_323599() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction f= bh.assertNonProblem("constBegin(); //ref", 10);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction f = bh.assertNonProblem("constBegin(); //ref", 10);
bh.assertProblem("begin(); //ref", 5);
}
@@ -9720,8 +9715,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// fint(p + p); // converted to boolean and then int.
// };
public void testExplicitConversionOperators() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertProblem("fint(pe + pe);", 4);
bh.assertNonProblem("fint(p + p);", 4);
}
@@ -9737,11 +9732,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
// C c (d);
// }
public void testExplicitOperatorInDirectInit() throws Exception {
- String code= getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code);
- ICPPASTFunctionDefinition fdef= getDeclaration(tu, 2);
- IASTDeclarationStatement declstmt= getStatement(fdef, 1);
- IASTSimpleDeclaration decl= (IASTSimpleDeclaration) declstmt.getDeclaration();
+ String code = getAboveComment();
+ IASTTranslationUnit tu = parseAndCheckBindings(code);
+ ICPPASTFunctionDefinition fdef = getDeclaration(tu, 2);
+ IASTDeclarationStatement declstmt = getStatement(fdef, 1);
+ IASTSimpleDeclaration decl = (IASTSimpleDeclaration) declstmt.getDeclaration();
IASTImplicitName[] names = ((IASTImplicitNameOwner) decl.getDeclarators()[0]).getImplicitNames();
assertEquals(1, names.length);
assertTrue(names[0].resolveBinding() instanceof ICPPConstructor);
@@ -9755,14 +9750,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
// g("abc");
// }
public void testRankingOfDeprecatedConversionOnStringLiteral() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction g= bh.assertNonProblem("g(char *)", 1);
- IFunction fconst= bh.assertNonProblem("f(const char *)", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction g = bh.assertNonProblem("g(char *)", 1);
+ IFunction fconst = bh.assertNonProblem("f(const char *)", 1);
- IBinding ref= bh.assertNonProblem("f(\"abc\")", 1);
+ IBinding ref = bh.assertNonProblem("f(\"abc\")", 1);
assertSame(fconst, ref);
- ref= bh.assertNonProblem("g(\"abc\")", 1);
+ ref = bh.assertNonProblem("g(\"abc\")", 1);
assertSame(g, ref);
}
@@ -9781,29 +9776,29 @@ public class AST2CPPTests extends AST2CPPTestBase {
// ar; // rvalue
// }
public void testXValueCategories() throws Exception {
- String code= getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code);
- ICPPASTFunctionDefinition fdef= getDeclaration(tu, 5);
+ String code = getAboveComment();
+ IASTTranslationUnit tu = parseAndCheckBindings(code);
+ ICPPASTFunctionDefinition fdef = getDeclaration(tu, 5);
IASTExpression expr;
- expr= getExpressionOfStatement(fdef, 0);
+ expr = getExpressionOfStatement(fdef, 0);
assertEquals(XVALUE, expr.getValueCategory());
assertEquals("A", ASTTypeUtil.getType(expr.getExpressionType()));
- expr= getExpressionOfStatement(fdef, 1);
+ expr = getExpressionOfStatement(fdef, 1);
assertEquals(XVALUE, expr.getValueCategory());
assertEquals("int", ASTTypeUtil.getType(expr.getExpressionType()));
- expr= getExpressionOfStatement(fdef, 2);
+ expr = getExpressionOfStatement(fdef, 2);
assertEquals(XVALUE, expr.getValueCategory());
assertEquals("A", ASTTypeUtil.getType(expr.getExpressionType()));
- expr= getExpressionOfStatement(fdef, 3);
+ expr = getExpressionOfStatement(fdef, 3);
assertEquals(XVALUE, expr.getValueCategory());
assertEquals("A", ASTTypeUtil.getType(expr.getExpressionType()));
// ar;
- expr= getExpressionOfStatement(fdef, 4);
+ expr = getExpressionOfStatement(fdef, 4);
assertEquals(LVALUE, expr.getValueCategory());
assertEquals("A", ASTTypeUtil.getType(expr.getExpressionType()));
}
@@ -9819,16 +9814,16 @@ public class AST2CPPTests extends AST2CPPTestBase {
// int l = g(f2()); // calls g(const int&&)
// }
public void testRankingOfReferenceBindings_a() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
- IFunction g1= bh.assertNonProblemOnFirstIdentifier("g(const int&)");
- IFunction g2= bh.assertNonProblemOnFirstIdentifier("g(const int&&)");
+ BindingAssertionHelper bh = getAssertionHelper();
+ IFunction g1 = bh.assertNonProblemOnFirstIdentifier("g(const int&)");
+ IFunction g2 = bh.assertNonProblemOnFirstIdentifier("g(const int&&)");
IFunction ref;
- ref= bh.assertNonProblemOnFirstIdentifier("g(i);");
+ ref = bh.assertNonProblemOnFirstIdentifier("g(i);");
assertSame(g1, ref);
- ref= bh.assertNonProblemOnFirstIdentifier("g(f1());");
+ ref = bh.assertNonProblemOnFirstIdentifier("g(f1());");
assertSame(g2, ref);
- ref= bh.assertNonProblemOnFirstIdentifier("g(f2());");
+ ref = bh.assertNonProblemOnFirstIdentifier("g(f2());");
assertSame(g2, ref);
}
@@ -9849,25 +9844,25 @@ public class AST2CPPTests extends AST2CPPTestBase {
// a.p();//6 // calls A::p()&
// }
public void testRankingOfReferenceBindings_b() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
- ICPPMethod s1= bh.assertNonProblem("operator<<(int)", 10);
- ICPPFunction s2= bh.assertNonProblem("operator<<(A&&, char)", 10);
- ICPPMethod p1= bh.assertNonProblemOnFirstIdentifier("p() &;");
- ICPPMethod p2= bh.assertNonProblemOnFirstIdentifier("p() &&;");
+ BindingAssertionHelper bh = getAssertionHelper();
+ ICPPMethod s1 = bh.assertNonProblem("operator<<(int)", 10);
+ ICPPFunction s2 = bh.assertNonProblem("operator<<(A&&, char)", 10);
+ ICPPMethod p1 = bh.assertNonProblemOnFirstIdentifier("p() &;");
+ ICPPMethod p2 = bh.assertNonProblemOnFirstIdentifier("p() &&;");
IASTImplicitName name;
- name= bh.assertImplicitName("<< 1;//1", 2, ICPPMethod.class);
+ name = bh.assertImplicitName("<< 1;//1", 2, ICPPMethod.class);
assertSame(s1, name.getBinding());
- name= bh.assertImplicitName("<< 'c';//2", 2, ICPPFunction.class);
+ name = bh.assertImplicitName("<< 'c';//2", 2, ICPPFunction.class);
assertSame(s2, name.getBinding());
- name= bh.assertImplicitName("<< 1;//3", 2, ICPPMethod.class);
+ name = bh.assertImplicitName("<< 1;//3", 2, ICPPMethod.class);
assertSame(s1, name.getBinding());
- name= bh.assertImplicitName("<< 'c';//4", 2, ICPPMethod.class);
+ name = bh.assertImplicitName("<< 'c';//4", 2, ICPPMethod.class);
assertSame(s1, name.getBinding());
ICPPMethod ref;
- ref= bh.assertNonProblemOnFirstIdentifier("p();//5");
+ ref = bh.assertNonProblemOnFirstIdentifier("p();//5");
assertSame(p2, ref);
- ref= bh.assertNonProblemOnFirstIdentifier("p();//6");
+ ref = bh.assertNonProblemOnFirstIdentifier("p();//6");
assertSame(p1, ref);
}
@@ -9883,25 +9878,25 @@ public class AST2CPPTests extends AST2CPPTestBase {
// S s2 = { 1, 2, 3 }; // invoke #2
// S s3 = { }; // invoke #3
public void testEmptyInitializerList_324096() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction ctor1= bh.assertNonProblem("S(std::initializer_list<double>);", 1);
- IFunction ctor2= bh.assertNonProblem("S(std::initializer_list<int>);", 1);
- IFunction ctor3= bh.assertNonProblem("S();", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction ctor1 = bh.assertNonProblem("S(std::initializer_list<double>);", 1);
+ IFunction ctor2 = bh.assertNonProblem("S(std::initializer_list<int>);", 1);
+ IFunction ctor3 = bh.assertNonProblem("S();", 1);
IASTName name;
IASTImplicitNameOwner dtor;
- name= bh.findName("s1", 2);
- dtor= (IASTImplicitNameOwner) name.getParent();
+ name = bh.findName("s1", 2);
+ dtor = (IASTImplicitNameOwner) name.getParent();
assertSame(ctor1, dtor.getImplicitNames()[0].resolveBinding());
- name= bh.findName("s2", 2);
- dtor= (IASTImplicitNameOwner) name.getParent();
+ name = bh.findName("s2", 2);
+ dtor = (IASTImplicitNameOwner) name.getParent();
assertSame(ctor2, dtor.getImplicitNames()[0].resolveBinding());
- name= bh.findName("s3", 2);
- dtor= (IASTImplicitNameOwner) name.getParent();
+ name = bh.findName("s3", 2);
+ dtor = (IASTImplicitNameOwner) name.getParent();
assertSame(ctor3, dtor.getImplicitNames()[0].resolveBinding());
}
-
+
// struct S {
// bool a;
// int b;
@@ -9940,9 +9935,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(true ? c : 1); // calls f(int), not f(C);
// }
public void testConditionalOperator_324853a() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
IBinding f = bh.assertNonProblem("f(int);", 1);
- IBinding ref= bh.assertNonProblem("f(true ? c : 1)", 1);
+ IBinding ref = bh.assertNonProblem("f(true ? c : 1)", 1);
assertSame(f, ref);
}
@@ -9955,14 +9950,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
// g(0 ? p : ""); // converts "" to char*
// }
public void testConditionalOperator_324853b() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
IBinding fc = bh.assertNonProblem("f(const char*);", 1);
IBinding ref;
- ref= bh.assertNonProblem("f(0 ? cp : p)", 1);
+ ref = bh.assertNonProblem("f(0 ? cp : p)", 1);
assertSame(fc, ref);
- ref= bh.assertNonProblem("f(0 ? p : \"\")", 1); // "" converted to char*
+ ref = bh.assertNonProblem("f(0 ? p : \"\")", 1); // "" converted to char*
assertSame(fc, ref);
- bh.assertNonProblem("g(0 ? p : \"\")", 1); //
+ bh.assertNonProblem("g(0 ? p : \"\")", 1); //
}
// struct C {
@@ -9976,27 +9971,27 @@ public class AST2CPPTests extends AST2CPPTestBase {
// C c4 ={1,2}; // C(C(int, int)) // copy ctor is elided
// C c5 {1,2}; // C(int, int)
public void testCtorForAutomaticVariables_156668() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction ctor1= bh.assertNonProblem("C();", 1);
- IFunction ctor2= bh.assertNonProblem("C(int a, int b);", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction ctor1 = bh.assertNonProblem("C();", 1);
+ IFunction ctor2 = bh.assertNonProblem("C(int a, int b);", 1);
IASTName name;
IASTImplicitNameOwner dtor;
- name= bh.findName("c1", 2);
- dtor= (IASTImplicitNameOwner) name.getParent();
+ name = bh.findName("c1", 2);
+ dtor = (IASTImplicitNameOwner) name.getParent();
assertSame(ctor1, dtor.getImplicitNames()[0].resolveBinding());
- name= bh.findName("c2", 2);
- dtor= (IASTImplicitNameOwner) name.getParent();
+ name = bh.findName("c2", 2);
+ dtor = (IASTImplicitNameOwner) name.getParent();
assertSame(ctor2, dtor.getImplicitNames()[0].resolveBinding());
- name= bh.findName("c3", 2);
- dtor= (IASTImplicitNameOwner) name.getParent();
+ name = bh.findName("c3", 2);
+ dtor = (IASTImplicitNameOwner) name.getParent();
assertSame(ctor2, dtor.getImplicitNames()[0].resolveBinding());
- name= bh.findName("c4", 2);
- dtor= (IASTImplicitNameOwner) name.getParent();
+ name = bh.findName("c4", 2);
+ dtor = (IASTImplicitNameOwner) name.getParent();
assertSame(ctor2, dtor.getImplicitNames()[0].resolveBinding());
- name= bh.findName("c5", 2);
- dtor= (IASTImplicitNameOwner) name.getParent();
+ name = bh.findName("c5", 2);
+ dtor = (IASTImplicitNameOwner) name.getParent();
assertSame(ctor2, dtor.getImplicitNames()[0].resolveBinding());
}
@@ -10008,13 +10003,13 @@ public class AST2CPPTests extends AST2CPPTestBase {
// g(&number);
// }
public void testTopLevelRestrictQualifier_327328() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction g= bh.assertNonProblem("g(int * __restrict a)", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction g = bh.assertNonProblem("g(int * __restrict a)", 1);
IFunction ref;
- ref= bh.assertNonProblem("g(int * a)", 1);
+ ref = bh.assertNonProblem("g(int * a)", 1);
assertSame(g, ref);
- ref= bh.assertNonProblem("g(&number)", 1);
+ ref = bh.assertNonProblem("g(&number)", 1);
assertSame(g, ref);
}
@@ -10028,14 +10023,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(&number); // calls f(int** a)
// }
public void testOverloadingWithRestrictQualifier_327328() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- IFunction f1= bh.assertNonProblem("f(int * __restrict* a)", 1);
- IFunction f2= bh.assertNonProblem("f(int ** a)", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ IFunction f1 = bh.assertNonProblem("f(int * __restrict* a)", 1);
+ IFunction f2 = bh.assertNonProblem("f(int ** a)", 1);
IFunction ref;
- ref= bh.assertNonProblem("f(&rnumber)", 1);
+ ref = bh.assertNonProblem("f(&rnumber)", 1);
assertSame(f1, ref);
- ref= bh.assertNonProblem("f(&number)", 1);
+ ref = bh.assertNonProblem("f(&number)", 1);
assertSame(f2, ref);
}
@@ -10110,8 +10105,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// auto f2 (); // missing late return type.
public void testBug332114a() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- IBinding b= bh.assertNonProblem("f2", 0);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ IBinding b = bh.assertNonProblem("f2", 0);
// Must not throw a NPE
IndexCPPSignatureUtil.getSignature(b);
}
@@ -10194,7 +10189,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testAutoTypeInRangeBasedFor_359653() throws Exception {
parseAndCheckBindings();
}
-
+
// struct Iter {
// Iter& operator++();
// int& operator*();
@@ -10238,18 +10233,18 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testOverrideSpecifierAfterTrailingReturnType_489876() throws Exception {
parseAndCheckBindings();
}
-
+
// auto (*x1)() -> int;
// int (*x2)();
//
// auto (*y1)() -> int(*)();
// int (*(*y2)())();
- //
+ //
// auto (*z1)() -> auto(*)() -> int(*)();
// int (*(*(*z2)())())();
public void testTrailingReturnTypeInFunctionPointer() throws Exception {
BindingAssertionHelper bh = getAssertionHelper();
-
+
ICPPVariable x1 = bh.assertNonProblem("x1");
ICPPVariable x2 = bh.assertNonProblem("x2");
assertSameType(x1.getType(), x2.getType());
@@ -10290,7 +10285,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testOverloadedOperatorWithInheritanceDistance_335387() throws Exception {
parseAndCheckBindings();
}
-
+
// struct Object {
// bool IsOk() const;
// };
@@ -10318,9 +10313,9 @@ public class AST2CPPTests extends AST2CPPTestBase {
// namespace ns {int a;}
// using ns::a;
public void testPropertyOfUsingDeclaration() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings();
- ICPPASTUsingDeclaration udecl= getDeclaration(tu, 1);
- ICPPASTQualifiedName qn= (ICPPASTQualifiedName) udecl.getName();
+ IASTTranslationUnit tu = parseAndCheckBindings();
+ ICPPASTUsingDeclaration udecl = getDeclaration(tu, 1);
+ ICPPASTQualifiedName qn = (ICPPASTQualifiedName) udecl.getName();
assertFalse(qn.isDefinition());
assertFalse(qn.getLastName().isDefinition());
assertTrue(qn.isDeclaration());
@@ -10349,24 +10344,24 @@ public class AST2CPPTests extends AST2CPPTestBase {
// X x = y2;
// }
public void testReferenceToCopyConstructor() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings();
- ICPPASTFunctionDefinition fdef= getDeclaration(tu, 2);
+ IASTTranslationUnit tu = parseAndCheckBindings();
+ ICPPASTFunctionDefinition fdef = getDeclaration(tu, 2);
- IASTDeclarationStatement dst= getStatement(fdef, 0);
- IASTDeclarator dtor= ((IASTSimpleDeclaration) dst.getDeclaration()).getDeclarators()[0];
- IBinding ctor= ((IASTImplicitNameOwner) dtor).getImplicitNames()[0].resolveBinding();
+ IASTDeclarationStatement dst = getStatement(fdef, 0);
+ IASTDeclarator dtor = ((IASTSimpleDeclaration) dst.getDeclaration()).getDeclarators()[0];
+ IBinding ctor = ((IASTImplicitNameOwner) dtor).getImplicitNames()[0].resolveBinding();
assertTrue(ctor instanceof ICPPConstructor);
assertEquals(0, ((ICPPConstructor) ctor).getType().getParameterTypes().length);
- dst= getStatement(fdef, 1);
- dtor= ((IASTSimpleDeclaration) dst.getDeclaration()).getDeclarators()[0];
- ctor= ((IASTImplicitNameOwner) dtor).getImplicitNames()[0].resolveBinding();
+ dst = getStatement(fdef, 1);
+ dtor = ((IASTSimpleDeclaration) dst.getDeclaration()).getDeclarators()[0];
+ ctor = ((IASTImplicitNameOwner) dtor).getImplicitNames()[0].resolveBinding();
assertTrue(ctor instanceof ICPPConstructor);
assertEquals(1, ((ICPPConstructor) ctor).getType().getParameterTypes().length);
- dst= getStatement(fdef, 2);
- dtor= ((IASTSimpleDeclaration) dst.getDeclaration()).getDeclarators()[0];
- ctor= ((IASTImplicitNameOwner) dtor).getImplicitNames()[0].resolveBinding();
+ dst = getStatement(fdef, 2);
+ dtor = ((IASTSimpleDeclaration) dst.getDeclaration()).getDeclarators()[0];
+ ctor = ((IASTImplicitNameOwner) dtor).getImplicitNames()[0].resolveBinding();
assertTrue(ctor instanceof ICPPConstructor);
assertEquals(1, ((ICPPConstructor) ctor).getType().getParameterTypes().length);
}
@@ -10429,14 +10424,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
// void (g)(int); //1
// void (g)(int); //2
public void testFunctionRedeclarations() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
- IFunction g1= bh.assertNonProblem("g)(char)", 1);
- IFunction g2= bh.assertNonProblem("g)(int); //1", 1);
- IFunction g3= bh.assertNonProblem("g)(int); //2", 1);
+ BindingAssertionHelper bh = getAssertionHelper();
+ IFunction g1 = bh.assertNonProblem("g)(char)", 1);
+ IFunction g2 = bh.assertNonProblem("g)(int); //1", 1);
+ IFunction g3 = bh.assertNonProblem("g)(int); //2", 1);
assertNotSame(g1, g2);
assertSame(g2, g3);
}
-
+
// int test() {
// extern int *e();
// if (auto r = e()) { return *r; }
@@ -10450,8 +10445,8 @@ public class AST2CPPTests extends AST2CPPTestBase {
// class A : A {
// };
public void testRecursiveClassInheritance_357256() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
- ICPPClassType c= bh.assertNonProblem("A", 1);
+ BindingAssertionHelper bh = getAssertionHelper();
+ ICPPClassType c = bh.assertNonProblem("A", 1);
assertEquals(0, SemanticQueries.getPureVirtualMethods(c, null).length);
}
@@ -10495,16 +10490,16 @@ public class AST2CPPTests extends AST2CPPTestBase {
// ~T();
// };
public void testErrorForDestructorWithWrongName_367590() throws Exception {
- IASTTranslationUnit tu= parse(getAboveComment(), CPP, false, false);
+ IASTTranslationUnit tu = parse(getAboveComment(), CPP, false, false);
IASTCompositeTypeSpecifier S;
IASTProblemDeclaration p;
IASTSimpleDeclaration s;
- S= getCompositeType(tu, 1);
- s= getDeclaration(S, 0);
- s= getDeclaration(S, 1);
- p= getDeclaration(S, 2);
- p= getDeclaration(S, 3);
+ S = getCompositeType(tu, 1);
+ s = getDeclaration(S, 0);
+ s = getDeclaration(S, 1);
+ p = getDeclaration(S, 2);
+ p = getDeclaration(S, 3);
}
// typedef int int8_t __attribute__ ((__mode__ (__QI__)));
@@ -10524,16 +10519,16 @@ public class AST2CPPTests extends AST2CPPTestBase {
// f(word);
// }
public void testModeAttribute_330635() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
String[] calls = { "f(i8)", "f(i16)", "f(i32)", "f(i64)", "f(word)" };
ICPPFunction[] functions = new ICPPFunction[calls.length];
for (int i = 0; i < calls.length; i++) {
functions[i] = bh.assertNonProblem(calls[i], 1, ICPPFunction.class);
}
for (int i = 0; i < functions.length - 1; i++) {
- for (int j = 0; j < i ; j++) {
- assertNotSame(calls[i] + " and " + calls[j] + " resolve to the same function",
- functions[i], functions[j]);
+ for (int j = 0; j < i; j++) {
+ assertNotSame(calls[i] + " and " + calls[j] + " resolve to the same function", functions[i],
+ functions[j]);
}
}
assertSame(calls[calls.length - 1] + " and " + calls[calls.length - 2] + " resolve to different functions",
@@ -10611,7 +10606,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// g( nullptr ); // error
// }
public void testNullptr_327298b() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertProblem("checkNullPtr(1)", 12);
bh.assertProblem("checklvalue(nullptr)", 11);
bh.assertProblem("g( nullptr )", 1);
@@ -10625,18 +10620,18 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testNullptr_327298c() throws Exception {
parseAndCheckBindings();
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- IFunction f= bh.assertNonProblem("f( nullptr )", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ IFunction f = bh.assertNonProblem("f( nullptr )", 1);
assertEquals("void (char *)", ASTTypeUtil.getType(f.getType()));
- f= bh.assertNonProblem("f( 0 )", 1);
+ f = bh.assertNonProblem("f( 0 )", 1);
assertEquals("void (int)", ASTTypeUtil.getType(f.getType()));
}
// void foo(struct S s);
public void testParameterForwardDeclaration_379511() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPClassType struct= bh.assertNonProblem("S", 1, ICPPClassType.class);
- IName[] declarations= bh.getTranslationUnit().getDeclarations(struct);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPClassType struct = bh.assertNonProblem("S", 1, ICPPClassType.class);
+ IName[] declarations = bh.getTranslationUnit().getDeclarations(struct);
assertEquals(1, declarations.length);
assertEquals(bh.findName("S", 1), declarations[0]);
}
@@ -10678,7 +10673,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testFriendConstructorDestructor_400940() throws Exception {
parseAndCheckBindings();
}
-
+
// namespace Hugo {
// class C {
// friend class Waldo;
@@ -10709,14 +10704,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTNode[] functionDeclarators = functionDeclarationBinding.getDeclarations();
assertEquals(1, functionDeclarators.length);
assertInstance(functionDeclarators[0], ICPPASTFunctionDeclarator.class);
- assertVirtualSpecifiers((ICPPASTFunctionDeclarator)functionDeclarators[0], false, true);
+ assertVirtualSpecifiers((ICPPASTFunctionDeclarator) functionDeclarators[0], false, true);
CPPMethod functionDefinitionBinding = bindingHelper.assertNonProblem("mFuncDef()", 8);
assertFalse(functionDefinitionBinding.isOverride());
assertTrue(functionDefinitionBinding.isFinal());
IASTFunctionDeclarator declarator = functionDefinitionBinding.getDefinition();
assertInstance(declarator, ICPPASTFunctionDeclarator.class);
- assertVirtualSpecifiers((ICPPASTFunctionDeclarator)declarator, false, true);
+ assertVirtualSpecifiers((ICPPASTFunctionDeclarator) declarator, false, true);
}
// struct Base {
@@ -10739,14 +10734,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTDeclarator[] functionDeclarators = functionDeclarationBinding.getDeclarations();
assertEquals(1, functionDeclarators.length);
assertInstance(functionDeclarators[0], ICPPASTFunctionDeclarator.class);
- assertVirtualSpecifiers((ICPPASTFunctionDeclarator)functionDeclarators[0], true, false);
+ assertVirtualSpecifiers((ICPPASTFunctionDeclarator) functionDeclarators[0], true, false);
CPPMethod functionDefinitionBinding = bindingHelper.assertNonProblem("mFuncDef() override", 8);
assertTrue(functionDefinitionBinding.isOverride());
assertFalse(functionDefinitionBinding.isFinal());
IASTFunctionDeclarator declarator = functionDefinitionBinding.getDefinition();
assertInstance(declarator, ICPPASTFunctionDeclarator.class);
- assertVirtualSpecifiers((ICPPASTFunctionDeclarator)declarator, true, false);
+ assertVirtualSpecifiers((ICPPASTFunctionDeclarator) declarator, true, false);
}
// struct Base {
@@ -10769,17 +10764,18 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTDeclarator[] functionDeclarators = functionDeclarationBinding.getDeclarations();
assertEquals(1, functionDeclarators.length);
assertInstance(functionDeclarators[0], ICPPASTFunctionDeclarator.class);
- assertVirtualSpecifiers((ICPPASTFunctionDeclarator)functionDeclarators[0], true, true);
+ assertVirtualSpecifiers((ICPPASTFunctionDeclarator) functionDeclarators[0], true, true);
CPPMethod functionDefinitionBinding = bindingHelper.assertNonProblem("mFuncDef() final", 8);
assertTrue(functionDefinitionBinding.isOverride());
assertTrue(functionDefinitionBinding.isFinal());
IASTFunctionDeclarator declarator = functionDefinitionBinding.getDefinition();
assertInstance(declarator, ICPPASTFunctionDeclarator.class);
- assertVirtualSpecifiers((ICPPASTFunctionDeclarator)declarator, true, true);
+ assertVirtualSpecifiers((ICPPASTFunctionDeclarator) declarator, true, true);
}
- private void assertVirtualSpecifiers(ICPPASTFunctionDeclarator declarator, boolean expectOverride, boolean expectFinal) {
+ private void assertVirtualSpecifiers(ICPPASTFunctionDeclarator declarator, boolean expectOverride,
+ boolean expectFinal) {
assertEquals(expectOverride, declarator.isOverride());
assertEquals(expectFinal, declarator.isFinal());
}
@@ -10799,16 +10795,16 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTNode baseDefinitionName = structBase.getDefinition();
IASTNode baseDefinition = baseDefinitionName.getParent();
assertInstance(baseDefinition, ICPPASTCompositeTypeSpecifier.class);
- assertFalse(((ICPPASTCompositeTypeSpecifier)baseDefinition).isFinal());
+ assertFalse(((ICPPASTCompositeTypeSpecifier) baseDefinition).isFinal());
CPPClassType structS = bh.assertNonProblem("S", 1);
assertTrue(structS.isFinal());
IASTNode sDefinitionName = structS.getDefinition();
IASTNode sDefinition = sDefinitionName.getParent();
assertInstance(sDefinition, ICPPASTCompositeTypeSpecifier.class);
- assertTrue(((ICPPASTCompositeTypeSpecifier)sDefinition).isFinal());
+ assertTrue(((ICPPASTCompositeTypeSpecifier) sDefinition).isFinal());
}
-
+
// struct S {
// template<typename T>
// void foo(T t) final {
@@ -10848,7 +10844,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testFinalParameter() throws Exception {
parseAndCheckBindings();
}
-
+
// struct S __final {};
// struct T { void foo() __final; };
public void testFinalGccExtension_442457() throws Exception {
@@ -10858,7 +10854,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
ICPPMethod foo = bh.assertNonProblem("foo");
assertTrue(foo.isFinal());
}
-
+
// struct S {};
// bool b1 = __is_trivially_copyable(S);
// bool b2 = __is_trivially_assignable(S, S&);
@@ -10898,7 +10894,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testADLForFunctionObject_388287() throws Exception {
parseAndCheckBindings();
}
-
+
// namespace A {
// template <typename T>
// void foo(T);
@@ -10907,7 +10903,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// namespace B {
// template <typename T>
// void foo(T);
- //
+ //
// struct S {};
// }
//
@@ -11114,7 +11110,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testThrowExpressionInConditional_396663() throws Exception {
parseAndCheckBindings(getAboveComment(), CPP, true);
}
-
+
// struct A {};
//
// struct B : A {};
@@ -11127,7 +11123,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testBasePointerConverstionInConditional_462705() throws Exception {
parseAndCheckBindings();
}
-
+
// struct S {};
// typedef S* S_ptr;
// void waldo(S*);
@@ -11288,7 +11284,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testGNUSyncBuiltins_389578() throws Exception {
parseAndCheckBindings(getAboveComment(), CPP, true);
}
-
+
// int main() {
// void* p;
// __sync_bool_compare_and_swap(&p, p, p);
@@ -11348,7 +11344,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertSameType((ITypedef) helper.assertNonProblem("ulong_type"), CPPBasicType.UNSIGNED_LONG);
assertSameType((ITypedef) helper.assertNonProblem("loong_type"), CPPBasicType.LONG);
}
-
+
// template <typename T>
// struct underlying_type {
// typedef __underlying_type(T) type;
@@ -11365,7 +11361,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testUnderlyingType_540909() throws Exception {
parseAndCheckBindings(getAboveComment(), CPP, true /* use GNU extensions */);
}
-
+
// void ptrFunc(void*);
// void intFunc(int);
// void foo(int* pi, unsigned i) {
@@ -11377,7 +11373,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testGCCBuiltins_512932a() throws Exception {
parseAndCheckBindings(getAboveComment(), CPP, true);
}
-
+
// void ptrFunc(void*);
// void intFunc(int);
// void foo(int* pi, unsigned i) {
@@ -11470,7 +11466,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testBuiltInOperatorFunctionType_423396() throws Exception {
parseAndCheckBindings();
}
-
+
// template <unsigned N>
// void waldo(const char (&)[N]);
// void foo() {
@@ -11479,7 +11475,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testTypeOfBuiltinSymbol_512932() throws Exception {
parseAndCheckBindings();
}
-
+
// struct S {
// int S;
// };
@@ -11524,7 +11520,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertEquals(',', argumentTokens[1].getTokenCharImage()[0]);
assertEquals('2', argumentTokens[2].getTokenCharImage()[0]);
}
-
+
// struct MyStruct {
// struct Inner {
// int waldo;
@@ -11538,12 +11534,12 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testFieldAndNestedTypeWithSameName_425033() throws Exception {
parseAndCheckBindings();
}
-
+
// void f(double (&(x)));
public void testParenthesizedReferenceArgument_424898() throws Exception {
parseAndCheckBindings();
}
-
+
// constexpr int naive_fibonacci(int x) {
// return x == 0 ? 0
// : x == 1 ? 1
@@ -11556,7 +11552,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
IVariable waldo = helper.assertNonProblem("waldo");
assertConstantValue(5, waldo);
}
-
+
// constexpr int naive_fibonacci(int x) {
// return x == 0 ? 0
// : x == 1 ? 1
@@ -11573,7 +11569,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
IVariable waldo = helper.assertNonProblem("waldo");
assertNull(waldo.getInitialValue().numberValue());
}
-
+
// constexpr int foo(int a = 42) {
// return a;
// }
@@ -11583,7 +11579,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
IVariable waldo = helper.assertNonProblem("waldo");
assertConstantValue(42, waldo);
}
-
+
// struct S1 { S1(int); };
// struct S2 { void operator()(int); };
// S2 s2;
@@ -11593,7 +11589,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testICPPASTFunctionCallExpression_getOverload_441701() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
-
+
ICPPASTFunctionCallExpression call1 = helper.assertNode("S1(42)");
ICPPFunction constructor = helper.assertNonProblem("S1(int)", "S1");
assertEquals(constructor, call1.getOverload());
@@ -11609,7 +11605,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) tu.getDeclarations()[0];
isParameterSignatureEqual(sd.getDeclarators()[0], "(int&&)");
}
-
+
// struct S { S(int); };
// void find(S&&);
// int main() {
@@ -11619,7 +11615,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testRValueReferenceBindingToTemporary_470943() throws Exception {
parseAndCheckBindings();
}
-
+
// constexpr int waldo1 = 42;
// constexpr auto waldo2 = 43;
public void testConstexprVariableIsConst_451091() throws Exception {
@@ -11630,7 +11626,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertSameType(waldo1.getType(), CommonCPPTypes.constInt);
assertSameType(waldo2.getType(), CommonCPPTypes.constInt);
}
-
+
// constexpr int waldo1();
// constexpr int (*waldo2())(int);
// struct S { constexpr int waldo3(); };
@@ -11642,22 +11638,22 @@ public class AST2CPPTests extends AST2CPPTestBase {
// constexpr on a function *should not* make its return type const
assertSameType(waldo1.getType().getReturnType(), CommonCPPTypes.int_);
assertSameType(waldo2.getType().getReturnType(),
- new CPPPointerType(new CPPFunctionType(CommonCPPTypes.int_, new IType[]{ CommonCPPTypes.int_ })));
+ new CPPPointerType(new CPPFunctionType(CommonCPPTypes.int_, new IType[] { CommonCPPTypes.int_ })));
// constexpr on a method *should not* make the method const
- assertSameType(waldo3.getType(), new CPPFunctionType(CommonCPPTypes.int_, new IType[]{}));
+ assertSameType(waldo3.getType(), new CPPFunctionType(CommonCPPTypes.int_, new IType[] {}));
}
-
+
// void waldo() noexcept;
public void testASTCopyForNoexceptDefault_bug456207() throws Exception {
parseAndCheckBindings();
}
-
+
// template <typename> struct waldo { waldo(int); };
// auto x = static_cast<waldo<int>>(0);
public void testTemplateIdInsideCastOperator_460080() throws Exception {
parseAndCheckBindings();
}
-
+
// alignas(8) int x;
// alignas(int) char y;
// alignas(16) struct { int x; int y; };
@@ -11679,7 +11675,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testAlignas_451082() throws Exception {
parseAndCheckBindings();
}
-
+
// struct alignas(16) Node {};
// enum alignas(8) E { E1, E2 };
public void testAlignas_475739() throws Exception {
@@ -11690,7 +11686,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testAlignasAfterAttribute_538615() throws Exception {
parseAndCheckBindings(getAboveComment(), CPP, true /* use GNU extensions */);
}
-
+
// int operator "" _A(unsigned long long i) { return 1; }
// int operator "" _B(long double d) { return 1; }
// int operator "" _C(const char* s, unsigned int sz) { return sz; }
@@ -12155,7 +12151,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
for (int i = 1; i < decls.length; i++) {
IASTDeclaration decl = decls[i];
assertTrue(decl instanceof IASTProblemDeclaration);
- assertEquals(IProblem.SYNTAX_ERROR, ((IASTProblemDeclaration)decl).getProblem().getID());
+ assertEquals(IProblem.SYNTAX_ERROR, ((IASTProblemDeclaration) decl).getProblem().getID());
}
}
@@ -12187,7 +12183,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
ICPPVariable test = bh.assertNonProblemOnFirstIdentifier("test");
assertTrue(test.getType() instanceof IProblemType); // resolution is ambiguous
}
-
+
// namespace N {
// class Color {};
// Color operator"" _color(const char*, unsigned long);
@@ -12200,7 +12196,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testUserDefinedLiteralInNamespace_510665() throws Exception {
parseAndCheckBindings();
}
-
+
// double waldo1 = 02.968;
// double waldo2 = 09.268;
// double waldo3 = 02e2;
@@ -12208,22 +12204,22 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testFloatLiteralWithLeadingZero_498434() throws Exception {
parseAndCheckImplicitNameBindings();
}
-
+
// char foo() {
// return '*';
// }
public void testRegression_484618() throws Exception {
parseAndCheckImplicitNameBindings();
}
-
- // constexpr int lambdas_supported =
+
+ // constexpr int lambdas_supported =
// #if __has_feature(cxx_lambdas)
// 1;
// #else
// 0;
// #endif
//
- // constexpr int generic_lambdas_supported =
+ // constexpr int generic_lambdas_supported =
// #if __has_feature(cxx_generic_lambdas)
// 1;
// #else
@@ -12252,31 +12248,31 @@ public class AST2CPPTests extends AST2CPPTestBase {
// }
public void testDesignatedInitializers() throws Exception {
BindingAssertionHelper bh = getAssertionHelper();
-// ICPPASTDesignatedInitializer d1 = bh.assertNode(".a = 10");
-// assertEquals(1, d1.getDesignators().length);
-// assertTrue(d1.getDesignators()[0] instanceof ICPPASTFieldDesignator);
-// ICPPASTDesignatedInitializer d2 = bh.assertNode(".b = 11");
-// assertEquals(1, d2.getDesignators().length);
-// assertTrue(d2.getDesignators()[0] instanceof ICPPASTFieldDesignator);
-// ICPPASTDesignatedInitializer d3 = bh.assertNode(".c[4 ... 6] = 3");
-// assertEquals(2, d3.getDesignators().length);
-// assertTrue(d3.getDesignators()[0] instanceof ICPPASTFieldDesignator);
-// assertTrue(d3.getDesignators()[1] instanceof IGPPASTArrayRangeDesignator);
-// ICPPASTDesignatedInitializer d4 = bh.assertNode(".d = 5");
-// assertEquals(1, d4.getDesignators().length);
-// assertTrue(d4.getDesignators()[0] instanceof ICPPASTFieldDesignator);
-// ICPPASTDesignatedInitializer d5 = bh.assertNode("[4] = 29");
-// assertEquals(1, d5.getDesignators().length);
-// assertTrue(d5.getDesignators()[0] instanceof ICPPASTArrayDesignator);
-// ICPPASTDesignatedInitializer d6 = bh.assertNode("[2] = 15");
-// assertEquals(1, d6.getDesignators().length);
-// assertTrue(d6.getDesignators()[0] instanceof ICPPASTArrayDesignator);
-// ICPPASTDesignatedInitializer d7 = bh.assertNode("[2 ... 4] = 29");
-// assertEquals(1, d7.getDesignators().length);
-// assertTrue(d7.getDesignators()[0] instanceof IGPPASTArrayRangeDesignator);
-// ICPPField a = bh.assertNonProblemOnFirstIdentifier(".a");
-// ICPPField b = bh.assertNonProblemOnFirstIdentifier(".b");
-// ICPPField c = bh.assertNonProblemOnFirstIdentifier(".c[4 ... 6]");
+ // ICPPASTDesignatedInitializer d1 = bh.assertNode(".a = 10");
+ // assertEquals(1, d1.getDesignators().length);
+ // assertTrue(d1.getDesignators()[0] instanceof ICPPASTFieldDesignator);
+ // ICPPASTDesignatedInitializer d2 = bh.assertNode(".b = 11");
+ // assertEquals(1, d2.getDesignators().length);
+ // assertTrue(d2.getDesignators()[0] instanceof ICPPASTFieldDesignator);
+ // ICPPASTDesignatedInitializer d3 = bh.assertNode(".c[4 ... 6] = 3");
+ // assertEquals(2, d3.getDesignators().length);
+ // assertTrue(d3.getDesignators()[0] instanceof ICPPASTFieldDesignator);
+ // assertTrue(d3.getDesignators()[1] instanceof IGPPASTArrayRangeDesignator);
+ // ICPPASTDesignatedInitializer d4 = bh.assertNode(".d = 5");
+ // assertEquals(1, d4.getDesignators().length);
+ // assertTrue(d4.getDesignators()[0] instanceof ICPPASTFieldDesignator);
+ // ICPPASTDesignatedInitializer d5 = bh.assertNode("[4] = 29");
+ // assertEquals(1, d5.getDesignators().length);
+ // assertTrue(d5.getDesignators()[0] instanceof ICPPASTArrayDesignator);
+ // ICPPASTDesignatedInitializer d6 = bh.assertNode("[2] = 15");
+ // assertEquals(1, d6.getDesignators().length);
+ // assertTrue(d6.getDesignators()[0] instanceof ICPPASTArrayDesignator);
+ // ICPPASTDesignatedInitializer d7 = bh.assertNode("[2 ... 4] = 29");
+ // assertEquals(1, d7.getDesignators().length);
+ // assertTrue(d7.getDesignators()[0] instanceof IGPPASTArrayRangeDesignator);
+ // ICPPField a = bh.assertNonProblemOnFirstIdentifier(".a");
+ // ICPPField b = bh.assertNonProblemOnFirstIdentifier(".b");
+ // ICPPField c = bh.assertNonProblemOnFirstIdentifier(".c[4 ... 6]");
ICPPField d = bh.assertNonProblemOnFirstIdentifier(".d");
}
@@ -12291,7 +12287,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// struct C : A {
// C() {}
// };
- //
+ //
// struct D : virtual A, virtual B {
// D() {}
// };
@@ -12305,7 +12301,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// };
public void testImplicitlyCalledBaseConstructor_393717() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
-
+
ICPPConstructor aCtor = helper.assertNonProblem("A()", "A");
ICPPConstructor bCtor = helper.assertNonProblem("B()", "B");
ICPPConstructor dCtor = helper.assertNonProblem("D()", "D");
@@ -12315,14 +12311,14 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) ctorDef).getImplicitNames();
assertEquals(1, implicitNames.length);
assertEquals(aCtor, implicitNames[0].resolveBinding());
-
+
ctorDef = helper.assertNode("D() {}");
implicitNames = ((IASTImplicitNameOwner) ctorDef).getImplicitNames();
sortNames(implicitNames);
assertEquals(2, implicitNames.length);
assertEquals(aCtor, implicitNames[0].resolveBinding());
assertEquals(bCtor, implicitNames[1].resolveBinding());
-
+
ctorDef = helper.assertNode("F() {}");
implicitNames = ((IASTImplicitNameOwner) ctorDef).getImplicitNames();
sortNames(implicitNames);
@@ -12332,7 +12328,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertEquals(dCtor, implicitNames[2].resolveBinding());
assertEquals(eCtor, implicitNames[3].resolveBinding());
}
-
+
// struct A {
// A(int, int);
// };
@@ -12348,7 +12344,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
assertEquals(1, implicitNames.length);
assertEquals(ctor, implicitNames[0].resolveBinding());
}
-
+
// template <typename T>
// struct Waldo {
// T x;
@@ -12361,7 +12357,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testShadowingAliasDeclaration_484200() throws Exception {
parseAndCheckBindings();
}
-
+
// struct foo {
// using E = enum { Zero, One, Two };
//
@@ -12372,7 +12368,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testAnonymousEnumInAliasDeclaration_502016() throws Exception {
parseAndCheckBindings();
}
-
+
// struct S {
// void foo() {
// bar(E::A); // ERROR: Symbol 'A' could not be resolved
@@ -12383,7 +12379,6 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testEnumDeclaredLaterInClass_491747() throws Exception {
parseAndCheckBindings();
}
-
// enum E { A = 2 };
// constexpr int operator+(E, E) {
@@ -12394,7 +12389,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableValue("waldo", 5);
}
-
+
// class S {
// static S waldo;
// };
@@ -12405,7 +12400,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// Trigger computation of value representation of S().
foo.getParameters()[0].getDefaultValue();
}
-
+
// class S {
// S waldo; // invalid
// };
@@ -12416,7 +12411,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
// Trigger computation of value representation of S().
foo.getParameters()[0].getDefaultValue();
}
-
+
// class T;
// class S {
// T waldo; // invalid
@@ -12430,7 +12425,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
ICPPFunction foo = helper.assertNonProblem("foo");
// Trigger computation of value representation of S().
foo.getParameters()[0].getDefaultValue();
- }
+ }
// namespace std {
// template<typename T> class initializer_list;
@@ -12552,7 +12547,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testDecltypeAutoReturnType_482225() throws Exception {
parseAndCheckBindings();
}
-
+
// struct Waldo {
// int foo();
// };
@@ -12564,7 +12559,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testAutoWithTwoDeclarators_522066() throws Exception {
parseAndCheckBindings();
}
-
+
// constexpr int waldo = (sizeof(double) % 16);
public void testSizeofDouble_506170() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
@@ -12586,27 +12581,30 @@ public class AST2CPPTests extends AST2CPPTestBase {
IASTNode functionBody = explicitBooleanContextsFunction.getChildren()[2];
IASTNode logicalAndExpressionStatement = functionBody.getChildren()[1];
- ICPPASTBinaryExpression logicalAndExpression = (ICPPASTBinaryExpression)logicalAndExpressionStatement.getChildren()[0];
+ ICPPASTBinaryExpression logicalAndExpression = (ICPPASTBinaryExpression) logicalAndExpressionStatement
+ .getChildren()[0];
ICPPFunction logicalAndOverload = logicalAndExpression.getOverload();
assertNotNull(logicalAndOverload);
ICPPFunctionType logicalAndType = logicalAndOverload.getType();
isTypeEqual(logicalAndType, "bool (bool, bool)");
IASTNode logicalOrExpressionStatement = functionBody.getChildren()[2];
- ICPPASTBinaryExpression logicalOrExpression = (ICPPASTBinaryExpression)logicalOrExpressionStatement.getChildren()[0];
+ ICPPASTBinaryExpression logicalOrExpression = (ICPPASTBinaryExpression) logicalOrExpressionStatement
+ .getChildren()[0];
ICPPFunction logicalOrOverload = logicalOrExpression.getOverload();
assertNotNull(logicalOrOverload);
ICPPFunctionType logicalOrType = logicalOrOverload.getType();
isTypeEqual(logicalOrType, "bool (bool, bool)");
IASTNode logicalNotExpressionStatement = functionBody.getChildren()[3];
- ICPPASTUnaryExpression logicalNotExpression = (ICPPASTUnaryExpression)logicalNotExpressionStatement.getChildren()[0];
+ ICPPASTUnaryExpression logicalNotExpression = (ICPPASTUnaryExpression) logicalNotExpressionStatement
+ .getChildren()[0];
ICPPFunction logicalNotOverload = logicalNotExpression.getOverload();
assertNotNull(logicalNotOverload);
ICPPFunctionType logicalNotType = logicalNotOverload.getType();
isTypeEqual(logicalNotType, "bool (bool)");
}
-
+
// enum enumDecl {
// el0 __attribute__((deprecated)),
// el1,
@@ -12614,13 +12612,12 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testEnumeratorAttribute_514821() throws Exception {
parseAndCheckBindings(getAboveComment(), CPP, true /* use GNU extensions */);
}
-
+
// void foo([[maybe_unused]] int a);
public void testCxx11AttributeBeforeParameterDeclaration_530729() throws Exception {
parseAndCheckBindings();
}
-
// struct CType {
// char m_Array[4];
// };
@@ -12672,7 +12669,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testNamespaceAliasNamespaceWithPreviousFunctionName_517402() throws Exception {
parseAndCheckBindings();
}
-
+
// class C {};
// typedef C D;
// constexpr bool waldo = __is_class(D);
@@ -12680,19 +12677,19 @@ public class AST2CPPTests extends AST2CPPTestBase {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableValue("waldo", 1);
}
-
+
// struct A {};
// struct A* b = (1 == 1) ? new struct A : new struct A;
- public void test_ElabTypeSpecInNewExprInConditional_526134() throws Exception {
- parseAndCheckBindings();
- }
-
- // constexpr bool waldo1 = __is_trivially_constructible(int, short);
- // struct S { int fMem; S(int mem) : fMem(mem) {} };
- // constexpr bool waldo2 = __is_trivially_constructible(S);
- // constexpr bool waldo3 = __is_trivially_constructible(S, const S&);
- // constexpr bool waldo4 = __is_trivially_constructible(S, int);
- // constexpr bool waldo5 = __is_trivially_constructible(S, const S&, float);
+ public void test_ElabTypeSpecInNewExprInConditional_526134() throws Exception {
+ parseAndCheckBindings();
+ }
+
+ // constexpr bool waldo1 = __is_trivially_constructible(int, short);
+ // struct S { int fMem; S(int mem) : fMem(mem) {} };
+ // constexpr bool waldo2 = __is_trivially_constructible(S);
+ // constexpr bool waldo3 = __is_trivially_constructible(S, const S&);
+ // constexpr bool waldo4 = __is_trivially_constructible(S, int);
+ // constexpr bool waldo5 = __is_trivially_constructible(S, const S&, float);
public void testIsTriviallyConstructible_528072() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableValue("waldo1", 1);
@@ -12701,7 +12698,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
helper.assertVariableValue("waldo4", 0);
helper.assertVariableValue("waldo5", 0);
}
-
+
// template <typename T, typename U>
// struct pair {
// pair();
@@ -12713,7 +12710,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableValue("waldo", 1);
}
-
+
// namespace x {
// void foo();
// }
@@ -12747,7 +12744,7 @@ public class AST2CPPTests extends AST2CPPTestBase {
helper.assertVariableType("v_b", CPPBasicType.UNSIGNED_LONG_LONG);
helper.assertVariableType("v_c", CPPBasicType.LONG_LONG);
}
-
+
// extern void *List[];
// extern void *List[];
// void *List[] = { 0 };
@@ -12764,11 +12761,11 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testStaticAssertWithoutMessage_534808() throws Exception {
parseAndCheckBindings();
}
-
+
// struct MyStruct {
// unsigned i;
// };
- //
+ //
// auto myFunA() -> struct MyStruct {
// return {5};
// };
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java
index f4892d2c3b3..e38f7146bd1 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java
@@ -30,20 +30,20 @@ public class AST2CSpecTest extends AST2SpecTestBase {
}
// /* Start Example(C 4-6) */
- // #ifdef _ _STDC_IEC_559_ _ // FE_UPWARD defined
+ // #ifdef _ _STDC_IEC_559_ _ // FE_UPWARD defined
// fesetround(FE_UPWARD);
// #endif
public void test4s6() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 5.1.1.3-2) */
// char i;
// int i;
public void test5_1_1_3s2() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 5.1.2.3-10) */
// int f() {
// char c1, c2;
@@ -52,7 +52,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test5_1_2_3s10() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 5.1.2.3-11) */
// int f() {
// float f1, f2;
@@ -62,7 +62,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test5_1_2_3s11() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 5.1.2.3-12) */
// int f() {
// double d1, d2;
@@ -73,7 +73,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test5_1_2_3s12() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 5.1.2.3-13) */
// int f() {
// double x, y, z;
@@ -85,7 +85,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test5_1_2_3s13() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 5.1.2.3-14) */
// int f() {
// int a, b;
@@ -98,7 +98,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test5_1_2_3s14() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 5.1.2.3-15) */
// //#include <stdio.h>
// int f() {
@@ -110,13 +110,13 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test5_1_2_3s15() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.2.5-28) */
// struct tag (* a[5])(float);
public void test6_2_5s28() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.2.7-5) */
// int f(int (*)(), double (*)[3]);
// int f(int (*)(char *), double (*)[]);
@@ -124,7 +124,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_2_7s5() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.4.4.4-12) */
// char x='\023';
// char y='\0';
@@ -132,7 +132,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_4_4_4s12() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.5.2.2-12) */
// int f1() {}
// int f2() {}
@@ -145,7 +145,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_2s12() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.5.2.3-7) */
// struct s { int i; const int ci; };
// struct s s;
@@ -162,7 +162,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_3s7() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.5.2.3-8a) */
// union {
// struct {
@@ -188,7 +188,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_3s8a() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.5.2.3-8b) */
// struct t1 { int m; };
// struct t2 { int m; };
@@ -209,13 +209,13 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_3s8b() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.5.2.5-9) */
// int *p = (int []){2, 4};
public void test6_5_2_5s9() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.5.2.5-10) */
// void f(void)
// {
@@ -225,7 +225,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_5s10() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.5.2.5-11) */
// int f(){
// drawline((struct point){.x=1, .y=1},
@@ -236,7 +236,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_5s11() throws Exception {
parse(getAboveComment(), ParserLanguage.C, false, 0);
}
-
+
// /* Start Example(C 6.5.2.5-12) */
// int f() {
// (const float []){1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6};
@@ -244,7 +244,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_5s12() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.5.2.5-13) */
// int f() {
// "/tmp/fileXXXXXX";
@@ -254,7 +254,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_5s13() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.5.2.5-14) */
// int f() {
// (const char []){"abc"} == "abc";
@@ -262,7 +262,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_5s14() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.5.2.5-15) */
// int f() {
// struct int_list { int car; struct int_list *cdr; };
@@ -272,7 +272,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_5s15() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.5.2.5-16) */
// struct s { int i; };
// int f (void)
@@ -287,14 +287,14 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_2_5s16() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.5.3.4-5) */
// extern void *alloc(size_t);
// double *dp = alloc(sizeof *dp);
public void test6_5_3_4s5() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.5.3.4-6) */
// int f() {
// int array[5];
@@ -303,7 +303,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_3_4s6() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.5.6-10) */
// int f() {
// int n = 4, m = 3;
@@ -316,7 +316,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_6s10() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.5.15-8) */
// int f(bool cond) {
// const void *c_vp;
@@ -348,7 +348,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
assertSameType(CommonCTypes.pointerToConstInt, c5.getExpressionType());
assertSameType(CommonCTypes.pointerToVoid, c6.getExpressionType());
}
-
+
// /* Start Example(C 6.5.16.1-5) */
// int f() {
// char c;
@@ -359,7 +359,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_16_1s5() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.5.16.1-6) */
// int f() {
// const char **cpp;
@@ -372,7 +372,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_5_16_1s6() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.2.1-17) */
// // offsetoff is a macro defined in stddef.h, using GNU definition
// #define offsetof(TYPE, MEMBER) ((size_t) (&((TYPE *)0)->MEMBER))
@@ -386,7 +386,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_2_1s17() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.7.2.1-18a) */
// int f() {
// struct s *s1;
@@ -397,14 +397,14 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_2_1s18a() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.7.2.1-18b) */
// struct { int n; double d[8]; } *s1;
// struct { int n; double d[5]; } *s2;
public void test6_7_2_1s18b() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.2.2-5) */
// int f() {
// enum hue { chartreuse, burgundy, claret=20, winedark };
@@ -417,7 +417,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_2_2s5() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.2.3-9) */
// struct tnode {
// int count;
@@ -427,7 +427,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_2_3s9() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.2.3-10) */
// typedef struct tnode TNODE;
// struct tnode {
@@ -438,7 +438,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_2_3s10() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.2.3-11) */
// struct s2;
// struct s1 { struct s2 *s2p; }; // D1
@@ -446,13 +446,13 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_2_3s11() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.3-10) */
// extern const volatile int real_time_clock;
public void test6_7_3s10() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.3-11) */
// int f() {
// const struct s { int mem; } cs = { 1 };
@@ -471,7 +471,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_3s11() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.3.1-7) */
// int * restrict a;
// int * restrict b;
@@ -479,7 +479,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_3_1s7() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.3.1-8) */
// void f(int n, int * restrict p, int * restrict q)
// {
@@ -489,7 +489,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_3_1s8() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.3.1-9) */
// void f(int n, int * restrict p, int * restrict q)
// {
@@ -505,7 +505,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_3_1s9() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.3.1-10) */
// void h(int n, int * restrict p, int * restrict q, int * restrict r)
// {
@@ -516,7 +516,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_3_1s10() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.3.1-11) */
// int f()
// {
@@ -533,7 +533,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_3_1s11() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.3.1-12) */
// typedef struct { int n; float * restrict v; } vector;
// vector new_vector(int n)
@@ -546,7 +546,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_3_1s12() throws Exception {
parse(getAboveComment(), ParserLanguage.C, false, 0);
}
-
+
// /* Start Example(C 6.7.4-7) */
// inline double fahr(double t)
// {
@@ -564,7 +564,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_4s7() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.5.1-4) */
// const int *ptr_to_constant;
// int *const constant_ptr1;
@@ -573,20 +573,20 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_5_1s4() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.5.2-7) */
// float fa[11], *afp[17];
public void test6_7_5_2s7() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.5.2-8) */
// extern int *x;
// extern int y[];
public void test6_7_5_2s8() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.5.2-9) */
// extern int n;
// extern int m;
@@ -603,7 +603,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_5_2s9() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.5.2-10) */
// extern int n;
// int A[n]; // invalid: file scope VLA
@@ -627,25 +627,25 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_5_2s10() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.7.5.3-16) */
// int f(void), *fip(), (*pfi)();
public void test6_7_5_3s16() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.5.3-18) */
// int (*apfi[3])(int *x, int *y);
public void test6_7_5_3s18() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.5.3-19) */
// int (*fpfi(int (*)(long), int))(int, ...);
public void test6_7_5_3s19() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.5.3-20) */
// void addscalar(int n, int m,
// double a[n][n*m+300], double x);
@@ -664,11 +664,11 @@ public class AST2CSpecTest extends AST2SpecTestBase {
// a[i][j] += x;
// }
public void test6_7_5_3s20() throws Exception {
- String code = getAboveComment();
+ String code = getAboveComment();
// no valid c++ code
parse(code, ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.5.3-21) */
// double maximum1(int n, int m, double a[n][m]);
// double maximum2(int n, int m, double a[*][*]);
@@ -681,7 +681,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_5_3s21() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.7-4) */
// typedef int MILES, KLICKSP();
// typedef struct { double hi, lo; } range;
@@ -692,14 +692,14 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_7s4() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.7-5) */
// typedef struct s1 { int x; } t1, *tp1;
// typedef struct s2 { int x; } t2, *tp2;
public void test6_7_7s5() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.7-7) */
// typedef void fv(int), (*pfv)(int);
// void (*signal(int, void (*)(int)))(int);
@@ -708,7 +708,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_7s7() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.7-8) */
// void copyt(int n)
// {
@@ -722,20 +722,20 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_7s8() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.8-24) */
// int i = 3.5;
// complex c = 5 + 3 * I;
public void test6_7_8s24() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.7.8-25) */
// int x[] = { 1, 3, 5 };
public void test6_7_8s25() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.8-26a) */
// int y[4][3] = {
// { 1, 3, 5 },
@@ -745,7 +745,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_8s26a() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.8-26b) */
// int y[4][3] = {
// 1, 3, 5, 2, 4, 6, 3, 5, 7
@@ -753,7 +753,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_8s26b() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.8-27) */
// int z[4][3] = {
// { 1 }, { 2 }, { 3 }, { 4 }
@@ -761,13 +761,13 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_8s27() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.8-28) */
// struct { int a[3], b; } w[] = { { 1 }, 2 };
public void test6_7_8s28() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.8-29) */
// short q1[4][3][2] = {
// { 1 },
@@ -794,7 +794,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_8s29() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.8-31) */
// typedef int A[]; // OK - declared with block scope
// A a1 = { 1, 2 }, b1 = { 3, 4, 5 };
@@ -802,7 +802,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_8s31() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.8-32) */
// int foo() {
// char s1[] = "abc", t1[3] = "abc";
@@ -813,7 +813,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_8s32() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.7.8-33) */
// enum { member_one, member_two };
// const char *nm[] = {
@@ -823,20 +823,20 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_8s33() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.8-34) */
// div_t answer = { .quot = 2, .rem = -1 };
public void test6_7_8s34() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 1); // div_t (correctly) cannot be resolved
}
-
+
// /* Start Example(C 6.7.8-35) */
// struct { int a[3], b; } w[] =
// { [0].a = {1}, [1].a[0] = 2 };
public void test6_7_8s35() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.8-36) */
// int MAX=15;
// int a[MAX] = {
@@ -845,13 +845,13 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_7_8s36() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.7.8-38) */
// union { int any_member; } u = { .any_member = 42 };
public void test6_7_8s38() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.8.3-4) */
// int p(int);
// int f() {
@@ -860,7 +860,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_8_3s4() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.8.3-5) */
// int f() {
// char *s;
@@ -870,7 +870,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_8_3s5() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.8.3-6) */
// int f() {
// int i=1;
@@ -886,7 +886,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_8_3s6() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.8.4-7) */
// int f(int a) {}
// int g(int expr) {
@@ -903,7 +903,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_8_4s7() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.8.6.1-3) */
// int f() {
// goto first_time;
@@ -921,7 +921,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_8_6_1s3() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.8.6.1-4) */
// int f() {
// goto lab3; // invalid: going INTO scope of VLA.
@@ -963,7 +963,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_8_6_4s4() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, 0);
}
-
+
// /* Start Example(C 6.9.1-13) */
// extern int max(int a, int b)
// {
@@ -972,7 +972,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_9_1s13() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.9.1-14) */
// void g(int (*funcp)(void))
// {
@@ -982,7 +982,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_9_1s14() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.9.2-4) */
// int i1 = 1; // definition, external linkage
// static int i2 = 2; // definition, internal linkage
@@ -1002,7 +1002,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_9_2s4() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.10.1-4) */
// int g() {}
// int f() {
@@ -1015,7 +1015,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_10_1s4() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.10.3.3-4) */
// #define hash_hash # ## #
// #define mkstr(a) # a
@@ -1026,20 +1026,20 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_10_3_3s4() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.10.3.5-3) */
// #define TABSIZE 100
// int table[TABSIZE];
public void test6_10_3_5s3() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.10.3.5-4) */
// #define max(a, b) ((a) > (b) ? (a) : (b))
public void test6_10_3_5s4() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.10.3.5-5) */
// #define x 3
// #define f(a) f(x * (a))
@@ -1086,7 +1086,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_10_3_5s6() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.10.3.5-7) */
// #define t(x,y,z) x ## y ## z
// int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),
@@ -1099,14 +1099,14 @@ public class AST2CSpecTest extends AST2SpecTestBase {
// #define OBJ_LIKE1 (1-1)
// #define OBJ_LIKE2 \
// (1-1) \
- // #define FUNC_LIKE1(a) ( a )
+ // #define FUNC_LIKE1(a) ( a )
// #define FUNC_LIKE2( a )( \
// a \
// )
public void test6_10_3_5s8() throws Exception {
parseCandCPP(getAboveComment(), true, 0);
}
-
+
// /* Start Example(C 6.10.3.5-9) */
// #define debug(...) fprintf(stderr, __VA_ARGS__)
// #define showlist(...) puts(#__VA_ARGS__)
@@ -1121,7 +1121,7 @@ public class AST2CSpecTest extends AST2SpecTestBase {
public void test6_10_3_5s9() throws Exception {
parseCandCPP(getAboveComment(), false, 0);
}
-
+
// /* Start Example(C 6.7.7-6) */
// typedef signed int t;
// typedef int plain;
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTestCase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTestCase.java
index 515566d497a..db53d108ae7 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTestCase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTestCase.java
@@ -39,15 +39,15 @@ import org.eclipse.core.runtime.NullProgressMonitor;
* @author dsteffle
*/
public class AST2FileBasePluginTestCase extends TestCase {
- static NullProgressMonitor monitor;
- static IWorkspace workspace;
- static IProject project;
- static FileManager fileManager;
- static int numProjects;
- static Class className;
+ static NullProgressMonitor monitor;
+ static IWorkspace workspace;
+ static IProject project;
+ static FileManager fileManager;
+ static int numProjects;
+ static Class className;
static ICProject cPrj;
- public AST2FileBasePluginTestCase() {
+ public AST2FileBasePluginTestCase() {
}
public AST2FileBasePluginTestCase(String name) {
@@ -55,88 +55,88 @@ public class AST2FileBasePluginTestCase extends TestCase {
}
private void initialize(Class aClassName) {
- if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null) {
+ if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null) {
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
monitor = new NullProgressMonitor();
workspace = ResourcesPlugin.getWorkspace();
- try {
- cPrj = CProjectHelper.createCCProject("AST2BasedProjectMofo", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
+ try {
+ cPrj = CProjectHelper.createCCProject("AST2BasedProjectMofo", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
- project = cPrj.getProject();
+ project = cPrj.getProject();
- // ugly
- if (className == null || !className.equals(aClassName)) {
- className = aClassName;
- numProjects++;
- }
- } catch (CoreException e) {
- // Ignore
- }
+ // ugly
+ if (className == null || !className.equals(aClassName)) {
+ className = aClassName;
+ numProjects++;
+ }
+ } catch (CoreException e) {
+ // Ignore
+ }
if (project == null)
throw new NullPointerException("Unable to create project"); //$NON-NLS-1$
// Create file manager
fileManager = new FileManager();
- }
- }
-
- public AST2FileBasePluginTestCase(String name, Class className) {
- super(name);
- initialize(className);
- }
-
- public void cleanupProject() throws Exception {
- numProjects--;
-
- try {
- if (numProjects == 0) {
- project.delete(true, false, monitor);
- project = null;
- }
- } catch (Throwable e) {
- // Ignore
- }
- }
-
- @Override
+ }
+ }
+
+ public AST2FileBasePluginTestCase(String name, Class className) {
+ super(name);
+ initialize(className);
+ }
+
+ public void cleanupProject() throws Exception {
+ numProjects--;
+
+ try {
+ if (numProjects == 0) {
+ project.delete(true, false, monitor);
+ project = null;
+ }
+ } catch (Throwable e) {
+ // Ignore
+ }
+ }
+
+ @Override
protected void tearDown() throws Exception {
- if (project == null || !project.exists())
- return;
-
- IResource[] members = project.members();
- for (int i = 0; i < members.length; i++) {
- if (members[i].getName().equals(".project") || members[i].getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
- continue;
- if (members[i].getName().equals(".settings"))
- continue;
- try {
- members[i].delete(false, monitor);
- } catch (Throwable e) {
- // Ignore
- }
- }
+ if (project == null || !project.exists())
+ return;
+
+ IResource[] members = project.members();
+ for (int i = 0; i < members.length; i++) {
+ if (members[i].getName().equals(".project") || members[i].getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
+ continue;
+ if (members[i].getName().equals(".settings"))
+ continue;
+ try {
+ members[i].delete(false, monitor);
+ } catch (Throwable e) {
+ // Ignore
+ }
+ }
}
- protected IFolder importFolder(String folderName) throws Exception {
- IFolder folder = project.getProject().getFolder(folderName);
+ protected IFolder importFolder(String folderName) throws Exception {
+ IFolder folder = project.getProject().getFolder(folderName);
// Create file input stream
if (!folder.exists())
folder.create(false, false, monitor);
return folder;
- }
+ }
- public IFile importFile(String fileName, String contents) throws Exception {
+ public IFile importFile(String fileName, String contents) throws Exception {
// Obtain file handle
IFile file = project.getProject().getFile(fileName);
InputStream stream = new ByteArrayInputStream(contents.getBytes());
// Create file input stream
if (file.exists()) {
- file.setContents(stream, false, false, monitor);
+ file.setContents(stream, false, false, monitor);
} else {
file.create(stream, false, monitor);
}
@@ -147,7 +147,7 @@ public class AST2FileBasePluginTestCase extends TestCase {
}
protected StringBuilder[] getContents(int sections) throws IOException {
- return TestSourceReader.getContentsForTest(
- CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), sections);
+ return TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "parser", getClass(),
+ getName(), sections);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java
index 72a44f6d01e..81ca1ccb5c7 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Rational Software - Initial API and implementation
* Anton Leherbauer (Wind River Systems)
@@ -63,8 +63,8 @@ import org.eclipse.cdt.internal.core.dom.parser.c.ICInternalBinding;
* @author dsteffle
*/
public class AST2KnRTests extends AST2TestBase {
-
- public AST2KnRTests() {
+
+ public AST2KnRTests() {
}
public AST2KnRTests(String name) {
@@ -72,574 +72,665 @@ public class AST2KnRTests extends AST2TestBase {
}
public void testSimpleKRCTest1() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("int f(char x);\n"); //$NON-NLS-1$
- buffer.append("int f(x) char x;\n"); //$NON-NLS-1$
- buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
-
- IASTSimpleDeclaration f1 = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTFunctionDefinition f2 = (IASTFunctionDefinition) tu.getDeclarations()[1];
-
- assertTrue(f1.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator);
-
- IParameter x4 = (IParameter) ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f2.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding();
- IParameter x3 = (IParameter) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName().resolveBinding();
- IParameter x2 = (IParameter) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterNames()[0].resolveBinding();
- IParameter x1 = (IParameter) ((IASTStandardFunctionDeclarator) f1.getDeclarators()[0]).getParameters()[0].getDeclarator().getName().resolveBinding();
-
- assertNotNull(x1);
- assertNotNull(x2);
- assertNotNull(x3);
- assertNotNull(x4);
- assertEquals(x1, x2);
- assertEquals(x2, x3);
- assertEquals(x3, x4);
-
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int f(char x);\n"); //$NON-NLS-1$
+ buffer.append("int f(x) char x;\n"); //$NON-NLS-1$
+ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
+
+ IASTSimpleDeclaration f1 = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTFunctionDefinition f2 = (IASTFunctionDefinition) tu.getDeclarations()[1];
+
+ assertTrue(f1.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator);
+
+ IParameter x4 = (IParameter) ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f2
+ .getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding();
+ IParameter x3 = (IParameter) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator())
+ .getParameterDeclarations()[0]).getDeclarators()[0].getName().resolveBinding();
+ IParameter x2 = (IParameter) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterNames()[0]
+ .resolveBinding();
+ IParameter x1 = (IParameter) ((IASTStandardFunctionDeclarator) f1.getDeclarators()[0]).getParameters()[0]
+ .getDeclarator().getName().resolveBinding();
+
+ assertNotNull(x1);
+ assertNotNull(x2);
+ assertNotNull(x3);
+ assertNotNull(x4);
+ assertEquals(x1, x2);
+ assertEquals(x2, x3);
+ assertEquals(x3, x4);
+
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(x1);
assertEquals(decls.length, 2);
- assertEquals(decls[0], ((IASTStandardFunctionDeclarator) f1.getDeclarators()[0]).getParameters()[0].getDeclarator().getName());
- assertEquals(decls[1], ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName());
+ assertEquals(decls[0],
+ ((IASTStandardFunctionDeclarator) f1.getDeclarators()[0]).getParameters()[0].getDeclarator().getName());
+ assertEquals(decls[1], ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator())
+ .getParameterDeclarations()[0]).getDeclarators()[0].getName());
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "f".toCharArray())); //$NON-NLS-1$
- assertNotNull(((CScope) ((IASTCompoundStatement) f2.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$
- }
-
- public void testSimpleKRCTest2() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("int f();\n"); //$NON-NLS-1$
- buffer.append("int f(x) char x;\n"); //$NON-NLS-1$
- buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
-
- IASTSimpleDeclaration f1 = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTFunctionDefinition f2 = (IASTFunctionDefinition) tu.getDeclarations()[1];
-
- assertTrue(f1.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator);
-
- IParameter x4 = (IParameter) ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f2.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding();
- IParameter x3 = (IParameter) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName().resolveBinding();
- IParameter x2 = (IParameter) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterNames()[0].resolveBinding();
-
- assertNotNull(x2);
- assertNotNull(x3);
- assertNotNull(x4);
- assertEquals(x2, x3);
- assertEquals(x3, x4);
-
+ assertNotNull(((CScope) ((IASTCompoundStatement) f2.getBody()).getScope())
+ .getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$
+ }
+
+ public void testSimpleKRCTest2() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int f();\n"); //$NON-NLS-1$
+ buffer.append("int f(x) char x;\n"); //$NON-NLS-1$
+ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
+
+ IASTSimpleDeclaration f1 = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTFunctionDefinition f2 = (IASTFunctionDefinition) tu.getDeclarations()[1];
+
+ assertTrue(f1.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator);
+
+ IParameter x4 = (IParameter) ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f2
+ .getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding();
+ IParameter x3 = (IParameter) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator())
+ .getParameterDeclarations()[0]).getDeclarators()[0].getName().resolveBinding();
+ IParameter x2 = (IParameter) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterNames()[0]
+ .resolveBinding();
+
+ assertNotNull(x2);
+ assertNotNull(x3);
+ assertNotNull(x4);
+ assertEquals(x2, x3);
+ assertEquals(x3, x4);
+
// test tu.getDeclarationsInAST(IBinding)
- IASTName[] decls = tu.getDeclarationsInAST(x2);
+ IASTName[] decls = tu.getDeclarationsInAST(x2);
assertEquals(decls.length, 1);
- assertEquals(decls[0], ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName());
+ assertEquals(decls[0], ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator())
+ .getParameterDeclarations()[0]).getDeclarators()[0].getName());
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "f".toCharArray())); //$NON-NLS-1$
- assertNotNull(((CScope) ((IASTCompoundStatement) f2.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$
- }
-
- public void testSimpleKRCTest3() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("int const *f();\n"); //$NON-NLS-1$
- buffer.append("int const *f(x) char x;\n"); //$NON-NLS-1$
- buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
-
- IASTSimpleDeclaration f1 = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTFunctionDefinition f2 = (IASTFunctionDefinition) tu.getDeclarations()[1];
-
- assertTrue(f1.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator);
-
- IParameter x4 = (IParameter) ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f2.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding();
- IParameter x3 = (IParameter) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName().resolveBinding();
- IParameter x2 = (IParameter) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterNames()[0].resolveBinding();
-
- assertNotNull(x2);
- assertNotNull(x3);
- assertNotNull(x4);
- assertEquals(x2, x3);
- assertEquals(x3, x4);
- }
-
- public void testKRC_1() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("int isroot (x, y) /* comment */ \n"); //$NON-NLS-1$
- buffer.append("int x;\n"); //$NON-NLS-1$
- buffer.append("int y;\n"); //$NON-NLS-1$
- buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
-
- IASTFunctionDefinition isroot_def = (IASTFunctionDefinition) tu.getDeclarations()[0];
-
- IASTName ret_x = ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) isroot_def.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName();
- IASTDeclarator isroot_decltor = isroot_def.getDeclarator();
-
- assertTrue(isroot_decltor instanceof ICASTKnRFunctionDeclarator);
- IASTDeclarator x1 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_decltor).getParameterDeclarations()[0]).getDeclarators()[0];
- IASTDeclarator y1 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_decltor).getParameterDeclarations()[1]).getDeclarators()[0];
-
- IParameter x_parm = (IParameter) x1.getName().resolveBinding();
- IParameter y_parm = (IParameter) y1.getName().resolveBinding();
- assertNotNull(x_parm);
- assertNotNull(y_parm);
-
- IASTDeclarator x2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_decltor).getParameterDeclarations()[0]).getDeclarators()[0];
- IASTDeclarator y2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_decltor).getParameterDeclarations()[1]).getDeclarators()[0];
-
- IParameter x_parm2 = (IParameter) x2.getName().resolveBinding();
- IParameter y_parm2 = (IParameter) y2.getName().resolveBinding();
-
- assertNotNull(x_parm2);
- assertNotNull(y_parm2);
- assertNotNull(ret_x.resolveBinding());
-
- assertEquals(x_parm, x_parm2);
- assertEquals(y_parm, y_parm2);
- assertEquals(ret_x.resolveBinding(), x_parm);
+ assertNotNull(((CScope) ((IASTCompoundStatement) f2.getBody()).getScope())
+ .getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$
+ }
+
+ public void testSimpleKRCTest3() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int const *f();\n"); //$NON-NLS-1$
+ buffer.append("int const *f(x) char x;\n"); //$NON-NLS-1$
+ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
+
+ IASTSimpleDeclaration f1 = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTFunctionDefinition f2 = (IASTFunctionDefinition) tu.getDeclarations()[1];
+
+ assertTrue(f1.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator);
+
+ IParameter x4 = (IParameter) ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f2
+ .getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding();
+ IParameter x3 = (IParameter) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator())
+ .getParameterDeclarations()[0]).getDeclarators()[0].getName().resolveBinding();
+ IParameter x2 = (IParameter) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterNames()[0]
+ .resolveBinding();
+
+ assertNotNull(x2);
+ assertNotNull(x3);
+ assertNotNull(x4);
+ assertEquals(x2, x3);
+ assertEquals(x3, x4);
+ }
+
+ public void testKRC_1() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int isroot (x, y) /* comment */ \n"); //$NON-NLS-1$
+ buffer.append("int x;\n"); //$NON-NLS-1$
+ buffer.append("int y;\n"); //$NON-NLS-1$
+ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
+
+ IASTFunctionDefinition isroot_def = (IASTFunctionDefinition) tu.getDeclarations()[0];
+
+ IASTName ret_x = ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) isroot_def
+ .getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName();
+ IASTDeclarator isroot_decltor = isroot_def.getDeclarator();
+
+ assertTrue(isroot_decltor instanceof ICASTKnRFunctionDeclarator);
+ IASTDeclarator x1 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_decltor)
+ .getParameterDeclarations()[0]).getDeclarators()[0];
+ IASTDeclarator y1 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_decltor)
+ .getParameterDeclarations()[1]).getDeclarators()[0];
+
+ IParameter x_parm = (IParameter) x1.getName().resolveBinding();
+ IParameter y_parm = (IParameter) y1.getName().resolveBinding();
+ assertNotNull(x_parm);
+ assertNotNull(y_parm);
+
+ IASTDeclarator x2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_decltor)
+ .getParameterDeclarations()[0]).getDeclarators()[0];
+ IASTDeclarator y2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_decltor)
+ .getParameterDeclarations()[1]).getDeclarators()[0];
+
+ IParameter x_parm2 = (IParameter) x2.getName().resolveBinding();
+ IParameter y_parm2 = (IParameter) y2.getName().resolveBinding();
+
+ assertNotNull(x_parm2);
+ assertNotNull(y_parm2);
+ assertNotNull(ret_x.resolveBinding());
+
+ assertEquals(x_parm, x_parm2);
+ assertEquals(y_parm, y_parm2);
+ assertEquals(ret_x.resolveBinding(), x_parm);
// test tu.getDeclarationsInAST(IBinding)
- IASTName[] decls = tu.getDeclarationsInAST(ret_x.resolveBinding());
+ IASTName[] decls = tu.getDeclarationsInAST(ret_x.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], x1.getName());
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "isroot".toCharArray())); //$NON-NLS-1$
- assertNotNull(((CScope) ((IASTCompoundStatement) isroot_def.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$
- assertNotNull(((CScope) ((IASTCompoundStatement) isroot_def.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "y".toCharArray())); //$NON-NLS-1$
- }
-
- public void testKRCWithTypes() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("typedef char c;\n"); //$NON-NLS-1$
- buffer.append("int isroot (c);\n"); //$NON-NLS-1$
- buffer.append("int isroot (x) \n"); //$NON-NLS-1$
- buffer.append("c x;\n"); //$NON-NLS-1$
- buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
-
- IASTSimpleDeclaration c_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTSimpleDeclaration isroot_decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
- IASTFunctionDefinition isroot_def = (IASTFunctionDefinition) tu.getDeclarations()[2];
-
- //IASTName x0 = ((IASTStandardFunctionDeclarator) isroot_decl.getDeclarators()[0]).getParameters()[0].getDeclarator().getName();
- IASTName x1 = ((ICASTKnRFunctionDeclarator) isroot_def.getDeclarator()).getParameterNames()[0];
- IASTName x2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_def.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName();
- IASTName x3 = ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) isroot_def.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName();
-
- IParameter x1_var = (IParameter) x1.resolveBinding();
- IParameter x2_var = (IParameter) x2.resolveBinding();
- IParameter x3_var = (IParameter) x3.resolveBinding();
-
- assertNotNull(x1_var);
- assertNotNull(x2_var);
- assertNotNull(x3_var);
- assertEquals(x1_var, x2_var);
- assertEquals(x2_var, x3_var);
-
- IASTName c1 = c_decl.getDeclarators()[0].getName();
- IASTName c2 = ((IASTNamedTypeSpecifier) ((IASTStandardFunctionDeclarator) isroot_decl.getDeclarators()[0]).getParameters()[0].getDeclSpecifier()).getName();
- IASTName c3 = ((IASTNamedTypeSpecifier) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_def.getDeclarator()).getParameterDeclarations()[0]).getDeclSpecifier()).getName();
-
- ITypedef c1_t = (ITypedef) c1.resolveBinding();
- ITypedef c2_t = (ITypedef) c2.resolveBinding();
- ITypedef c3_t = (ITypedef) c3.resolveBinding();
-
- assertNotNull(c1_t);
- assertNotNull(c2_t);
- assertNotNull(c3_t);
- assertEquals(c1_t, c2_t);
- assertEquals(c2_t, c3_t);
- assertTrue(c1_t.getType() instanceof IBasicType);
- assertEquals(((IBasicType) c1_t.getType()).getType(), IBasicType.t_char);
-
+ assertNotNull(((CScope) ((IASTCompoundStatement) isroot_def.getBody()).getScope())
+ .getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$
+ assertNotNull(((CScope) ((IASTCompoundStatement) isroot_def.getBody()).getScope())
+ .getBinding(CScope.NAMESPACE_TYPE_OTHER, "y".toCharArray())); //$NON-NLS-1$
+ }
+
+ public void testKRCWithTypes() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("typedef char c;\n"); //$NON-NLS-1$
+ buffer.append("int isroot (c);\n"); //$NON-NLS-1$
+ buffer.append("int isroot (x) \n"); //$NON-NLS-1$
+ buffer.append("c x;\n"); //$NON-NLS-1$
+ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
+
+ IASTSimpleDeclaration c_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTSimpleDeclaration isroot_decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
+ IASTFunctionDefinition isroot_def = (IASTFunctionDefinition) tu.getDeclarations()[2];
+
+ //IASTName x0 = ((IASTStandardFunctionDeclarator) isroot_decl.getDeclarators()[0]).getParameters()[0].getDeclarator().getName();
+ IASTName x1 = ((ICASTKnRFunctionDeclarator) isroot_def.getDeclarator()).getParameterNames()[0];
+ IASTName x2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_def.getDeclarator())
+ .getParameterDeclarations()[0]).getDeclarators()[0].getName();
+ IASTName x3 = ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) isroot_def
+ .getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName();
+
+ IParameter x1_var = (IParameter) x1.resolveBinding();
+ IParameter x2_var = (IParameter) x2.resolveBinding();
+ IParameter x3_var = (IParameter) x3.resolveBinding();
+
+ assertNotNull(x1_var);
+ assertNotNull(x2_var);
+ assertNotNull(x3_var);
+ assertEquals(x1_var, x2_var);
+ assertEquals(x2_var, x3_var);
+
+ IASTName c1 = c_decl.getDeclarators()[0].getName();
+ IASTName c2 = ((IASTNamedTypeSpecifier) ((IASTStandardFunctionDeclarator) isroot_decl.getDeclarators()[0])
+ .getParameters()[0].getDeclSpecifier()).getName();
+ IASTName c3 = ((IASTNamedTypeSpecifier) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_def
+ .getDeclarator()).getParameterDeclarations()[0]).getDeclSpecifier()).getName();
+
+ ITypedef c1_t = (ITypedef) c1.resolveBinding();
+ ITypedef c2_t = (ITypedef) c2.resolveBinding();
+ ITypedef c3_t = (ITypedef) c3.resolveBinding();
+
+ assertNotNull(c1_t);
+ assertNotNull(c2_t);
+ assertNotNull(c3_t);
+ assertEquals(c1_t, c2_t);
+ assertEquals(c2_t, c3_t);
+ assertTrue(c1_t.getType() instanceof IBasicType);
+ assertEquals(((IBasicType) c1_t.getType()).getType(), IBasicType.t_char);
+
// test tu.getDeclarationsInAST(IBinding)
- IASTName[] decls = tu.getDeclarationsInAST(x3.resolveBinding());
+ IASTName[] decls = tu.getDeclarationsInAST(x3.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], x2);
-
+
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "c".toCharArray())); //$NON-NLS-1$
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "isroot".toCharArray())); //$NON-NLS-1$
- assertNotNull(((CScope) ((IASTCompoundStatement) isroot_def.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$
- }
-
- public void testKRCProblem1() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("int f(x) char\n"); //$NON-NLS-1$
- buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false);
- IASTDeclaration[] decls= tu.getDeclarations();
-
- assertTrue(CVisitor.getProblems(tu).length > 0);
- }
-
- public void testKRCProblem2() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("int i=0;\n"); //$NON-NLS-1$
- buffer.append("int f(x) i++;\n"); //$NON-NLS-1$
- buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false);
-
- IASTSimpleDeclaration sd= getDeclaration(tu, 0);
- assertTrue(CVisitor.getProblems(tu).length > 0);
+ assertNotNull(((CScope) ((IASTCompoundStatement) isroot_def.getBody()).getScope())
+ .getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$
+ }
+
+ public void testKRCProblem1() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int f(x) char\n"); //$NON-NLS-1$
+ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false);
+ IASTDeclaration[] decls = tu.getDeclarations();
+
+ assertTrue(CVisitor.getProblems(tu).length > 0);
}
- public void testKRCProblem3() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("int f(x) char y;\n"); //$NON-NLS-1$
- buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false);
-
- IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
- assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
- ICASTKnRFunctionDeclarator f_kr = (ICASTKnRFunctionDeclarator) f.getDeclarator();
- assertEquals(f_kr.getName().toString(), "f"); //$NON-NLS-1$
- assertEquals(f_kr.getParameterNames()[0].toString(), "x"); //$NON-NLS-1$
- assertTrue(f_kr.getParameterDeclarations()[0] instanceof IASTProblemDeclaration);
- assertTrue(f.getBody() instanceof IASTCompoundStatement);
- assertTrue(((IASTCompoundStatement) f.getBody()).getStatements()[0] instanceof IASTReturnStatement);
- assertTrue(((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue() instanceof IASTBinaryExpression);
- assertTrue(((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1() instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().toString(), "x"); //$NON-NLS-1$
- assertTrue(((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand2() instanceof IASTLiteralExpression);
- assertEquals(((IASTLiteralExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand2()).toString(), "0"); //$NON-NLS-1$
+ public void testKRCProblem2() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int i=0;\n"); //$NON-NLS-1$
+ buffer.append("int f(x) i++;\n"); //$NON-NLS-1$
+ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false);
+
+ IASTSimpleDeclaration sd = getDeclaration(tu, 0);
+ assertTrue(CVisitor.getProblems(tu).length > 0);
+ }
+
+ public void testKRCProblem3() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int f(x) char y;\n"); //$NON-NLS-1$
+ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false);
+
+ IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
+ ICASTKnRFunctionDeclarator f_kr = (ICASTKnRFunctionDeclarator) f.getDeclarator();
+ assertEquals(f_kr.getName().toString(), "f"); //$NON-NLS-1$
+ assertEquals(f_kr.getParameterNames()[0].toString(), "x"); //$NON-NLS-1$
+ assertTrue(f_kr.getParameterDeclarations()[0] instanceof IASTProblemDeclaration);
+ assertTrue(f.getBody() instanceof IASTCompoundStatement);
+ assertTrue(((IASTCompoundStatement) f.getBody()).getStatements()[0] instanceof IASTReturnStatement);
+ assertTrue(((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0])
+ .getReturnValue() instanceof IASTBinaryExpression);
+ assertTrue(
+ ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0])
+ .getReturnValue()).getOperand1() instanceof IASTIdExpression);
+ assertEquals(
+ ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody())
+ .getStatements()[0]).getReturnValue()).getOperand1()).getName().toString(),
+ "x"); //$NON-NLS-1$
+ assertTrue(
+ ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0])
+ .getReturnValue()).getOperand2() instanceof IASTLiteralExpression);
+ assertEquals(((IASTLiteralExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f
+ .getBody()).getStatements()[0]).getReturnValue()).getOperand2()).toString(), "0"); //$NON-NLS-1$
// test tu.getDeclarationsInAST(IBinding)
- IASTName[] decls = tu.getDeclarationsInAST(((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding());
+ IASTName[] decls = tu.getDeclarationsInAST(
+ ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody())
+ .getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding());
assertEquals(decls.length, 0);
- }
-
- public void testKRCProblem4() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("int f(x,y,z) char x,y,z; int a;\n"); //$NON-NLS-1$
- buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false);
-
- IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
- assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
- ICASTKnRFunctionDeclarator f_kr = (ICASTKnRFunctionDeclarator) f.getDeclarator();
- assertEquals(f_kr.getName().toString(), "f"); //$NON-NLS-1$
- assertEquals(f_kr.getParameterNames()[0].toString(), "x"); //$NON-NLS-1$
- assertTrue(f_kr.getParameterDeclarations()[0] instanceof IASTSimpleDeclaration);
- assertTrue(f_kr.getParameterDeclarations()[1] instanceof IASTProblemDeclaration);
- assertTrue(f.getBody() instanceof IASTCompoundStatement);
- assertTrue(((IASTCompoundStatement) f.getBody()).getStatements()[0] instanceof IASTReturnStatement);
- assertTrue(((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue() instanceof IASTBinaryExpression);
- assertTrue(((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1() instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().toString(), "x"); //$NON-NLS-1$
- assertTrue(((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand2() instanceof IASTLiteralExpression);
- assertEquals(((IASTLiteralExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand2()).toString(), "0"); //$NON-NLS-1$
-
- // bindings should still be ok
- IASTName x1 = f_kr.getParameterNames()[0];
- IASTName y1 = f_kr.getParameterNames()[1];
- IASTName z1 = f_kr.getParameterNames()[2];
- IASTName x2 = ((IASTSimpleDeclaration) f_kr.getParameterDeclarations()[0]).getDeclarators()[0].getName();
- IASTName y2 = ((IASTSimpleDeclaration) f_kr.getParameterDeclarations()[0]).getDeclarators()[1].getName();
- IASTName z2 = ((IASTSimpleDeclaration) f_kr.getParameterDeclarations()[0]).getDeclarators()[2].getName();
- IASTName x3 = ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName();
-
- IParameter x1_parm = (IParameter) x1.resolveBinding();
- IParameter x2_parm = (IParameter) x2.resolveBinding();
- IParameter x3_parm = (IParameter) x3.resolveBinding();
- IParameter y1_parm = (IParameter) y1.resolveBinding();
- IParameter y2_parm = (IParameter) y2.resolveBinding();
- IParameter z1_parm = (IParameter) z1.resolveBinding();
- IParameter z2_parm = (IParameter) z2.resolveBinding();
-
- assertEquals(x1_parm, x2_parm);
- assertEquals(x2_parm, x3_parm);
- assertEquals(y1_parm, y2_parm);
- assertEquals(z1_parm, z2_parm);
-
+ }
+
+ public void testKRCProblem4() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int f(x,y,z) char x,y,z; int a;\n"); //$NON-NLS-1$
+ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false);
+
+ IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
+ ICASTKnRFunctionDeclarator f_kr = (ICASTKnRFunctionDeclarator) f.getDeclarator();
+ assertEquals(f_kr.getName().toString(), "f"); //$NON-NLS-1$
+ assertEquals(f_kr.getParameterNames()[0].toString(), "x"); //$NON-NLS-1$
+ assertTrue(f_kr.getParameterDeclarations()[0] instanceof IASTSimpleDeclaration);
+ assertTrue(f_kr.getParameterDeclarations()[1] instanceof IASTProblemDeclaration);
+ assertTrue(f.getBody() instanceof IASTCompoundStatement);
+ assertTrue(((IASTCompoundStatement) f.getBody()).getStatements()[0] instanceof IASTReturnStatement);
+ assertTrue(((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0])
+ .getReturnValue() instanceof IASTBinaryExpression);
+ assertTrue(
+ ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0])
+ .getReturnValue()).getOperand1() instanceof IASTIdExpression);
+ assertEquals(
+ ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody())
+ .getStatements()[0]).getReturnValue()).getOperand1()).getName().toString(),
+ "x"); //$NON-NLS-1$
+ assertTrue(
+ ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0])
+ .getReturnValue()).getOperand2() instanceof IASTLiteralExpression);
+ assertEquals(((IASTLiteralExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f
+ .getBody()).getStatements()[0]).getReturnValue()).getOperand2()).toString(), "0"); //$NON-NLS-1$
+
+ // bindings should still be ok
+ IASTName x1 = f_kr.getParameterNames()[0];
+ IASTName y1 = f_kr.getParameterNames()[1];
+ IASTName z1 = f_kr.getParameterNames()[2];
+ IASTName x2 = ((IASTSimpleDeclaration) f_kr.getParameterDeclarations()[0]).getDeclarators()[0].getName();
+ IASTName y2 = ((IASTSimpleDeclaration) f_kr.getParameterDeclarations()[0]).getDeclarators()[1].getName();
+ IASTName z2 = ((IASTSimpleDeclaration) f_kr.getParameterDeclarations()[0]).getDeclarators()[2].getName();
+ IASTName x3 = ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f
+ .getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName();
+
+ IParameter x1_parm = (IParameter) x1.resolveBinding();
+ IParameter x2_parm = (IParameter) x2.resolveBinding();
+ IParameter x3_parm = (IParameter) x3.resolveBinding();
+ IParameter y1_parm = (IParameter) y1.resolveBinding();
+ IParameter y2_parm = (IParameter) y2.resolveBinding();
+ IParameter z1_parm = (IParameter) z1.resolveBinding();
+ IParameter z2_parm = (IParameter) z2.resolveBinding();
+
+ assertEquals(x1_parm, x2_parm);
+ assertEquals(x2_parm, x3_parm);
+ assertEquals(y1_parm, y2_parm);
+ assertEquals(z1_parm, z2_parm);
+
// test tu.getDeclarationsInAST(IBinding)
- IASTName[] decls = tu.getDeclarationsInAST(((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding());
+ IASTName[] decls = tu.getDeclarationsInAST(
+ ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody())
+ .getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], x2);
- }
-
- public void testKRCProblem5() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("int f(x) char x,a;\n"); //$NON-NLS-1$
- buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false);
-
- IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
- assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
- ICASTKnRFunctionDeclarator f_kr = (ICASTKnRFunctionDeclarator) f.getDeclarator();
- assertEquals(f_kr.getName().toString(), "f"); //$NON-NLS-1$
- assertEquals(f_kr.getParameterNames()[0].toString(), "x"); //$NON-NLS-1$
- assertTrue(f_kr.getParameterDeclarations()[0] instanceof IASTProblemDeclaration);
- assertTrue(f.getBody() instanceof IASTCompoundStatement);
- assertTrue(((IASTCompoundStatement) f.getBody()).getStatements()[0] instanceof IASTReturnStatement);
- assertTrue(((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue() instanceof IASTBinaryExpression);
- assertTrue(((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1() instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().toString(), "x"); //$NON-NLS-1$
- assertTrue(((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand2() instanceof IASTLiteralExpression);
- assertEquals(((IASTLiteralExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand2()).toString(), "0"); //$NON-NLS-1$
-
+ }
+
+ public void testKRCProblem5() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int f(x) char x,a;\n"); //$NON-NLS-1$
+ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false);
+
+ IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
+ ICASTKnRFunctionDeclarator f_kr = (ICASTKnRFunctionDeclarator) f.getDeclarator();
+ assertEquals(f_kr.getName().toString(), "f"); //$NON-NLS-1$
+ assertEquals(f_kr.getParameterNames()[0].toString(), "x"); //$NON-NLS-1$
+ assertTrue(f_kr.getParameterDeclarations()[0] instanceof IASTProblemDeclaration);
+ assertTrue(f.getBody() instanceof IASTCompoundStatement);
+ assertTrue(((IASTCompoundStatement) f.getBody()).getStatements()[0] instanceof IASTReturnStatement);
+ assertTrue(((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0])
+ .getReturnValue() instanceof IASTBinaryExpression);
+ assertTrue(
+ ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0])
+ .getReturnValue()).getOperand1() instanceof IASTIdExpression);
+ assertEquals(
+ ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody())
+ .getStatements()[0]).getReturnValue()).getOperand1()).getName().toString(),
+ "x"); //$NON-NLS-1$
+ assertTrue(
+ ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0])
+ .getReturnValue()).getOperand2() instanceof IASTLiteralExpression);
+ assertEquals(((IASTLiteralExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f
+ .getBody()).getStatements()[0]).getReturnValue()).getOperand2()).toString(), "0"); //$NON-NLS-1$
+
// test tu.getDeclarationsInAST(IBinding)
- IASTName[] decls = tu.getDeclarationsInAST(((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding());
- assertEquals(decls.length, 0);
- }
-
-
- public void testKRC_monop_cards1() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("#ifdef __STDC__\n"); //$NON-NLS-1$
- buffer.append("#define __P(x) x\n"); //$NON-NLS-1$
- buffer.append("#else\n"); //$NON-NLS-1$
- buffer.append("#define __P(x) ()\n"); //$NON-NLS-1$
- buffer.append("#endif\n"); //$NON-NLS-1$
- buffer.append("struct A_struct {\n"); //$NON-NLS-1$
- buffer.append("int a;\n"); //$NON-NLS-1$
- buffer.append("long *c;\n"); //$NON-NLS-1$
- buffer.append("};\n"); //$NON-NLS-1$
- buffer.append("typedef struct A_struct A;\n"); //$NON-NLS-1$
- buffer.append("static void f __P((A *));\n"); //$NON-NLS-1$
- buffer.append("static void\n"); //$NON-NLS-1$
- buffer.append("f(x)\n"); //$NON-NLS-1$
- buffer.append("A *x; {\n"); //$NON-NLS-1$
- buffer.append("x->a = 0;\n"); //$NON-NLS-1$
- buffer.append("x->c[1]=x->c[2];\n"); //$NON-NLS-1$
- buffer.append("}\n"); //$NON-NLS-1$
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
-
- IASTSimpleDeclaration A_struct = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTSimpleDeclaration A = (IASTSimpleDeclaration) tu.getDeclarations()[1];
- IASTSimpleDeclaration f_decl = (IASTSimpleDeclaration) tu.getDeclarations()[2];
- IASTFunctionDefinition f_def = (IASTFunctionDefinition) tu.getDeclarations()[3];
-
- // check A_struct
- assertTrue(A_struct.getDeclSpecifier() instanceof IASTCompositeTypeSpecifier);
- assertEquals(A_struct.getDeclarators().length, 0);
- IASTName A_struct_name1 = ((IASTCompositeTypeSpecifier)A_struct.getDeclSpecifier()).getName();
- assertEquals(A_struct_name1.toString(), "A_struct"); //$NON-NLS-1$
- ICompositeType A_struct_type1 = (ICompositeType)A_struct_name1.resolveBinding();
- assertEquals(((ICInternalBinding)A_struct_type1).getPhysicalNode(), ((IASTCompositeTypeSpecifier)A_struct.getDeclSpecifier()).getName());
- IField[] fields = A_struct_type1.getFields();
- IField a1 = fields[0];
- IField c1 = fields[1];
- assertEquals(a1.getName().toString(), "a"); //$NON-NLS-1$
- assertEquals(c1.getName().toString(), "c"); //$NON-NLS-1$
- IBasicType a1_t = (IBasicType) a1.getType();
- IPointerType c1_t = (IPointerType) c1.getType();
- assertEquals(a1_t.getType(), IBasicType.t_int);
- assertTrue(c1_t.getType() instanceof IBasicType);
- assertTrue(((IBasicType) c1_t.getType()).isLong());
-
- // check A
- IASTName A_name1 = A.getDeclarators()[0].getName();
- assertEquals(A_name1.toString(), "A"); //$NON-NLS-1$
- ITypedef A_var1 = (ITypedef)A_name1.resolveBinding();
- assertTrue(A.getDeclSpecifier() instanceof IASTElaboratedTypeSpecifier);
- IASTName A_struct_name_2 = ((IASTElaboratedTypeSpecifier)A.getDeclSpecifier()).getName();
- assertEquals(A_struct_name_2.toString(), "A_struct"); //$NON-NLS-1$
- assertEquals(((IASTElaboratedTypeSpecifier)A.getDeclSpecifier()).getStorageClass(), IASTDeclSpecifier.sc_typedef);
- ICompositeType A_struct_type2 = (ICompositeType)A_struct_name_2.resolveBinding();
- assertEquals(A_struct_type2, A_struct_type1);
-
- // check f_decl
- assertTrue(f_decl.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator);
- IASTStandardFunctionDeclarator f_decltor1 = ((IASTStandardFunctionDeclarator) f_decl.getDeclarators()[0]);
- IASTName f_name1 = f_decltor1.getName();
- IFunction f_fun1 = (IFunction) f_name1.resolveBinding();
- assertEquals(f_name1.toString(), "f"); //$NON-NLS-1$
- assertEquals(f_decltor1.getParameters().length, 1);
- //IASTName x0 = f_decltor1.getParameters()[0].getDeclarator().getName();
- IASTName A_name2 = ((ICASTTypedefNameSpecifier) f_decltor1.getParameters()[0].getDeclSpecifier()).getName();
- assertEquals(A_name2.toString(), "A"); //$NON-NLS-1$
- ITypedef A_var2 = (ITypedef)A_name2.resolveBinding();
- assertEquals(A_var1, A_var2);
-
- // check f_def
- assertTrue(f_def.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
-
- ICASTKnRFunctionDeclarator f_decltor2 = (ICASTKnRFunctionDeclarator) f_def.getDeclarator();
- assertEquals(f_decltor2.getName().toString(), "f"); //$NON-NLS-1$
- IFunction f_fun2 = (IFunction) f_decltor2.getName().resolveBinding();
- assertEquals(f_fun1, f_fun2);
- ICBasicType f_ret_t = (ICBasicType) f_fun2.getType().getReturnType();
- assertEquals(f_ret_t.getType(), IBasicType.t_void);
- IASTName x1 = f_decltor2.getParameterNames()[0];
- assertEquals(x1.toString(), "x"); //$NON-NLS-1$
- IASTSimpleDeclaration x_parm = (IASTSimpleDeclaration) f_decltor2.getParameterDeclarations()[0];
- IASTName x2 = x_parm.getDeclarators()[0].getName();
- assertEquals(x2.toString(), "x"); //$NON-NLS-1$
- assertEquals(x_parm.getDeclarators()[0].getPointerOperators().length, 1);
- IASTName A3 = ((IASTNamedTypeSpecifier) x_parm.getDeclSpecifier()).getName();
- ITypedef A_var3 = (ITypedef)A3.resolveBinding();
- assertEquals(A_var2, A_var3);
- assertEquals(A3.toString(), "A"); //$NON-NLS-1$;
- assertEquals(x1.resolveBinding(), x2.resolveBinding());
-
- // check f_def body
- assertTrue(f_def.getBody() instanceof IASTCompoundStatement);
- IASTCompoundStatement f_def_body = (IASTCompoundStatement) f_def.getBody();
- IASTExpressionStatement stmt1 = (IASTExpressionStatement) f_def_body.getStatements()[0];
- IASTExpressionStatement stmt2 = (IASTExpressionStatement) f_def_body.getStatements()[1];
- IASTName a2 = ((IASTFieldReference) ((IASTBinaryExpression) stmt1.getExpression()).getOperand1()).getFieldName();
- assertEquals(((IASTName) ((ICInternalBinding) a1).getPhysicalNode()).resolveBinding(), a2.resolveBinding());
- IASTName x3 = ((IASTIdExpression) ((IASTFieldReference) ((IASTBinaryExpression) stmt1.getExpression()).getOperand1()).getFieldOwner()).getName();
- assertEquals(x2.resolveBinding(), x3.resolveBinding());
- assertEquals(((IASTBinaryExpression) stmt1.getExpression()).getOperand2().toString(), "0"); //$NON-NLS-1$
- assertTrue(((IASTBinaryExpression) stmt2.getExpression()).getOperand1() instanceof IASTArraySubscriptExpression);
- assertTrue(((IASTBinaryExpression) stmt2.getExpression()).getOperand2() instanceof IASTArraySubscriptExpression);
- IASTName c2 = ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTBinaryExpression) stmt2.getExpression()).getOperand1()).getArrayExpression()).getFieldName();
- IASTName x4 = ((IASTIdExpression) ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTBinaryExpression) stmt2.getExpression()).getOperand1()).getArrayExpression()).getFieldOwner()).getName();
- IASTName c3 = ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTBinaryExpression) stmt2.getExpression()).getOperand2()).getArrayExpression()).getFieldName();
- IASTName x5 = ((IASTIdExpression) ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTBinaryExpression) stmt2.getExpression()).getOperand1()).getArrayExpression()).getFieldOwner()).getName();
- assertEquals(((IASTName) ((ICInternalBinding) c1).getPhysicalNode()).resolveBinding(), c2.resolveBinding());
- assertEquals(((IASTName) ((ICInternalBinding) c1).getPhysicalNode()).resolveBinding(), c3.resolveBinding());
- assertEquals(x3.resolveBinding(), x4.resolveBinding());
- assertEquals(x4.resolveBinding(), x5.resolveBinding());
-
- // test CFunction.getParameters size
- IParameter[] f1_parms = f_fun1.getParameters();
- assertEquals(f1_parms.length, 1);
+ IASTName[] decls = tu.getDeclarationsInAST(
+ ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody())
+ .getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding());
+ assertEquals(decls.length, 0);
+ }
+
+ public void testKRC_monop_cards1() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#ifdef __STDC__\n"); //$NON-NLS-1$
+ buffer.append("#define __P(x) x\n"); //$NON-NLS-1$
+ buffer.append("#else\n"); //$NON-NLS-1$
+ buffer.append("#define __P(x) ()\n"); //$NON-NLS-1$
+ buffer.append("#endif\n"); //$NON-NLS-1$
+ buffer.append("struct A_struct {\n"); //$NON-NLS-1$
+ buffer.append("int a;\n"); //$NON-NLS-1$
+ buffer.append("long *c;\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+ buffer.append("typedef struct A_struct A;\n"); //$NON-NLS-1$
+ buffer.append("static void f __P((A *));\n"); //$NON-NLS-1$
+ buffer.append("static void\n"); //$NON-NLS-1$
+ buffer.append("f(x)\n"); //$NON-NLS-1$
+ buffer.append("A *x; {\n"); //$NON-NLS-1$
+ buffer.append("x->a = 0;\n"); //$NON-NLS-1$
+ buffer.append("x->c[1]=x->c[2];\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
+
+ IASTSimpleDeclaration A_struct = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTSimpleDeclaration A = (IASTSimpleDeclaration) tu.getDeclarations()[1];
+ IASTSimpleDeclaration f_decl = (IASTSimpleDeclaration) tu.getDeclarations()[2];
+ IASTFunctionDefinition f_def = (IASTFunctionDefinition) tu.getDeclarations()[3];
+
+ // check A_struct
+ assertTrue(A_struct.getDeclSpecifier() instanceof IASTCompositeTypeSpecifier);
+ assertEquals(A_struct.getDeclarators().length, 0);
+ IASTName A_struct_name1 = ((IASTCompositeTypeSpecifier) A_struct.getDeclSpecifier()).getName();
+ assertEquals(A_struct_name1.toString(), "A_struct"); //$NON-NLS-1$
+ ICompositeType A_struct_type1 = (ICompositeType) A_struct_name1.resolveBinding();
+ assertEquals(((ICInternalBinding) A_struct_type1).getPhysicalNode(),
+ ((IASTCompositeTypeSpecifier) A_struct.getDeclSpecifier()).getName());
+ IField[] fields = A_struct_type1.getFields();
+ IField a1 = fields[0];
+ IField c1 = fields[1];
+ assertEquals(a1.getName().toString(), "a"); //$NON-NLS-1$
+ assertEquals(c1.getName().toString(), "c"); //$NON-NLS-1$
+ IBasicType a1_t = (IBasicType) a1.getType();
+ IPointerType c1_t = (IPointerType) c1.getType();
+ assertEquals(a1_t.getType(), IBasicType.t_int);
+ assertTrue(c1_t.getType() instanceof IBasicType);
+ assertTrue(((IBasicType) c1_t.getType()).isLong());
+
+ // check A
+ IASTName A_name1 = A.getDeclarators()[0].getName();
+ assertEquals(A_name1.toString(), "A"); //$NON-NLS-1$
+ ITypedef A_var1 = (ITypedef) A_name1.resolveBinding();
+ assertTrue(A.getDeclSpecifier() instanceof IASTElaboratedTypeSpecifier);
+ IASTName A_struct_name_2 = ((IASTElaboratedTypeSpecifier) A.getDeclSpecifier()).getName();
+ assertEquals(A_struct_name_2.toString(), "A_struct"); //$NON-NLS-1$
+ assertEquals(((IASTElaboratedTypeSpecifier) A.getDeclSpecifier()).getStorageClass(),
+ IASTDeclSpecifier.sc_typedef);
+ ICompositeType A_struct_type2 = (ICompositeType) A_struct_name_2.resolveBinding();
+ assertEquals(A_struct_type2, A_struct_type1);
+
+ // check f_decl
+ assertTrue(f_decl.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator);
+ IASTStandardFunctionDeclarator f_decltor1 = ((IASTStandardFunctionDeclarator) f_decl.getDeclarators()[0]);
+ IASTName f_name1 = f_decltor1.getName();
+ IFunction f_fun1 = (IFunction) f_name1.resolveBinding();
+ assertEquals(f_name1.toString(), "f"); //$NON-NLS-1$
+ assertEquals(f_decltor1.getParameters().length, 1);
+ //IASTName x0 = f_decltor1.getParameters()[0].getDeclarator().getName();
+ IASTName A_name2 = ((ICASTTypedefNameSpecifier) f_decltor1.getParameters()[0].getDeclSpecifier()).getName();
+ assertEquals(A_name2.toString(), "A"); //$NON-NLS-1$
+ ITypedef A_var2 = (ITypedef) A_name2.resolveBinding();
+ assertEquals(A_var1, A_var2);
+
+ // check f_def
+ assertTrue(f_def.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
+
+ ICASTKnRFunctionDeclarator f_decltor2 = (ICASTKnRFunctionDeclarator) f_def.getDeclarator();
+ assertEquals(f_decltor2.getName().toString(), "f"); //$NON-NLS-1$
+ IFunction f_fun2 = (IFunction) f_decltor2.getName().resolveBinding();
+ assertEquals(f_fun1, f_fun2);
+ ICBasicType f_ret_t = (ICBasicType) f_fun2.getType().getReturnType();
+ assertEquals(f_ret_t.getType(), IBasicType.t_void);
+ IASTName x1 = f_decltor2.getParameterNames()[0];
+ assertEquals(x1.toString(), "x"); //$NON-NLS-1$
+ IASTSimpleDeclaration x_parm = (IASTSimpleDeclaration) f_decltor2.getParameterDeclarations()[0];
+ IASTName x2 = x_parm.getDeclarators()[0].getName();
+ assertEquals(x2.toString(), "x"); //$NON-NLS-1$
+ assertEquals(x_parm.getDeclarators()[0].getPointerOperators().length, 1);
+ IASTName A3 = ((IASTNamedTypeSpecifier) x_parm.getDeclSpecifier()).getName();
+ ITypedef A_var3 = (ITypedef) A3.resolveBinding();
+ assertEquals(A_var2, A_var3);
+ assertEquals(A3.toString(), "A"); //$NON-NLS-1$;
+ assertEquals(x1.resolveBinding(), x2.resolveBinding());
+
+ // check f_def body
+ assertTrue(f_def.getBody() instanceof IASTCompoundStatement);
+ IASTCompoundStatement f_def_body = (IASTCompoundStatement) f_def.getBody();
+ IASTExpressionStatement stmt1 = (IASTExpressionStatement) f_def_body.getStatements()[0];
+ IASTExpressionStatement stmt2 = (IASTExpressionStatement) f_def_body.getStatements()[1];
+ IASTName a2 = ((IASTFieldReference) ((IASTBinaryExpression) stmt1.getExpression()).getOperand1())
+ .getFieldName();
+ assertEquals(((IASTName) ((ICInternalBinding) a1).getPhysicalNode()).resolveBinding(), a2.resolveBinding());
+ IASTName x3 = ((IASTIdExpression) ((IASTFieldReference) ((IASTBinaryExpression) stmt1.getExpression())
+ .getOperand1()).getFieldOwner()).getName();
+ assertEquals(x2.resolveBinding(), x3.resolveBinding());
+ assertEquals(((IASTBinaryExpression) stmt1.getExpression()).getOperand2().toString(), "0"); //$NON-NLS-1$
+ assertTrue(
+ ((IASTBinaryExpression) stmt2.getExpression()).getOperand1() instanceof IASTArraySubscriptExpression);
+ assertTrue(
+ ((IASTBinaryExpression) stmt2.getExpression()).getOperand2() instanceof IASTArraySubscriptExpression);
+ IASTName c2 = ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTBinaryExpression) stmt2
+ .getExpression()).getOperand1()).getArrayExpression()).getFieldName();
+ IASTName x4 = ((IASTIdExpression) ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTBinaryExpression) stmt2
+ .getExpression()).getOperand1()).getArrayExpression()).getFieldOwner()).getName();
+ IASTName c3 = ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTBinaryExpression) stmt2
+ .getExpression()).getOperand2()).getArrayExpression()).getFieldName();
+ IASTName x5 = ((IASTIdExpression) ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTBinaryExpression) stmt2
+ .getExpression()).getOperand1()).getArrayExpression()).getFieldOwner()).getName();
+ assertEquals(((IASTName) ((ICInternalBinding) c1).getPhysicalNode()).resolveBinding(), c2.resolveBinding());
+ assertEquals(((IASTName) ((ICInternalBinding) c1).getPhysicalNode()).resolveBinding(), c3.resolveBinding());
+ assertEquals(x3.resolveBinding(), x4.resolveBinding());
+ assertEquals(x4.resolveBinding(), x5.resolveBinding());
+
+ // test CFunction.getParameters size
+ IParameter[] f1_parms = f_fun1.getParameters();
+ assertEquals(f1_parms.length, 1);
// test tu.getDeclarationsInAST(IBinding)
- IASTName[] decls = tu.getDeclarationsInAST(x2.resolveBinding());
+ IASTName[] decls = tu.getDeclarationsInAST(x2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], x2);
-
+
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_TAG, "A_struct".toCharArray())); //$NON-NLS-1$
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "A".toCharArray())); //$NON-NLS-1$
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "f".toCharArray())); //$NON-NLS-1$
- assertNotNull(((CScope) ((IASTCompoundStatement) f_def.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$
- }
-
- public void testKRC_monop_cards2() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("int\n"); //$NON-NLS-1$
- buffer.append("getinp(prompt, list)\n"); //$NON-NLS-1$
- buffer.append(" const char *prompt, *const list[];\n"); //$NON-NLS-1$
- buffer.append("{\n *list[1] = 'a';\n}\n"); //$NON-NLS-1$
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
-
- IASTFunctionDefinition getinp = (IASTFunctionDefinition) tu.getDeclarations()[0];
-
- IASTName prompt1 = ((ICASTKnRFunctionDeclarator) getinp.getDeclarator()).getParameterNames()[0];
- IASTName list1 = ((ICASTKnRFunctionDeclarator) getinp.getDeclarator()).getParameterNames()[1];
- IASTName prompt2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) getinp.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName();
- IASTName list2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) getinp.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[1].getName();
- IASTName list3 = ((IASTIdExpression) ((IASTArraySubscriptExpression) ((IASTUnaryExpression) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) getinp.getBody()).getStatements()[0]).getExpression()).getOperand1()).getOperand()).getArrayExpression()).getName();
-
- assertEquals(prompt1.resolveBinding(), prompt2.resolveBinding());
- assertEquals(list1.resolveBinding(), list2.resolveBinding());
- assertEquals(list2.resolveBinding(), list3.resolveBinding());
-
- IASTSimpleDeclaration parm_decl = (IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) getinp.getDeclarator()).getParameterDeclarations()[0];
- assertTrue(((IASTSimpleDeclSpecifier) parm_decl.getDeclSpecifier()).isConst());
- assertEquals(((IASTSimpleDeclSpecifier) parm_decl.getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_char);
- IASTDeclarator prompt = parm_decl.getDeclarators()[0];
- IASTArrayDeclarator list = (IASTArrayDeclarator) parm_decl.getDeclarators()[1];
- assertEquals(prompt.getName().toString(), "prompt"); //$NON-NLS-1$
- assertEquals(prompt.getPointerOperators().length, 1);
- assertEquals(list.getName().toString(), "list"); //$NON-NLS-1$
- assertEquals(list.getArrayModifiers().length, 1);
- assertNull(list.getArrayModifiers()[0].getConstantExpression());
- assertEquals(list.getPointerOperators().length, 1);
-
+ assertNotNull(((CScope) ((IASTCompoundStatement) f_def.getBody()).getScope())
+ .getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$
+ }
+
+ public void testKRC_monop_cards2() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int\n"); //$NON-NLS-1$
+ buffer.append("getinp(prompt, list)\n"); //$NON-NLS-1$
+ buffer.append(" const char *prompt, *const list[];\n"); //$NON-NLS-1$
+ buffer.append("{\n *list[1] = 'a';\n}\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
+
+ IASTFunctionDefinition getinp = (IASTFunctionDefinition) tu.getDeclarations()[0];
+
+ IASTName prompt1 = ((ICASTKnRFunctionDeclarator) getinp.getDeclarator()).getParameterNames()[0];
+ IASTName list1 = ((ICASTKnRFunctionDeclarator) getinp.getDeclarator()).getParameterNames()[1];
+ IASTName prompt2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) getinp.getDeclarator())
+ .getParameterDeclarations()[0]).getDeclarators()[0].getName();
+ IASTName list2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) getinp.getDeclarator())
+ .getParameterDeclarations()[0]).getDeclarators()[1].getName();
+ IASTName list3 = ((IASTIdExpression) ((IASTArraySubscriptExpression) ((IASTUnaryExpression) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) getinp
+ .getBody()).getStatements()[0]).getExpression()).getOperand1()).getOperand()).getArrayExpression())
+ .getName();
+
+ assertEquals(prompt1.resolveBinding(), prompt2.resolveBinding());
+ assertEquals(list1.resolveBinding(), list2.resolveBinding());
+ assertEquals(list2.resolveBinding(), list3.resolveBinding());
+
+ IASTSimpleDeclaration parm_decl = (IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) getinp.getDeclarator())
+ .getParameterDeclarations()[0];
+ assertTrue(((IASTSimpleDeclSpecifier) parm_decl.getDeclSpecifier()).isConst());
+ assertEquals(((IASTSimpleDeclSpecifier) parm_decl.getDeclSpecifier()).getType(),
+ IASTSimpleDeclSpecifier.t_char);
+ IASTDeclarator prompt = parm_decl.getDeclarators()[0];
+ IASTArrayDeclarator list = (IASTArrayDeclarator) parm_decl.getDeclarators()[1];
+ assertEquals(prompt.getName().toString(), "prompt"); //$NON-NLS-1$
+ assertEquals(prompt.getPointerOperators().length, 1);
+ assertEquals(list.getName().toString(), "list"); //$NON-NLS-1$
+ assertEquals(list.getArrayModifiers().length, 1);
+ assertNull(list.getArrayModifiers()[0].getConstantExpression());
+ assertEquals(list.getPointerOperators().length, 1);
+
// test tu.getDeclarationsInAST(IBinding)
- IASTName[] decls = tu.getDeclarationsInAST(list3.resolveBinding());
+ IASTName[] decls = tu.getDeclarationsInAST(list3.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], list2);
-
- decls = tu.getDeclarationsInAST(prompt1.resolveBinding());
+
+ decls = tu.getDeclarationsInAST(prompt1.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], prompt2);
- }
-
- public void testKRC_getParametersOrder() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("int f(a, b) int b,a;{}\n"); //$NON-NLS-1$
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
-
- IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
- ICASTKnRFunctionDeclarator f_decltor = (ICASTKnRFunctionDeclarator) f.getDeclarator();
- IFunction f_fun = (IFunction) f_decltor.getName().resolveBinding();
- IParameter[] f_parms = f_fun.getParameters();
- assertEquals(f_parms.length, 2);
- assertEquals(((CParameter) f_parms[0]).getName(), "a"); //$NON-NLS-1$
- assertEquals(((CParameter) f_parms[1]).getName(), "b"); //$NON-NLS-1$
- }
-
- public void testKRC_Ethereal_1() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("struct symbol {\n"); //$NON-NLS-1$
- buffer.append("int lambda;\n};\n"); //$NON-NLS-1$
- buffer.append("struct lemon {\n"); //$NON-NLS-1$
- buffer.append("struct symbol **symbols;\n"); //$NON-NLS-1$
- buffer.append("int errorcnt;\n};\n"); //$NON-NLS-1$
- buffer.append("void f(lemp)\n"); //$NON-NLS-1$
- buffer.append("struct lemon *lemp;\n{\n"); //$NON-NLS-1$
- buffer.append("lemp->symbols[1]->lambda = 1;\n"); //$NON-NLS-1$
- buffer.append("lemp->errorcnt++;}\n"); //$NON-NLS-1$
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
-
- IASTSimpleDeclaration symbol_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTSimpleDeclaration lemon_decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
- IASTFunctionDefinition f_def = (IASTFunctionDefinition) tu.getDeclarations()[2];
-
- IASTName symbol_name1 = ((IASTCompositeTypeSpecifier) symbol_decl.getDeclSpecifier()).getName();
- IASTName lambda_name1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) symbol_decl.getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
- IASTName lemon_name1 = ((IASTCompositeTypeSpecifier) lemon_decl.getDeclSpecifier()).getName();
- IASTName symbol_name2 = ((IASTElaboratedTypeSpecifier) ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) lemon_decl.getDeclSpecifier()).getMembers()[0]).getDeclSpecifier()).getName();
- IASTName symbols_name1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) lemon_decl.getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
- IASTName errorcnt_name1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) lemon_decl.getDeclSpecifier()).getMembers()[1]).getDeclarators()[0].getName();
- IASTName lemp_name1 = ((ICASTKnRFunctionDeclarator) f_def.getDeclarator()).getParameterNames()[0];
- IASTName lemon_name2 = ((IASTElaboratedTypeSpecifier) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f_def.getDeclarator()).getParameterDeclarations()[0]).getDeclSpecifier()).getName();
- IASTName lemp_name2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f_def.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName();
- IASTName lemp_name3 = ((IASTIdExpression) ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def.getBody()).getStatements()[0]).getExpression()).getOperand1()).getFieldOwner()).getArrayExpression()).getFieldOwner()).getName();
- IASTName symbols_name2 = ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def.getBody()).getStatements()[0]).getExpression()).getOperand1()).getFieldOwner()).getArrayExpression()).getFieldName();
- IASTName lambda_name2 = ((IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def.getBody()).getStatements()[0]).getExpression()).getOperand1()).getFieldName();
-
- IASTName lemp_name4 = ((IASTIdExpression) ((IASTFieldReference) ((IASTUnaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def.getBody()).getStatements()[1]).getExpression()).getOperand()).getFieldOwner()).getName();
- IASTName errorcnt_name2 = ((IASTFieldReference) ((IASTUnaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def.getBody()).getStatements()[1]).getExpression()).getOperand()).getFieldName();
-
- assertEquals(symbol_name1.resolveBinding(), symbol_name2.resolveBinding());
- assertEquals(lambda_name1.resolveBinding(), lambda_name2.resolveBinding());
- assertEquals(lemon_name1.resolveBinding(), lemon_name2.resolveBinding());
- assertEquals(symbols_name1.resolveBinding(), symbols_name2.resolveBinding());
- assertEquals(errorcnt_name1.resolveBinding(), errorcnt_name2.resolveBinding());
- assertEquals(lemp_name1.resolveBinding(), lemp_name2.resolveBinding());
- assertEquals(lemp_name2.resolveBinding(), lemp_name3.resolveBinding());
- assertEquals(lemp_name3.resolveBinding(), lemp_name4.resolveBinding());
- }
-
- public void testBug97447() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("void f(a) int a; {} \n"); //$NON-NLS-1$
- buffer.append("void f(int); \n"); //$NON-NLS-1$
-
+ }
+
+ public void testKRC_getParametersOrder() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int f(a, b) int b,a;{}\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
+
+ IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ ICASTKnRFunctionDeclarator f_decltor = (ICASTKnRFunctionDeclarator) f.getDeclarator();
+ IFunction f_fun = (IFunction) f_decltor.getName().resolveBinding();
+ IParameter[] f_parms = f_fun.getParameters();
+ assertEquals(f_parms.length, 2);
+ assertEquals(((CParameter) f_parms[0]).getName(), "a"); //$NON-NLS-1$
+ assertEquals(((CParameter) f_parms[1]).getName(), "b"); //$NON-NLS-1$
+ }
+
+ public void testKRC_Ethereal_1() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("struct symbol {\n"); //$NON-NLS-1$
+ buffer.append("int lambda;\n};\n"); //$NON-NLS-1$
+ buffer.append("struct lemon {\n"); //$NON-NLS-1$
+ buffer.append("struct symbol **symbols;\n"); //$NON-NLS-1$
+ buffer.append("int errorcnt;\n};\n"); //$NON-NLS-1$
+ buffer.append("void f(lemp)\n"); //$NON-NLS-1$
+ buffer.append("struct lemon *lemp;\n{\n"); //$NON-NLS-1$
+ buffer.append("lemp->symbols[1]->lambda = 1;\n"); //$NON-NLS-1$
+ buffer.append("lemp->errorcnt++;}\n"); //$NON-NLS-1$
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
- NameCollector col = new NameCollector();
- tu.accept(col);
-
- IFunction def = (IFunction) col.getName(0).resolveBinding();
- IFunction f1 = (IFunction) col.getName(3).resolveBinding();
- IParameter a = (IParameter) col.getName(4).resolveBinding();
- }
-
- public void testBug100104() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("typedef int ush;\n"); //$NON-NLS-1$
- buffer.append("int f()\n"); //$NON-NLS-1$
- buffer.append("{\n"); //$NON-NLS-1$
- buffer.append("int a=1;\n"); //$NON-NLS-1$
- buffer.append("((ush) (a)*(ush) (a) * a);\n"); //$NON-NLS-1$
- buffer.append("{\n"); //$NON-NLS-1$
- buffer.append("};\n"); //$NON-NLS-1$
- buffer.append("}\n"); //$NON-NLS-1$
-
+
+ IASTSimpleDeclaration symbol_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTSimpleDeclaration lemon_decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
+ IASTFunctionDefinition f_def = (IASTFunctionDefinition) tu.getDeclarations()[2];
+
+ IASTName symbol_name1 = ((IASTCompositeTypeSpecifier) symbol_decl.getDeclSpecifier()).getName();
+ IASTName lambda_name1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) symbol_decl.getDeclSpecifier())
+ .getMembers()[0]).getDeclarators()[0].getName();
+ IASTName lemon_name1 = ((IASTCompositeTypeSpecifier) lemon_decl.getDeclSpecifier()).getName();
+ IASTName symbol_name2 = ((IASTElaboratedTypeSpecifier) ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) lemon_decl
+ .getDeclSpecifier()).getMembers()[0]).getDeclSpecifier()).getName();
+ IASTName symbols_name1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) lemon_decl.getDeclSpecifier())
+ .getMembers()[0]).getDeclarators()[0].getName();
+ IASTName errorcnt_name1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) lemon_decl.getDeclSpecifier())
+ .getMembers()[1]).getDeclarators()[0].getName();
+ IASTName lemp_name1 = ((ICASTKnRFunctionDeclarator) f_def.getDeclarator()).getParameterNames()[0];
+ IASTName lemon_name2 = ((IASTElaboratedTypeSpecifier) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f_def
+ .getDeclarator()).getParameterDeclarations()[0]).getDeclSpecifier()).getName();
+ IASTName lemp_name2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f_def.getDeclarator())
+ .getParameterDeclarations()[0]).getDeclarators()[0].getName();
+ IASTName lemp_name3 = ((IASTIdExpression) ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def
+ .getBody()).getStatements()[0]).getExpression()).getOperand1()).getFieldOwner()).getArrayExpression())
+ .getFieldOwner()).getName();
+ IASTName symbols_name2 = ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def
+ .getBody()).getStatements()[0]).getExpression()).getOperand1()).getFieldOwner()).getArrayExpression())
+ .getFieldName();
+ IASTName lambda_name2 = ((IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def
+ .getBody()).getStatements()[0]).getExpression()).getOperand1()).getFieldName();
+
+ IASTName lemp_name4 = ((IASTIdExpression) ((IASTFieldReference) ((IASTUnaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def
+ .getBody()).getStatements()[1]).getExpression()).getOperand()).getFieldOwner()).getName();
+ IASTName errorcnt_name2 = ((IASTFieldReference) ((IASTUnaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def
+ .getBody()).getStatements()[1]).getExpression()).getOperand()).getFieldName();
+
+ assertEquals(symbol_name1.resolveBinding(), symbol_name2.resolveBinding());
+ assertEquals(lambda_name1.resolveBinding(), lambda_name2.resolveBinding());
+ assertEquals(lemon_name1.resolveBinding(), lemon_name2.resolveBinding());
+ assertEquals(symbols_name1.resolveBinding(), symbols_name2.resolveBinding());
+ assertEquals(errorcnt_name1.resolveBinding(), errorcnt_name2.resolveBinding());
+ assertEquals(lemp_name1.resolveBinding(), lemp_name2.resolveBinding());
+ assertEquals(lemp_name2.resolveBinding(), lemp_name3.resolveBinding());
+ assertEquals(lemp_name3.resolveBinding(), lemp_name4.resolveBinding());
+ }
+
+ public void testBug97447() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("void f(a) int a; {} \n"); //$NON-NLS-1$
+ buffer.append("void f(int); \n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
+ NameCollector col = new NameCollector();
+ tu.accept(col);
+
+ IFunction def = (IFunction) col.getName(0).resolveBinding();
+ IFunction f1 = (IFunction) col.getName(3).resolveBinding();
+ IParameter a = (IParameter) col.getName(4).resolveBinding();
+ }
+
+ public void testBug100104() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("typedef int ush;\n"); //$NON-NLS-1$
+ buffer.append("int f()\n"); //$NON-NLS-1$
+ buffer.append("{\n"); //$NON-NLS-1$
+ buffer.append("int a=1;\n"); //$NON-NLS-1$
+ buffer.append("((ush) (a)*(ush) (a) * a);\n"); //$NON-NLS-1$
+ buffer.append("{\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, true);
- assertTrue(tu.getDeclarations()[0] instanceof IASTSimpleDeclaration);
- assertTrue(tu.getDeclarations()[1] instanceof IASTFunctionDefinition);
- IASTStatement[] stmts = ((IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[1]).getBody()).getStatements();
- assertTrue(stmts[0] instanceof IASTDeclarationStatement);
- assertTrue(stmts[1] instanceof IASTExpressionStatement);
- assertTrue(stmts[2] instanceof IASTCompoundStatement);
- assertTrue(stmts[3] instanceof IASTNullStatement);
- }
-
+ assertTrue(tu.getDeclarations()[0] instanceof IASTSimpleDeclaration);
+ assertTrue(tu.getDeclarations()[1] instanceof IASTFunctionDefinition);
+ IASTStatement[] stmts = ((IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[1]).getBody())
+ .getStatements();
+ assertTrue(stmts[0] instanceof IASTDeclarationStatement);
+ assertTrue(stmts[1] instanceof IASTExpressionStatement);
+ assertTrue(stmts[2] instanceof IASTCompoundStatement);
+ assertTrue(stmts[3] instanceof IASTNullStatement);
+ }
+
// typedef long time_t;
//
// void (foo)(timep)
@@ -656,33 +747,34 @@ public class AST2KnRTests extends AST2TestBase {
// {
// return 0;
// }
- public void testBug203050() throws Exception {
+ public void testBug203050() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, true, true);
- assertTrue(tu.getDeclarations()[0] instanceof IASTSimpleDeclaration);
- assertTrue(tu.getDeclarations()[1] instanceof IASTFunctionDefinition);
- assertTrue(tu.getDeclarations()[2] instanceof IASTFunctionDefinition);
- IASTStatement[] stmts = ((IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[1]).getBody()).getStatements();
- assertTrue(stmts[0] instanceof IASTDeclarationStatement);
- assertTrue(stmts[1] instanceof IASTExpressionStatement);
- IASTExpression expr= ((IASTExpressionStatement) stmts[1]).getExpression();
- assertTrue(expr instanceof IASTFunctionCallExpression);
- IASTIdExpression fnameExpr= (IASTIdExpression) ((IASTFunctionCallExpression) expr).getFunctionNameExpression();
- fnameExpr.getName().resolveBinding();
-
- IASTName fname= ((IASTFunctionDefinition) tu.getDeclarations()[2]).getDeclarator().getName();
- try {
- fname.resolveBinding();
- } catch (StackOverflowError e) {
- fail(e.getMessage());
- }
- }
-
- // void push_constant (in_char, conv_base)
- // char (*in_char)(void);
- // int conv_base;
- // {}
- public void testFunctionPtrParameter_378614() throws Exception {
- String code= getAboveComment();
- parseAndCheckBindings(code, ParserLanguage.C, true);
- }
+ assertTrue(tu.getDeclarations()[0] instanceof IASTSimpleDeclaration);
+ assertTrue(tu.getDeclarations()[1] instanceof IASTFunctionDefinition);
+ assertTrue(tu.getDeclarations()[2] instanceof IASTFunctionDefinition);
+ IASTStatement[] stmts = ((IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[1]).getBody())
+ .getStatements();
+ assertTrue(stmts[0] instanceof IASTDeclarationStatement);
+ assertTrue(stmts[1] instanceof IASTExpressionStatement);
+ IASTExpression expr = ((IASTExpressionStatement) stmts[1]).getExpression();
+ assertTrue(expr instanceof IASTFunctionCallExpression);
+ IASTIdExpression fnameExpr = (IASTIdExpression) ((IASTFunctionCallExpression) expr).getFunctionNameExpression();
+ fnameExpr.getName().resolveBinding();
+
+ IASTName fname = ((IASTFunctionDefinition) tu.getDeclarations()[2]).getDeclarator().getName();
+ try {
+ fname.resolveBinding();
+ } catch (StackOverflowError e) {
+ fail(e.getMessage());
+ }
+ }
+
+ // void push_constant (in_char, conv_base)
+ // char (*in_char)(void);
+ // int conv_base;
+ // {}
+ public void testFunctionPtrParameter_378614() throws Exception {
+ String code = getAboveComment();
+ parseAndCheckBindings(code, ParserLanguage.C, true);
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java
index 9250a36af40..87234755799 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java
@@ -64,735 +64,708 @@ public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
super(name, AST2SelectionParseTest.class);
}
- public void testBaseCase_VariableReference() throws Exception
- {
+ public void testBaseCase_VariableReference() throws Exception {
String code = "void f() { int x; x=3; }"; //$NON-NLS-1$
- int offset1 = code.indexOf( "x=" ); //$NON-NLS-1$
+ int offset1 = code.indexOf("x="); //$NON-NLS-1$
int length = "x".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, offset1, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.C, offset1, length).getParent();
assertNotNull(node);
- assertTrue( node instanceof IASTIdExpression );
- assertEquals(((IASTIdExpression)node).getName().toString(), "x"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, offset1, length ).getParent();
+ assertTrue(node instanceof IASTIdExpression);
+ assertEquals(((IASTIdExpression) node).getName().toString(), "x"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, offset1, length).getParent();
assertNotNull(node);
- assertTrue( node instanceof IASTIdExpression );
- assertEquals(((IASTIdExpression)node).getName().toString(), "x"); //$NON-NLS-1$
- IASTName name = ((IASTIdExpression)node).getName();
+ assertTrue(node instanceof IASTIdExpression);
+ assertEquals(((IASTIdExpression) node).getName().toString(), "x"); //$NON-NLS-1$
+ IASTName name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IVariable);
- assertEquals(((IVariable)name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
+ assertEquals(((IVariable) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
}
- public void testBaseCase_FunctionReference() throws Exception
- {
+ public void testBaseCase_FunctionReference() throws Exception {
String code = "int x(){x( );}"; //$NON-NLS-1$
- int offset1 = code.indexOf( "x( " ); //$NON-NLS-1$
+ int offset1 = code.indexOf("x( "); //$NON-NLS-1$
int length = "x".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, offset1, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.C, offset1, length).getParent();
assertNotNull(node);
- assertTrue( node instanceof IASTIdExpression );
- assertEquals(((IASTIdExpression)node).getName().toString(), "x"); //$NON-NLS-1$
- IASTName name = ((IASTIdExpression)node).getName();
+ assertTrue(node instanceof IASTIdExpression);
+ assertEquals(((IASTIdExpression) node).getName().toString(), "x"); //$NON-NLS-1$
+ IASTName name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, offset1, length ).getParent();
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, offset1, length).getParent();
assertNotNull(node);
- assertTrue( node instanceof IASTIdExpression );
- assertEquals(((IASTIdExpression)node).getName().toString(), "x"); //$NON-NLS-1$
- name = ((IASTIdExpression)node).getName();
+ assertTrue(node instanceof IASTIdExpression);
+ assertEquals(((IASTIdExpression) node).getName().toString(), "x"); //$NON-NLS-1$
+ name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
}
-
- public void testBaseCase_FunctionDeclaration() throws Exception
- {
+
+ public void testBaseCase_FunctionDeclaration() throws Exception {
String code = "int x(); x( );"; //$NON-NLS-1$
- int offset1 = code.indexOf( "x()" ); //$NON-NLS-1$
+ int offset1 = code.indexOf("x()"); //$NON-NLS-1$
int length = "x".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, offset1, length );
+ IASTNode node = parse(code, ParserLanguage.C, offset1, length);
assertNotNull(node);
- assertTrue( node instanceof IASTName );
+ assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "x"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, offset1, length );
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, offset1, length);
assertNotNull(node);
- assertTrue( node instanceof IASTName );
+ assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "x"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
}
-
- public void testBaseCase_FunctionDeclaration2() throws Exception
- {
+
+ public void testBaseCase_FunctionDeclaration2() throws Exception {
String code = "int printf( const char *, ... ); "; //$NON-NLS-1$
- int offset1 = code.indexOf( "printf" ); //$NON-NLS-1$
+ int offset1 = code.indexOf("printf"); //$NON-NLS-1$
int length = "printf".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, offset1, length );
+ IASTNode node = parse(code, ParserLanguage.C, offset1, length);
assertNotNull(node);
- assertTrue( node instanceof IASTName );
+ assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "printf"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "printf"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, offset1, length );
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "printf"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, offset1, length);
assertNotNull(node);
- assertTrue( node instanceof IASTName );
+ assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "printf"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "printf"); //$NON-NLS-1$
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "printf"); //$NON-NLS-1$
}
- public void testBaseCase_VariableDeclaration() throws Exception
- {
+ public void testBaseCase_VariableDeclaration() throws Exception {
String code = "int x = 3;"; //$NON-NLS-1$
- int offset1 = code.indexOf( "x" ); //$NON-NLS-1$
+ int offset1 = code.indexOf("x"); //$NON-NLS-1$
int length = "x".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, offset1, length );
+ IASTNode node = parse(code, ParserLanguage.C, offset1, length);
assertNotNull(node);
- assertTrue( node instanceof IASTName );
+ assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "x"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IVariable);
- assertEquals(((IVariable)name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, offset1, length );
+ assertEquals(((IVariable) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, offset1, length);
assertNotNull(node);
- assertTrue( node instanceof IASTName );
+ assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "x"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IVariable);
- assertEquals(((IVariable)name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
+ assertEquals(((IVariable) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
}
-
- public void testBaseCase_Parameter() throws Exception
- {
+
+ public void testBaseCase_Parameter() throws Exception {
String code = "int main( int argc ) { int x = argc; }"; //$NON-NLS-1$
- int offset1 = code.indexOf( "argc;" ); //$NON-NLS-1$
+ int offset1 = code.indexOf("argc;"); //$NON-NLS-1$
int length = "argc".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, offset1, length ).getParent().getParent();
+ IASTNode node = parse(code, ParserLanguage.C, offset1, length).getParent().getParent();
assertNotNull(node);
- assertTrue( node instanceof IASTEqualsInitializer );
- assertEquals( ((IASTIdExpression)((IASTEqualsInitializer)node).getInitializerClause()).getName().toString(), "argc" ); //$NON-NLS-1$
- IASTName name = ((IASTIdExpression)((IASTEqualsInitializer)node).getInitializerClause()).getName();
+ assertTrue(node instanceof IASTEqualsInitializer);
+ assertEquals(((IASTIdExpression) ((IASTEqualsInitializer) node).getInitializerClause()).getName().toString(),
+ "argc"); //$NON-NLS-1$
+ IASTName name = ((IASTIdExpression) ((IASTEqualsInitializer) node).getInitializerClause()).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IParameter);
- assertEquals(((IParameter)name.resolveBinding()).getName(), "argc"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, offset1, length ).getParent().getParent();
+ assertEquals(((IParameter) name.resolveBinding()).getName(), "argc"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, offset1, length).getParent().getParent();
assertNotNull(node);
- assertTrue( node instanceof IASTEqualsInitializer );
- assertEquals( ((IASTIdExpression)((IASTEqualsInitializer)node).getInitializerClause()).getName().toString(), "argc" ); //$NON-NLS-1$
- name = ((IASTIdExpression)((IASTEqualsInitializer)node).getInitializerClause()).getName();
+ assertTrue(node instanceof IASTEqualsInitializer);
+ assertEquals(((IASTIdExpression) ((IASTEqualsInitializer) node).getInitializerClause()).getName().toString(),
+ "argc"); //$NON-NLS-1$
+ name = ((IASTIdExpression) ((IASTEqualsInitializer) node).getInitializerClause()).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IParameter);
- assertEquals(((IParameter)name.resolveBinding()).getName(), "argc"); //$NON-NLS-1$
+ assertEquals(((IParameter) name.resolveBinding()).getName(), "argc"); //$NON-NLS-1$
}
-
- public void testBug57898() throws Exception
- {
+
+ public void testBug57898() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Gonzo { public: void playHorn(); };\n" ); //$NON-NLS-1$
- writer.write( "void Gonzo::playHorn() { return; }\n" ); //$NON-NLS-1$
- writer.write( "int main(int argc, char **argv) { Gonzo gonzo; gonzo.playHorn(); }\n" ); //$NON-NLS-1$
+ writer.write("class Gonzo { public: void playHorn(); };\n"); //$NON-NLS-1$
+ writer.write("void Gonzo::playHorn() { return; }\n"); //$NON-NLS-1$
+ writer.write("int main(int argc, char **argv) { Gonzo gonzo; gonzo.playHorn(); }\n"); //$NON-NLS-1$
String code = writer.toString();
- for( int i = 0; i < 3; ++i )
- {
+ for (int i = 0; i < 3; ++i) {
int start = -1, stop = -1;
- switch( i )
- {
- case 0:
- start = code.indexOf( "void playHorn") + 5; //$NON-NLS-1$
- break;
- case 1:
- start = code.indexOf( "::playHorn") + 2; //$NON-NLS-1$
- break;
- case 2:
- start = code.indexOf( ".playHorn") + 1; //$NON-NLS-1$
- break;
+ switch (i) {
+ case 0:
+ start = code.indexOf("void playHorn") + 5; //$NON-NLS-1$
+ break;
+ case 1:
+ start = code.indexOf("::playHorn") + 2; //$NON-NLS-1$
+ break;
+ case 2:
+ start = code.indexOf(".playHorn") + 1; //$NON-NLS-1$
+ break;
}
stop = 8;
- IASTNode node = parse( code, ParserLanguage.CPP, start, stop );
+ IASTNode node = parse(code, ParserLanguage.CPP, start, stop);
assertNotNull(node);
- assertTrue( node instanceof IASTName );
- assertEquals( node.toString(), "playHorn" ); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ assertTrue(node instanceof IASTName);
+ assertEquals(node.toString(), "playHorn"); //$NON-NLS-1$
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPMethod);
- assertEquals(((ICPPMethod)name.resolveBinding()).getName(), "playHorn"); //$NON-NLS-1$
+ assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "playHorn"); //$NON-NLS-1$
}
}
-
- public void testConstructorDestructorDeclaration() throws Exception
- {
+
+ public void testConstructorDestructorDeclaration() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Gonzo { Gonzo(); ~Gonzo(); };"); //$NON-NLS-1$
+ writer.write("class Gonzo { Gonzo(); ~Gonzo(); };"); //$NON-NLS-1$
String code = writer.toString();
- int offset = code.indexOf( " Gonzo()") + 1; //$NON-NLS-1$
+ int offset = code.indexOf(" Gonzo()") + 1; //$NON-NLS-1$
int length = "Gonzo".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, offset, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, offset, length);
assertNotNull(node);
- assertTrue( node instanceof IASTName );
+ assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Gonzo"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPConstructor);
- assertEquals(((ICPPConstructor)name.resolveBinding()).getName(), "Gonzo"); //$NON-NLS-1$
- offset = code.indexOf( " ~Gonzo") + 1; //$NON-NLS-1$
+ assertEquals(((ICPPConstructor) name.resolveBinding()).getName(), "Gonzo"); //$NON-NLS-1$
+ offset = code.indexOf(" ~Gonzo") + 1; //$NON-NLS-1$
length = "~Gonzo".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, offset, length );
+ node = parse(code, ParserLanguage.CPP, offset, length);
assertNotNull(node);
- assertTrue( node instanceof IASTName );
+ assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "~Gonzo"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPMethod);
- assertEquals(((ICPPMethod)name.resolveBinding()).getName(), "~Gonzo"); //$NON-NLS-1$
+ assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "~Gonzo"); //$NON-NLS-1$
+
+ }
- }
-
- public void testBug60264() throws Exception
- {
+ public void testBug60264() throws Exception {
Writer writer = new StringWriter();
- writer.write( "namespace Muppets { int i; }\n" ); //$NON-NLS-1$
- writer.write( "int main(int argc, char **argv) { Muppets::i = 1; }\n" ); //$NON-NLS-1$
+ writer.write("namespace Muppets { int i; }\n"); //$NON-NLS-1$
+ writer.write("int main(int argc, char **argv) { Muppets::i = 1; }\n"); //$NON-NLS-1$
String code = writer.toString();
- int index = code.indexOf( "Muppets::"); //$NON-NLS-1$
+ int index = code.indexOf("Muppets::"); //$NON-NLS-1$
int length = "Muppets".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, index, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Muppets"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPNamespace);
- assertEquals(((ICPPNamespace)name.resolveBinding()).getName(), "Muppets"); //$NON-NLS-1$
- index = code.indexOf( "e Muppets") + 2; //$NON-NLS-1$
+ assertEquals(((ICPPNamespace) name.resolveBinding()).getName(), "Muppets"); //$NON-NLS-1$
+ index = code.indexOf("e Muppets") + 2; //$NON-NLS-1$
length = "Muppets".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Muppets"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPNamespace);
- assertEquals(((ICPPNamespace)name.resolveBinding()).getName(), "Muppets"); //$NON-NLS-1$
+ assertEquals(((ICPPNamespace) name.resolveBinding()).getName(), "Muppets"); //$NON-NLS-1$
}
-
- public void testBug61613() throws Exception
- {
+
+ public void testBug61613() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Foo { // ** (A) **\n" ); //$NON-NLS-1$
- writer.write( " public:\n" ); //$NON-NLS-1$
- writer.write( "Foo() {};\n" ); //$NON-NLS-1$
- writer.write( "};\n" ); //$NON-NLS-1$
- writer.write( "int \n" ); //$NON-NLS-1$
- writer.write( "main(int argc, char **argv) {\n" ); //$NON-NLS-1$
- writer.write( "Foo foo; // ** (B) **\n" ); //$NON-NLS-1$
- writer.write( "}\n" ); //$NON-NLS-1$
+ writer.write("class Foo { // ** (A) **\n"); //$NON-NLS-1$
+ writer.write(" public:\n"); //$NON-NLS-1$
+ writer.write("Foo() {};\n"); //$NON-NLS-1$
+ writer.write("};\n"); //$NON-NLS-1$
+ writer.write("int \n"); //$NON-NLS-1$
+ writer.write("main(int argc, char **argv) {\n"); //$NON-NLS-1$
+ writer.write("Foo foo; // ** (B) **\n"); //$NON-NLS-1$
+ writer.write("}\n"); //$NON-NLS-1$
String code = writer.toString();
- int index = code.indexOf( "class Foo") + 6; //$NON-NLS-1$
+ int index = code.indexOf("class Foo") + 6; //$NON-NLS-1$
int length = "Foo".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, index, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Foo"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPClassType);
- assertEquals(((ICPPClassType)name.resolveBinding()).getName(), "Foo"); //$NON-NLS-1$
+ assertEquals(((ICPPClassType) name.resolveBinding()).getName(), "Foo"); //$NON-NLS-1$
}
-
- public void testBug60038() throws Exception
- {
+
+ public void testBug60038() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Gonzo {\n"); //$NON-NLS-1$
- writer.write( "public:\n"); //$NON-NLS-1$
- writer.write( "Gonzo( const Gonzo & other ){}\n"); //$NON-NLS-1$
- writer.write( "Gonzo() {}\n"); //$NON-NLS-1$
- writer.write( "~Gonzo(){}\n"); //$NON-NLS-1$
- writer.write( "};\n"); //$NON-NLS-1$
- writer.write( "int main(int argc, char **argv) {\n"); //$NON-NLS-1$
- writer.write( " Gonzo * g = new Gonzo();\n"); //$NON-NLS-1$
- writer.write( " Gonzo * g2 = new Gonzo( *g );\n"); //$NON-NLS-1$
- writer.write( " g->~Gonzo();\n"); //$NON-NLS-1$
- writer.write( " return (int) g2;\n"); //$NON-NLS-1$
- writer.write( "}\n"); //$NON-NLS-1$
+ writer.write("class Gonzo {\n"); //$NON-NLS-1$
+ writer.write("public:\n"); //$NON-NLS-1$
+ writer.write("Gonzo( const Gonzo & other ){}\n"); //$NON-NLS-1$
+ writer.write("Gonzo() {}\n"); //$NON-NLS-1$
+ writer.write("~Gonzo(){}\n"); //$NON-NLS-1$
+ writer.write("};\n"); //$NON-NLS-1$
+ writer.write("int main(int argc, char **argv) {\n"); //$NON-NLS-1$
+ writer.write(" Gonzo * g = new Gonzo();\n"); //$NON-NLS-1$
+ writer.write(" Gonzo * g2 = new Gonzo( *g );\n"); //$NON-NLS-1$
+ writer.write(" g->~Gonzo();\n"); //$NON-NLS-1$
+ writer.write(" return (int) g2;\n"); //$NON-NLS-1$
+ writer.write("}\n"); //$NON-NLS-1$
String code = writer.toString();
- for( int i = 0; i < 3; ++i )
- {
+ for (int i = 0; i < 3; ++i) {
int startOffset = 0, length = 0;
- switch( i )
- {
- case 0:
- startOffset = code.indexOf( "new Gonzo()") + 4; //$NON-NLS-1$
- length = 5;
- break;
- case 1:
- startOffset = code.indexOf( "new Gonzo( ") + 4; //$NON-NLS-1$
- length = 5;
- break;
- default:
- startOffset = code.indexOf( "->~") + 2; //$NON-NLS-1$
- length = 6;
+ switch (i) {
+ case 0:
+ startOffset = code.indexOf("new Gonzo()") + 4; //$NON-NLS-1$
+ length = 5;
+ break;
+ case 1:
+ startOffset = code.indexOf("new Gonzo( ") + 4; //$NON-NLS-1$
+ length = 5;
+ break;
+ default:
+ startOffset = code.indexOf("->~") + 2; //$NON-NLS-1$
+ length = 6;
}
- IASTNode node = parse( code, ParserLanguage.CPP, startOffset, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, startOffset, length);
assertNotNull(node);
IASTName name = null;
- switch( i )
- {
- case 0:
- case 1:
- node= node.getParent().getParent();
- assertTrue(node instanceof IASTTypeId);
- assertEquals(((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName().toString(), "Gonzo"); //$NON-NLS-1$
- name = ((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName();
- name = TestUtil.findImplicitName(name);
- IBinding binding = name.resolveBinding();
- assertTrue(binding instanceof ICPPConstructor);
- assertEquals(((ICPPConstructor)binding).getName(), "Gonzo"); //$NON-NLS-1$
- break;
- default:
- assertTrue(node instanceof IASTName);
- assertEquals(node.toString(), "~Gonzo"); //$NON-NLS-1$
- name = (IASTName)node;
- assertNotNull(name.resolveBinding());
- assertTrue(name.resolveBinding() instanceof ICPPMethod);
- assertEquals(((ICPPMethod)name.resolveBinding()).getName(), "~Gonzo"); //$NON-NLS-1$
- break;
-
+ switch (i) {
+ case 0:
+ case 1:
+ node = node.getParent().getParent();
+ assertTrue(node instanceof IASTTypeId);
+ assertEquals(((IASTNamedTypeSpecifier) ((IASTTypeId) node).getDeclSpecifier()).getName().toString(),
+ "Gonzo"); //$NON-NLS-1$
+ name = ((IASTNamedTypeSpecifier) ((IASTTypeId) node).getDeclSpecifier()).getName();
+ name = TestUtil.findImplicitName(name);
+ IBinding binding = name.resolveBinding();
+ assertTrue(binding instanceof ICPPConstructor);
+ assertEquals(((ICPPConstructor) binding).getName(), "Gonzo"); //$NON-NLS-1$
+ break;
+ default:
+ assertTrue(node instanceof IASTName);
+ assertEquals(node.toString(), "~Gonzo"); //$NON-NLS-1$
+ name = (IASTName) node;
+ assertNotNull(name.resolveBinding());
+ assertTrue(name.resolveBinding() instanceof ICPPMethod);
+ assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "~Gonzo"); //$NON-NLS-1$
+ break;
+
}
}
}
-
- public void testMethodReference() throws Exception
- {
+
+ public void testMethodReference() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Sample { public:\n"); //$NON-NLS-1$
- writer.write( " int getAnswer() const;\n"); //$NON-NLS-1$
- writer.write( "};\n"); //$NON-NLS-1$
- writer.write( "int main(int argc, char **argv) {\n" ); //$NON-NLS-1$
- writer.write( " Sample * s = new Sample();\n" ); //$NON-NLS-1$
- writer.write( " return s->getAnswer();\n" ); //$NON-NLS-1$
- writer.write( "}\n" ); //$NON-NLS-1$
+ writer.write("class Sample { public:\n"); //$NON-NLS-1$
+ writer.write(" int getAnswer() const;\n"); //$NON-NLS-1$
+ writer.write("};\n"); //$NON-NLS-1$
+ writer.write("int main(int argc, char **argv) {\n"); //$NON-NLS-1$
+ writer.write(" Sample * s = new Sample();\n"); //$NON-NLS-1$
+ writer.write(" return s->getAnswer();\n"); //$NON-NLS-1$
+ writer.write("}\n"); //$NON-NLS-1$
String code = writer.toString();
- int startIndex = code.indexOf( "->getAnswer") + 2; //$NON-NLS-1$
+ int startIndex = code.indexOf("->getAnswer") + 2; //$NON-NLS-1$
int length = "getAnswer".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, startIndex, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "getAnswer"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPMethod);
- assertEquals(((ICPPMethod)name.resolveBinding()).getName(), "getAnswer"); //$NON-NLS-1$
+ assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "getAnswer"); //$NON-NLS-1$
}
-
- public void testConstructorDefinition() throws Exception
- {
+
+ public void testConstructorDefinition() throws Exception {
String code = "class ABC { public: ABC(); }; ABC::ABC(){}"; //$NON-NLS-1$
- int startIndex = code.indexOf( "::ABC") + 2; //$NON-NLS-1$
+ int startIndex = code.indexOf("::ABC") + 2; //$NON-NLS-1$
int length = "ABC".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, startIndex, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertEquals(node.toString(), "ABC"); //$NON-NLS-1$
assertTrue(name.resolveBinding() instanceof ICPPConstructor);
- assertEquals(((ICPPConstructor)name.resolveBinding()).getName(), "ABC"); //$NON-NLS-1$
+ assertEquals(((ICPPConstructor) name.resolveBinding()).getName(), "ABC"); //$NON-NLS-1$
}
-
- public void testBug63966() throws Exception
- {
+
+ public void testBug63966() throws Exception {
Writer writer = new StringWriter();
- writer.write( "void foo(int a) {}\n" ); //$NON-NLS-1$
- writer.write( "void foo(long a) {}\n" ); //$NON-NLS-1$
- writer.write( "int main(int argc, char **argv) {\n" ); //$NON-NLS-1$
- writer.write( "foo(1); \n }" ); //$NON-NLS-1$
+ writer.write("void foo(int a) {}\n"); //$NON-NLS-1$
+ writer.write("void foo(long a) {}\n"); //$NON-NLS-1$
+ writer.write("int main(int argc, char **argv) {\n"); //$NON-NLS-1$
+ writer.write("foo(1); \n }"); //$NON-NLS-1$
String code = writer.toString();
- int startIndex = code.indexOf( "foo(1)"); //$NON-NLS-1$
+ int startIndex = code.indexOf("foo(1)"); //$NON-NLS-1$
int length = "foo".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, startIndex, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.C, startIndex, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression)node).getName().toString(), "foo"); //$NON-NLS-1$
- IASTName name = ((IASTIdExpression)node).getName();
+ assertEquals(((IASTIdExpression) node).getName().toString(), "foo"); //$NON-NLS-1$
+ IASTName name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "foo"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, startIndex, length ).getParent();
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "foo"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, startIndex, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression)node).getName().toString(), "foo"); //$NON-NLS-1$
- name = ((IASTIdExpression)node).getName();
+ assertEquals(((IASTIdExpression) node).getName().toString(), "foo"); //$NON-NLS-1$
+ name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "foo"); //$NON-NLS-1$
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "foo"); //$NON-NLS-1$
}
-
- public void testBug66744() throws Exception
- {
+
+ public void testBug66744() throws Exception {
Writer writerCPP = new StringWriter();
- writerCPP.write( "enum EColours { RED, GREEN, BLUE }; \n" ); //$NON-NLS-1$
- writerCPP.write( "void foo() { EColours color = GREEN; } \n" ); //$NON-NLS-1$
-
+ writerCPP.write("enum EColours { RED, GREEN, BLUE }; \n"); //$NON-NLS-1$
+ writerCPP.write("void foo() { EColours color = GREEN; } \n"); //$NON-NLS-1$
+
Writer writerC = new StringWriter();
- writerC.write( "enum EColours { RED, GREEN, BLUE }; \n" ); //$NON-NLS-1$
- writerC.write( "void foo() { enum EColours color = GREEN; } \n" ); //$NON-NLS-1$
-
+ writerC.write("enum EColours { RED, GREEN, BLUE }; \n"); //$NON-NLS-1$
+ writerC.write("void foo() { enum EColours color = GREEN; } \n"); //$NON-NLS-1$
+
String codeCPP = writerCPP.toString();
String codeC = writerC.toString();
- int startIndex = codeC.indexOf( "EColours color"); //$NON-NLS-1$
+ int startIndex = codeC.indexOf("EColours color"); //$NON-NLS-1$
int length = "EColours".length(); //$NON-NLS-1$
- IASTNode node = parse( codeC, ParserLanguage.C, startIndex, length );
+ IASTNode node = parse(codeC, ParserLanguage.C, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "EColours"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IEnumeration);
- assertEquals(((IEnumeration)name.resolveBinding()).getName(), "EColours"); //$NON-NLS-1$
- startIndex = codeCPP.indexOf( "EColours color"); //$NON-NLS-1$
- node = parse( codeCPP, ParserLanguage.CPP, startIndex, length ).getParent();
+ assertEquals(((IEnumeration) name.resolveBinding()).getName(), "EColours"); //$NON-NLS-1$
+ startIndex = codeCPP.indexOf("EColours color"); //$NON-NLS-1$
+ node = parse(codeCPP, ParserLanguage.CPP, startIndex, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTNamedTypeSpecifier);
- assertEquals(((IASTNamedTypeSpecifier)node).getName().toString(), "EColours"); //$NON-NLS-1$
- name = ((IASTNamedTypeSpecifier)node).getName();
+ assertEquals(((IASTNamedTypeSpecifier) node).getName().toString(), "EColours"); //$NON-NLS-1$
+ name = ((IASTNamedTypeSpecifier) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IEnumeration);
- assertEquals(((IEnumeration)name.resolveBinding()).getName(), "EColours"); //$NON-NLS-1$
+ assertEquals(((IEnumeration) name.resolveBinding()).getName(), "EColours"); //$NON-NLS-1$
}
-
-
- public void testBug68527() throws Exception
- {
+ public void testBug68527() throws Exception {
Writer writer = new StringWriter();
writer.write("struct X;\n"); //$NON-NLS-1$
writer.write("struct X anA;"); //$NON-NLS-1$
String code = writer.toString();
- int startIndex = code.indexOf( "X anA"); //$NON-NLS-1$
+ int startIndex = code.indexOf("X anA"); //$NON-NLS-1$
int length = "X".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, startIndex, length );
+ IASTNode node = parse(code, ParserLanguage.C, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "X"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICompositeType);
- assertEquals(((ICompositeType)name.resolveBinding()).getName(), "X"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, startIndex, length );
+ assertEquals(((ICompositeType) name.resolveBinding()).getName(), "X"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "X"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICompositeType);
- assertEquals(((ICompositeType)name.resolveBinding()).getName(), "X"); //$NON-NLS-1$
+ assertEquals(((ICompositeType) name.resolveBinding()).getName(), "X"); //$NON-NLS-1$
}
- public void testBug60407() throws Exception
- {
+ public void testBug60407() throws Exception {
Writer writer = new StringWriter();
- writer.write( "struct ZZZ { int x, y, z; };\n" ); //$NON-NLS-1$
- writer.write( "typedef struct ZZZ _FILE;\n" ); //$NON-NLS-1$
- writer.write( "typedef _FILE FILE;\n" ); //$NON-NLS-1$
- writer.write( "static void static_function(FILE * lcd){}\n" ); //$NON-NLS-1$
- writer.write( "int main(int argc, char **argv) {\n" ); //$NON-NLS-1$
- writer.write( "FILE * file = 0;\n" ); //$NON-NLS-1$
- writer.write( "static_function( file );\n" ); //$NON-NLS-1$
- writer.write( "return 0;\n" ); //$NON-NLS-1$
- writer.write( "}\n" ); //$NON-NLS-1$
+ writer.write("struct ZZZ { int x, y, z; };\n"); //$NON-NLS-1$
+ writer.write("typedef struct ZZZ _FILE;\n"); //$NON-NLS-1$
+ writer.write("typedef _FILE FILE;\n"); //$NON-NLS-1$
+ writer.write("static void static_function(FILE * lcd){}\n"); //$NON-NLS-1$
+ writer.write("int main(int argc, char **argv) {\n"); //$NON-NLS-1$
+ writer.write("FILE * file = 0;\n"); //$NON-NLS-1$
+ writer.write("static_function( file );\n"); //$NON-NLS-1$
+ writer.write("return 0;\n"); //$NON-NLS-1$
+ writer.write("}\n"); //$NON-NLS-1$
String code = writer.toString();
- int startIndex = code.indexOf( "static_function( file )"); //$NON-NLS-1$
+ int startIndex = code.indexOf("static_function( file )"); //$NON-NLS-1$
int length = "static_function".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, startIndex, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.C, startIndex, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression)node).getName().toString(), "static_function"); //$NON-NLS-1$
- IASTName name = ((IASTIdExpression)node).getName();
+ assertEquals(((IASTIdExpression) node).getName().toString(), "static_function"); //$NON-NLS-1$
+ IASTName name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "static_function"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, startIndex, length ).getParent();
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "static_function"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, startIndex, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression)node).getName().toString(), "static_function"); //$NON-NLS-1$
- name = ((IASTIdExpression)node).getName();
+ assertEquals(((IASTIdExpression) node).getName().toString(), "static_function"); //$NON-NLS-1$
+ name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "static_function"); //$NON-NLS-1$
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "static_function"); //$NON-NLS-1$
}
-
- public void testBug61800() throws Exception
- {
+
+ public void testBug61800() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class B {};\n"); //$NON-NLS-1$
- writer.write( "class ABCDEF {\n"); //$NON-NLS-1$
- writer.write( " static B stInt; };\n"); //$NON-NLS-1$
- writer.write( "B ABCDEF::stInt = 5;\n"); //$NON-NLS-1$
+ writer.write("class B {};\n"); //$NON-NLS-1$
+ writer.write("class ABCDEF {\n"); //$NON-NLS-1$
+ writer.write(" static B stInt; };\n"); //$NON-NLS-1$
+ writer.write("B ABCDEF::stInt = 5;\n"); //$NON-NLS-1$
String code = writer.toString();
- int startIndex = code.indexOf( "::stInt") + 2; //$NON-NLS-1$
+ int startIndex = code.indexOf("::stInt") + 2; //$NON-NLS-1$
int length = "stInt".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, startIndex, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "stInt"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPField);
- assertEquals(((ICPPField)name.resolveBinding()).getName(), "stInt"); //$NON-NLS-1$
+ assertEquals(((ICPPField) name.resolveBinding()).getName(), "stInt"); //$NON-NLS-1$
}
-
- public void testBug68739() throws Exception
- {
- Writer writer = new StringWriter();
- writer.write( "int fprintf( int *, const char *, ... ); \n" ); //$NON-NLS-1$
- writer.write( "void boo( int * lcd ) { \n" ); //$NON-NLS-1$
- writer.write( " /**/fprintf( lcd, \"%c%s 0x%x\", ' ', \"bbb\", 2 ); \n" ); //$NON-NLS-1$
- writer.write( "} \n" ); //$NON-NLS-1$
-
- String code = writer.toString();
- int startIndex = code.indexOf( "/**/fprintf") + 4; //$NON-NLS-1$
+
+ public void testBug68739() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("int fprintf( int *, const char *, ... ); \n"); //$NON-NLS-1$
+ writer.write("void boo( int * lcd ) { \n"); //$NON-NLS-1$
+ writer.write(" /**/fprintf( lcd, \"%c%s 0x%x\", ' ', \"bbb\", 2 ); \n"); //$NON-NLS-1$
+ writer.write("} \n"); //$NON-NLS-1$
+
+ String code = writer.toString();
+ int startIndex = code.indexOf("/**/fprintf") + 4; //$NON-NLS-1$
int length = "fprintf".length(); //$NON-NLS-1$
-
- IASTNode node = parse( code, ParserLanguage.C, startIndex, length ).getParent();
+
+ IASTNode node = parse(code, ParserLanguage.C, startIndex, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression)node).getName().toString(), "fprintf"); //$NON-NLS-1$
- IASTName name = ((IASTIdExpression)node).getName();
+ assertEquals(((IASTIdExpression) node).getName().toString(), "fprintf"); //$NON-NLS-1$
+ IASTName name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "fprintf"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, startIndex, length ).getParent();
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "fprintf"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, startIndex, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression)node).getName().toString(), "fprintf"); //$NON-NLS-1$
- name = ((IASTIdExpression)node).getName();
+ assertEquals(((IASTIdExpression) node).getName().toString(), "fprintf"); //$NON-NLS-1$
+ name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "fprintf"); //$NON-NLS-1$
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "fprintf"); //$NON-NLS-1$
}
-
- public void testBug72818() throws Exception
- {
+
+ public void testBug72818() throws Exception {
Writer writerCPP = new StringWriter();
- writerCPP.write( "union Squaw { int x; double u; };\n" ); //$NON-NLS-1$
- writerCPP.write( "int main(int argc, char **argv) {\n" ); //$NON-NLS-1$
- writerCPP.write( "return sizeof( Squaw );\n" ); //$NON-NLS-1$
- writerCPP.write( "}\n" ); //$NON-NLS-1$
-
+ writerCPP.write("union Squaw { int x; double u; };\n"); //$NON-NLS-1$
+ writerCPP.write("int main(int argc, char **argv) {\n"); //$NON-NLS-1$
+ writerCPP.write("return sizeof( Squaw );\n"); //$NON-NLS-1$
+ writerCPP.write("}\n"); //$NON-NLS-1$
+
Writer writerC = new StringWriter();
- writerC.write( "union Squaw { int x; double u; };\n" ); //$NON-NLS-1$
- writerC.write( "int main(int argc, char **argv) {\n" ); //$NON-NLS-1$
- writerC.write( "return sizeof( union Squaw );\n" ); //$NON-NLS-1$
- writerC.write( "}\n" ); //$NON-NLS-1$
-
+ writerC.write("union Squaw { int x; double u; };\n"); //$NON-NLS-1$
+ writerC.write("int main(int argc, char **argv) {\n"); //$NON-NLS-1$
+ writerC.write("return sizeof( union Squaw );\n"); //$NON-NLS-1$
+ writerC.write("}\n"); //$NON-NLS-1$
+
String codeC = writerC.toString();
String codeCPP = writerCPP.toString();
- int startIndex = codeC.indexOf( "sizeof( union ") + "sizeof( union ".length(); //$NON-NLS-1$ //$NON-NLS-2$
+ int startIndex = codeC.indexOf("sizeof( union ") + "sizeof( union ".length(); //$NON-NLS-1$ //$NON-NLS-2$
int length = "Squaw".length(); //$NON-NLS-1$
- IASTNode node = parse( codeC, ParserLanguage.C, startIndex, length );
+ IASTNode node = parse(codeC, ParserLanguage.C, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Squaw"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICompositeType);
- assertEquals(((ICompositeType)name.resolveBinding()).getName(), "Squaw"); //$NON-NLS-1$
- startIndex = codeCPP.indexOf( "sizeof( ") + "sizeof( ".length(); //$NON-NLS-1$ //$NON-NLS-2$
- node = parse( codeCPP, ParserLanguage.CPP, startIndex, length ).getParent().getParent();
+ assertEquals(((ICompositeType) name.resolveBinding()).getName(), "Squaw"); //$NON-NLS-1$
+ startIndex = codeCPP.indexOf("sizeof( ") + "sizeof( ".length(); //$NON-NLS-1$ //$NON-NLS-2$
+ node = parse(codeCPP, ParserLanguage.CPP, startIndex, length).getParent().getParent();
assertNotNull(node);
assertTrue(node instanceof IASTTypeId);
- assertEquals(((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName().toString(), "Squaw"); //$NON-NLS-1$
- name = ((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName();
+ assertEquals(((IASTNamedTypeSpecifier) ((IASTTypeId) node).getDeclSpecifier()).getName().toString(), "Squaw"); //$NON-NLS-1$
+ name = ((IASTNamedTypeSpecifier) ((IASTTypeId) node).getDeclSpecifier()).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPClassType);
- assertEquals(((ICPPClassType)name.resolveBinding()).getName(), "Squaw"); //$NON-NLS-1$
+ assertEquals(((ICPPClassType) name.resolveBinding()).getName(), "Squaw"); //$NON-NLS-1$
}
-
- public void test72220() throws Exception
- {
+
+ public void test72220() throws Exception {
Writer writer = new StringWriter();
- writer.write( "const int FOUND_ME = 1;\n" ); //$NON-NLS-1$
- writer.write( "class Test{\n" ); //$NON-NLS-1$
- writer.write( "public:\n" ); //$NON-NLS-1$
- writer.write( "const int findCode() const;\n" ); //$NON-NLS-1$
- writer.write( "};\n" ); //$NON-NLS-1$
- writer.write( "const int Test::findCode() const {\n" ); //$NON-NLS-1$
- writer.write( "return FOUND_ME;\n" ); //$NON-NLS-1$
- writer.write( "}\n" ); //$NON-NLS-1$
+ writer.write("const int FOUND_ME = 1;\n"); //$NON-NLS-1$
+ writer.write("class Test{\n"); //$NON-NLS-1$
+ writer.write("public:\n"); //$NON-NLS-1$
+ writer.write("const int findCode() const;\n"); //$NON-NLS-1$
+ writer.write("};\n"); //$NON-NLS-1$
+ writer.write("const int Test::findCode() const {\n"); //$NON-NLS-1$
+ writer.write("return FOUND_ME;\n"); //$NON-NLS-1$
+ writer.write("}\n"); //$NON-NLS-1$
String code = writer.toString();
- int startIndex = code.indexOf( "return ") + "return ".length(); //$NON-NLS-1$ //$NON-NLS-2$
+ int startIndex = code.indexOf("return ") + "return ".length(); //$NON-NLS-1$ //$NON-NLS-2$
int length = "FOUND_ME".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, startIndex, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.CPP, startIndex, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression)node).getName().toString(), "FOUND_ME"); //$NON-NLS-1$
- IASTName name = ((IASTIdExpression)node).getName();
+ assertEquals(((IASTIdExpression) node).getName().toString(), "FOUND_ME"); //$NON-NLS-1$
+ IASTName name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IVariable);
- assertEquals(((IVariable)name.resolveBinding()).getName(), "FOUND_ME"); //$NON-NLS-1$
+ assertEquals(((IVariable) name.resolveBinding()).getName(), "FOUND_ME"); //$NON-NLS-1$
}
-
- public void testBug72721() throws Exception{
- Writer writer = new StringWriter();
- writer.write(" class ABC { public: ABC(int); }; \n"); //$NON-NLS-1$
- writer.write("void f() { \n"); //$NON-NLS-1$
- writer.write(" int j = 1; \n"); //$NON-NLS-1$
- writer.write(" new ABC( j + 1 ); \n"); //$NON-NLS-1$
- writer.write("} \n"); //$NON-NLS-1$
-
- String code = writer.toString();
- int startIndex = code.indexOf( "ABC(" ); //$NON-NLS-1$
+
+ public void testBug72721() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write(" class ABC { public: ABC(int); }; \n"); //$NON-NLS-1$
+ writer.write("void f() { \n"); //$NON-NLS-1$
+ writer.write(" int j = 1; \n"); //$NON-NLS-1$
+ writer.write(" new ABC( j + 1 ); \n"); //$NON-NLS-1$
+ writer.write("} \n"); //$NON-NLS-1$
+
+ String code = writer.toString();
+ int startIndex = code.indexOf("ABC("); //$NON-NLS-1$
int length = "ABC".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, startIndex, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "ABC"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPConstructor);
- assertEquals(((ICPPConstructor)name.resolveBinding()).getName(), "ABC"); //$NON-NLS-1$
+ assertEquals(((ICPPConstructor) name.resolveBinding()).getName(), "ABC"); //$NON-NLS-1$
}
-
- public void testBug72372() throws Exception{
- Writer writer = new StringWriter();
- writer.write("namespace B { \n"); //$NON-NLS-1$
- writer.write(" class SD_02 { void f_SD(); }; \n"); //$NON-NLS-1$
- writer.write("} \n"); //$NON-NLS-1$
- writer.write("using namespace B; \n"); //$NON-NLS-1$
- writer.write("void SD_02::f_SD(){} \n"); //$NON-NLS-1$
-
- String code = writer.toString();
- int startIndex = code.indexOf( ":f_SD" ) + 1; //$NON-NLS-1$
+
+ public void testBug72372() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("namespace B { \n"); //$NON-NLS-1$
+ writer.write(" class SD_02 { void f_SD(); }; \n"); //$NON-NLS-1$
+ writer.write("} \n"); //$NON-NLS-1$
+ writer.write("using namespace B; \n"); //$NON-NLS-1$
+ writer.write("void SD_02::f_SD(){} \n"); //$NON-NLS-1$
+
+ String code = writer.toString();
+ int startIndex = code.indexOf(":f_SD") + 1; //$NON-NLS-1$
int length = "f_SD".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, startIndex, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "f_SD"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPMethod);
- assertEquals(((ICPPMethod)name.resolveBinding()).getName(), "f_SD"); //$NON-NLS-1$
+ assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "f_SD"); //$NON-NLS-1$
}
- public void testBug72372_2() throws Exception{
- Writer writer = new StringWriter();
- writer.write("namespace A { \n"); //$NON-NLS-1$
- writer.write(" namespace B { \n"); //$NON-NLS-1$
- writer.write(" void f_SD(); \n"); //$NON-NLS-1$
- writer.write(" } \n"); //$NON-NLS-1$
- writer.write("} \n"); //$NON-NLS-1$
- writer.write("namespace C { \n"); //$NON-NLS-1$
- writer.write(" using namespace A; \n"); //$NON-NLS-1$
- writer.write("} \n"); //$NON-NLS-1$
- writer.write("void C::B::f_SD(){} \n"); //$NON-NLS-1$
-
- String code = writer.toString();
- int startIndex = code.indexOf( ":f_SD" ) + 1; //$NON-NLS-1$
+
+ public void testBug72372_2() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("namespace A { \n"); //$NON-NLS-1$
+ writer.write(" namespace B { \n"); //$NON-NLS-1$
+ writer.write(" void f_SD(); \n"); //$NON-NLS-1$
+ writer.write(" } \n"); //$NON-NLS-1$
+ writer.write("} \n"); //$NON-NLS-1$
+ writer.write("namespace C { \n"); //$NON-NLS-1$
+ writer.write(" using namespace A; \n"); //$NON-NLS-1$
+ writer.write("} \n"); //$NON-NLS-1$
+ writer.write("void C::B::f_SD(){} \n"); //$NON-NLS-1$
+
+ String code = writer.toString();
+ int startIndex = code.indexOf(":f_SD") + 1; //$NON-NLS-1$
int length = "f_SD".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, startIndex, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "f_SD"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "f_SD"); //$NON-NLS-1$
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "f_SD"); //$NON-NLS-1$
}
-
- public void testBug72713() throws Exception{
- Writer writer = new StringWriter();
- writer.write( "class Deck{ void initialize(); }; \n"); //$NON-NLS-1$
- writer.write( "void Deck::initialize(){} \n"); //$NON-NLS-1$
-
- String code = writer.toString();
- int startIndex = code.indexOf( ":initialize" ) + 1; //$NON-NLS-1$
- int length = "initialize".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, startIndex, length );
+
+ public void testBug72713() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class Deck{ void initialize(); }; \n"); //$NON-NLS-1$
+ writer.write("void Deck::initialize(){} \n"); //$NON-NLS-1$
+
+ String code = writer.toString();
+ int startIndex = code.indexOf(":initialize") + 1; //$NON-NLS-1$
+ int length = "initialize".length(); //$NON-NLS-1$
+ IASTNode node = parse(code, ParserLanguage.CPP, startIndex, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "initialize"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPMethod);
- assertEquals(((ICPPMethod)name.resolveBinding()).getName(), "initialize"); //$NON-NLS-1$
+ assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "initialize"); //$NON-NLS-1$
}
-
- public void testBug72712() throws Exception{
- Writer writer = new StringWriter();
- writer.write( "class B{ public: B(); }; void f(){ B* b; b = new B(); }" ); //$NON-NLS-1$
-
- String code = writer.toString();
- int startIndex = code.indexOf( "new B" ) + 4; //$NON-NLS-1$
- int length = "B".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, startIndex, length ).getParent().getParent();
+
+ public void testBug72712() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class B{ public: B(); }; void f(){ B* b; b = new B(); }"); //$NON-NLS-1$
+
+ String code = writer.toString();
+ int startIndex = code.indexOf("new B") + 4; //$NON-NLS-1$
+ int length = "B".length(); //$NON-NLS-1$
+ IASTNode node = parse(code, ParserLanguage.CPP, startIndex, length).getParent().getParent();
assertNotNull(node);
assertTrue(node instanceof IASTTypeId);
- assertEquals(((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName().toString(), "B"); //$NON-NLS-1$
- IASTName name = ((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName();
+ assertEquals(((IASTNamedTypeSpecifier) ((IASTTypeId) node).getDeclSpecifier()).getName().toString(), "B"); //$NON-NLS-1$
+ IASTName name = ((IASTNamedTypeSpecifier) ((IASTTypeId) node).getDeclSpecifier()).getName();
name = TestUtil.findImplicitName(name);
- IBinding binding = name.resolveBinding();
- assertTrue(binding instanceof ICPPConstructor);
- assertEquals(((ICPPConstructor)binding).getName(), "B"); //$NON-NLS-1$
+ IBinding binding = name.resolveBinding();
+ assertTrue(binding instanceof ICPPConstructor);
+ assertEquals(((ICPPConstructor) binding).getName(), "B"); //$NON-NLS-1$
}
-
- public void testBug72712_2() throws Exception{
- Writer writer = new StringWriter();
- writer.write( "class A {}; \n"); //$NON-NLS-1$
- writer.write( "class B{ public: B( A* ); }; \n"); //$NON-NLS-1$
- writer.write( "void f(){ B* b; b = new B( (A*)0 ); } \n"); //$NON-NLS-1$
-
- String code = writer.toString();
- int startIndex = code.indexOf( "(A*)" ) + 1; //$NON-NLS-1$
- int length = "A".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, startIndex, length ).getParent();
+
+ public void testBug72712_2() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class A {}; \n"); //$NON-NLS-1$
+ writer.write("class B{ public: B( A* ); }; \n"); //$NON-NLS-1$
+ writer.write("void f(){ B* b; b = new B( (A*)0 ); } \n"); //$NON-NLS-1$
+
+ String code = writer.toString();
+ int startIndex = code.indexOf("(A*)") + 1; //$NON-NLS-1$
+ int length = "A".length(); //$NON-NLS-1$
+ IASTNode node = parse(code, ParserLanguage.CPP, startIndex, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTNamedTypeSpecifier);
- assertEquals(((IASTNamedTypeSpecifier)node).getName().toString(), "A"); //$NON-NLS-1$
- IASTName name = ((IASTNamedTypeSpecifier)node).getName();
+ assertEquals(((IASTNamedTypeSpecifier) node).getName().toString(), "A"); //$NON-NLS-1$
+ IASTName name = ((IASTNamedTypeSpecifier) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPClassType);
- assertEquals(((ICPPClassType)name.resolveBinding()).getName(), "A"); //$NON-NLS-1$
+ assertEquals(((ICPPClassType) name.resolveBinding()).getName(), "A"); //$NON-NLS-1$
}
-
- public void testBug72710() throws Exception
- {
+
+ public void testBug72710() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Card{\n" ); //$NON-NLS-1$
- writer.write( " Card( int rank );\n" ); //$NON-NLS-1$
- writer.write( " int rank;\n" ); //$NON-NLS-1$
- writer.write( "};\n" ); //$NON-NLS-1$
- writer.write( "Card::Card( int rank ) {\n" ); //$NON-NLS-1$
- writer.write( "this->rank = rank;\n" ); //$NON-NLS-1$
- writer.write( "}\n" ); //$NON-NLS-1$
+ writer.write("class Card{\n"); //$NON-NLS-1$
+ writer.write(" Card( int rank );\n"); //$NON-NLS-1$
+ writer.write(" int rank;\n"); //$NON-NLS-1$
+ writer.write("};\n"); //$NON-NLS-1$
+ writer.write("Card::Card( int rank ) {\n"); //$NON-NLS-1$
+ writer.write("this->rank = rank;\n"); //$NON-NLS-1$
+ writer.write("}\n"); //$NON-NLS-1$
String code = writer.toString();
- int index = code.indexOf( "this->rank") + 6; //$NON-NLS-1$
+ int index = code.indexOf("this->rank") + 6; //$NON-NLS-1$
int length = "rank".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, index, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "rank"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPField);
- assertEquals(((ICPPField)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+ assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
}
-
-
- public void testBug75731() throws Exception
- {
+
+ public void testBug75731() throws Exception {
Writer writer = new StringWriter();
writer.write("int rank() {\n"); //$NON-NLS-1$
writer.write("return 5;\n}\n"); //$NON-NLS-1$
@@ -800,212 +773,212 @@ public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
writer.write("private:\n"); //$NON-NLS-1$
writer.write("Card( int rank );\n"); //$NON-NLS-1$
writer.write("int rank;\n"); //$NON-NLS-1$
- writer.write("public:\n"); //$NON-NLS-1$
+ writer.write("public:\n"); //$NON-NLS-1$
writer.write("int getRank();\n};\n"); //$NON-NLS-1$
- writer.write("Card::Card( int rank )\n{\n"); //$NON-NLS-1$
+ writer.write("Card::Card( int rank )\n{\n"); //$NON-NLS-1$
writer.write("this->rank = ::rank();\n"); //$NON-NLS-1$
writer.write("this->rank = this->rank;\n"); //$NON-NLS-1$
writer.write("this->rank = rank;\n"); //$NON-NLS-1$
writer.write("this->rank = Card::rank;\n"); //$NON-NLS-1$
writer.write("this->rank = getRank();\n}\n"); //$NON-NLS-1$
-
+
String code = writer.toString();
- int index = code.indexOf( "int rank() {") + 4; //$NON-NLS-1$
+ int index = code.indexOf("int rank() {") + 4; //$NON-NLS-1$
int length = "rank".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, index, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "rank"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "class Card{") + 6; //$NON-NLS-1$
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("class Card{") + 6; //$NON-NLS-1$
length = "Card".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Card"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPClassType);
- assertEquals(((ICPPClassType)name.resolveBinding()).getName(), "Card"); //$NON-NLS-1$
-
- index = code.indexOf( "Card( int rank );"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((ICPPClassType) name.resolveBinding()).getName(), "Card"); //$NON-NLS-1$
+
+ index = code.indexOf("Card( int rank );"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Card"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPConstructor);
- assertEquals(((ICPPConstructor)name.resolveBinding()).getName(), "Card"); //$NON-NLS-1$
-
- index = code.indexOf( "Card( int rank );") + 10; //$NON-NLS-1$
+ assertEquals(((ICPPConstructor) name.resolveBinding()).getName(), "Card"); //$NON-NLS-1$
+
+ index = code.indexOf("Card( int rank );") + 10; //$NON-NLS-1$
length = "rank".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length ).getParent();
+ node = parse(code, ParserLanguage.CPP, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTDeclarator);
- assertEquals(((IASTDeclarator)node).getName().toString(), "rank"); //$NON-NLS-1$
- name = ((IASTDeclarator)node).getName();
+ assertEquals(((IASTDeclarator) node).getName().toString(), "rank"); //$NON-NLS-1$
+ name = ((IASTDeclarator) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IVariable);
- assertEquals(((IVariable)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+ assertEquals(((IVariable) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
- index = code.indexOf( "int rank;") + 4; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length ).getParent();
+ index = code.indexOf("int rank;") + 4; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTDeclarator);
- assertEquals(((IASTDeclarator)node).getName().toString(), "rank"); //$NON-NLS-1$
- name = ((IASTDeclarator)node).getName();
+ assertEquals(((IASTDeclarator) node).getName().toString(), "rank"); //$NON-NLS-1$
+ name = ((IASTDeclarator) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPField);
- assertEquals(((ICPPField)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "int getRank();") + 4; //$NON-NLS-1$
+ assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("int getRank();") + 4; //$NON-NLS-1$
length = "getRank".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "getRank"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPMethod);
- assertEquals(((ICPPMethod)name.resolveBinding()).getName(), "getRank"); //$NON-NLS-1$
-
- index = code.indexOf( "Card::Card( int rank )"); //$NON-NLS-1$
+ assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "getRank"); //$NON-NLS-1$
+
+ index = code.indexOf("Card::Card( int rank )"); //$NON-NLS-1$
length = "Card".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Card"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPClassType);
- assertEquals(((ICPPClassType)name.resolveBinding()).getName(), "Card"); //$NON-NLS-1$
-
- index = code.indexOf( "Card::Card( int rank )") + 6; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((ICPPClassType) name.resolveBinding()).getName(), "Card"); //$NON-NLS-1$
+
+ index = code.indexOf("Card::Card( int rank )") + 6; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Card"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPConstructor);
- assertEquals(((ICPPConstructor)name.resolveBinding()).getName(), "Card"); //$NON-NLS-1$
-
- index = code.indexOf( "Card::Card( int rank )") + 16; //$NON-NLS-1$
+ assertEquals(((ICPPConstructor) name.resolveBinding()).getName(), "Card"); //$NON-NLS-1$
+
+ index = code.indexOf("Card::Card( int rank )") + 16; //$NON-NLS-1$
length = "rank".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length ).getParent();
+ node = parse(code, ParserLanguage.CPP, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTDeclarator);
- assertEquals(((IASTDeclarator)node).getName().toString(), "rank"); //$NON-NLS-1$
- name = ((IASTDeclarator)node).getName();
+ assertEquals(((IASTDeclarator) node).getName().toString(), "rank"); //$NON-NLS-1$
+ name = ((IASTDeclarator) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IVariable);
- assertEquals(((IVariable)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "this->rank = ::rank();") + 6; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((IVariable) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("this->rank = ::rank();") + 6; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "rank"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPField);
- assertEquals(((ICPPField)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "this->rank = ::rank();") + 15; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("this->rank = ::rank();") + 15; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "rank"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IFunction);
- assertEquals(((IFunction)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "this->rank = this->rank;") + 6; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((IFunction) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("this->rank = this->rank;") + 6; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "rank"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPField);
- assertEquals(((ICPPField)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "this->rank = this->rank;") + 19; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("this->rank = this->rank;") + 19; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "rank"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPField);
- assertEquals(((ICPPField)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "this->rank = rank;") + 6; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("this->rank = rank;") + 6; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "rank"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPField);
- assertEquals(((ICPPField)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "this->rank = rank;") + 13; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length ).getParent();
+ assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("this->rank = rank;") + 13; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression)node).getName().toString(), "rank"); //$NON-NLS-1$
- name = ((IASTIdExpression)node).getName();
+ assertEquals(((IASTIdExpression) node).getName().toString(), "rank"); //$NON-NLS-1$
+ name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IVariable);
- assertEquals(((IVariable)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "this->rank = Card::rank;") + 6; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((IVariable) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("this->rank = Card::rank;") + 6; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "rank"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPField);
- assertEquals(((ICPPField)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "this->rank = Card::rank;") + 19; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("this->rank = Card::rank;") + 19; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "rank"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPField);
- assertEquals(((ICPPField)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "this->rank = getRank();") + 6; //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("this->rank = getRank();") + 6; //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "rank"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPField);
- assertEquals(((ICPPField)name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
-
- index = code.indexOf( "this->rank = getRank();") + 13; //$NON-NLS-1$
+ assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$
+
+ index = code.indexOf("this->rank = getRank();") + 13; //$NON-NLS-1$
length = "getRank".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length ).getParent();
+ node = parse(code, ParserLanguage.CPP, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTIdExpression);
- assertEquals(((IASTIdExpression)node).getName().toString(), "getRank"); //$NON-NLS-1$
- name = ((IASTIdExpression)node).getName();
+ assertEquals(((IASTIdExpression) node).getName().toString(), "getRank"); //$NON-NLS-1$
+ name = ((IASTIdExpression) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPMethod);
- assertEquals(((ICPPMethod)name.resolveBinding()).getName(), "getRank"); //$NON-NLS-1$
+ assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "getRank"); //$NON-NLS-1$
}
public void testBug77989() throws Exception {
@@ -1014,44 +987,44 @@ public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
writer.write("class C{};\n}\n"); //$NON-NLS-1$
writer.write("using namespace N; /* B */\n"); //$NON-NLS-1$
writer.write("N::C c; /* C */\n"); //$NON-NLS-1$
-
+
String code = writer.toString();
- int index = code.indexOf( "using namespace N;") + 16; //$NON-NLS-1$
+ int index = code.indexOf("using namespace N;") + 16; //$NON-NLS-1$
int length = "N".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, index, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "N"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICPPNamespace);
- assertEquals(((ICPPNamespace)name.resolveBinding()).getName(), "N"); //$NON-NLS-1$
+ assertEquals(((ICPPNamespace) name.resolveBinding()).getName(), "N"); //$NON-NLS-1$
}
public void testBug78435() throws Exception {
Writer writer = new StringWriter();
- writer.write("int itself; //A\n"); //$NON-NLS-1$
+ writer.write("int itself; //A\n"); //$NON-NLS-1$
writer.write("void f(int itself){} //B\n"); //$NON-NLS-1$
-
+
String code = writer.toString();
- int index = code.indexOf( "void f(int itself){}") + 11; //$NON-NLS-1$
+ int index = code.indexOf("void f(int itself){}") + 11; //$NON-NLS-1$
int length = "itself".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, index, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.C, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTDeclarator);
- assertEquals(((IASTDeclarator)node).getName().toString(), "itself"); //$NON-NLS-1$
- IASTName name = ((IASTDeclarator)node).getName();
+ assertEquals(((IASTDeclarator) node).getName().toString(), "itself"); //$NON-NLS-1$
+ IASTName name = ((IASTDeclarator) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IVariable);
- assertEquals(((IVariable)name.resolveBinding()).getName(), "itself"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length ).getParent();
+ assertEquals(((IVariable) name.resolveBinding()).getName(), "itself"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTDeclarator);
- assertEquals(((IASTDeclarator)node).getName().toString(), "itself"); //$NON-NLS-1$
- name = ((IASTDeclarator)node).getName();
+ assertEquals(((IASTDeclarator) node).getName().toString(), "itself"); //$NON-NLS-1$
+ name = ((IASTDeclarator) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IVariable);
- assertEquals(((IVariable)name.resolveBinding()).getName(), "itself"); //$NON-NLS-1$
+ assertEquals(((IVariable) name.resolveBinding()).getName(), "itself"); //$NON-NLS-1$
}
public void testBug78231A() throws Exception {
@@ -1059,402 +1032,400 @@ public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
writer.write("struct Base {\n"); //$NON-NLS-1$
writer.write("int Data; // 1\n"); //$NON-NLS-1$
writer.write("struct Data; // 2\n};\n"); //$NON-NLS-1$
-
+
String code = writer.toString();
int index = code.indexOf("struct Data;") + 7; //$NON-NLS-1$
int length = "Data".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, index, length );
+ IASTNode node = parse(code, ParserLanguage.C, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Data"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICompositeType);
- assertEquals(((ICompositeType)name.resolveBinding()).getName(), "Data"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((ICompositeType) name.resolveBinding()).getName(), "Data"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Data"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICompositeType);
- assertEquals(((ICompositeType)name.resolveBinding()).getName(), "Data"); //$NON-NLS-1$
+ assertEquals(((ICompositeType) name.resolveBinding()).getName(), "Data"); //$NON-NLS-1$
}
-
+
public void testBug78231B() throws Exception {
Writer writer = new StringWriter();
writer.write("int Data;\n"); //$NON-NLS-1$
writer.write("struct Base {\n"); //$NON-NLS-1$
writer.write("int Data; // 1\n"); //$NON-NLS-1$
writer.write("struct Data; // 2\n};\n"); //$NON-NLS-1$
-
+
String code = writer.toString();
int index = code.indexOf("struct Data;") + 7; //$NON-NLS-1$
int length = "Data".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, index, length );
+ IASTNode node = parse(code, ParserLanguage.C, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Data"); //$NON-NLS-1$
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICompositeType);
- assertEquals(((ICompositeType)name.resolveBinding()).getName(), "Data"); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length );
+ assertEquals(((ICompositeType) name.resolveBinding()).getName(), "Data"); //$NON-NLS-1$
+ node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertEquals(node.toString(), "Data"); //$NON-NLS-1$
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ICompositeType);
- assertEquals(((ICompositeType)name.resolveBinding()).getName(), "Data"); //$NON-NLS-1$
+ assertEquals(((ICompositeType) name.resolveBinding()).getName(), "Data"); //$NON-NLS-1$
}
-
+
public void testSimpleKRCTest1() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append( "int f(char x);\n" ); //$NON-NLS-1$
- buffer.append( "int f(x) char x;\n" ); //$NON-NLS-1$
- buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
-
+ buffer.append("int f(char x);\n"); //$NON-NLS-1$
+ buffer.append("int f(x) char x;\n"); //$NON-NLS-1$
+ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
+
String code = buffer.toString();
int index = code.indexOf("x;"); //$NON-NLS-1$
int length = "x".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, true, true, index, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.C, true, true, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTDeclarator);
- assertEquals(((IASTDeclarator)node).getName().toString(), "x"); //$NON-NLS-1$
- IASTName name = ((IASTDeclarator)node).getName();
+ assertEquals(((IASTDeclarator) node).getName().toString(), "x"); //$NON-NLS-1$
+ IASTName name = ((IASTDeclarator) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IParameter);
- assertEquals(((IParameter)name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
+ assertEquals(((IParameter) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
}
-
+
public void testSimpleKRCTest2() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append( "int f();\n" ); //$NON-NLS-1$
- buffer.append( "int f(x) char x;\n" ); //$NON-NLS-1$
- buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
-
+ buffer.append("int f();\n"); //$NON-NLS-1$
+ buffer.append("int f(x) char x;\n"); //$NON-NLS-1$
+ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
+
String code = buffer.toString();
int index = code.indexOf("x;"); //$NON-NLS-1$
int length = "x".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, true, true, index, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.C, true, true, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTDeclarator);
- assertEquals(((IASTDeclarator)node).getName().toString(), "x"); //$NON-NLS-1$
- IASTName name = ((IASTDeclarator)node).getName();
+ assertEquals(((IASTDeclarator) node).getName().toString(), "x"); //$NON-NLS-1$
+ IASTName name = ((IASTDeclarator) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IParameter);
- assertEquals(((IParameter)name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
+ assertEquals(((IParameter) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
}
-
+
public void testSimpleKRCTest3() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append( "int const *f();\n" ); //$NON-NLS-1$
- buffer.append( "int const *f(x) char x;\n" ); //$NON-NLS-1$
- buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
+ buffer.append("int const *f();\n"); //$NON-NLS-1$
+ buffer.append("int const *f(x) char x;\n"); //$NON-NLS-1$
+ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
String code = buffer.toString();
int index = code.indexOf("char x;"); //$NON-NLS-1$
int length = "char x;".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, true, true, index, length );
+ IASTNode node = parse(code, ParserLanguage.C, true, true, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTSimpleDeclaration);
- assertEquals( ((IASTSimpleDeclaration)node).getDeclarators()[0].getName().toString(), "x" ); //$NON-NLS-1$
- IASTName name = ((IASTSimpleDeclaration)node).getDeclarators()[0].getName();
+ assertEquals(((IASTSimpleDeclaration) node).getDeclarators()[0].getName().toString(), "x"); //$NON-NLS-1$
+ IASTName name = ((IASTSimpleDeclaration) node).getDeclarators()[0].getName();
assertNotNull(name.resolveBinding());
- assertTrue( name.resolveBinding() instanceof IParameter );
- assertEquals( ((IParameter)name.resolveBinding()).getName(), "x" ); //$NON-NLS-1$
+ assertTrue(name.resolveBinding() instanceof IParameter);
+ assertEquals(((IParameter) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
}
-
+
public void testKRC_1() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append( "int isroot (x, y) /* comment */ \n" ); //$NON-NLS-1$
- buffer.append( "int x;\n" ); //$NON-NLS-1$
- buffer.append( "int y;\n" ); //$NON-NLS-1$
- buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
+ buffer.append("int isroot (x, y) /* comment */ \n"); //$NON-NLS-1$
+ buffer.append("int x;\n"); //$NON-NLS-1$
+ buffer.append("int y;\n"); //$NON-NLS-1$
+ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
String code = buffer.toString();
int index = code.indexOf("y;"); //$NON-NLS-1$
int length = "y".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, true, true, index, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.C, true, true, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTDeclarator);
- assertEquals(((IASTDeclarator)node).getName().toString(), "y"); //$NON-NLS-1$
- IASTName name = ((IASTDeclarator)node).getName();
+ assertEquals(((IASTDeclarator) node).getName().toString(), "y"); //$NON-NLS-1$
+ IASTName name = ((IASTDeclarator) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IParameter);
- assertEquals(((IParameter)name.resolveBinding()).getName(), "y"); //$NON-NLS-1$
+ assertEquals(((IParameter) name.resolveBinding()).getName(), "y"); //$NON-NLS-1$
}
-
+
public void testKRCWithTypes() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append( "typedef char c;\n" ); //$NON-NLS-1$
- buffer.append( "int isroot (c);\n" ); //$NON-NLS-1$
- buffer.append( "int isroot (x) \n" ); //$NON-NLS-1$
- buffer.append( "c x;\n" ); //$NON-NLS-1$
- buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
+ buffer.append("typedef char c;\n"); //$NON-NLS-1$
+ buffer.append("int isroot (c);\n"); //$NON-NLS-1$
+ buffer.append("int isroot (x) \n"); //$NON-NLS-1$
+ buffer.append("c x;\n"); //$NON-NLS-1$
+ buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
String code = buffer.toString();
int index = code.indexOf("c x;"); //$NON-NLS-1$
int length = "c".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, true, true, index, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.C, true, true, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTNamedTypeSpecifier);
- assertEquals(((IASTNamedTypeSpecifier)node).getName().toString(), "c"); //$NON-NLS-1$
- IASTName name = ((IASTNamedTypeSpecifier)node).getName();
+ assertEquals(((IASTNamedTypeSpecifier) node).getName().toString(), "c"); //$NON-NLS-1$
+ IASTName name = ((IASTNamedTypeSpecifier) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof ITypedef);
- assertEquals(((ITypedef)name.resolveBinding()).getName(), "c"); //$NON-NLS-1$
-
+ assertEquals(((ITypedef) name.resolveBinding()).getName(), "c"); //$NON-NLS-1$
+
index = code.indexOf("x;"); //$NON-NLS-1$
length = "x".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, true, true, index, length ).getParent();
+ node = parse(code, ParserLanguage.C, true, true, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTDeclarator);
- assertEquals(((IASTDeclarator)node).getName().toString(), "x"); //$NON-NLS-1$
- name = ((IASTDeclarator)node).getName();
+ assertEquals(((IASTDeclarator) node).getName().toString(), "x"); //$NON-NLS-1$
+ name = ((IASTDeclarator) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IParameter);
- assertEquals(((IParameter)name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
+ assertEquals(((IParameter) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$
}
-
+
public void testKRC_monop_cards1() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append( "#ifdef __STDC__\n" ); //$NON-NLS-1$
- buffer.append( "#define __P(x) x\n" ); //$NON-NLS-1$
- buffer.append( "#else\n" ); //$NON-NLS-1$
- buffer.append( "#define __P(x) ()\n" ); //$NON-NLS-1$
- buffer.append( "#endif\n" ); //$NON-NLS-1$
- buffer.append( "struct A_struct {\n" ); //$NON-NLS-1$
- buffer.append( "int a;\n" ); //$NON-NLS-1$
- buffer.append( "long *c;\n" ); //$NON-NLS-1$
- buffer.append( "};\n" ); //$NON-NLS-1$
- buffer.append( "typedef struct A_struct A;\n" ); //$NON-NLS-1$
- buffer.append( "static void f __P((A *));\n" ); //$NON-NLS-1$
- buffer.append( "static void\n" ); //$NON-NLS-1$
- buffer.append( "f(x)\n" ); //$NON-NLS-1$
- buffer.append( "A *x; {\n" ); //$NON-NLS-1$
- buffer.append( "x->a = 0;\n" ); //$NON-NLS-1$
- buffer.append( "x->c[1]=x->c[2];\n" ); //$NON-NLS-1$
- buffer.append( "}\n" ); //$NON-NLS-1$
+ buffer.append("#ifdef __STDC__\n"); //$NON-NLS-1$
+ buffer.append("#define __P(x) x\n"); //$NON-NLS-1$
+ buffer.append("#else\n"); //$NON-NLS-1$
+ buffer.append("#define __P(x) ()\n"); //$NON-NLS-1$
+ buffer.append("#endif\n"); //$NON-NLS-1$
+ buffer.append("struct A_struct {\n"); //$NON-NLS-1$
+ buffer.append("int a;\n"); //$NON-NLS-1$
+ buffer.append("long *c;\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+ buffer.append("typedef struct A_struct A;\n"); //$NON-NLS-1$
+ buffer.append("static void f __P((A *));\n"); //$NON-NLS-1$
+ buffer.append("static void\n"); //$NON-NLS-1$
+ buffer.append("f(x)\n"); //$NON-NLS-1$
+ buffer.append("A *x; {\n"); //$NON-NLS-1$
+ buffer.append("x->a = 0;\n"); //$NON-NLS-1$
+ buffer.append("x->c[1]=x->c[2];\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
String code = buffer.toString();
int index = code.indexOf("*c;"); //$NON-NLS-1$
int length = "*".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, index, length );
+ IASTNode node = parse(code, ParserLanguage.C, index, length);
assertNotNull(node);
assertTrue(node instanceof ICASTPointer);
-
-
+
index = code.indexOf("*c;") + 1; //$NON-NLS-1$
length = "c".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, index, length );
+ node = parse(code, ParserLanguage.C, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IField);
- assertEquals(((IField)name.resolveBinding()).getName(), "c"); //$NON-NLS-1$
-
+ assertEquals(((IField) name.resolveBinding()).getName(), "c"); //$NON-NLS-1$
+
index = code.indexOf("c[2]"); //$NON-NLS-1$
length = "c".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, true, true, index, length );
+ node = parse(code, ParserLanguage.C, true, true, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IField);
- assertEquals(((IField)name.resolveBinding()).getName(), "c"); //$NON-NLS-1$
+ assertEquals(((IField) name.resolveBinding()).getName(), "c"); //$NON-NLS-1$
}
-
+
public void testKRC_monop_cards2() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append( "int\n" ); //$NON-NLS-1$
- buffer.append( "getinp(prompt, list)\n" ); //$NON-NLS-1$
- buffer.append( " const char *prompt, *const list[];\n" ); //$NON-NLS-1$
- buffer.append( "{\n *list[1] = 'a';\n}\n" ); //$NON-NLS-1$
+ buffer.append("int\n"); //$NON-NLS-1$
+ buffer.append("getinp(prompt, list)\n"); //$NON-NLS-1$
+ buffer.append(" const char *prompt, *const list[];\n"); //$NON-NLS-1$
+ buffer.append("{\n *list[1] = 'a';\n}\n"); //$NON-NLS-1$
String code = buffer.toString();
int index = code.indexOf("list[]"); //$NON-NLS-1$
int length = "list".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, true, true, index, length );
+ IASTNode node = parse(code, ParserLanguage.C, true, true, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertEquals(name.toString(), "list"); //$NON-NLS-1$
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IParameter);
- assertEquals(((IParameter)name.resolveBinding()).getName(), "list"); //$NON-NLS-1$
-
+ assertEquals(((IParameter) name.resolveBinding()).getName(), "list"); //$NON-NLS-1$
+
index = code.indexOf("[]"); //$NON-NLS-1$
length = "[]".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, true, true, index, length );
+ node = parse(code, ParserLanguage.C, true, true, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTArrayModifier);
-
+
index = code.indexOf("*const list[]"); //$NON-NLS-1$
length = "*const".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, true, true, index, length );
+ node = parse(code, ParserLanguage.C, true, true, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTPointer);
}
-
-
+
public void testKRC_getParametersOrder() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append( "int f(a, b) int b,a;{}\n" ); //$NON-NLS-1$
+ buffer.append("int f(a, b) int b,a;{}\n"); //$NON-NLS-1$
String code = buffer.toString();
int index = code.indexOf("b,a"); //$NON-NLS-1$
int length = "b".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, true, true, index, length ).getParent();
+ IASTNode node = parse(code, ParserLanguage.C, true, true, index, length).getParent();
assertNotNull(node);
assertTrue(node instanceof IASTDeclarator);
- IASTName name = ((IASTDeclarator)node).getName();
+ IASTName name = ((IASTDeclarator) node).getName();
assertEquals(name.toString(), "b"); //$NON-NLS-1$
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IParameter);
- assertEquals(((IParameter)name.resolveBinding()).getName(), "b"); //$NON-NLS-1$
+ assertEquals(((IParameter) name.resolveBinding()).getName(), "b"); //$NON-NLS-1$
}
-
+
public void testKRC_Ethereal_1() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append( "struct symbol {\n" ); //$NON-NLS-1$
- buffer.append( "int lambda;\n};\n" ); //$NON-NLS-1$
- buffer.append( "struct lemon {\n" ); //$NON-NLS-1$
- buffer.append( "struct symbol **symbols;\n" ); //$NON-NLS-1$
- buffer.append( "int errorcnt;\n};\n" ); //$NON-NLS-1$
- buffer.append( "void f(lemp)\n" ); //$NON-NLS-1$
- buffer.append( "struct lemon *lemp;\n{\n" ); //$NON-NLS-1$
- buffer.append( "lemp->symbols[1]->lambda = 1;\n" ); //$NON-NLS-1$
- buffer.append( "lemp->errorcnt++;}\n" ); //$NON-NLS-1$
+ buffer.append("struct symbol {\n"); //$NON-NLS-1$
+ buffer.append("int lambda;\n};\n"); //$NON-NLS-1$
+ buffer.append("struct lemon {\n"); //$NON-NLS-1$
+ buffer.append("struct symbol **symbols;\n"); //$NON-NLS-1$
+ buffer.append("int errorcnt;\n};\n"); //$NON-NLS-1$
+ buffer.append("void f(lemp)\n"); //$NON-NLS-1$
+ buffer.append("struct lemon *lemp;\n{\n"); //$NON-NLS-1$
+ buffer.append("lemp->symbols[1]->lambda = 1;\n"); //$NON-NLS-1$
+ buffer.append("lemp->errorcnt++;}\n"); //$NON-NLS-1$
String code = buffer.toString();
int index = code.indexOf("**symbols"); //$NON-NLS-1$
int length = "*".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, index, length );
+ IASTNode node = parse(code, ParserLanguage.C, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTPointer);
-
+
index = code.indexOf("**symbols") + 1; //$NON-NLS-1$
length = "*".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, index, length );
+ node = parse(code, ParserLanguage.C, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTPointer);
index = code.indexOf("**symbols") + 2; //$NON-NLS-1$
length = "symbols".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, index, length );
+ node = parse(code, ParserLanguage.C, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IField);
- assertEquals(((IField)name.resolveBinding()).getName(), "symbols"); //$NON-NLS-1$
-
+ assertEquals(((IField) name.resolveBinding()).getName(), "symbols"); //$NON-NLS-1$
+
index = code.indexOf("lemp->symbols") + 6; //$NON-NLS-1$
length = "symbols".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, true, true, index, length );
+ node = parse(code, ParserLanguage.C, true, true, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
- name = (IASTName)node;
+ name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IField);
- assertEquals(((IField)name.resolveBinding()).getName(), "symbols"); //$NON-NLS-1$
+ assertEquals(((IField) name.resolveBinding()).getName(), "symbols"); //$NON-NLS-1$
}
public void testBug86698() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append( "struct C;\n"); //$NON-NLS-1$
- buffer.append( "void no_opt(C*);\n"); //$NON-NLS-1$
- buffer.append( "struct C {\n"); //$NON-NLS-1$
- buffer.append( "int c;\n"); //$NON-NLS-1$
- buffer.append( "C() : c(0) { no_opt(this); }\n"); //$NON-NLS-1$
- buffer.append( "};\n"); //$NON-NLS-1$
+ buffer.append("struct C;\n"); //$NON-NLS-1$
+ buffer.append("void no_opt(C*);\n"); //$NON-NLS-1$
+ buffer.append("struct C {\n"); //$NON-NLS-1$
+ buffer.append("int c;\n"); //$NON-NLS-1$
+ buffer.append("C() : c(0) { no_opt(this); }\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
String code = buffer.toString();
int index = code.indexOf("c(0)"); //$NON-NLS-1$
int length = "c".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.CPP, index, length );
+ IASTNode node = parse(code, ParserLanguage.CPP, index, length);
assertNotNull(node);
assertTrue(node instanceof IASTName);
- IASTName name = (IASTName)node;
+ IASTName name = (IASTName) node;
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IField);
- assertEquals(((IField)name.resolveBinding()).getName(), "c"); //$NON-NLS-1$
-
+ assertEquals(((IField) name.resolveBinding()).getName(), "c"); //$NON-NLS-1$
+
}
-
+
public void testLittleThings() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("int a[3];\r\n"); //$NON-NLS-1$
buffer.append("int *b;\r\n"); //$NON-NLS-1$
buffer.append("int &c;\r\n"); //$NON-NLS-1$
buffer.append("char d='e';\r\n"); //$NON-NLS-1$
-
+
String code = buffer.toString();
- int index = 0;
+ int index = 0;
int length = 0;
-
+
IASTNode node = null;
ParserLanguage lang = null;
- for(int i=0; i<2; i++) {
- lang = i==0 ? ParserLanguage.C : ParserLanguage.CPP;
-
+ for (int i = 0; i < 2; i++) {
+ lang = i == 0 ? ParserLanguage.C : ParserLanguage.CPP;
+
index = code.indexOf("[3]"); //$NON-NLS-1$
length = "[3]".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
-
+
index = code.indexOf("3"); //$NON-NLS-1$
length = "3".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
-
+
index = code.indexOf("*"); //$NON-NLS-1$
length = "*".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
-
+
if (lang != ParserLanguage.C) {
index = code.indexOf("&"); //$NON-NLS-1$
length = "&".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
-
+
index = code.indexOf("&c"); //$NON-NLS-1$
length = "&c".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
}
-
+
index = code.indexOf("int a"); //$NON-NLS-1$
length = "int".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
-
+
index = code.indexOf("int a[3];"); //$NON-NLS-1$
length = "int a[3];".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
-
+
index = code.indexOf("a[3]"); //$NON-NLS-1$
length = "a[3]".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
-
+
index = code.indexOf("*b"); //$NON-NLS-1$
length = "*b".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
-
+
index = code.indexOf("'e'"); //$NON-NLS-1$
length = "'e'".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
}
}
-
+
public void testSimpleWindowsPreprocessorSelections() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("#define ONE 1\r\n"); //$NON-NLS-1$
@@ -1463,44 +1434,44 @@ public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
buffer.append("#else\r\n"); //$NON-NLS-1$
buffer.append("char c='c';\r\n"); //$NON-NLS-1$
buffer.append("#endif\r\n"); //$NON-NLS-1$
-
+
String code = buffer.toString();
- int index = 0;
+ int index = 0;
int length = 0;
-
+
IASTNode node = null;
ParserLanguage lang = null;
- for(int i=0; i<2; i++) {
- lang = i==0 ? ParserLanguage.C : ParserLanguage.CPP;
-
+ for (int i = 0; i < 2; i++) {
+ lang = i == 0 ? ParserLanguage.C : ParserLanguage.CPP;
+
index = code.indexOf("#define ONE 1"); //$NON-NLS-1$
length = "#define ONE 1".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
// TODO bug 87179
-// index = code.indexOf("#ifdef ONE"); //$NON-NLS-1$
-// length = "#ifdef ONE".length(); //$NON-NLS-1$
-// node = parse( code, lang, index, length );
-// assertNotNull(node);
-
+ // index = code.indexOf("#ifdef ONE"); //$NON-NLS-1$
+ // length = "#ifdef ONE".length(); //$NON-NLS-1$
+ // node = parse( code, lang, index, length );
+ // assertNotNull(node);
+
index = code.indexOf("int x=0;"); //$NON-NLS-1$
length = "int x=0;".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
-
+
index = code.indexOf("#else"); //$NON-NLS-1$
length = "#else".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
-
+
index = code.indexOf("#endif"); //$NON-NLS-1$
length = "#endif".length(); //$NON-NLS-1$
- node = parse( code, lang, index, length );
+ node = parse(code, lang, index, length);
assertNotNull(node);
}
}
-
+
public void testBug86993() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("#define _BEGIN_STD_C extern \"C\" {\r\n"); //$NON-NLS-1$
@@ -1508,24 +1479,24 @@ public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
buffer.append("_BEGIN_STD_C\r\n"); //$NON-NLS-1$
buffer.append("char c;\r\n"); //$NON-NLS-1$
buffer.append("_END_STD_C\r\n"); //$NON-NLS-1$
-
+
String code = buffer.toString();
- int index = 0;
+ int index = 0;
int length = 0;
-
+
IASTNode node = null;
-
+
index = code.indexOf("c;"); //$NON-NLS-1$
length = "c".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.CPP, index, length ).getParent();
+ node = parse(code, ParserLanguage.CPP, index, length).getParent();
assertNotNull(node);
- assertTrue( node instanceof IASTDeclarator);
- assertEquals(((IASTDeclarator)node).getName().toString(), "c"); //$NON-NLS-1$
- IASTName name = ((IASTDeclarator)node).getName();
+ assertTrue(node instanceof IASTDeclarator);
+ assertEquals(((IASTDeclarator) node).getName().toString(), "c"); //$NON-NLS-1$
+ IASTName name = ((IASTDeclarator) node).getName();
assertNotNull(name.resolveBinding());
assertTrue(name.resolveBinding() instanceof IVariable);
}
-
+
public void testBug86870() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("#if VERSION == 1\r\n"); //$NON-NLS-1$
@@ -1535,47 +1506,46 @@ public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
buffer.append("#else\r\n"); //$NON-NLS-1$
buffer.append("#define INCFILE \"versN.h\"\r\n"); //$NON-NLS-1$
buffer.append("#endif\r\n"); //$NON-NLS-1$
-
+
String code = buffer.toString();
- int offset1 = code.indexOf( "#if VERSION == 1" ); //$NON-NLS-1$
+ int offset1 = code.indexOf("#if VERSION == 1"); //$NON-NLS-1$
int length = "#if VERSION == 1".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, offset1, length );
+ IASTNode node = parse(code, ParserLanguage.C, offset1, length);
assertNotNull(node);
- assertEquals( ((ASTNode)node).getLength(), length);
-
- offset1 = code.indexOf( "#elif VERSION == 2" ); //$NON-NLS-1$
+ assertEquals(((ASTNode) node).getLength(), length);
+
+ offset1 = code.indexOf("#elif VERSION == 2"); //$NON-NLS-1$
length = "#elif VERSION == 2".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, offset1, length );
+ node = parse(code, ParserLanguage.C, offset1, length);
assertNotNull(node);
- assertEquals( ((ASTNode)node).getLength(), length);
-
- offset1 = code.indexOf( "#else" ); //$NON-NLS-1$
+ assertEquals(((ASTNode) node).getLength(), length);
+
+ offset1 = code.indexOf("#else"); //$NON-NLS-1$
length = "#else".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, offset1, length );
+ node = parse(code, ParserLanguage.C, offset1, length);
assertNotNull(node);
- assertEquals( ((ASTNode)node).getLength(), length);
+ assertEquals(((ASTNode) node).getLength(), length);
- offset1 = code.indexOf( "#define INCFILE \"versN.h\"" ); //$NON-NLS-1$
+ offset1 = code.indexOf("#define INCFILE \"versN.h\""); //$NON-NLS-1$
length = "#define INCFILE \"versN.h\"".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, offset1, length );
+ node = parse(code, ParserLanguage.C, offset1, length);
assertNotNull(node);
- assertEquals( ((ASTNode)node).getLength(), length);
-
- offset1 = code.indexOf( "INCFILE \"versN.h\"" ); //$NON-NLS-1$
+ assertEquals(((ASTNode) node).getLength(), length);
+
+ offset1 = code.indexOf("INCFILE \"versN.h\""); //$NON-NLS-1$
length = "INCFILE".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, offset1, length );
+ node = parse(code, ParserLanguage.C, offset1, length);
assertNotNull(node);
- assertEquals( ((ASTNode)node).getLength(), length);
-
- offset1 = code.indexOf( "#endif" ); //$NON-NLS-1$
+ assertEquals(((ASTNode) node).getLength(), length);
+
+ offset1 = code.indexOf("#endif"); //$NON-NLS-1$
length = "#endif".length(); //$NON-NLS-1$
- node = parse( code, ParserLanguage.C, offset1, length );
+ node = parse(code, ParserLanguage.C, offset1, length);
assertNotNull(node);
- assertEquals( ((ASTNode)node).getLength(), length);
+ assertEquals(((ASTNode) node).getLength(), length);
}
-
- public void testBug87179() throws Exception
- {
+
+ public void testBug87179() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("#define ONE 1\r\n"); //$NON-NLS-1$
buffer.append("#ifdef ONE\r\n"); //$NON-NLS-1$
@@ -1583,26 +1553,26 @@ public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
buffer.append("#else\r\n"); //$NON-NLS-1$
buffer.append("char c='c';\r\n"); //$NON-NLS-1$
buffer.append("#endif\r\n"); //$NON-NLS-1$
-
+
String code = buffer.toString();
- int offset1 = code.indexOf( "#ifdef ONE" ); //$NON-NLS-1$
+ int offset1 = code.indexOf("#ifdef ONE"); //$NON-NLS-1$
int length = "#ifdef ONE".length(); //$NON-NLS-1$
- IASTNode node = parse( code, ParserLanguage.C, offset1, length );
+ IASTNode node = parse(code, ParserLanguage.C, offset1, length);
assertNotNull(node);
}
public void testBug96702() throws Exception {
importFile("test.h", "int x;\n"); //$NON-NLS-1$ //$NON-NLS-2$
String code = "#include \"test.h\" // comment \nvoid f(); // comment \n"; //$NON-NLS-1$
-
- int offset = code.indexOf( "f()" ); //$NON-NLS-1$
+
+ int offset = code.indexOf("f()"); //$NON-NLS-1$
IFile file = importFile("blah.c", code);
- IASTNode node = parse( file, ParserLanguage.C, offset, 1 ); // select f();
+ IASTNode node = parse(file, ParserLanguage.C, offset, 1); // select f();
assertTrue(node instanceof IASTName);
- assertEquals(((ASTNode)node).getOffset(), 44);
- assertEquals(((ASTNode)node).getLength(), 1);
+ assertEquals(((ASTNode) node).getOffset(), 44);
+ assertEquals(((ASTNode) node).getLength(), 1);
}
-
+
public void testBug97301() throws Exception {
StringBuilder buffer = new StringBuilder();
// test2.h:
@@ -1621,8 +1591,7 @@ public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
buffer.append("#endif\r\n"); //$NON-NLS-1$
String test2_h = buffer.toString();
importFile("test2.h", test2_h); //$NON-NLS-1$
-
-
+
// test1.h:
buffer = new StringBuilder();
buffer.append("#ifdef RC_INVOKED\r\n"); //$NON-NLS-1$
@@ -1632,35 +1601,34 @@ public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
buffer.append("#endif\r\n"); //$NON-NLS-1$
buffer.append("#endif\r\n"); //$NON-NLS-1$
importFile("test1.h", buffer.toString()); //$NON-NLS-1$
-
+
// test.c:
IFile file = importFile("test.c", "#include \"test1.h\""); //$NON-NLS-1$ //$NON-NLS-2$
-
+
IASTTranslationUnit tu = parse(file, ParserLanguage.CPP, false, true);
IASTPreprocessorStatement[] stmts = tu.getAllPreprocessorStatements();
IASTFileLocation fileLoc = stmts[5].getFileLocation();
int fileOffset = test2_h.indexOf("#ifndef _WINGDI_H");
- int fileLocOffset = fileLoc.getNodeOffset();
+ int fileLocOffset = fileLoc.getNodeOffset();
assertEquals(fileOffset, fileLocOffset);
}
-
+
public void testBug86126() throws Exception {
- String header= "foo"+System.currentTimeMillis()+".h";
- String source= "blah"+System.currentTimeMillis()+".c";
- importFile(header, "int x;\r\n"); //$NON-NLS-1$
- String code = "#include \""+header+"\"\r\n"; //$NON-NLS-1$
+ String header = "foo" + System.currentTimeMillis() + ".h";
+ String source = "blah" + System.currentTimeMillis() + ".c";
+ importFile(header, "int x;\r\n"); //$NON-NLS-1$
+ String code = "#include \"" + header + "\"\r\n"; //$NON-NLS-1$
IFile file = importFile(source, code);
- int offset1 = code.indexOf( "#include \""+header+"\"" ); //$NON-NLS-1$
- int length = ("#include \""+header+"\"").length(); //$NON-NLS-1$
- IASTNode node = parse( file, ParserLanguage.C, offset1, length );
+ int offset1 = code.indexOf("#include \"" + header + "\""); //$NON-NLS-1$
+ int length = ("#include \"" + header + "\"").length(); //$NON-NLS-1$
+ IASTNode node = parse(file, ParserLanguage.C, offset1, length);
assertNotNull(node);
}
-
- public void testBug98806() throws Exception {
- String code = "template <class T> class A { typedef typename T::B _B;};";
- IASTNode node = parse( code, ParserLanguage.CPP, code.indexOf( "T::B"), "T::B".length() );
- assertNotNull( node );
- assertTrue( node instanceof IASTName );
- }
+ public void testBug98806() throws Exception {
+ String code = "template <class T> class A { typedef typename T::B _B;};";
+ IASTNode node = parse(code, ParserLanguage.CPP, code.indexOf("T::B"), "T::B".length());
+ assertNotNull(node);
+ assertTrue(node instanceof IASTName);
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTestBase.java
index 0ebfebbaca1..1b3c460d146 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTestBase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTestBase.java
@@ -45,7 +45,7 @@ import org.eclipse.core.resources.IFile;
*/
public class AST2SelectionParseTestBase extends FileBasePluginTestCase {
- public AST2SelectionParseTestBase() {
+ public AST2SelectionParseTestBase() {
}
public AST2SelectionParseTestBase(String name) {
@@ -53,7 +53,7 @@ public class AST2SelectionParseTestBase extends FileBasePluginTestCase {
}
private static final IParserLogService NULL_LOG = new NullLogService();
-
+
public AST2SelectionParseTestBase(String name, Class className) {
super(name, className);
}
@@ -61,81 +61,85 @@ public class AST2SelectionParseTestBase extends FileBasePluginTestCase {
protected IASTNode parse(String code, ParserLanguage lang, int offset, int length) throws ParserException {
return parse(code, lang, false, false, offset, length);
}
-
+
protected IASTNode parse(IFile file, ParserLanguage lang, int offset, int length) throws ParserException {
IASTTranslationUnit tu = parse(file, lang, false, false);
return tu.getNodeSelector(null).findNode(offset, length);
}
-
- protected IASTNode parse(String code, ParserLanguage lang, int offset, int length, boolean expectedToPass) throws ParserException {
+
+ protected IASTNode parse(String code, ParserLanguage lang, int offset, int length, boolean expectedToPass)
+ throws ParserException {
return parse(code, lang, false, expectedToPass, offset, length);
}
-
- protected IASTNode parse(String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems, int offset, int length) throws ParserException {
+
+ protected IASTNode parse(String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems,
+ int offset, int length) throws ParserException {
IASTTranslationUnit tu = parse(code, lang, useGNUExtensions, expectNoProblems);
return tu.getNodeSelector(null).findNode(offset, length);
- }
+ }
- protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems) throws ParserException {
+ protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions,
+ boolean expectNoProblems) throws ParserException {
FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
- ScannerInfo scannerInfo = new ScannerInfo();
- IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
-
- ISourceCodeParser parser2 = null;
- if (lang == ParserLanguage.CPP) {
- ICPPParserExtensionConfiguration config = null;
- if (useGNUExtensions)
- config = new GPPParserExtensionConfiguration();
- else
- config = new ANSICPPParserExtensionConfiguration();
- parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
- } else {
- ICParserExtensionConfiguration config = null;
-
- if (useGNUExtensions)
- config = new GCCParserExtensionConfiguration();
- else
- config = new ANSICParserExtensionConfiguration();
-
- parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
- }
-
- IASTTranslationUnit tu = parser2.parse();
-
- if (parser2.encounteredError() && expectNoProblems)
- throw new ParserException("FAILURE"); //$NON-NLS-1$
-
- if (lang == ParserLanguage.C && expectNoProblems) {
- assertEquals(CVisitor.getProblems(tu).length, 0);
- assertEquals(tu.getPreprocessorProblems().length, 0);
- } else if (lang == ParserLanguage.CPP && expectNoProblems) {
- assertEquals(CPPVisitor.getProblems(tu).length, 0);
- assertEquals(tu.getPreprocessorProblems().length, 0);
- }
- if (expectNoProblems)
- assertEquals(0, tu.getPreprocessorProblems().length);
-
- return tu;
- }
-
- protected IASTTranslationUnit parse(IFile file, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems) throws ParserException {
- IASTTranslationUnit tu= null;
+ ScannerInfo scannerInfo = new ScannerInfo();
+ IScanner scanner = AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
+
+ ISourceCodeParser parser2 = null;
+ if (lang == ParserLanguage.CPP) {
+ ICPPParserExtensionConfiguration config = null;
+ if (useGNUExtensions)
+ config = new GPPParserExtensionConfiguration();
+ else
+ config = new ANSICPPParserExtensionConfiguration();
+ parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
+ } else {
+ ICParserExtensionConfiguration config = null;
+
+ if (useGNUExtensions)
+ config = new GCCParserExtensionConfiguration();
+ else
+ config = new ANSICParserExtensionConfiguration();
+
+ parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
+ }
+
+ IASTTranslationUnit tu = parser2.parse();
+
+ if (parser2.encounteredError() && expectNoProblems)
+ throw new ParserException("FAILURE"); //$NON-NLS-1$
+
+ if (lang == ParserLanguage.C && expectNoProblems) {
+ assertEquals(CVisitor.getProblems(tu).length, 0);
+ assertEquals(tu.getPreprocessorProblems().length, 0);
+ } else if (lang == ParserLanguage.CPP && expectNoProblems) {
+ assertEquals(CPPVisitor.getProblems(tu).length, 0);
+ assertEquals(tu.getPreprocessorProblems().length, 0);
+ }
+ if (expectNoProblems)
+ assertEquals(0, tu.getPreprocessorProblems().length);
+
+ return tu;
+ }
+
+ protected IASTTranslationUnit parse(IFile file, ParserLanguage lang, boolean useGNUExtensions,
+ boolean expectNoProblems) throws ParserException {
+ IASTTranslationUnit tu = null;
try {
tu = CDOM.getInstance().getASTService().getTranslationUnit(file);
} catch (UnsupportedDialectException e) {
assertFalse(true); // shouldn't happen
}
- if (lang == ParserLanguage.C && expectNoProblems) {
- assertEquals(CVisitor.getProblems(tu).length, 0);
- assertEquals(tu.getPreprocessorProblems().length, 0);
- } else if (lang == ParserLanguage.CPP && expectNoProblems) {
- assertEquals(CPPVisitor.getProblems(tu).length, 0);
- assertEquals(tu.getPreprocessorProblems().length, 0);
- }
- if (expectNoProblems)
- assertEquals(0, tu.getPreprocessorProblems().length);
-
- return tu;
- }
+ if (lang == ParserLanguage.C && expectNoProblems) {
+ assertEquals(CVisitor.getProblems(tu).length, 0);
+ assertEquals(tu.getPreprocessorProblems().length, 0);
+ } else if (lang == ParserLanguage.CPP && expectNoProblems) {
+ assertEquals(CPPVisitor.getProblems(tu).length, 0);
+ assertEquals(tu.getPreprocessorProblems().length, 0);
+ }
+ if (expectNoProblems)
+ assertEquals(0, tu.getPreprocessorProblems().length);
+
+ return tu;
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecTestBase.java
index 08f1d7150b6..cd08241332b 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecTestBase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecTestBase.java
@@ -61,83 +61,86 @@ public class AST2SpecTestBase extends AST2TestBase {
* @param expectedProblemBindings the number of problem bindings you expect to encounter
* @throws ParserException
*/
- protected void parseCandCPP(String code, boolean checkBindings, int expectedProblemBindings) throws ParserException {
+ protected void parseCandCPP(String code, boolean checkBindings, int expectedProblemBindings)
+ throws ParserException {
parse(code, ParserLanguage.C, false, true, checkBindings, expectedProblemBindings, null);
parse(code, ParserLanguage.CPP, false, true, checkBindings, expectedProblemBindings, null);
}
protected IASTTranslationUnit parseWithErrors(String code, ParserLanguage lang) throws ParserException {
- return parse(code, lang, false, false, false, 0, null);
- }
+ return parse(code, lang, false, false, false, 0, null);
+ }
+
+ protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean checkBindings,
+ int expectedProblemBindings) throws ParserException {
+ return parse(code, lang, false, true, checkBindings, expectedProblemBindings, null);
+ }
- protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean checkBindings, int expectedProblemBindings) throws ParserException {
- return parse(code, lang, false, true, checkBindings, expectedProblemBindings, null);
- }
-
protected IASTTranslationUnit parse(String code, ParserLanguage lang, String[] problems) throws ParserException {
- return parse(code, lang, false, true, true, problems.length, problems);
+ return parse(code, lang, false, true, true, problems.length, problems);
}
-
- private IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems,
- boolean checkBindings, int expectedProblemBindings, String[] problems) throws ParserException {
+
+ private IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions,
+ boolean expectNoProblems, boolean checkBindings, int expectedProblemBindings, String[] problems)
+ throws ParserException {
// TODO beef this up with tests... i.e. run once with \n, and then run again with \r\n replacing \n ... etc
// TODO another example might be to replace all characters with corresponding trigraph/digraph tests...
-
- FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
- return parse(codeReader, lang, useGNUExtensions, expectNoProblems, checkBindings, expectedProblemBindings, problems);
- }
-
-// private IASTTranslationUnit parse(IFile filename, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems) throws ParserException {
-// CodeReader codeReader=null;
-// try {
-// codeReader = new CodeReader(filename.getName(), filename.getContents());
-// } catch (IOException e) {
-// e.printStackTrace();
-// } catch (CoreException e) {
-// e.printStackTrace();
-// }
-//
-// return parse(codeReader, lang, useGNUExtensions, expectNoProblems);
-// }
-
- private IASTTranslationUnit parse(FileContent codeReader, ParserLanguage lang,
- boolean useGNUExtensions, boolean expectNoProblems, boolean checkBindings,
- int expectedProblemBindings, String[] problems) throws ParserException {
- ScannerInfo scannerInfo = new ScannerInfo();
- IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
-
- ISourceCodeParser parser2 = null;
- if (lang == ParserLanguage.CPP) {
- ICPPParserExtensionConfiguration config = null;
- if (useGNUExtensions)
- config = new GPPParserExtensionConfiguration();
- else
- config = new ANSICPPParserExtensionConfiguration();
- parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
- } else {
- ICParserExtensionConfiguration config = null;
-
- if (useGNUExtensions)
- config = new GCCParserExtensionConfiguration();
- else
- config = new ANSICParserExtensionConfiguration();
-
- parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE,
- NULL_LOG, config);
- }
-
- if (expectedProblemBindings > 0)
- CPPASTNameBase.sAllowNameComputation= true;
-
- IASTTranslationUnit tu = parser2.parse();
-
+
+ FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
+ return parse(codeReader, lang, useGNUExtensions, expectNoProblems, checkBindings, expectedProblemBindings,
+ problems);
+ }
+
+ // private IASTTranslationUnit parse(IFile filename, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems) throws ParserException {
+ // CodeReader codeReader=null;
+ // try {
+ // codeReader = new CodeReader(filename.getName(), filename.getContents());
+ // } catch (IOException e) {
+ // e.printStackTrace();
+ // } catch (CoreException e) {
+ // e.printStackTrace();
+ // }
+ //
+ // return parse(codeReader, lang, useGNUExtensions, expectNoProblems);
+ // }
+
+ private IASTTranslationUnit parse(FileContent codeReader, ParserLanguage lang, boolean useGNUExtensions,
+ boolean expectNoProblems, boolean checkBindings, int expectedProblemBindings, String[] problems)
+ throws ParserException {
+ ScannerInfo scannerInfo = new ScannerInfo();
+ IScanner scanner = AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
+
+ ISourceCodeParser parser2 = null;
+ if (lang == ParserLanguage.CPP) {
+ ICPPParserExtensionConfiguration config = null;
+ if (useGNUExtensions)
+ config = new GPPParserExtensionConfiguration();
+ else
+ config = new ANSICPPParserExtensionConfiguration();
+ parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
+ } else {
+ ICParserExtensionConfiguration config = null;
+
+ if (useGNUExtensions)
+ config = new GCCParserExtensionConfiguration();
+ else
+ config = new ANSICParserExtensionConfiguration();
+
+ parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
+ }
+
+ if (expectedProblemBindings > 0)
+ CPPASTNameBase.sAllowNameComputation = true;
+
+ IASTTranslationUnit tu = parser2.parse();
+
// resolve all bindings
if (checkBindings) {
NameResolver res = new NameResolver();
- tu.accept(res);
+ tu.accept(res);
if (res.problemBindings.size() != expectedProblemBindings)
- throw new ParserException("Expected " + expectedProblemBindings +
- " problems, encountered " + res.problemBindings.size());
+ throw new ParserException(
+ "Expected " + expectedProblemBindings + " problems, encountered " + res.problemBindings.size());
if (problems != null) {
for (int i = 0; i < problems.length; i++) {
assertEquals(problems[i], res.problemBindings.get(i));
@@ -145,37 +148,37 @@ public class AST2SpecTestBase extends AST2TestBase {
}
}
- if (parser2.encounteredError() && expectNoProblems)
- throw new ParserException("FAILURE");
-
- if (lang == ParserLanguage.C && expectNoProblems) {
+ if (parser2.encounteredError() && expectNoProblems)
+ throw new ParserException("FAILURE");
+
+ if (lang == ParserLanguage.C && expectNoProblems) {
if (CVisitor.getProblems(tu).length != 0) {
- throw new ParserException("CVisitor has AST Problems");
+ throw new ParserException("CVisitor has AST Problems");
}
if (tu.getPreprocessorProblems().length != 0) {
- throw new ParserException("C TranslationUnit has Preprocessor Problems");
+ throw new ParserException("C TranslationUnit has Preprocessor Problems");
}
- } else if (lang == ParserLanguage.CPP && expectNoProblems) {
+ } else if (lang == ParserLanguage.CPP && expectNoProblems) {
if (CPPVisitor.getProblems(tu).length != 0) {
- throw new ParserException("CPPVisitor has AST Problems");
+ throw new ParserException("CPPVisitor has AST Problems");
}
if (tu.getPreprocessorProblems().length != 0) {
- throw new ParserException("CPP TranslationUnit has Preprocessor Problems");
+ throw new ParserException("CPP TranslationUnit has Preprocessor Problems");
}
- }
-
- return tu;
+ }
+
+ return tu;
}
-
+
static protected class NameResolver extends ASTVisitor {
{
shouldVisitNames = true;
}
-
+
public List<IASTName> nameList = new ArrayList<IASTName>();
public List<String> problemBindings = new ArrayList<String>();
public int numNullBindings = 0;
-
+
@Override
public int visit(IASTName name) {
nameList.add(name);
@@ -186,15 +189,15 @@ public class AST2SpecTestBase extends AST2TestBase {
numNullBindings++;
return PROCESS_CONTINUE;
}
-
+
public IASTName getName(int idx) {
if (idx < 0 || idx >= nameList.size())
return null;
return nameList.get(idx);
}
-
- public int size() {
- return nameList.size();
+
+ public int size() {
+ return nameList.size();
}
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
index 292a165d23f..42e967458c5 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
@@ -183,7 +183,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertSame(A_int, a.getType());
assertTrue(A_int instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A_int).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) A_int).getTemplateDefinition(), A);
ICPPClassScope A_int_Scope = (ICPPClassScope) A_int.getCompositeScope();
assertNotSame(A_int_Scope, ((ICompositeType) A).getCompositeScope());
@@ -228,7 +228,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType A_int = (ICPPClassType) col.getName(7).resolveBinding();
assertTrue(A_int instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A_int).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) A_int).getTemplateDefinition(), A);
ICPPMethod f_int = (ICPPMethod) col.getName(11).resolveBinding();
assertTrue(f_int instanceof ICPPSpecialization);
@@ -303,9 +303,11 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPTemplateParameter T1 = (ICPPTemplateParameter) col.getName(0).resolveBinding();
ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(1).resolveBinding();
ICPPTemplateParameter T2 = (ICPPTemplateParameter) col.getName(2).resolveBinding();
- ICPPClassTemplatePartialSpecialization A2 = (ICPPClassTemplatePartialSpecialization) col.getName(3).resolveBinding();
+ ICPPClassTemplatePartialSpecialization A2 = (ICPPClassTemplatePartialSpecialization) col.getName(3)
+ .resolveBinding();
ICPPTemplateParameter T3 = (ICPPTemplateParameter) col.getName(5).resolveBinding();
- ICPPClassTemplatePartialSpecialization A3 = (ICPPClassTemplatePartialSpecialization) col.getName(7).resolveBinding();
+ ICPPClassTemplatePartialSpecialization A3 = (ICPPClassTemplatePartialSpecialization) col.getName(7)
+ .resolveBinding();
ICPPTemplateParameter T4 = (ICPPTemplateParameter) col.getName(6).resolveBinding();
assertSame(A2.getPrimaryClassTemplate(), A1);
@@ -385,7 +387,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// const int *p;
// f(p); //calls f(const T *) , 3 is more specialized than 1 or 2
// }
- public void test14_5_5_2s5_OrderingFunctionTemplates_a() throws Exception{
+ public void test14_5_5_2s5_OrderingFunctionTemplates_a() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -409,7 +411,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// float x;
// f(x); //ambiguous 1 or 2
// }
- public void test14_5_5_2s5_OrderingFunctionTemplates_b() throws Exception{
+ public void test14_5_5_2s5_OrderingFunctionTemplates_b() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -492,7 +494,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// A <int, char*, 5> a3; //uses #4, T is char
// A <int, char*, 1> a4; //uses #5, T is int, T2 is char, I is1
// A <int*, int*, 2> a5; //ambiguous, matches #3 & #5.
- public void test14_5_4_1s2_MatchingTemplateSpecializations() throws Exception{
+ public void test14_5_4_1s2_MatchingTemplateSpecializations() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -504,7 +506,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassTemplate A5 = (ICPPClassTemplate) col.getName(26).resolveBinding();
assertTrue(A3 instanceof ICPPClassTemplatePartialSpecialization);
- assertSame(((ICPPClassTemplatePartialSpecialization)A3).getPrimaryClassTemplate(), A1);
+ assertSame(((ICPPClassTemplatePartialSpecialization) A3).getPrimaryClassTemplate(), A1);
ICPPTemplateTypeParameter T1 = (ICPPTemplateTypeParameter) col.getName(11).resolveBinding();
ICPPTemplateTypeParameter T2 = (ICPPTemplateTypeParameter) col.getName(12).resolveBinding();
@@ -820,7 +822,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType A1 = (ICPPClassType) col.getName(7).resolveBinding();
assertTrue(A1 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A1).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) A1).getTemplateDefinition(), A);
ICPPField u2 = (ICPPField) col.getName(11).resolveBinding();
assertTrue(u2 instanceof ICPPSpecialization);
@@ -846,7 +848,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertSame(A1, A2);
assertTrue(A1 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A1).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) A1).getTemplateDefinition(), A);
}
// template <class T> void f(T);
@@ -886,7 +888,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertSame(A1, A2);
assertTrue(A1 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A1).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) A1).getTemplateDefinition(), A);
ICPPClassType AI = (ICPPClassType) col.getName(10).resolveBinding();
ICPPMethod f2 = (ICPPMethod) col.getName(14).resolveBinding();
@@ -935,7 +937,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType A2 = (ICPPClassType) col.getName(9).resolveBinding();
assertTrue(A2 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A2).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) A2).getTemplateDefinition(), A);
ICPPMethod f2_2 = (ICPPMethod) col.getName(16).resolveBinding();
assertTrue(f2_2 instanceof ICPPSpecialization);
@@ -972,7 +974,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType A2 = (ICPPClassType) col.getName(2).resolveBinding();
assertTrue(A2 instanceof ICPPSpecialization);
- assertSame(((ICPPSpecialization)A2).getSpecializedBinding(), A1);
+ assertSame(((ICPPSpecialization) A2).getSpecializedBinding(), A1);
ICPPClassType r1 = (ICPPClassType) col.getName(4).resolveBinding();
ICPPClassType r2 = (ICPPClassType) col.getName(7).resolveBinding();
@@ -1005,7 +1007,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType A2 = (ICPPClassType) col.getName(5).resolveBinding();
assertTrue(A2 instanceof ICPPSpecialization);
- assertSame(((ICPPSpecialization)A2).getSpecializedBinding(), A1);
+ assertSame(((ICPPSpecialization) A2).getSpecializedBinding(), A1);
ICPPMethod f2 = (ICPPMethod) col.getName(7).resolveBinding();
assertNotSame(f1, f2);
@@ -1044,13 +1046,13 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType A1 = (ICPPClassType) col.getName(11).resolveBinding();
assertTrue(A1 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A1).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) A1).getTemplateDefinition(), A);
ICPPClassType B1 = (ICPPClassType) col.getName(13).resolveBinding();
assertTrue(B1 instanceof ICPPTemplateInstance);
- ICPPClassType B2 = (ICPPClassType) ((ICPPTemplateInstance)B1).getTemplateDefinition();
+ ICPPClassType B2 = (ICPPClassType) ((ICPPTemplateInstance) B1).getTemplateDefinition();
assertTrue(B2 instanceof ICPPSpecialization);
- assertSame(((ICPPSpecialization)B2).getSpecializedBinding(), B);
+ assertSame(((ICPPSpecialization) B2).getSpecializedBinding(), B);
ICPPMethod f1 = (ICPPMethod) col.getName(20).resolveBinding();
assertTrue(f1 instanceof ICPPSpecialization);
@@ -1080,11 +1082,12 @@ public class AST2TemplateTests extends AST2CPPTestBase {
tu.accept(col);
ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(3).resolveBinding();
- ICPPClassTemplatePartialSpecialization A2 = (ICPPClassTemplatePartialSpecialization) col.getName(9).resolveBinding();
+ ICPPClassTemplatePartialSpecialization A2 = (ICPPClassTemplatePartialSpecialization) col.getName(9)
+ .resolveBinding();
ICPPClassType A3 = (ICPPClassType) col.getName(13).resolveBinding();
assertTrue(A3 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A3).getTemplateDefinition(), A2);
+ assertSame(((ICPPTemplateInstance) A3).getTemplateDefinition(), A2);
ICPPClassTemplate A4 = (ICPPClassTemplate) col.getName(14).resolveBinding();
assertSame(A4, A1);
@@ -1111,7 +1114,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(1).resolveBinding();
ICPPField x1 = (ICPPField) col.getName(2).resolveBinding();
- ICPPClassTemplatePartialSpecialization A2 = (ICPPClassTemplatePartialSpecialization) col.getName(4).resolveBinding();
+ ICPPClassTemplatePartialSpecialization A2 = (ICPPClassTemplatePartialSpecialization) col.getName(4)
+ .resolveBinding();
ICPPField x2 = (ICPPField) col.getName(7).resolveBinding();
ICPPClassTemplate C = (ICPPClassTemplate) col.getName(10).resolveBinding();
@@ -1120,7 +1124,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType C1 = (ICPPClassType) col.getName(18).resolveBinding();
assertTrue(C1 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)C1).getTemplateDefinition(), C);
+ assertSame(((ICPPTemplateInstance) C1).getTemplateDefinition(), C);
ICPPField y2 = (ICPPField) col.getName(23).resolveBinding();
assertTrue(y2 instanceof ICPPSpecialization);
@@ -1250,9 +1254,9 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType Acb = (ICPPClassType) col.getName(14).resolveBinding();
assertTrue(Acb instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)Acb).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) Acb).getTemplateDefinition(), A);
- ICPPField s2 = (ICPPField) col.getName(21).resolveBinding();
+ ICPPField s2 = (ICPPField) col.getName(21).resolveBinding();
assertTrue(s2 instanceof ICPPSpecialization);
assertSame(((ICPPSpecialization) s2).getSpecializedBinding(), s);
@@ -1290,7 +1294,6 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType A3 = (ICPPClassType) col.getName(9).resolveBinding();
assertSame(A, A3);
-
ICPPTemplateParameter U2 = (ICPPTemplateParameter) col.getName(13).resolveBinding();
assertSame(U, U2);
assertSame(T, U);
@@ -1335,13 +1338,13 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// A<B> ab;
// A<C> ac;
public void testEnclosingScopes_a() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPSpecialization b0= ba.assertNonProblem("A<B>", 4, ICPPSpecialization.class, ICPPClassType.class);
- ICPPTemplateInstance b1= ba.assertNonProblem("A<C>", 4, ICPPTemplateInstance.class, ICPPClassType.class);
+ ICPPSpecialization b0 = ba.assertNonProblem("A<B>", 4, ICPPSpecialization.class, ICPPClassType.class);
+ ICPPTemplateInstance b1 = ba.assertNonProblem("A<C>", 4, ICPPTemplateInstance.class, ICPPClassType.class);
- ICPPClassType sc0= assertInstance(b0.getSpecializedBinding(), ICPPClassType.class);
- ICPPClassType sc1= assertInstance(b1.getSpecializedBinding(), ICPPClassType.class);
+ ICPPClassType sc0 = assertInstance(b0.getSpecializedBinding(), ICPPClassType.class);
+ ICPPClassType sc1 = assertInstance(b1.getSpecializedBinding(), ICPPClassType.class);
assertTrue(sc0.isSameType(sc1));
assertInstance(b0, ICPPSpecialization.class);
@@ -1349,8 +1352,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertInstance(b0.getScope(), ICPPTemplateScope.class);
- IScope ts0= ((ICPPClassType) b0.getSpecializedBinding()).getScope();
- IScope ts1= ((ICPPClassType) b1.getSpecializedBinding()).getScope();
+ IScope ts0 = ((ICPPClassType) b0.getSpecializedBinding()).getScope();
+ IScope ts1 = ((ICPPClassType) b1.getSpecializedBinding()).getScope();
assertInstance(ts0, ICPPTemplateScope.class);
@@ -1376,18 +1379,18 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// A<D>::B adb;
// }
public void testEnclosingScopes_b() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPClassType b0= ba.assertNonProblem("B acb", 1, ICPPClassType.class);
- ICPPClassType b1= ba.assertNonProblem("B adb", 1, ICPPClassType.class, ICPPSpecialization.class);
- ICPPClassType b2= ba.assertNonProblem("A<C>", 4, ICPPClassType.class, ICPPSpecialization.class);
- ICPPClassType b3= ba.assertNonProblem("A {", 1, ICPPClassType.class, ICPPTemplateDefinition.class);
- ICPPClassType b4= ba.assertNonProblem("B {}", 1, ICPPClassType.class);
+ ICPPClassType b0 = ba.assertNonProblem("B acb", 1, ICPPClassType.class);
+ ICPPClassType b1 = ba.assertNonProblem("B adb", 1, ICPPClassType.class, ICPPSpecialization.class);
+ ICPPClassType b2 = ba.assertNonProblem("A<C>", 4, ICPPClassType.class, ICPPSpecialization.class);
+ ICPPClassType b3 = ba.assertNonProblem("A {", 1, ICPPClassType.class, ICPPTemplateDefinition.class);
+ ICPPClassType b4 = ba.assertNonProblem("B {}", 1, ICPPClassType.class);
assertFalse(b0 instanceof ICPPSpecialization);
assertSame(b0.getScope(), b2.getCompositeScope());
- ICPPClassScope cs1= assertInstance(b1.getScope(), ICPPClassScope.class);
+ ICPPClassScope cs1 = assertInstance(b1.getScope(), ICPPClassScope.class);
assertInstance(cs1.getClassType(), ICPPTemplateInstance.class);
assertSame(b4.getScope(), b3.getCompositeScope());
}
@@ -1403,15 +1406,15 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// X<A>::Y::Z xayz;
public void testEnclosingScopes_c() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPClassType b0= ba.assertNonProblem("Y::Z x", 1, ICPPClassType.class);
- ICPPClassType b1= ba.assertNonProblem("Z xayz", 1, ICPPClassType.class);
+ ICPPClassType b0 = ba.assertNonProblem("Y::Z x", 1, ICPPClassType.class);
+ ICPPClassType b1 = ba.assertNonProblem("Z xayz", 1, ICPPClassType.class);
- ICPPClassScope cs0= assertInstance(b0.getScope(), ICPPClassScope.class);
+ ICPPClassScope cs0 = assertInstance(b0.getScope(), ICPPClassScope.class);
assertInstance(cs0.getClassType(), ICPPSpecialization.class);
- ICPPClassScope cs1= assertInstance(b1.getScope(), ICPPClassScope.class);
+ ICPPClassScope cs1 = assertInstance(b1.getScope(), ICPPClassScope.class);
assertInstance(cs1.getClassType(), ICPPSpecialization.class);
}
@@ -1427,18 +1430,18 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// X<B,A>::N n;
public void testEnclosingScopes_d() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPClassType b0= ba.assertNonProblem("N n", 1, ICPPClassType.class);
- ICPPClassType b1= ba.assertNonProblem("N {", 1, ICPPClassType.class);
+ ICPPClassType b0 = ba.assertNonProblem("N n", 1, ICPPClassType.class);
+ ICPPClassType b1 = ba.assertNonProblem("N {", 1, ICPPClassType.class);
- ICPPClassScope s0= assertInstance(b0.getScope(), ICPPClassScope.class);
+ ICPPClassScope s0 = assertInstance(b0.getScope(), ICPPClassScope.class);
assertInstance(s0.getClassType(), ICPPTemplateInstance.class);
- ICPPClassScope s1= assertInstance(b1.getScope(), ICPPClassScope.class);
+ ICPPClassScope s1 = assertInstance(b1.getScope(), ICPPClassScope.class);
assertInstance(s1.getClassType(), ICPPTemplateDefinition.class);
- ICPPTemplateScope s2= assertInstance(s1.getClassType().getScope(), ICPPTemplateScope.class);
+ ICPPTemplateScope s2 = assertInstance(s1.getClassType().getScope(), ICPPTemplateScope.class);
}
// template<class T> struct A {
@@ -1476,7 +1479,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType A2 = (ICPPClassType) col.getName(15).resolveBinding();
assertTrue(A2 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A2).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) A2).getTemplateDefinition(), A);
ICPPMethod f2 = (ICPPMethod) col.getName(17).resolveBinding();
assertTrue(f2 instanceof ICPPSpecialization);
assertSame(((ICPPSpecialization) f2).getSpecializedBinding(), f);
@@ -1557,7 +1560,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType A2 = (ICPPClassType) col.getName(4).resolveBinding();
assertTrue(A2 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A2).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) A2).getTemplateDefinition(), A);
ICPPFunction s2 = (ICPPFunction) col.getName(8).resolveBinding();
assertTrue(s2 instanceof ICPPTemplateInstance);
@@ -1565,7 +1568,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType A3 = (ICPPClassType) col.getName(10).resolveBinding();
assertTrue(A3 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A3).getTemplateDefinition(), A);
+ assertSame(((ICPPTemplateInstance) A3).getTemplateDefinition(), A);
assertNotSame(A2, A3);
}
@@ -1581,7 +1584,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(1).resolveBinding();
ICPPClassType A2 = (ICPPClassType) col.getName(2).resolveBinding();
assertTrue(A2 instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A2).getTemplateDefinition(), A1);
+ assertSame(((ICPPTemplateInstance) A2).getTemplateDefinition(), A1);
ICPPFunctionTemplate s1 = (ICPPFunctionTemplate) col.getName(5).resolveBinding();
ICPPFunction s2 = (ICPPFunction) col.getName(10).resolveBinding();
@@ -1605,7 +1608,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
IASTName f = col.getName(6);
IASTFunctionDefinition fdef = (IASTFunctionDefinition) f.getParent().getParent();
- IASTExpressionStatement statement = (IASTExpressionStatement) ((IASTCompoundStatement) fdef.getBody()).getStatements()[0];
+ IASTExpressionStatement statement = (IASTExpressionStatement) ((IASTCompoundStatement) fdef.getBody())
+ .getStatements()[0];
IType type = statement.getExpression().getExpressionType();
assertTrue(type.isSameType(p.getType()));
@@ -1729,7 +1733,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// f(A<int>(1));
// }
public void testBug99254a() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
ICPPConstructor ctor = bh.assertNonProblem("A(T t)", "A", ICPPConstructor.class);
ICPPSpecialization spec = bh.assertNonProblem("A<int>(1)", "A<int>", ICPPSpecialization.class);
assertSame(ctor.getOwner(), spec.getSpecializedBinding());
@@ -1755,12 +1759,13 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// b->add(core::A<int>(10, 2));
// }
public void testBug99254b() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
ICPPConstructor ctor = bh.assertNonProblem("A(T x, T y)", "A", ICPPConstructor.class);
ICPPSpecialization spec = bh.assertNonProblem("A<int>(10, 2)", "A<int>", ICPPSpecialization.class);
assertSame(ctor.getOwner(), spec.getSpecializedBinding());
IASTName name = bh.findName("A<int>(10, 2)", "A<int>");
- IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) name.getParent().getParent().getParent()).getImplicitNames();
+ IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) name.getParent().getParent().getParent())
+ .getImplicitNames();
assertEquals(1, implicitNames.length);
ICPPSpecialization ctor2 = (ICPPSpecialization) implicitNames[0].getBinding();
assertSame(ctor, ctor2.getSpecializedBinding());
@@ -1778,7 +1783,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// b->add(A<int>(10));
// }
public void testBug99254c() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
ICPPConstructor ctor = bh.assertNonProblem("A(T)", "A", ICPPConstructor.class);
ICPPSpecialization spec = bh.assertNonProblem("A<int>(10)", "A<int>", ICPPSpecialization.class);
assertSame(ctor.getOwner(), spec.getSpecializedBinding());
@@ -1793,7 +1798,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
}
public void testBug98666() throws Exception {
- CPPASTNameBase.sAllowNameComputation= true;
+ CPPASTNameBase.sAllowNameComputation = true;
IASTTranslationUnit tu = parse("A::template B<T> b;", CPP);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -1828,14 +1833,15 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertSame(T, col.getName(10).resolveBinding());
assertSame(T2ofPartialSpec, col.getName(14).resolveBinding());
- ICPPClassTemplatePartialSpecialization spec = (ICPPClassTemplatePartialSpecialization) col.getName(12).resolveBinding();
+ ICPPClassTemplatePartialSpecialization spec = (ICPPClassTemplatePartialSpecialization) col.getName(12)
+ .resolveBinding();
assertSame(spec.getPrimaryClassTemplate(), B);
ICPPClassType BI = (ICPPClassType) col.getName(19).resolveBinding();
assertTrue(BI instanceof ICPPTemplateInstance);
- final IBinding partialSpecSpec = ((ICPPTemplateInstance)BI).getSpecializedBinding();
+ final IBinding partialSpecSpec = ((ICPPTemplateInstance) BI).getSpecializedBinding();
assertTrue(partialSpecSpec instanceof ICPPSpecialization);
- IBinding partialSpec= ((ICPPSpecialization) partialSpecSpec).getSpecializedBinding();
+ IBinding partialSpec = ((ICPPSpecialization) partialSpecSpec).getSpecializedBinding();
assertSame(partialSpec, spec);
}
@@ -1844,7 +1850,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// int k = f(1); // uses #2
// int l = f<>(1); // uses #1
public void testBug95208() throws Exception {
- String content= getAboveComment();
+ String content = getAboveComment();
IASTTranslationUnit tu = parse(content, CPP);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -1859,8 +1865,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertSame(((ICPPTemplateInstance) b).getSpecializedBinding(), f1);
assertSame(f1, col.getName(10).resolveBinding());
-
- tu = parse(content,CPP);
+ tu = parse(content, CPP);
col = new NameCollector();
tu.accept(col);
@@ -1952,11 +1957,11 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ITypedef myType = (ITypedef) col.getName(31).resolveBinding();
ICPPClassType A = (ICPPClassType) myType.getType();
- ICPPClassTemplatePartialSpecialization Aspec =
- (ICPPClassTemplatePartialSpecialization) col.getName(10).resolveBinding();
+ ICPPClassTemplatePartialSpecialization Aspec = (ICPPClassTemplatePartialSpecialization) col.getName(10)
+ .resolveBinding();
assertTrue(A instanceof ICPPTemplateInstance);
- assertSame(((ICPPTemplateInstance)A).getTemplateDefinition(), Aspec);
+ assertSame(((ICPPTemplateInstance) A).getTemplateDefinition(), Aspec);
}
// template<class T>
@@ -2043,8 +2048,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// }
// };
public void testBug201204() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPFunction fn= bh.assertNonProblem("makeClosure(this", 11, ICPPFunction.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPFunction fn = bh.assertNonProblem("makeClosure(this", 11, ICPPFunction.class);
}
// template <class R, class T, class P1, class P2, class P3, class P4>
@@ -2069,9 +2074,9 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// func(d, &C::m2);
// }
public void testBug233889() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPFunction fn1= bh.assertNonProblem("func(c", 4, ICPPFunction.class);
- ICPPFunction fn2= bh.assertNonProblem("func(d", 4, ICPPFunction.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPFunction fn1 = bh.assertNonProblem("func(c", 4, ICPPFunction.class);
+ ICPPFunction fn2 = bh.assertNonProblem("func(d", 4, ICPPFunction.class);
assertNotSame(fn1, fn2);
}
@@ -2092,7 +2097,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// GetPair(x, 1);
// }
public void testBug229917a() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
ICPPFunction fn = bh.assertNonProblem("GetPair(x", 7, ICPPFunction.class);
}
@@ -2109,7 +2114,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// template <class _C>
// typename _C::value_type GetPair(_C& collection, typename _C::value_type::first_type key);
public void testBug229917b() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
IBinding b0 = bh.assertNonProblem("value_type GetPair", 10, IBinding.class);
}
@@ -2128,7 +2133,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// str.m();
// }
public void testBug232086() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
ICPPFunction b0 = bh.assertNonProblem("m();", 1, ICPPFunction.class);
}
@@ -2151,15 +2156,15 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// bar(ca);
// }
public void testBug214646() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
- IBinding b0= bh.assertNonProblem("foo(a)", 3);
- IBinding b1= bh.assertNonProblem("bar(ca)", 3);
+ IBinding b0 = bh.assertNonProblem("foo(a)", 3);
+ IBinding b1 = bh.assertNonProblem("bar(ca)", 3);
assertInstance(b0, ICPPFunction.class);
assertInstance(b1, ICPPFunction.class);
- ICPPFunction f0= (ICPPFunction) b0, f1= (ICPPFunction) b1;
+ ICPPFunction f0 = (ICPPFunction) b0, f1 = (ICPPFunction) b1;
assertEquals(1, f0.getParameters().length);
assertEquals(1, f1.getParameters().length);
@@ -2183,10 +2188,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// func(a2);
// }
public void testFunctionTemplate_245049a() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPFunction b0= bh.assertNonProblem("func(a1)", 4, ICPPFunction.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPFunction b0 = bh.assertNonProblem("func(a1)", 4, ICPPFunction.class);
assertInstance(b0, ICPPTemplateInstance.class);
- ICPPFunction b1= bh.assertNonProblem("func(a2)", 4, ICPPFunction.class);
+ ICPPFunction b1 = bh.assertNonProblem("func(a2)", 4, ICPPFunction.class);
assertSame(b0, b1);
}
@@ -2206,10 +2211,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// func(a2);
// }
public void testFunctionTemplate_245049b() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPFunction b0= bh.assertNonProblem("func(a1)", 4, ICPPFunction.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPFunction b0 = bh.assertNonProblem("func(a1)", 4, ICPPFunction.class);
assertInstance(b0, ICPPTemplateInstance.class);
- ICPPFunction b1= bh.assertNonProblem("func(a2)", 4, ICPPFunction.class);
+ ICPPFunction b1 = bh.assertNonProblem("func(a2)", 4, ICPPFunction.class);
assertNotSame(b0, b1);
}
@@ -2229,7 +2234,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// using ns::make_pair;
// pair<int, int> p = make_pair(1, 2);
public void testFunctionTemplateWithUsing() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertNonProblem("make_pair(1", 9, ICPPFunction.class);
}
@@ -2276,7 +2281,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// f(a(x));
// }
public void testFunctionTemplate_264963() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertNonProblem("f(a(x));", 1, ICPPFunction.class);
}
@@ -2291,7 +2296,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// f(&A::m);
// }
public void testFunctionTemplate_266532() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertNonProblem("f(&A::m);", 1, ICPPFunction.class);
}
@@ -2362,7 +2367,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// f1(x, &f2);
// }
public void testFunctionTemplateWithFunctionPointer_281783() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertNonProblem("f1(x, &f2);", 2, ICPPFunction.class);
}
@@ -2393,14 +2398,14 @@ public class AST2TemplateTests extends AST2CPPTestBase {
NameCollector col = new NameCollector(true);
tu.accept(col);
- IASTImplicitName tid= (IASTImplicitName) col.getName(20);
- IASTName cn= col.getName(22);
+ IASTImplicitName tid = (IASTImplicitName) col.getName(20);
+ IASTName cn = col.getName(22);
assertInstance(cn.resolveBinding(), ICPPClassTemplate.class); // *D*<int>(5, 6)
assertInstance(cn.resolveBinding(), ICPPClassType.class); // *D*<int>(5, 6)
assertInstance(tid.resolveBinding(), ICPPTemplateInstance.class); // *D<int>*(5, 6)
assertInstance(tid.resolveBinding(), ICPPConstructor.class); // *D<int>*(5, 6)
- IBinding tidSpc= ((ICPPTemplateInstance) tid.resolveBinding()).getSpecializedBinding();
+ IBinding tidSpc = ((ICPPTemplateInstance) tid.resolveBinding()).getSpecializedBinding();
assertInstance(tidSpc, ICPPConstructor.class);
assertInstance(tidSpc, ICPPSpecialization.class);
assertInstance(tidSpc, ICPPFunctionTemplate.class);
@@ -2421,27 +2426,27 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertFalse(name.resolveBinding() instanceof IProblemBinding);
}
- name= col.nameList.get(0);
+ name = col.nameList.get(0);
assertTrue(name.resolveBinding() instanceof ICPPTemplateParameter);
- name= col.nameList.get(1);
+ name = col.nameList.get(1);
assertTrue(name.resolveBinding() instanceof ICPPTemplateParameter);
- name= col.nameList.get(2);
+ name = col.nameList.get(2);
assertTrue(name.resolveBinding() instanceof ICPPFunction);
- name= col.nameList.get(3);
+ name = col.nameList.get(3);
assertTrue(name.resolveBinding() instanceof ICPPTemplateParameter);
- name= col.nameList.get(4);
+ name = col.nameList.get(4);
assertTrue(name.resolveBinding() instanceof IParameter);
- name= col.nameList.get(5);
+ name = col.nameList.get(5);
assertTrue(name.resolveBinding() instanceof ICPPTemplateParameter);
- name= col.nameList.get(6);
+ name = col.nameList.get(6);
assertTrue(name.resolveBinding() instanceof IParameter);
- name= col.nameList.get(7);
+ name = col.nameList.get(7);
assertTrue(name.resolveBinding() instanceof IParameter);
- name= col.nameList.get(8);
+ name = col.nameList.get(8);
assertTrue(name.resolveBinding() instanceof IParameter);
- name= col.nameList.get(9);
+ name = col.nameList.get(9);
assertTrue(name.resolveBinding() instanceof IParameter);
- name= col.nameList.get(10);
+ name = col.nameList.get(10);
assertTrue(name.resolveBinding() instanceof IParameter);
}
@@ -2459,7 +2464,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// void f(B<int>::tb r) {}
public void testTemplateTypedef_214447() throws Exception {
- CPPASTNameBase.sAllowNameComputation= true;
+ CPPASTNameBase.sAllowNameComputation = true;
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
NameCollector col = new NameCollector();
@@ -2493,7 +2498,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// void f(Vec<int>::reference r) {}
public void testRebindPattern_214447a() throws Exception {
- CPPASTNameBase.sAllowNameComputation= true;
+ CPPASTNameBase.sAllowNameComputation = true;
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
NameCollector col = new NameCollector();
@@ -2533,7 +2538,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// void f(Vec<int>::reference r) {}
public void testRebindPattern_214447b() throws Exception {
- CPPASTNameBase.sAllowNameComputation= true;
+ CPPASTNameBase.sAllowNameComputation = true;
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
NameCollector col = new NameCollector();
@@ -2572,7 +2577,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// void f(map<int>::value_type r) {}
public void testRebindPattern_236197() throws Exception {
- CPPASTNameBase.sAllowNameComputation= true;
+ CPPASTNameBase.sAllowNameComputation = true;
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -2604,7 +2609,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// void main(Iter<int*>::iter_reference r);
public void testSpecializationSelection_229218() throws Exception {
- CPPASTNameBase.sAllowNameComputation= true;
+ CPPASTNameBase.sAllowNameComputation = true;
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
NameCollector col = new NameCollector();
tu.accept(col);
@@ -2734,7 +2739,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// B<int>::b::a x;
public void testDefaultTemplateParameter() throws Exception {
- CPPASTNameBase.sAllowNameComputation= true;
+ CPPASTNameBase.sAllowNameComputation = true;
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
NameCollector col = new NameCollector();
@@ -2784,8 +2789,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// foo(d);
// }
public void testUserDefinedConversions_224364() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPFunction fn= bh.assertNonProblem("foo(d)", 3, ICPPFunction.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPFunction fn = bh.assertNonProblem("foo(d)", 3, ICPPFunction.class);
}
// class B {};
@@ -2804,8 +2809,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// foo(d);
// }
public void testUserDefinedConversions_224364a() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPFunction fn= bh.assertNonProblem("foo(d)", 3, ICPPFunction.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPFunction fn = bh.assertNonProblem("foo(d)", 3, ICPPFunction.class);
}
// class Z {};
@@ -2827,8 +2832,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// Z z= foo(*new E<Z>());
public void testUserDefinedConversions_224364b() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPFunction fn= bh.assertNonProblem("foo(*new", 3, ICPPFunction.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPFunction fn = bh.assertNonProblem("foo(*new", 3, ICPPFunction.class);
}
// class X {}; class B {};
@@ -2851,8 +2856,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// foo(cx);
// }
public void testUserDefinedConversions_226231() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPFunction fn= bh.assertNonProblem("foo(cx", 3, ICPPFunction.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPFunction fn = bh.assertNonProblem("foo(cx", 3, ICPPFunction.class);
}
// class A;
@@ -2870,7 +2875,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// return foo(c);
// }
public void testUserDefinedConversions_239023() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
ba.assertNonProblem("foo(c);", 3);
}
@@ -2893,7 +2898,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// class A {};
//
// void foo() {
- // A<i> a1;
+ // A<i> a1;
// }
//
// const int i= 1;
@@ -2971,7 +2976,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// return at;
// }
public void testTypeIdAsTemplateArgumentIsTypeId_229942a() throws Exception {
- BindingAssertionHelper ba=new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
ba.assertNonProblem("T> at) {", 1);
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
@@ -3010,13 +3015,13 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// template<> class Alias<td const *> {
// };
public void testNonAmbiguityCase_229942() throws Exception {
- IASTTranslationUnit tu= parse(getAboveComment(), CPP);
- NameCollector col= new NameCollector();
+ IASTTranslationUnit tu = parse(getAboveComment(), CPP);
+ NameCollector col = new NameCollector();
tu.accept(col);
// 2 is Alias
- ICPPASTTemplateId tid= assertInstance(col.getName(2).getParent(), ICPPASTTemplateId.class);
- IASTNode[] args= tid.getTemplateArguments();
+ ICPPASTTemplateId tid = assertInstance(col.getName(2).getParent(), ICPPASTTemplateId.class);
+ IASTNode[] args = tid.getTemplateArguments();
assertEquals(1, args.length);
assertInstance(args[0], IASTTypeId.class);
}
@@ -3036,7 +3041,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// C c1;
// C<> c2; // ok - default args
public void testMissingTemplateArgumentLists() throws Exception {
- BindingAssertionHelper ba=new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
ba.assertProblem("B b1", 1);
ba.assertNonProblem("B<> b2", 1, ICPPTemplateDefinition.class, ICPPClassType.class);
ba.assertProblem("B<> b2", 3);
@@ -3053,11 +3058,11 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// member1 = 0;
// }
public void testDefinitionOfClassTemplateWithNonTypeParameter() throws Exception {
- BindingAssertionHelper ba=new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPMethod f1= ba.assertNonProblem("fun1(void);", 4, ICPPMethod.class);
- ICPPField m1= ba.assertNonProblem("member1;", 7, ICPPField.class);
- ICPPMethod f2= ba.assertNonProblem("fun1(void) {", 4, ICPPMethod.class);
- ICPPField m2= ba.assertNonProblem("member1 =", 7, ICPPField.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPMethod f1 = ba.assertNonProblem("fun1(void);", 4, ICPPMethod.class);
+ ICPPField m1 = ba.assertNonProblem("member1;", 7, ICPPField.class);
+ ICPPMethod f2 = ba.assertNonProblem("fun1(void) {", 4, ICPPMethod.class);
+ ICPPField m2 = ba.assertNonProblem("member1 =", 7, ICPPField.class);
assertSame(m1, m2);
assertSame(f1, f2);
}
@@ -3078,11 +3083,11 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// void ref() {
// A<short>::B<> b;
// }
- public void testNestedTemplateDefinitionParameter() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPTemplateTypeParameter T3a= ba.assertNonProblem("T3 f", 2, ICPPTemplateTypeParameter.class);
- ICPPTemplateTypeParameter T3b= ba.assertNonProblem("T3)", 2, ICPPTemplateTypeParameter.class);
- ICPPClassType b= ba.assertNonProblem("B<>", 3, ICPPClassType.class, ICPPTemplateInstance.class);
+ public void testNestedTemplateDefinitionParameter() throws Exception {
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPTemplateTypeParameter T3a = ba.assertNonProblem("T3 f", 2, ICPPTemplateTypeParameter.class);
+ ICPPTemplateTypeParameter T3b = ba.assertNonProblem("T3)", 2, ICPPTemplateTypeParameter.class);
+ ICPPClassType b = ba.assertNonProblem("B<>", 3, ICPPClassType.class, ICPPTemplateInstance.class);
}
// template<class T, int x> class A {public: class X {};};
@@ -3095,18 +3100,18 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// A<B, 1>::Y y;
// A<B, 2>::Z z;
public void testNonTypeArgumentDisambiguation_233460() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPClassType b2= ba.assertNonProblem("A<B, 0>", 7, ICPPClassType.class, ICPPTemplateInstance.class);
- ICPPClassType b3= ba.assertNonProblem("A<B, 1>", 7, ICPPClassType.class, ICPPTemplateInstance.class);
- ICPPClassType b4= ba.assertNonProblem("A<B, 2>", 7, ICPPClassType.class, ICPPTemplateInstance.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPClassType b2 = ba.assertNonProblem("A<B, 0>", 7, ICPPClassType.class, ICPPTemplateInstance.class);
+ ICPPClassType b3 = ba.assertNonProblem("A<B, 1>", 7, ICPPClassType.class, ICPPTemplateInstance.class);
+ ICPPClassType b4 = ba.assertNonProblem("A<B, 2>", 7, ICPPClassType.class, ICPPTemplateInstance.class);
assertTrue(!b2.isSameType(b3));
assertTrue(!b3.isSameType(b4));
assertTrue(!b4.isSameType(b2));
- ICPPClassType X= ba.assertNonProblem("X x", 1, ICPPClassType.class);
- ICPPClassType Y= ba.assertNonProblem("Y y", 1, ICPPClassType.class);
- ICPPClassType Z= ba.assertNonProblem("Z z", 1, ICPPClassType.class);
+ ICPPClassType X = ba.assertNonProblem("X x", 1, ICPPClassType.class);
+ ICPPClassType Y = ba.assertNonProblem("Y y", 1, ICPPClassType.class);
+ ICPPClassType Z = ba.assertNonProblem("Z z", 1, ICPPClassType.class);
assertTrue(!X.isSameType(Y));
assertTrue(!Y.isSameType(Z));
@@ -3124,10 +3129,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// A<B, true>::X x; //3 should be an error
// A<B, false>::Y y; //4 should be an error
public void testNonTypeBooleanArgumentDisambiguation() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPClassType X= ba.assertNonProblem("X x; //1", 1, ICPPClassType.class);
- ICPPClassType Y= ba.assertNonProblem("Y y; //2", 1, ICPPClassType.class);
+ ICPPClassType X = ba.assertNonProblem("X x; //1", 1, ICPPClassType.class);
+ ICPPClassType Y = ba.assertNonProblem("Y y; //2", 1, ICPPClassType.class);
ba.assertProblem("X x; //3", 1);
ba.assertProblem("Y y; //4", 1);
@@ -3155,21 +3160,21 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// baz();
// }
public void testBug207871() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPVariable _256= ba.assertNonProblem("_256=0x100", 4, ICPPVariable.class);
- IQualifierType qt1= assertInstance(_256.getType(), IQualifierType.class);
- ICPPBasicType bt1= assertInstance(qt1.getType(), ICPPBasicType.class);
+ ICPPVariable _256 = ba.assertNonProblem("_256=0x100", 4, ICPPVariable.class);
+ IQualifierType qt1 = assertInstance(_256.getType(), IQualifierType.class);
+ ICPPBasicType bt1 = assertInstance(qt1.getType(), ICPPBasicType.class);
assertConstantValue(256, _256);
- ICPPVariable t= ba.assertNonProblem("t;", 1, ICPPVariable.class);
- ICPPTemplateInstance ci1= assertInstance(t.getType(), ICPPTemplateInstance.class, ICPPClassType.class);
- ICPPTemplateParameterMap args1= ci1.getTemplateParameterMap();
+ ICPPVariable t = ba.assertNonProblem("t;", 1, ICPPVariable.class);
+ ICPPTemplateInstance ci1 = assertInstance(t.getType(), ICPPTemplateInstance.class, ICPPClassType.class);
+ ICPPTemplateParameterMap args1 = ci1.getTemplateParameterMap();
assertEquals(1, args1.getAllParameterPositions().length);
assertEquals(256, args1.getArgument(0).getNonTypeValue().numberValue().intValue());
- ICPPTemplateInstance ct= ba.assertNonProblem("C<_256> ", 7, ICPPTemplateInstance.class, ICPPClassType.class);
- ICPPTemplateParameterMap args= ct.getTemplateParameterMap();
+ ICPPTemplateInstance ct = ba.assertNonProblem("C<_256> ", 7, ICPPTemplateInstance.class, ICPPClassType.class);
+ ICPPTemplateParameterMap args = ct.getTemplateParameterMap();
assertEquals(1, args.getAllParameterPositions().length);
assertEquals(256, args.getArgument(0).getNonTypeValue().numberValue().intValue());
@@ -3186,9 +3191,9 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// C<y> go();
// };
public void testDeferredNonTypeArgument() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPDeferredClassInstance ci= ba.assertNonProblem("C<y>", 4, ICPPDeferredClassInstance.class);
- ICPPTemplateArgument[] args= ci.getTemplateArguments();
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPDeferredClassInstance ci = ba.assertNonProblem("C<y>", 4, ICPPDeferredClassInstance.class);
+ ICPPTemplateArgument[] args = ci.getTemplateArguments();
assertEquals(1, args.length);
assertEquals(0, IntegralValue.isTemplateParameter(args[0].getNonTypeValue()));
}
@@ -3198,7 +3203,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// A<int> aint; // should be an error
public void testTypeArgumentToNonTypeParameter() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
ba.assertProblem("A<int>", 6);
}
@@ -3218,18 +3223,18 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// inline This<I>::This() : That<I>(I) {
// }
public void testParameterReferenceInChainInitializer_a() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
// These intermediate assertions will not hold until deferred non-type arguments are
// correctly modelled
- ICPPClassType tid= ba.assertNonProblem("This<I>::T", 7, ICPPClassType.class);
+ ICPPClassType tid = ba.assertNonProblem("This<I>::T", 7, ICPPClassType.class);
assertFalse(tid instanceof ICPPSpecialization);
- ICPPConstructor th1sCtor= ba.assertNonProblem("This() :", 4, ICPPConstructor.class);
+ ICPPConstructor th1sCtor = ba.assertNonProblem("This() :", 4, ICPPConstructor.class);
assertFalse(th1sCtor instanceof ICPPSpecialization);
ICPPTemplateNonTypeParameter np = ba.assertNonProblem("I>(I)", 1, ICPPTemplateNonTypeParameter.class);
- ICPPConstructor clazz= ba.assertNonProblem("That<I>(I)", 4, ICPPConstructor.class);
- ICPPConstructor ctor= ba.assertNonProblem("That<I>(I)", 7, ICPPConstructor.class);
+ ICPPConstructor clazz = ba.assertNonProblem("That<I>(I)", 4, ICPPConstructor.class);
+ ICPPConstructor ctor = ba.assertNonProblem("That<I>(I)", 7, ICPPConstructor.class);
ICPPTemplateNonTypeParameter np1 = ba.assertNonProblem("I)", 1, ICPPTemplateNonTypeParameter.class);
assertSame(np, np1);
@@ -3251,16 +3256,16 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// inline This<I>::This() : That<I>() {
// }
public void testParameterReferenceInChainInitializer_b() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPClassType tid= ba.assertNonProblem("This<I>::T", 7, ICPPClassType.class);
+ ICPPClassType tid = ba.assertNonProblem("This<I>::T", 7, ICPPClassType.class);
assertFalse(tid instanceof ICPPSpecialization);
- ICPPConstructor th1sCtor= ba.assertNonProblem("This() :", 4, ICPPConstructor.class);
+ ICPPConstructor th1sCtor = ba.assertNonProblem("This() :", 4, ICPPConstructor.class);
assertFalse(th1sCtor instanceof ICPPSpecialization);
- ICPPTemplateTypeParameter np= ba.assertNonProblem("I>()", 1, ICPPTemplateTypeParameter.class);
- ICPPConstructor clazz= ba.assertNonProblem("That<I>()", 4, ICPPConstructor.class);
- ICPPConstructor ctor= ba.assertNonProblem("That<I>()", 7, ICPPConstructor.class);
+ ICPPTemplateTypeParameter np = ba.assertNonProblem("I>()", 1, ICPPTemplateTypeParameter.class);
+ ICPPConstructor clazz = ba.assertNonProblem("That<I>()", 4, ICPPConstructor.class);
+ ICPPConstructor ctor = ba.assertNonProblem("That<I>()", 7, ICPPConstructor.class);
}
// template<typename T, int I>
@@ -3273,8 +3278,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// C<A,5L> ca5L;
public void testIntegralConversionInPartialSpecializationMatching_237914() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPTemplateInstance ctps= ba.assertNonProblem("C<A,5L>", 7, ICPPTemplateInstance.class, ICPPClassType.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPTemplateInstance ctps = ba.assertNonProblem("C<A,5L>", 7, ICPPTemplateInstance.class, ICPPClassType.class);
assertInstance(ctps.getTemplateDefinition(), ICPPClassTemplatePartialSpecialization.class);
}
@@ -3293,8 +3298,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// ca5L.test= 0;
// }
public void testIntegralConversionInSpecializationMatching_237914() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPSpecialization ctps= ba.assertNonProblem("C<A,5L>", 7, ICPPSpecialization.class, ICPPClassType.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPSpecialization ctps = ba.assertNonProblem("C<A,5L>", 7, ICPPSpecialization.class, ICPPClassType.class);
ba.assertNonProblem("test=", 4, ICPPField.class);
}
@@ -3361,7 +3366,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// B(const B<T>& other) : A(other) {}
// };
public void testChainInitializerLookupThroughDeferredClassBase() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
ba.assertNonProblem("A(other", 1);
}
@@ -3394,7 +3399,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// }
// };
public void testMemberLookupThroughDeferredClassBase() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
ba.assertNonProblem("foo(s", 3);
}
@@ -3470,7 +3475,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// return foo();
// }
public void testMemberReferenceFromTemplatedMethodDefinition_238232() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
ba.assertNonProblem("foo();", 3);
}
@@ -3515,14 +3520,15 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// } // detail
public void testBug238180_ClassCast() throws Exception {
// the code above used to trigger a ClassCastException
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPClassType p= ba.assertNonProblem("str<true, true, false, A, B>", 0, ICPPClassType.class);
- ICPPConstructor con= p.getConstructors()[1];
- ICPPReferenceType reftype= (ICPPReferenceType) con.getType().getParameterTypes()[0];
- IQualifierType qt= (IQualifierType) reftype.getType();
- ICPPDeferredClassInstance dcl= (ICPPDeferredClassInstance) qt.getType();
- ICPPClassTemplatePartialSpecialization spec= (ICPPClassTemplatePartialSpecialization) dcl.getSpecializedBinding();
- ICPPTemplateTypeParameter tp= (ICPPTemplateTypeParameter) spec.getTemplateParameters()[0];
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPClassType p = ba.assertNonProblem("str<true, true, false, A, B>", 0, ICPPClassType.class);
+ ICPPConstructor con = p.getConstructors()[1];
+ ICPPReferenceType reftype = (ICPPReferenceType) con.getType().getParameterTypes()[0];
+ IQualifierType qt = (IQualifierType) reftype.getType();
+ ICPPDeferredClassInstance dcl = (ICPPDeferredClassInstance) qt.getType();
+ ICPPClassTemplatePartialSpecialization spec = (ICPPClassTemplatePartialSpecialization) dcl
+ .getSpecializedBinding();
+ ICPPTemplateTypeParameter tp = (ICPPTemplateTypeParameter) spec.getTemplateParameters()[0];
assertNull(tp.getDefault());
}
@@ -3543,10 +3549,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// };
// template<typename T> int CT<T>::x = sizeof(T);
public void testUsingTemplParamInInitializerOfStaticField() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPTemplateTypeParameter t= ba.assertNonProblem("T)", 1, ICPPTemplateTypeParameter.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPTemplateTypeParameter t = ba.assertNonProblem("T)", 1, ICPPTemplateTypeParameter.class);
}
-
+
// template <typename T>
// constexpr T id(T a) {
// return a;
@@ -3613,11 +3619,11 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// func(cb);
// }
public void testTemplateMetaProgramming_245027() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPMethod method= ba.assertNonProblem("method();", 6, ICPPMethod.class);
- ICPPVariable a= ba.assertNonProblem("a =", 1, ICPPVariable.class);
- ICPPVariable b= ba.assertNonProblem("b =", 1, ICPPVariable.class);
- ICPPFunction func= ba.assertNonProblem("func(cb)", 4, ICPPFunction.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPMethod method = ba.assertNonProblem("method();", 6, ICPPMethod.class);
+ ICPPVariable a = ba.assertNonProblem("a =", 1, ICPPVariable.class);
+ ICPPVariable b = ba.assertNonProblem("b =", 1, ICPPVariable.class);
+ ICPPFunction func = ba.assertNonProblem("func(cb)", 4, ICPPFunction.class);
}
// class Incomplete;
@@ -3639,7 +3645,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// ns1::A<(sizeof(probe(x)) == 1)>::m(x);
// }
public void testNonTypeTemplateParameter_252108() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP);
ba.assertNonProblem("x))", 1, ICPPVariable.class);
}
@@ -3659,14 +3665,14 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// > > > > >
// type;
public void testNestedArguments_246079() throws Throwable {
- final Throwable[] th= {null};
- Thread t= new Thread() {
+ final Throwable[] th = { null };
+ Thread t = new Thread() {
@Override
public void run() {
try {
- parseAndCheckBindings(getAboveComment(), CPP);
+ parseAndCheckBindings(getAboveComment(), CPP);
} catch (Throwable e) {
- th[0]= e;
+ th[0] = e;
}
}
};
@@ -3684,10 +3690,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// };
// template<class T> void A<T, int>::foo(T t) {}
public void testBug177418() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true );
+ IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
NameCollector col = new NameCollector();
- tu.accept( col );
+ tu.accept(col);
ICPPTemplateParameter T1 = (ICPPTemplateParameter) col.getName(0).resolveBinding();
ICPPTemplateParameter U = (ICPPTemplateParameter) col.getName(1).resolveBinding();
@@ -3696,7 +3702,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPTemplateParameter T2 = (ICPPTemplateParameter) col.getName(3).resolveBinding();
assertNotSame(T1, T2);
- ICPPClassTemplatePartialSpecialization A2 = (ICPPClassTemplatePartialSpecialization) col.getName(4).resolveBinding();
+ ICPPClassTemplatePartialSpecialization A2 = (ICPPClassTemplatePartialSpecialization) col.getName(4)
+ .resolveBinding();
assertSame(A2.getPrimaryClassTemplate(), A);
assertSame(A, col.getName(5).resolveBinding());
assertSame(T2, col.getName(6).resolveBinding());
@@ -3731,11 +3738,11 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testFunctionSpecializationAsFriend() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPFunctionTemplate f= bh.assertNonProblem("f(T)", 1);
- IFunction fref1= bh.assertNonProblem("f<>", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPFunctionTemplate f = bh.assertNonProblem("f(T)", 1);
+ IFunction fref1 = bh.assertNonProblem("f<>", 1);
assertSame(fref1, f);
- IFunction fref2= bh.assertNonProblem("f<>", 3);
+ IFunction fref2 = bh.assertNonProblem("f<>", 3);
assertInstance(fref2, ICPPTemplateInstance.class);
assertSame(f, ((ICPPTemplateInstance) fref2).getSpecializedBinding());
}
@@ -3758,15 +3765,15 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testMethodImplWithNonDeferredType() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPMethod m1= bh.assertNonProblem("m1();", 2);
- ICPPMethod m2= bh.assertNonProblem("m1() ", 2);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPMethod m1 = bh.assertNonProblem("m1();", 2);
+ ICPPMethod m2 = bh.assertNonProblem("m1() ", 2);
assertSame(m1, m2);
- m1= bh.assertNonProblem("m2();", 2);
- m2= bh.assertNonProblem("m2() ", 2);
+ m1 = bh.assertNonProblem("m2();", 2);
+ m2 = bh.assertNonProblem("m2() ", 2);
assertSame(m1, m2);
- m1= bh.assertNonProblem("m3();", 2);
- m2= bh.assertNonProblem("m3() ", 2);
+ m1 = bh.assertNonProblem("m3();", 2);
+ m2 = bh.assertNonProblem("m3() ", 2);
assertSame(m1, m2);
}
@@ -3783,16 +3790,16 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testClassTemplateMemberFunctionTemplate_104262() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
- ICPPClassTemplate A1= bh.assertNonProblem("A1", 2);
- ICPPMethod method= bh.assertNonProblem("A1<float>::f1", 13);
- IBinding owner= method.getOwner();
+ ICPPClassTemplate A1 = bh.assertNonProblem("A1", 2);
+ ICPPMethod method = bh.assertNonProblem("A1<float>::f1", 13);
+ IBinding owner = method.getOwner();
assertInstance(owner, ICPPClassSpecialization.class);
assertSame(A1, ((ICPPClassSpecialization) owner).getSpecializedBinding());
- ICPPClassSpecialization special= bh.assertNonProblem("A<float>", 8);
- method= bh.assertNonProblem("A<float>::f", 11);
+ ICPPClassSpecialization special = bh.assertNonProblem("A<float>", 8);
+ method = bh.assertNonProblem("A<float>::f", 11);
assertSame(method.getOwner(), special);
}
@@ -3806,10 +3813,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testQualifiedMethodTemplate() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
- ICPPMethod mt1= bh.assertNonProblem("m(V);", 1);
- ICPPMethod mt2= bh.assertNonProblem("m(V) ", 1);
+ ICPPMethod mt1 = bh.assertNonProblem("m(V);", 1);
+ ICPPMethod mt2 = bh.assertNonProblem("m(V) ", 1);
assertSame(mt1, mt2);
assertInstance(mt1, ICPPFunctionTemplate.class);
}
@@ -3878,10 +3885,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testFieldReference_257186() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
- IBinding a1= bh.assertNonProblem("a;", 1);
- IBinding a2= bh.assertNonProblem("a=", 1);
+ IBinding a1 = bh.assertNonProblem("a;", 1);
+ IBinding a2 = bh.assertNonProblem("a=", 1);
assertInstance(a1, ICPPField.class);
assertSame(a1, a2);
}
@@ -3900,7 +3907,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testUnknownReferences_257194() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("func();", 4, ICPPUnknownBinding.class);
bh.assertNonProblem("var;", 3, ICPPUnknownBinding.class);
@@ -3923,7 +3930,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testTypeOfUnknownReferences_257194a() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("b.c", 1, ICPPUnknownBinding.class);
bh.assertNonProblem("c;", 1, ICPPUnknownBinding.class);
@@ -3948,7 +3955,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testTypeOfUnknownReferences_257194b() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("b->c", 1, ICPPUnknownBinding.class);
bh.assertNonProblem("c;", 1, ICPPUnknownBinding.class);
@@ -3973,23 +3980,23 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testTypeVsExpressionInArgsOfDependentTemplateID_257194() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
- ICPPUnknownBinding b= bh.assertNonProblem("a>", 1);
+ ICPPUnknownBinding b = bh.assertNonProblem("a>", 1);
assertFalse(b instanceof IType);
- b= bh.assertNonProblem("A>", 1);
+ b = bh.assertNonProblem("A>", 1);
assertTrue(b instanceof IType);
- ICPPUsingDeclaration ud= bh.assertNonProblem("b;", 1);
- b= (ICPPUnknownBinding) ud.getDelegates()[0];
+ ICPPUsingDeclaration ud = bh.assertNonProblem("b;", 1);
+ b = (ICPPUnknownBinding) ud.getDelegates()[0];
assertFalse(b instanceof IType);
- ud= bh.assertNonProblem("B;", 1);
- b= (ICPPUnknownBinding) ud.getDelegates()[0];
+ ud = bh.assertNonProblem("B;", 1);
+ b = (ICPPUnknownBinding) ud.getDelegates()[0];
assertTrue(b instanceof IType);
- b= bh.assertNonProblem("f();", 1);
+ b = bh.assertNonProblem("f();", 1);
assertFalse(b instanceof IType);
- b= bh.assertNonProblem("F();", 1);
+ b = bh.assertNonProblem("F();", 1);
assertTrue(b instanceof IType);
}
@@ -4009,7 +4016,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// func(p);
// }
public void testTypedefReference_259871() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertNonProblem("func(p)", 4, ICPPFunction.class);
}
@@ -4052,7 +4059,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// auto s3 = s2.append("foo");
// }
public void testTypedefPreservation_380498a() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ICPPVariable s1 = ba.assertNonProblem("s1");
assertTrue(s1.getType() instanceof ITypedef);
assertEquals("string", ((ITypedef) s1.getType()).getName());
@@ -4076,7 +4083,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// auto it = v.begin();
// }
public void testTypedefPreservation_380498b() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ICPPVariable it = ba.assertNonProblem("it =", "it", ICPPVariable.class);
assertTrue(it.getType() instanceof ITypedef);
assertEquals("vector<Element>::const_iterator", ASTTypeUtil.getType(it.getType(), false));
@@ -4117,7 +4124,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// }
// }
public void testTypedefPreservation_380498c() throws Exception {
- BindingAssertionHelper ba= getAssertionHelper();
+ BindingAssertionHelper ba = getAssertionHelper();
ICPPVariable s = ba.assertNonProblem("s :", "s", ICPPVariable.class);
assertInstance(s.getType(), ITypedef.class);
assertEquals("string", ASTTypeUtil.getType(s.getType(), false));
@@ -4158,7 +4165,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// }
// };
public void testNestedTemplates_259872a() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertNonProblem("A<B, int>", 9, ICPPClassType.class);
}
@@ -4183,7 +4190,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// }
// };
public void testNestedTemplates_259872b() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertNonProblem("A<B, int>", 9, ICPPClassType.class);
}
@@ -4202,9 +4209,9 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testCtorWithTemplateID_259600() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPConstructor ctor= bh.assertNonProblem("DumbPtr/**/", 7);
- ICPPMethod dtor= bh.assertNonProblem("~DumbPtr/**/", 8);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPConstructor ctor = bh.assertNonProblem("DumbPtr/**/", 7);
+ ICPPMethod dtor = bh.assertNonProblem("~DumbPtr/**/", 8);
}
// template <class T> class XT {
@@ -4217,9 +4224,9 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testCtorTemplateWithTemplateID_259600() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPConstructor ctor= bh.assertNonProblem("XT/**/", 2);
- ctor= bh.assertNonProblem("XT<T>/**/", 5);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPConstructor ctor = bh.assertNonProblem("XT/**/", 2);
+ ctor = bh.assertNonProblem("XT<T>/**/", 5);
}
// template <typename T> class XT {
@@ -4241,12 +4248,12 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testResolutionOfUnknownBindings_262163() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- IVariable x= bh.assertNonProblem("x;", 1);
- ITypedef Nested= bh.assertNonProblem("Nested;", 6);
- IType t= x.getType();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ IVariable x = bh.assertNonProblem("x;", 1);
+ ITypedef Nested = bh.assertNonProblem("Nested;", 6);
+ IType t = x.getType();
assertInstance(t, ITypedef.class);
- t= ((ITypedef) t).getType();
+ t = ((ITypedef) t).getType();
assertSame(t, Nested);
}
@@ -4273,7 +4280,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// s.substr(0);
// }
public void testResolutionOfUnknownBindings_262328() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertNonProblem("substr(0)", 6, ICPPMethod.class);
}
@@ -4311,10 +4318,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// x.append(3, 'c');
// }
public void testConflictInTemplateArgumentDeduction() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPMethod m= bh.assertNonProblem("append(3", 6);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPMethod m = bh.assertNonProblem("append(3", 6);
assertFalse(m instanceof ICPPTemplateInstance);
}
@@ -4332,8 +4339,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// p.m();
// }
public void testConversionSequence_263159() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPMethod m= bh.assertNonProblem("m();", 1, ICPPMethod.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPMethod m = bh.assertNonProblem("m();", 1, ICPPMethod.class);
}
// template <class C> class A;
@@ -4352,7 +4359,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// return A<C>(p);
// }
public void testForwardDeclarations_264109() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertNonProblem("A<C> make_A(C* p) {", 4, ICPPTemplateInstance.class);
parseAndCheckBindings(getAboveComment());
}
@@ -4415,7 +4422,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// getline2(i);
// }
public void testAmbiguousDeclaratorInFunctionTemplate_265342() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertNonProblem("getline2(i)", 8, ICPPTemplateInstance.class);
parseAndCheckBindings(getAboveComment());
}
@@ -4433,21 +4440,21 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// };
// };
public void testOwnerOfFriendTemplate_265671() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- IFunction f= bh.assertNonProblem("f1(", 2, IFunction.class);
- IBinding owner= f.getOwner();
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ IFunction f = bh.assertNonProblem("f1(", 2, IFunction.class);
+ IBinding owner = f.getOwner();
assertNull(owner);
- ICPPFunctionTemplate ft= bh.assertNonProblem("f2(", 2, ICPPFunctionTemplate.class);
- owner= f.getOwner();
+ ICPPFunctionTemplate ft = bh.assertNonProblem("f2(", 2, ICPPFunctionTemplate.class);
+ owner = f.getOwner();
assertNull(owner);
- ICPPTemplateParameter tpar= ft.getTemplateParameters()[0];
+ ICPPTemplateParameter tpar = ft.getTemplateParameters()[0];
assertEquals(0, tpar.getTemplateNestingLevel());
- tpar= bh.assertNonProblem("T1", 2, ICPPTemplateParameter.class);
+ tpar = bh.assertNonProblem("T1", 2, ICPPTemplateParameter.class);
assertEquals(0, tpar.getTemplateNestingLevel());
- tpar= bh.assertNonProblem("T2", 2, ICPPTemplateParameter.class);
+ tpar = bh.assertNonProblem("T2", 2, ICPPTemplateParameter.class);
assertEquals(1, tpar.getTemplateNestingLevel());
- tpar= bh.assertNonProblem("T3", 2, ICPPTemplateParameter.class);
+ tpar = bh.assertNonProblem("T3", 2, ICPPTemplateParameter.class);
assertEquals(2, tpar.getTemplateNestingLevel());
parseAndCheckBindings(getAboveComment());
@@ -4478,10 +4485,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// }
// template <typename T> void g(T t) {}
public void testDependentNameReferencingLaterDeclaration_265926a() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- IFunction gref= bh.assertNonProblem("g(t)", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ IFunction gref = bh.assertNonProblem("g(t)", 1);
assertInstance(gref, ICPPUnknownBinding.class);
- IFunction gdecl= bh.assertNonProblem("g(T t)", 1);
+ IFunction gdecl = bh.assertNonProblem("g(T t)", 1);
parseAndCheckBindings(getAboveComment());
}
@@ -4704,8 +4711,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// }
public void testInlineFriendFunction_287409() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPFunction func= bh.assertNonProblem("f(x)", 1, ICPPFunction.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPFunction func = bh.assertNonProblem("f(x)", 1, ICPPFunction.class);
assertFalse(func instanceof ICPPUnknownBinding);
}
@@ -4736,8 +4743,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// };
public void testResolutionOfNonDependentNames_293052() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPFunction func= bh.assertNonProblem("m();", 1, ICPPFunction.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPFunction func = bh.assertNonProblem("m();", 1, ICPPFunction.class);
assertFalse(func instanceof ICPPUnknownBinding);
bh.assertProblem("n();", 1);
}
@@ -4761,7 +4768,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// }
public void testArgumentDeduction_293409() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("f1(d);", 2, ICPPFunction.class);
bh.assertNonProblem("f2(&d);", 2, ICPPFunction.class);
bh.assertNonProblem("f2(&cd);", 2, ICPPFunction.class);
@@ -4882,10 +4889,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// return a;
// }
public void testClosingAngleBrackets2_261268() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
IASTTranslationUnit tu = parse(code, CPP, true, false);
- IASTFunctionDefinition fdef= getDeclaration(tu, 2);
- IASTProblemStatement p1= getStatement(fdef, 1);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 2);
+ IASTProblemStatement p1 = getStatement(fdef, 1);
}
// template<typename T> class CT {};
@@ -4920,24 +4927,24 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// X<const int&&> x2; // X<const int&&>::f has the parameter type const int&
// // X<const int&&>::g has the parameter type const int&&
public void testRValueReferences_294730() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
- ICPPClassType type= bh.assertNonProblem("X<int&>", 7);
- ICPPMethod[] ms= ClassTypeHelper.getMethods(type);
- int i= ms[0].getName().equals("f") ? 0 : 1;
- ICPPMethod m= ms[i];
+ ICPPClassType type = bh.assertNonProblem("X<int&>", 7);
+ ICPPMethod[] ms = ClassTypeHelper.getMethods(type);
+ int i = ms[0].getName().equals("f") ? 0 : 1;
+ ICPPMethod m = ms[i];
assertEquals("int &", ASTTypeUtil.getType(m.getType().getParameterTypes()[0]));
- m= ms[1 - i];
+ m = ms[1 - i];
assertEquals("int &", ASTTypeUtil.getType(m.getType().getParameterTypes()[0]));
- type= bh.assertNonProblem("X<const int&&>", 14);
- ms= ClassTypeHelper.getMethods(type);
- i= ms[0].getName().equals("f") ? 0 : 1;
- m= ms[i];
+ type = bh.assertNonProblem("X<const int&&>", 14);
+ ms = ClassTypeHelper.getMethods(type);
+ i = ms[0].getName().equals("f") ? 0 : 1;
+ m = ms[i];
assertEquals("const int &", ASTTypeUtil.getType(m.getType().getParameterTypes()[0]));
- m= ms[1 - i];
+ m = ms[1 - i];
assertEquals("const int &&", ASTTypeUtil.getType(m.getType().getParameterTypes()[0]));
}
@@ -4949,28 +4956,28 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// template<typename NonPack> void f6(NonPack ...);
// template<typename... T> void f7() throw(T...);
public void testFunctionParameterPacks_280909() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPFunctionTemplate f= bh.assertNonProblem("f1", 2);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPFunctionTemplate f = bh.assertNonProblem("f1", 2);
assertEquals("void (int (*)(#0(...) ...))", ASTTypeUtil.getType(f.getType(), true));
assertFalse(f.getParameters()[0].isParameterPack());
- f= bh.assertNonProblem("f2", 2);
+ f = bh.assertNonProblem("f2", 2);
assertEquals("void (int (* ...)(#0(...), int))", ASTTypeUtil.getType(f.getType(), true));
assertTrue(f.getParameters()[0].isParameterPack());
- f= bh.assertNonProblem("f3", 2);
+ f = bh.assertNonProblem("f3", 2);
assertEquals("void (#0(...) (* ...)())", ASTTypeUtil.getType(f.getType(), true));
assertTrue(f.getParameters()[0].isParameterPack());
- f= bh.assertNonProblem("f4", 2);
+ f = bh.assertNonProblem("f4", 2);
assertEquals("void (int (& ...)[3 *0 0])", ASTTypeUtil.getType(f.getType(), true));
assertTrue(f.getParameters()[0].isParameterPack());
- f= bh.assertNonProblem("f5", 2);
+ f = bh.assertNonProblem("f5", 2);
assertEquals("void (#0(...) ...)", ASTTypeUtil.getType(f.getType(), true));
assertTrue(f.getParameters()[0].isParameterPack());
- f= bh.assertNonProblem("f6", 2);
+ f = bh.assertNonProblem("f6", 2);
assertEquals("void (#0, ...)", ASTTypeUtil.getType(f.getType(), true));
assertFalse(f.getParameters()[0].isParameterPack());
- f= bh.assertNonProblem("f7", 2);
+ f = bh.assertNonProblem("f7", 2);
assertEquals("#0(...) ...", ASTTypeUtil.getType(f.getExceptionSpecification()[0], true));
}
@@ -4978,19 +4985,19 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// template<template<typename... NP> class... Pack> class C2 {};
// template<int... Pack> class C3 {};
public void testTemplateParameterPacks_280909() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPClassTemplate ct= bh.assertNonProblem("C1", 2);
- ICPPTemplateParameter tp= ct.getTemplateParameters()[0];
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPClassTemplate ct = bh.assertNonProblem("C1", 2);
+ ICPPTemplateParameter tp = ct.getTemplateParameters()[0];
assertTrue(tp.isParameterPack());
- ct= bh.assertNonProblem("C2", 2);
- tp= ct.getTemplateParameters()[0];
+ ct = bh.assertNonProblem("C2", 2);
+ tp = ct.getTemplateParameters()[0];
assertTrue(tp.isParameterPack());
- ct= bh.assertNonProblem("C3", 2);
- tp= ct.getTemplateParameters()[0];
+ ct = bh.assertNonProblem("C3", 2);
+ tp = ct.getTemplateParameters()[0];
assertTrue(tp.isParameterPack());
}
@@ -5007,14 +5014,14 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// c.mem();
// }
public void testParameterPackExpansions_280909() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPField field= bh.assertNonProblem("a= 1", 1);
- field= bh.assertNonProblem("b= 1", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPField field = bh.assertNonProblem("a= 1", 1);
+ field = bh.assertNonProblem("b= 1", 1);
- ICPPMethod meth= bh.assertNonProblem("mem();", 3);
- IType[] spec= meth.getExceptionSpecification();
+ ICPPMethod meth = bh.assertNonProblem("mem();", 3);
+ IType[] spec = meth.getExceptionSpecification();
assertEquals(2, spec.length);
assertEquals("A", ASTTypeUtil.getType(spec[0]));
assertEquals("B", ASTTypeUtil.getType(spec[1]));
@@ -5023,15 +5030,15 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// template<typename... T> void f1(T*...);
// template<typename T> void f2(T*...);
public void testTemplateParameterPacksAmbiguity_280909() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPFunctionTemplate ft= bh.assertNonProblem("f1", 2);
- ICPPTemplateParameter tp= ft.getTemplateParameters()[0];
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPFunctionTemplate ft = bh.assertNonProblem("f1", 2);
+ ICPPTemplateParameter tp = ft.getTemplateParameters()[0];
assertTrue(tp.isParameterPack());
- ft= bh.assertNonProblem("f2", 2);
- tp= ft.getTemplateParameters()[0];
+ ft = bh.assertNonProblem("f2", 2);
+ tp = ft.getTemplateParameters()[0];
assertFalse(tp.isParameterPack());
}
@@ -5084,8 +5091,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// Tuple<>* t; // OK: Elements is empty
// Tuple* u; // syntax error
public void testVariadicTemplateExamples_280909e() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("String<>", 6);
bh.assertProblem("String*", 6);
bh.assertNonProblem("Tuple<>", 5);
@@ -5104,8 +5111,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// Y<B> yb; // okay
// Y<C> yc; // okay
public void testVariadicTemplateExamples_280909f() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("X<A>", 4);
bh.assertProblem("X<B>", 4);
bh.assertProblem("X<C>", 4);
@@ -5127,8 +5134,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// template<class... Types> void B<Types...>::f3() {} // OK
// template<class... Types> void B<Types>::f4() {} // error
public void testVariadicTemplateExamples_280909g() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("f1() {}", 2);
bh.assertProblem("f2() {}", 2);
bh.assertNonProblem("f3() {}", 2);
@@ -5148,8 +5155,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// f<void>(g<int, bool>); // Y for outer f deduced to be
// } // int (*)(bool), Z is deduced to an empty sequence
public void testVariadicTemplateExamples_280909h() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("f<int>(5.6)", 6);
bh.assertProblem("f(5.6)", 1);
bh.assertNonProblem("f<void>(f<int, bool>)", 7);
@@ -5169,8 +5176,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// f2<char, short, int, long>(); // okay
// }
public void testVariadicTemplateExamples_280909i() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("f<int,char*,double>", 0);
bh.assertNonProblem("f<int,char*>", 0);
bh.assertNonProblem("f<int>", 0);
@@ -5222,8 +5229,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// Tuple<0> error; // Error: 0 is not a type
// }
public void testVariadicTemplateExamples_280909p() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("Tuple<>", 0);
bh.assertNonProblem("Tuple<int>", 0);
bh.assertNonProblem("Tuple<int, float>", 0);
@@ -5269,20 +5276,21 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// f(h(args...) + args...); // okay: first 'args' expanded within h, second 'args' expanded within f.
// }
public void testVariadicTemplateExamples_280909s() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ITypedef td= bh.assertNonProblem("T1;", 2);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ITypedef td = bh.assertNonProblem("T1;", 2);
IType type = getNestedType(td, TDEF);
- assertEquals("Tuple<Pair<short int,unsigned short int>,Pair<int,unsigned int>>", ASTTypeUtil.getType(type, false));
- td= bh.assertNonProblem("zip<short>::with<unsigned short, unsigned>::type", 0);
+ assertEquals("Tuple<Pair<short int,unsigned short int>,Pair<int,unsigned int>>",
+ ASTTypeUtil.getType(type, false));
+ td = bh.assertNonProblem("zip<short>::with<unsigned short, unsigned>::type", 0);
type = getNestedType(td, TDEF);
assertTrue(type instanceof IProblemBinding);
ICPPUnknownBinding ub;
- ub= bh.assertNonProblem("f(const_cast<const Args*>(&args)...)", 1);
- ub= bh.assertNonProblem("f(5 ...)", 1); // no diagnostics in CDT, treated as unknown function.
- ub= bh.assertNonProblem("f(args)", 1); // no diagnostics in CDT
- ub= bh.assertNonProblem("f(h(args...) + args...)", 1);
+ ub = bh.assertNonProblem("f(const_cast<const Args*>(&args)...)", 1);
+ ub = bh.assertNonProblem("f(5 ...)", 1); // no diagnostics in CDT, treated as unknown function.
+ ub = bh.assertNonProblem("f(args)", 1); // no diagnostics in CDT
+ ub = bh.assertNonProblem("f(h(args...) + args...)", 1);
}
// template <typename... Args>
@@ -5336,26 +5344,26 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// f<int,char>(); // f<int,char>(0,0)
// }
public void testDefaultTemplateArgsForFunctionTemplates_294730() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
- ICPPTemplateInstance f= bh.assertNonProblem("f(1, 'c');", 1);
+ ICPPTemplateInstance f = bh.assertNonProblem("f(1, 'c');", 1);
assertEquals("<int,char>", ASTTypeUtil.getArgumentListString(f.getTemplateArguments(), true));
- f= bh.assertNonProblem("f(1);", 1);
+ f = bh.assertNonProblem("f(1);", 1);
assertEquals("<int,double>", ASTTypeUtil.getArgumentListString(f.getTemplateArguments(), true));
bh.assertProblem("f();", 1);
- f= bh.assertNonProblem("f<int>();", -3);
+ f = bh.assertNonProblem("f<int>();", -3);
assertEquals("<int,double>", ASTTypeUtil.getArgumentListString(f.getTemplateArguments(), true));
- f= bh.assertNonProblem("f<int,char>();", -3);
+ f = bh.assertNonProblem("f<int,char>();", -3);
assertEquals("<int,char>", ASTTypeUtil.getArgumentListString(f.getTemplateArguments(), true));
}
// template<typename T> class CT {};
// extern template class CT<int>;
public void testExternTemplates_294730() throws Exception {
- final String code= getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code);
- ICPPASTExplicitTemplateInstantiation ti= getDeclaration(tu, 1);
+ final String code = getAboveComment();
+ IASTTranslationUnit tu = parseAndCheckBindings(code);
+ ICPPASTExplicitTemplateInstantiation ti = getDeclaration(tu, 1);
assertEquals(ICPPASTExplicitTemplateInstantiation.EXTERN, ti.getModifier());
}
@@ -5374,24 +5382,24 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// eval<D<int, 17>> eD; // error: D does not match TT in partial specialization
// eval<E<int, float>> eE; // error: E does not match TT in partial specialization
public void testExtendingVariadicTemplateTemplateParameters_302282() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPClassTemplate ct= bh.assertNonProblem("eval;", -1);
- ICPPClassTemplatePartialSpecialization pspec= bh.assertNonProblem("eval<TT<T1, Rest...>>", 0);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPClassTemplate ct = bh.assertNonProblem("eval;", -1);
+ ICPPClassTemplatePartialSpecialization pspec = bh.assertNonProblem("eval<TT<T1, Rest...>>", 0);
- ICPPTemplateInstance inst= bh.assertNonProblem("eval<A<int>>", 0);
+ ICPPTemplateInstance inst = bh.assertNonProblem("eval<A<int>>", 0);
assertSame(pspec, inst.getSpecializedBinding());
- inst= bh.assertNonProblem("eval<B<int, float>>", 0);
+ inst = bh.assertNonProblem("eval<B<int, float>>", 0);
assertSame(pspec, inst.getSpecializedBinding());
- inst= bh.assertNonProblem("eval<C<17>>", 0);
+ inst = bh.assertNonProblem("eval<C<17>>", 0);
assertSame(ct, inst.getSpecializedBinding());
- inst= bh.assertNonProblem("eval<D<int, 17>>", 0);
+ inst = bh.assertNonProblem("eval<D<int, 17>>", 0);
assertSame(ct, inst.getSpecializedBinding());
- inst= bh.assertNonProblem("eval<E<int, float>>", 0);
+ inst = bh.assertNonProblem("eval<E<int, float>>", 0);
assertSame(ct, inst.getSpecializedBinding());
}
@@ -5408,11 +5416,11 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// g(1);
// }
public void testExplicitSpecializations_296427() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("X<int>", 0);
+ inst = bh.assertNonProblem("X<int>", 0);
assertFalse(inst.isExplicitSpecialization());
inst = bh.assertNonProblem("Y<int> y;", 6);
assertTrue(inst.isExplicitSpecialization());
@@ -5447,8 +5455,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// func<int>(1);
// }
public void testBug306213a() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertNonProblem("func<int>", 0);
parseAndCheckBindings(code);
}
@@ -5463,9 +5471,9 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// func<int*>(1);
// }
public void testBug306213b() throws Exception {
- CPPASTNameBase.sAllowRecursionBindings= true;
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ CPPASTNameBase.sAllowRecursionBindings = true;
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
bh.assertProblem("func<int*>", 0);
}
@@ -5488,27 +5496,27 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// template<> class CT<int,char> {};
// template<> class CT<char,char> {};
public void testBug311164() throws Exception {
- CPPASTNameBase.sAllowNameComputation= true;
- final String code= getAboveComment();
+ CPPASTNameBase.sAllowNameComputation = true;
+ final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
final IASTTranslationUnit tu = bh.getTranslationUnit();
- IBinding b= bh.assertNonProblem("CT {", 2);
+ IBinding b = bh.assertNonProblem("CT {", 2);
IName[] names = tu.getDeclarationsInAST(b);
assertEquals(1, names.length);
assertEquals("CT", names[0].toString());
- names= tu.getReferences(b);
+ names = tu.getReferences(b);
assertEquals(2, names.length);
assertEquals("CT", names[0].toString());
assertEquals("CT", names[1].toString());
- b= bh.assertNonProblem("CT<int,char>", 0);
+ b = bh.assertNonProblem("CT<int,char>", 0);
names = tu.getDeclarationsInAST(b);
assertEquals(1, names.length);
assertEquals("CT<int, char>", names[0].toString());
- b= bh.assertNonProblem("CT<char,char>", 0);
+ b = bh.assertNonProblem("CT<char,char>", 0);
names = tu.getDeclarationsInAST(b);
assertEquals(1, names.length);
assertEquals("CT<char, char>", names[0].toString());
@@ -5518,7 +5526,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// if any methods that were added during the refactoring need
// to be added to ASTComparer.methodsToIgnore.
public void testBug316704() throws Exception {
- StringBuilder code= new StringBuilder("typedef if_< bool,");
+ StringBuilder code = new StringBuilder("typedef if_< bool,");
for (int i = 0; i < 50; i++) {
code.append('\n').append("if_<bool,");
}
@@ -5527,7 +5535,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
code.append('\n').append("int_<0> >::type,");
}
code.append("int_<0> >::type tdef;");
- IASTTranslationUnit tu= parse(code.toString(), CPP, true, true);
+ IASTTranslationUnit tu = parse(code.toString(), CPP, true, true);
tu = validateCopy(tu);
assertEquals(1, tu.getDeclarations().length);
}
@@ -5563,24 +5571,24 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testInlineNamespaces_305980() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPFunctionTemplate ft= bh.assertNonProblem("f(T&)", 1);
- ICPPNamespace M= (ICPPNamespace) ft.getOwner();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPFunctionTemplate ft = bh.assertNonProblem("f(T&)", 1);
+ ICPPNamespace M = (ICPPNamespace) ft.getOwner();
ICPPTemplateInstance inst;
- inst= bh.assertNonProblem("f<char>", 0);
+ inst = bh.assertNonProblem("f<char>", 0);
assertSame(ft, inst.getTemplateDefinition());
assertSame(M, inst.getOwner());
- inst= bh.assertNonProblem("f<short>", 0);
+ inst = bh.assertNonProblem("f<short>", 0);
assertSame(ft, inst.getTemplateDefinition());
assertSame(M, inst.getOwner());
- inst= bh.assertNonProblem("f<int>", 0);
+ inst = bh.assertNonProblem("f<int>", 0);
assertSame(ft, inst.getTemplateDefinition());
assertSame(M, inst.getOwner());
- inst= bh.assertNonProblem("f<long>", 0);
+ inst = bh.assertNonProblem("f<long>", 0);
assertSame(ft, inst.getTemplateDefinition());
assertSame(M, inst.getOwner());
}
@@ -5667,11 +5675,11 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// out << endl;
// }
public void testInstantiationOfEndl_297457() throws Exception {
- final String code= getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code);
+ final String code = getAboveComment();
+ IASTTranslationUnit tu = parseAndCheckBindings(code);
final IASTNodeSelector nodeSelector = tu.getNodeSelector(null);
- IASTName methodName= nodeSelector.findEnclosingName(code.indexOf("operator<<"), 1);
+ IASTName methodName = nodeSelector.findEnclosingName(code.indexOf("operator<<"), 1);
IASTImplicitName name = nodeSelector.findImplicitName(code.indexOf("<< endl"), 2);
final IBinding method = methodName.resolveBinding();
@@ -5721,23 +5729,23 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// f(g, 1);
// }
public void testInstantiationOfFunctionTemplateWithOverloadedFunctionSetArgument_326492() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPFunctionTemplate f1= bh.assertNonProblem("f(T (*)(int), char)", 1);
- ICPPFunctionTemplate f2= bh.assertNonProblem("f(int (*)(T), int)", 1);
- IFunction g1= bh.assertNonProblem("g(char)", 1);
- IFunction g2= bh.assertNonProblem("g(int)", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPFunctionTemplate f1 = bh.assertNonProblem("f(T (*)(int), char)", 1);
+ ICPPFunctionTemplate f2 = bh.assertNonProblem("f(int (*)(T), int)", 1);
+ IFunction g1 = bh.assertNonProblem("g(char)", 1);
+ IFunction g2 = bh.assertNonProblem("g(int)", 1);
ICPPTemplateInstance t;
- t= bh.assertNonProblem("f(g, '1')", 1);
+ t = bh.assertNonProblem("f(g, '1')", 1);
assertSame(f1, t.getTemplateDefinition());
- t= bh.assertNonProblem("f(g, 1)", 1);
+ t = bh.assertNonProblem("f(g, 1)", 1);
assertSame(f2, t.getTemplateDefinition());
ICPPFunction g;
- g= bh.assertNonProblem("g, '1')", 1);
+ g = bh.assertNonProblem("g, '1')", 1);
assertSame(g2, g);
- g= bh.assertNonProblem("g, 1)", 1);
+ g = bh.assertNonProblem("g, 1)", 1);
assertSame(g1, g);
}
@@ -5789,10 +5797,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// l.m().foo = 1;
// }
public void testNestedTypedefSpecialization_329795() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, CPP);
- ICPPField f1= bh.assertNonProblem("foo;", 3);
- IBinding f2= bh.assertNonProblem("foo =", 3);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+ ICPPField f1 = bh.assertNonProblem("foo;", 3);
+ IBinding f2 = bh.assertNonProblem("foo =", 3);
assertSame(f1, f2);
}
@@ -6032,20 +6040,20 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// s<1 && 2>::f(); // f is global
// }
public void testTemplateIDAmbiguity_341747a() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings();
- IASTFunctionDefinition fdef= getDeclaration(tu, 4);
+ IASTTranslationUnit tu = parseAndCheckBindings();
+ IASTFunctionDefinition fdef = getDeclaration(tu, 4);
IASTExpressionStatement stmt;
- stmt= getStatement(fdef, 0);
+ stmt = getStatement(fdef, 0);
assertTrue(stmt.getExpression() instanceof IASTBinaryExpression);
- stmt= getStatement(fdef, 1);
+ stmt = getStatement(fdef, 1);
assertTrue(stmt.getExpression() instanceof IASTFunctionCallExpression);
- stmt= getStatement(fdef, 2);
+ stmt = getStatement(fdef, 2);
assertTrue(stmt.getExpression() instanceof IASTFunctionCallExpression);
- stmt= getStatement(fdef, 0);
+ stmt = getStatement(fdef, 0);
assertTrue(stmt.getExpression() instanceof IASTBinaryExpression);
}
@@ -6162,9 +6170,9 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// }
public void testArgumentDeductionFromReturnTypeOfExplicitSpecialization_355304() throws Exception {
parseAndCheckBindings();
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPFunctionTemplate template= bh.assertNonProblem("f();", 1);
- ICPPTemplateInstance inst= bh.assertNonProblem("f() {", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPFunctionTemplate template = bh.assertNonProblem("f();", 1);
+ ICPPTemplateInstance inst = bh.assertNonProblem("f() {", 1);
assertSame(template, inst.getTemplateDefinition());
}
@@ -6354,8 +6362,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// B<int>::pointer a;
public void testDependentExpressions_b() throws Exception {
parseAndCheckBindings();
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPVariable var= bh.assertNonProblem("a;", 1, ICPPVariable.class);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPVariable var = bh.assertNonProblem("a;", 1, ICPPVariable.class);
IType type = var.getType();
type = SemanticUtil.getNestedType(type, TDEF);
assertEquals("int *", type.toString());
@@ -6554,8 +6562,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// };
public void testTemplateShortNameInQualifiedName_367607() throws Exception {
parseAndCheckBindings();
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- ICPPDeferredClassInstance shortHand= bh.assertNonProblem("derived:", -1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ ICPPDeferredClassInstance shortHand = bh.assertNonProblem("derived:", -1);
assertTrue(shortHand.getClassTemplate() instanceof ICPPClassTemplatePartialSpecialization);
}
@@ -6601,8 +6609,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// e.x; // ERROR HERE: "Field 'x' could not be resolved"
// }
public void testAutoTypeWithTypedef_368311() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
- IVariable v= bh.assertNonProblem("cur = r.begin()", 3);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ IVariable v = bh.assertNonProblem("cur = r.begin()", 3);
assertEquals("A<S>::iterator_t", ASTTypeUtil.getType(v.getType(), true));
parseAndCheckBindings();
}
@@ -6921,16 +6929,16 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// };
public void testNestedAliasDeclarationNestingLevel() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPAliasTemplate templateParameterAlias = bh.assertNonProblem("Alias=", "Alias", ICPPAliasTemplate.class);
- ICPPTemplateParameter aliasParameterT= templateParameterAlias.getTemplateParameters()[0];
+ ICPPTemplateParameter aliasParameterT = templateParameterAlias.getTemplateParameters()[0];
assertEquals(1, aliasParameterT.getTemplateNestingLevel());
ICPPAliasTemplateInstance aliasIntInstance = bh.assertNonProblem("Alias<int>");
IType typeOfAliasIntInstance = aliasIntInstance.getType();
assertTrue(typeOfAliasIntInstance instanceof ICPPBasicType);
- assertEquals(((ICPPBasicType)typeOfAliasIntInstance).getKind(), IBasicType.Kind.eInt);
+ assertEquals(((ICPPBasicType) typeOfAliasIntInstance).getKind(), IBasicType.Kind.eInt);
parseAndCheckBindings(code);
}
@@ -6942,7 +6950,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// };
public void testAliasDeclarationNestingLevel() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
ICPPAliasTemplate templateParameterAlias = bh.assertNonProblem("Alias=", "Alias", ICPPAliasTemplate.class);
ICPPTemplateParameter aliasParameterT = templateParameterAlias.getTemplateParameters()[0];
@@ -6975,7 +6983,6 @@ public class AST2TemplateTests extends AST2CPPTestBase {
IFunction foo = assertionHelper.assertNonProblem("void foo() {", "foo", IFunction.class);
IVariable myA = assertionHelper.assertNonProblem("Alias myA", "myA", IVariable.class);
-
assertInstances(collector, S, 2);
assertInstances(collector, x, 2);
assertInstances(collector, Alias, 2);
@@ -7004,7 +7011,6 @@ public class AST2TemplateTests extends AST2CPPTestBase {
IVariable myA = assertionHelper.assertNonProblem("Alias myA;", "myA", IVariable.class);
ICPPSpecialization xRef = assertionHelper.assertNonProblem("myA.x = 42;", "x", ICPPSpecialization.class);
-
assertInstances(collector, S, 2);
assertInstances(collector, Alias, 2);
assertInstances(collector, myA, 2);
@@ -7023,8 +7029,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
NameCollector collector = getNameCollector(assertionHelper.getTranslationUnit());
- ICPPAliasTemplate Alias = assertionHelper.assertNonProblem("using Alias = int;", "Alias", ICPPAliasTemplate.class);
- ICPPAliasTemplateInstance aliasFloatInstance = assertionHelper.assertNonProblem("Alias<float> myA;", "Alias<float>", ICPPAliasTemplateInstance.class);
+ ICPPAliasTemplate Alias = assertionHelper.assertNonProblem("using Alias = int;", "Alias",
+ ICPPAliasTemplate.class);
+ ICPPAliasTemplateInstance aliasFloatInstance = assertionHelper.assertNonProblem("Alias<float> myA;",
+ "Alias<float>", ICPPAliasTemplateInstance.class);
assertInstances(collector, Alias, 2);
assertSameType(aliasFloatInstance, new CPPBasicType(IBasicType.Kind.eInt, 0));
@@ -7048,9 +7056,12 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPClassType S = assertionHelper.assertNonProblem("struct S {", "S", ICPPClassType.class);
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
- ICPPTemplateParameter T = assertionHelper.assertNonProblem("template<typename _T>", "_T", ICPPTemplateParameter.class);
- ICPPTemplateParameter TRef = assertionHelper.assertNonProblem("using TAlias = S<_T>;", "_T", ICPPTemplateParameter.class);
- ICPPAliasTemplate TAlias = assertionHelper.assertNonProblem("using TAlias = S<_T>;", "TAlias", ICPPAliasTemplate.class);
+ ICPPTemplateParameter T = assertionHelper.assertNonProblem("template<typename _T>", "_T",
+ ICPPTemplateParameter.class);
+ ICPPTemplateParameter TRef = assertionHelper.assertNonProblem("using TAlias = S<_T>;", "_T",
+ ICPPTemplateParameter.class);
+ ICPPAliasTemplate TAlias = assertionHelper.assertNonProblem("using TAlias = S<_T>;", "TAlias",
+ ICPPAliasTemplate.class);
ICPPVariable myA = assertionHelper.assertNonProblem("TAlias<int> myA;", "myA", ICPPVariable.class);
ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = 42;", "t", ICPPSpecialization.class);
@@ -7087,13 +7098,18 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPField t2 = assertionHelper.assertNonProblem("T2 t2;", "t2", ICPPField.class);
ICPPField t3 = assertionHelper.assertNonProblem("T3 t3;", "t3", ICPPField.class);
- ICPPTemplateParameter P1 = assertionHelper.assertNonProblem("template<typename P1, typename P2>", "P1", ICPPTemplateParameter.class);
- ICPPTemplateParameter P2 = assertionHelper.assertNonProblem("template<typename P1, typename P2>", "P2", ICPPTemplateParameter.class);
+ ICPPTemplateParameter P1 = assertionHelper.assertNonProblem("template<typename P1, typename P2>", "P1",
+ ICPPTemplateParameter.class);
+ ICPPTemplateParameter P2 = assertionHelper.assertNonProblem("template<typename P1, typename P2>", "P2",
+ ICPPTemplateParameter.class);
- ICPPTemplateParameter P1Ref = assertionHelper.assertNonProblem("using TAlias = S<int, P2, P1>;", "P1", ICPPTemplateParameter.class);
- ICPPTemplateParameter P2Ref = assertionHelper.assertNonProblem("using TAlias = S<int, P2, P1>;", "P2", ICPPTemplateParameter.class);
+ ICPPTemplateParameter P1Ref = assertionHelper.assertNonProblem("using TAlias = S<int, P2, P1>;", "P1",
+ ICPPTemplateParameter.class);
+ ICPPTemplateParameter P2Ref = assertionHelper.assertNonProblem("using TAlias = S<int, P2, P1>;", "P2",
+ ICPPTemplateParameter.class);
- ICPPAliasTemplateInstance TAliasInstance = assertionHelper.assertNonProblem("TAlias<bool, float> myA;", "TAlias<bool, float>", ICPPAliasTemplateInstance.class);
+ ICPPAliasTemplateInstance TAliasInstance = assertionHelper.assertNonProblem("TAlias<bool, float> myA;",
+ "TAlias<bool, float>", ICPPAliasTemplateInstance.class);
ICPPTemplateInstance aliasedTypeInstance = (ICPPTemplateInstance) TAliasInstance.getType();
ICPPSpecialization t1Ref = assertionHelper.assertNonProblem("myA.t1 = 42;", "t1", ICPPSpecialization.class);
@@ -7106,9 +7122,12 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertEquals(t1, t1Ref.getSpecializedBinding());
assertEquals(t2, t2Ref.getSpecializedBinding());
assertEquals(t3, t3Ref.getSpecializedBinding());
- assertSameType(new CPPBasicType(IBasicType.Kind.eInt, 0), aliasedTypeInstance.getTemplateArguments()[0].getTypeValue());
- assertSameType(new CPPBasicType(IBasicType.Kind.eFloat, 0), aliasedTypeInstance.getTemplateArguments()[1].getTypeValue());
- assertSameType(new CPPBasicType(IBasicType.Kind.eBoolean, 0), aliasedTypeInstance.getTemplateArguments()[2].getTypeValue());
+ assertSameType(new CPPBasicType(IBasicType.Kind.eInt, 0),
+ aliasedTypeInstance.getTemplateArguments()[0].getTypeValue());
+ assertSameType(new CPPBasicType(IBasicType.Kind.eFloat, 0),
+ aliasedTypeInstance.getTemplateArguments()[1].getTypeValue());
+ assertSameType(new CPPBasicType(IBasicType.Kind.eBoolean, 0),
+ aliasedTypeInstance.getTemplateArguments()[2].getTypeValue());
}
// template<typename T>
@@ -7127,11 +7146,12 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
- ICPPAliasTemplateInstance TAliasSInt = assertionHelper.assertNonProblem("TAlias<S<int>> myA;", "TAlias<S<int>>", ICPPAliasTemplateInstance.class);
+ ICPPAliasTemplateInstance TAliasSInt = assertionHelper.assertNonProblem("TAlias<S<int>> myA;", "TAlias<S<int>>",
+ ICPPAliasTemplateInstance.class);
ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = S<int>()", "t", ICPPSpecialization.class);
assertEquals(t, tRef.getSpecializedBinding());
- assertSameType(TAliasSInt, (IType)tRef.getOwner());
+ assertSameType(TAliasSInt, (IType) tRef.getOwner());
}
// template<typename T>
@@ -7150,7 +7170,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
- ICPPTemplateInstance STAliasInt = assertionHelper.assertNonProblem("S<TAlias<int>> myA;", "S<TAlias<int>>", ICPPTemplateInstance.class);
+ ICPPTemplateInstance STAliasInt = assertionHelper.assertNonProblem("S<TAlias<int>> myA;", "S<TAlias<int>>",
+ ICPPTemplateInstance.class);
ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = S<int>();", "t", ICPPSpecialization.class);
assertEquals(t, tRef.getSpecializedBinding());
@@ -7173,11 +7194,12 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
ICPPField buff = assertionHelper.assertNonProblem("int buff [Size];", "buff", ICPPField.class);
- ICPPSpecialization buffRef = assertionHelper.assertNonProblem("myA.buff[0] = 1;", "buff", ICPPSpecialization.class);
+ ICPPSpecialization buffRef = assertionHelper.assertNonProblem("myA.buff[0] = 1;", "buff",
+ ICPPSpecialization.class);
assertEquals(buff, buffRef.getSpecializedBinding());
- assertEquals(Long.valueOf(4),buffRef.getTemplateParameterMap().getArgument(0).getNonTypeValue().numberValue());
- assertEquals(Long.valueOf(5),buffRef.getTemplateParameterMap().getArgument(1).getNonTypeValue().numberValue());
+ assertEquals(Long.valueOf(4), buffRef.getTemplateParameterMap().getArgument(0).getNonTypeValue().numberValue());
+ assertEquals(Long.valueOf(5), buffRef.getTemplateParameterMap().getArgument(1).getNonTypeValue().numberValue());
}
// template<typename T, int Size>
@@ -7196,12 +7218,15 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
ICPPField buff = assertionHelper.assertNonProblem("T buff [Size];", "buff", ICPPField.class);
- ICPPAliasTemplateInstance myA = assertionHelper.assertNonProblem("TAlias<> myA;", "TAlias<>", ICPPAliasTemplateInstance.class);
- ICPPSpecialization buffRef = assertionHelper.assertNonProblem("myA.buff[0] = 1;", "buff", ICPPSpecialization.class);
+ ICPPAliasTemplateInstance myA = assertionHelper.assertNonProblem("TAlias<> myA;", "TAlias<>",
+ ICPPAliasTemplateInstance.class);
+ ICPPSpecialization buffRef = assertionHelper.assertNonProblem("myA.buff[0] = 1;", "buff",
+ ICPPSpecialization.class);
assertEquals(buff, buffRef.getSpecializedBinding());
- assertSameType(buffRef.getTemplateParameterMap().getArgument(0).getTypeValue(), new CPPBasicType(IBasicType.Kind.eInt, 0));
- assertEquals(Long.valueOf(5),buffRef.getTemplateParameterMap().getArgument(1).getNonTypeValue().numberValue());
+ assertSameType(buffRef.getTemplateParameterMap().getArgument(0).getTypeValue(),
+ new CPPBasicType(IBasicType.Kind.eInt, 0));
+ assertEquals(Long.valueOf(5), buffRef.getTemplateParameterMap().getArgument(1).getNonTypeValue().numberValue());
}
// template<typename T>
@@ -7221,7 +7246,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
ICPPSpecialization tRef = assertionHelper.assertNonProblem(" myA.t = S<int>();", "t", ICPPSpecialization.class);
- ICPPClassSpecialization Sint = assertionHelper.assertNonProblem("myA.t = S<int>();", "S<int>", ICPPClassSpecialization.class);
+ ICPPClassSpecialization Sint = assertionHelper.assertNonProblem("myA.t = S<int>();", "S<int>",
+ ICPPClassSpecialization.class);
assertEquals(t, tRef.getSpecializedBinding());
assertSameType(tRef.getTemplateParameterMap().getArgument(0).getTypeValue(), Sint);
@@ -7247,7 +7273,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
ICPPFunction bar = assertionHelper.assertNonProblem("void bar(TAlias<int> arg){", "bar", ICPPFunction.class);
- ICPPFunction barRefAlias = assertionHelper.assertNonProblem("bar(myA);", "bar", ICPPFunction.class);
+ ICPPFunction barRefAlias = assertionHelper.assertNonProblem("bar(myA);", "bar", ICPPFunction.class);
ICPPFunction barRefSInt = assertionHelper.assertNonProblem("bar(myS);", "bar", ICPPFunction.class);
assertEquals(bar, barRefAlias);
@@ -7288,7 +7314,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// void bar(TAlias<int> arg){
// }
public void testTemplatedAliasRedefinitionOfSameFunction() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
bh.assertNonProblem("bar(S", "bar", ICPPFunction.class);
bh.assertProblem("bar(TAlias", "bar", ISemanticProblem.BINDING_INVALID_REDEFINITION);
}
@@ -7306,7 +7332,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// f(v);
// }
public void testTemplatedAliasDeduction() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper();
+ BindingAssertionHelper bh = getAssertionHelper();
bh.assertNonProblem("g(v)", "g", ICPPFunction.class);
bh.assertProblem("f(v)", "f", ISemanticProblem.BINDING_NOT_FOUND);
}
@@ -7321,12 +7347,13 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
NameCollector collector = getNameCollector(assertionHelper.getTranslationUnit());
- ITypedef function = assertionHelper.assertNonProblem("using function = void (&)(int)", "function", ITypedef.class);
+ ITypedef function = assertionHelper.assertNonProblem("using function = void (&)(int)", "function",
+ ITypedef.class);
ICPPFunction foo = assertionHelper.assertNonProblem("void foo(int)", "foo", ICPPFunction.class);
assertInstances(collector, function, 2);
assertInstances(collector, foo, 2);
- assertSameType(((ICPPReferenceType)function.getType()).getType(), foo.getType());
+ assertSameType(((ICPPReferenceType) function.getType()).getType(), foo.getType());
}
// template<typename T>
@@ -7345,8 +7372,10 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
- ICPPClassSpecialization SInt = assertionHelper.assertNonProblem("S<int> myS;", "S<int>", ICPPClassSpecialization.class);
- ICPPAliasTemplateInstance TAliasInt = assertionHelper.assertNonProblem("TAlias<int> myA = myS;", "TAlias<int>", ICPPAliasTemplateInstance.class);
+ ICPPClassSpecialization SInt = assertionHelper.assertNonProblem("S<int> myS;", "S<int>",
+ ICPPClassSpecialization.class);
+ ICPPAliasTemplateInstance TAliasInt = assertionHelper.assertNonProblem("TAlias<int> myA = myS;", "TAlias<int>",
+ ICPPAliasTemplateInstance.class);
assertSameType(new CPPReferenceType(SInt, false), TAliasInt);
}
@@ -7362,13 +7391,15 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
NameCollector collector = getNameCollector(assertionHelper.getTranslationUnit());
- ICPPAliasTemplate function = assertionHelper.assertNonProblem("using function = void (int)", "function", ICPPAliasTemplate.class);
- ICPPFunction foo = assertionHelper.assertNonProblem("void foo(int) {", "foo", ICPPFunction.class);
- ICPPAliasTemplateInstance functionInt = assertionHelper.assertNonProblem("function<int> f = &foo;", "function<int>", ICPPAliasTemplateInstance.class);
+ ICPPAliasTemplate function = assertionHelper.assertNonProblem("using function = void (int)", "function",
+ ICPPAliasTemplate.class);
+ ICPPFunction foo = assertionHelper.assertNonProblem("void foo(int) {", "foo", ICPPFunction.class);
+ ICPPAliasTemplateInstance functionInt = assertionHelper.assertNonProblem("function<int> f = &foo;",
+ "function<int>", ICPPAliasTemplateInstance.class);
assertInstances(collector, function, 2);
assertInstances(collector, foo, 2);
- assertSameType(foo.getType(),functionInt);
+ assertSameType(foo.getType(), functionInt);
}
// template<typename T>
@@ -7382,13 +7413,15 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
NameCollector collector = getNameCollector(assertionHelper.getTranslationUnit());
- ICPPAliasTemplate function = assertionHelper.assertNonProblem("using function = void (&)(int)", "function", ICPPAliasTemplate.class);
+ ICPPAliasTemplate function = assertionHelper.assertNonProblem("using function = void (&)(int)", "function",
+ ICPPAliasTemplate.class);
ICPPFunction foo = assertionHelper.assertNonProblem("void foo(int) {", "foo", ICPPFunction.class);
- ICPPAliasTemplateInstance functionInt = assertionHelper.assertNonProblem("function<int> f = &foo;", "function<int>", ICPPAliasTemplateInstance.class);
+ ICPPAliasTemplateInstance functionInt = assertionHelper.assertNonProblem("function<int> f = &foo;",
+ "function<int>", ICPPAliasTemplateInstance.class);
assertInstances(collector, function, 2);
assertInstances(collector, foo, 2);
- assertSameType(new CPPReferenceType(foo.getType(), false),functionInt.getType());
+ assertSameType(new CPPReferenceType(foo.getType(), false), functionInt.getType());
}
// template<typename T>
@@ -7408,7 +7441,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = S<int>();", "t", ICPPSpecialization.class);
- ICPPClassSpecialization Sint = assertionHelper.assertNonProblem("myA.t = S<int>();", "S<int>", ICPPClassSpecialization.class);
+ ICPPClassSpecialization Sint = assertionHelper.assertNonProblem("myA.t = S<int>();", "S<int>",
+ ICPPClassSpecialization.class);
assertEquals(t, tRef.getSpecializedBinding());
assertSameType(tRef.getTemplateParameterMap().getArgument(0).getTypeValue(), Sint);
@@ -7454,8 +7488,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper assertionHelper = getAssertionHelper();
- ICPPAliasTemplateInstance AliasInt =
- assertionHelper.assertNonProblem("Alias<int> intAlias;", "Alias<int>", ICPPAliasTemplateInstance.class);
+ ICPPAliasTemplateInstance AliasInt = assertionHelper.assertNonProblem("Alias<int> intAlias;", "Alias<int>",
+ ICPPAliasTemplateInstance.class);
assertEquals("Alias", AliasInt.getName());
assertEquals("NS", AliasInt.getQualifiedName()[0]);
assertEquals("Alias", AliasInt.getQualifiedName()[1]);
@@ -7463,7 +7497,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertInstance(aliasedType, ICPPTemplateInstance.class);
ICPPTemplateArgument[] args = ((ICPPTemplateInstance) aliasedType).getTemplateArguments();
assertEquals(1, args.length);
- assertSameType(CommonCPPTypes.int_, args[0].getTypeValue());
+ assertSameType(CommonCPPTypes.int_, args[0].getTypeValue());
ICPPNamespace namespaceNS = assertionHelper.assertNonProblem("using namespace NS;", "NS", ICPPNamespace.class);
assertEquals(namespaceNS, AliasInt.getOwner());
@@ -7854,7 +7888,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testConstexprFunctionCallInTemplateArgument_332829() throws Exception {
parseAndCheckBindings();
}
-
+
// struct IntConvertible {
// constexpr operator int() const { return 42; }
// };
@@ -7866,7 +7900,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testUniformInitializationInTemplateArgument_510010() throws Exception {
parseAndCheckBindings();
}
-
+
// int f() {
// int i = 0;
// if(i < 1){
@@ -8314,26 +8348,26 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertEquals(1, num.longValue());
}
- // template <int>
+ // template <int>
// struct A {
// void waldo();
// };
- //
- // template <typename>
+ //
+ // template <typename>
// struct traits {
// enum {
// E = 1,
// };
// };
//
- // template <typename T>
+ // template <typename T>
// struct L {
- // enum {
+ // enum {
// X = traits<T>::E & 1
// };
// };
- //
- // template <typename T>
+ //
+ // template <typename T>
// struct B : A<L<T>::X> {
// using A<L<T>::X>::waldo;
// };
@@ -8627,7 +8661,6 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertVariableValue(answer, 1);
}
-
// template <template <class> class ... Mixins>
// struct C : Mixins<int>... {};
//
@@ -9020,7 +9053,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testDecltypeInPackExpansion_486425b() throws Exception {
parseAndCheckBindings();
}
-
+
// template <typename T>
// T __declval();
//
@@ -9034,8 +9067,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testDeclvalDeclaration_540957() throws Exception {
parseAndCheckBindings();
}
-
- // template <typename T>
+
+ // template <typename T>
// class meta {
// typedef T type;
// };
@@ -9052,7 +9085,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testDependentPackExpansionInFunctionType_526684() throws Exception {
parseAndCheckBindings();
}
-
+
// template <int> struct __make;
// template <> struct __make<2> { typedef int type; };
//
@@ -9070,7 +9103,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ITypedef waldo = helper.assertNonProblem("Waldo");
assertSameType(CommonCPPTypes.int_, waldo);
}
-
+
// template <int, class>
// struct A {};
//
@@ -9220,7 +9253,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testUnqualifiedFunctionCallInTemplate_402498d() throws Exception {
parseAndCheckBindings();
}
-
+
// void bar();
//
// template <typename T>
@@ -9605,12 +9638,12 @@ public class AST2TemplateTests extends AST2CPPTestBase {
ICPPVariable waldo = helper.assertNonProblem("waldo");
assertConstantValue(0, waldo);
}
-
+
// template <typename T>
// struct traits {
// static constexpr int Flags = 1;
// };
- //
+ //
// template <typename T>
// struct S {
// static constexpr int a = traits<T>::Flags;
@@ -9792,7 +9825,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
IVariable var2 = helper.assertNonProblem("var2");
assertSameType(var1.getType(), var2.getType());
}
-
+
// template <typename T>
// void foo() {
// typedef decltype(T::member) C;
@@ -9937,7 +9970,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testAmbiguityResolutionInNestedClassMethodBody_485388() throws Exception {
parseAndCheckBindings();
}
-
+
// template <typename...>
// struct Voider {
// using type = void;
@@ -10104,7 +10137,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
IVariable waldo = helper.assertNonProblem("waldo");
helper.assertVariableValue("waldo", -13);
}
-
+
// template<int P, int Q>
// struct gcd : gcd<Q, P % Q> {};
//
@@ -10131,7 +10164,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// template<typename R1, typename R2>
// struct ratio_multiply {
- // static constexpr int div = gcd<1, R1::den>::value;
+ // static constexpr int div = gcd<1, R1::den>::value;
// typedef ratio<1, R1::den / div> type;
// };
//
@@ -10141,8 +10174,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// Just check that resolution does not throw an exception.
helper.findName("waldo").resolveBinding();
}
-
- // template <typename Ty>
+
+ // template <typename Ty>
// struct has_rbegin_impl {
// typedef char yes[1];
// typedef char no[2];
@@ -10176,7 +10209,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testSFINAEInEvalIdWithFieldOwner_510834() throws Exception {
parseAndCheckBindings();
}
-
+
// class C {};
//
// void aux(C);
@@ -10194,7 +10227,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testSFINAEInDecltype_516291a() throws Exception {
parseAndCheckBindings();
}
-
+
// class C {};
//
// void aux(C);
@@ -10212,8 +10245,8 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testSFINAEInDecltype_516291b() throws Exception {
parseAndCheckBindings();
}
-
- // template <typename>
+
+ // template <typename>
// using void_t = void;
//
// template <typename T, typename = void>
@@ -10228,7 +10261,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testSFINAEInAliasTemplateArgs_516338() throws Exception {
parseAndCheckBindings();
}
-
+
// template <typename, typename>
// struct is_same {
// static constexpr bool value = false;
@@ -10264,7 +10297,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testInstantiationOfEvalIdWithFieldOwner_511108() throws Exception {
parseAndCheckBindings();
}
-
+
// class C {};
// typedef C D;
//
@@ -10280,7 +10313,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testDependentDestructorName_511122() throws Exception {
parseAndCheckBindings();
}
-
+
// template <class T>
// using alias = T;
//
@@ -10299,6 +10332,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testNoexceptSpecifierInTypeTemplateArgument_511186() throws Exception {
parseAndCheckBindings();
}
+
// namespace ns {
//
// template <typename T>
@@ -10318,7 +10352,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testFriendFunctionDeclarationInNamespace_513681() throws Exception {
parseAndCheckBindings();
}
-
+
// template<class T, unsigned long Size = sizeof(T)>
// class foobar {};
//
@@ -10332,7 +10366,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testDependentSizeofInDefaultArgument_513430() throws Exception {
parseAndCheckBindings();
}
-
+
// struct S {
// int& foo();
// };
@@ -10348,7 +10382,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testDependentMemberAccess_516290() throws Exception {
parseAndCheckBindings();
}
-
+
// template <typename>
// struct A;
//
@@ -10360,7 +10394,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testDelegatingConstructorInPartialSpecialization_512932() throws Exception {
parseAndCheckBindings();
}
-
+
// enum class E { F };
//
// template <unsigned char>
@@ -10375,7 +10409,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testOverloadingOnTypeOfNonTypeTemplateParameter_512932() throws Exception {
parseAndCheckBindings();
}
-
+
// template <typename T>
// void waldo(T&);
//
@@ -10388,7 +10422,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testReferenceBinding_Regression_516284() throws Exception {
parseAndCheckBindings();
}
-
+
// // Declare a constexpr function that turns int and int& into different values.
// template <typename T> constexpr int foo();
// template <> constexpr int foo<int>() { return 42; };
@@ -10410,7 +10444,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// Check that the TypeOfDependentExpression instantiated to the correct type.
helper.assertVariableValue("waldo", 42);
}
-
+
// template <int N>
// struct Model {
// static constexpr int getFamily() {
@@ -10427,7 +10461,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableValue("waldo", 1300);
}
-
+
// template <int N>
// struct constant {
// static constexpr int value = N;
@@ -10448,7 +10482,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableValue("waldo", 1300);
}
-
+
// template <class>
// struct A {
// template <class>
@@ -10465,7 +10499,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testMemberOfUnknownMemberClass_519819() throws Exception {
parseAndCheckBindings();
}
-
+
// template <class> class any {};
// typedef any<any<any<any<any<any<any<any<any<any<any<any<any<any<any<any<
// any<any<any<any<any<any<any<any<any<any<any<any<any<any<any<
@@ -10512,7 +10546,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
assertNotNull(problem);
assertEquals(IProblem.TEMPLATE_ARGUMENT_NESTING_DEPTH_LIMIT_EXCEEDED, problem.getID());
}
-
+
// template<class... Ts>
// struct infinite;
//
@@ -10542,7 +10576,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertProblem("generate<400>", "generate<400>");
}
-
+
// template <typename T> T declval();
//
// template <class T>
@@ -10554,13 +10588,13 @@ public class AST2TemplateTests extends AST2CPPTestBase {
IType waldo = helper.assertNonProblem("Waldo");
assertSameType(CommonCPPTypes.void_, waldo);
}
-
+
// template <int, int, int, int, int, int, int, int> int constant8f();
//
// template <int i0, int i1, int i2, int i3>
// void foo() {
// constant8f<
- // i0 < 0, i0 < 0,
+ // i0 < 0, i0 < 0,
// i1 < 0, i1 < 0,
// i2 < 0, i2 < 0,
// i3 < 0, i3 < 0>();
@@ -10568,7 +10602,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testTemplateIdAmbiguity_529696() throws Exception {
parseAndCheckBindings();
}
-
+
// template <int...>
// using index_sequence = int;
//
@@ -10577,7 +10611,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testTemplateAliasWithVariadicNonTypeArgs_530086a() throws Exception {
parseAndCheckBindings();
}
-
+
// template <int...>
// struct integer_sequence {};
//
@@ -10586,14 +10620,14 @@ public class AST2TemplateTests extends AST2CPPTestBase {
//
// template <typename, int... I>
// void bar(index_sequence<I...>);
- //
+ //
// void foo() {
// bar<int>(integer_sequence<0>{});
// }
public void testTemplateAliasWithVariadicArgs_530086b() throws Exception {
parseAndCheckBindings();
}
-
+
// template<bool, typename _Tp = void>
// struct enable_if {};
//
@@ -10812,7 +10846,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableValue("waldo", 42);
}
-
+
// namespace std {
// template <class E>
// struct initializer_list {
@@ -10843,7 +10877,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testOverloadResolutionWithInitializerList_531322() throws Exception {
parseAndCheckBindings();
}
-
+
// using size_t = decltype(sizeof(int));
//
// template <class Fn, class... Ts>
@@ -10937,7 +10971,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// // Make it long enough to be sure that if the runtime is exponential
// // in the length of the list, the test suite times out.
// TypeList<int, short, void, float, double, long, char
- // int*, short*, void*, float*, double*, long*, char*>,
+ // int*, short*, void*, float*, double*, long*, char*>,
// Empty,
// MetaFlip<Fn>>;
//
@@ -10951,7 +10985,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testMetaprogrammingWithAliasTemplates_534126() throws Exception {
parseAndCheckBindings();
}
-
+
// template <class>
// struct hhh {
// using type = int;
@@ -11038,7 +11072,7 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// template <typename> struct B;
// using C = B<A>;
public void testInvalidAliasTemplateWithTemplateTemplateParameter_540676() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), CPP);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
bh.assertProblem("B<A>", 4);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java
index 9d9f2370519..569c4fbdede 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java
@@ -101,13 +101,13 @@ import junit.framework.AssertionFailedError;
public class AST2TestBase extends SemanticTestBase {
public final static String TEST_CODE = "<testcode>";
protected static final IParserLogService NULL_LOG = new NullLogService();
- protected static boolean sValidateCopy;
+ protected static boolean sValidateCopy;
- private static final ScannerInfo GNU_SCANNER_INFO = new ScannerInfo(getGnuMap());
+ private static final ScannerInfo GNU_SCANNER_INFO = new ScannerInfo(getGnuMap());
private static final ScannerInfo SCANNER_INFO = new ScannerInfo(getStdMap());
private static Map<String, String> getGnuMap() {
- Map<String, String> map= new HashMap<>();
+ Map<String, String> map = new HashMap<>();
map.put("__GNUC__", Integer.toString(GCC_MAJOR_VERSION_FOR_TESTS));
map.put("__GNUC_MINOR__", Integer.toString(GCC_MINOR_VERSION_FOR_TESTS));
map.put("__SIZEOF_SHORT__", "2");
@@ -119,7 +119,7 @@ public class AST2TestBase extends SemanticTestBase {
}
private static Map<String, String> getStdMap() {
- Map<String, String> map= new HashMap<>();
+ Map<String, String> map = new HashMap<>();
map.put("__SIZEOF_SHORT__", "2");
map.put("__SIZEOF_INT__", "4");
map.put("__SIZEOF_LONG__", "8");
@@ -128,80 +128,81 @@ public class AST2TestBase extends SemanticTestBase {
return map;
}
- public AST2TestBase() {
- super();
- }
+ public AST2TestBase() {
+ super();
+ }
public AST2TestBase(String name) {
- super(name);
- }
+ super(name);
+ }
- @Override
+ @Override
protected void setUp() throws Exception {
- sValidateCopy= true;
+ sValidateCopy = true;
super.setUp();
}
protected IASTTranslationUnit parse(String code, ParserLanguage lang) throws ParserException {
- return parse(code, lang, false, true);
- }
-
- protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions) throws ParserException {
- return parse(code, lang, useGNUExtensions, true);
- }
-
- protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions,
- boolean expectNoProblems) throws ParserException {
- return parse(code, lang, useGNUExtensions, expectNoProblems, Integer.MAX_VALUE);
- }
-
- protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions,
- boolean expectNoProblems, int limitTrivialInitializers) throws ParserException {
- IScanner scanner = createScanner(FileContent.create(TEST_CODE, code.toCharArray()), lang, ParserMode.COMPLETE_PARSE,
- createScannerInfo(useGNUExtensions));
- configureScanner(scanner);
- AbstractGNUSourceCodeParser parser = null;
- if (lang == ParserLanguage.CPP) {
- ICPPParserExtensionConfiguration config = null;
- if (useGNUExtensions) {
- config = new GPPParserExtensionConfiguration();
- } else {
- config = new ANSICPPParserExtensionConfiguration();
- }
- parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null);
- } else {
- ICParserExtensionConfiguration config = null;
-
- if (useGNUExtensions) {
- config = new GCCParserExtensionConfiguration();
- } else {
- config = new ANSICParserExtensionConfiguration();
- }
-
- parser = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null);
- }
- parser.setMaximumTrivialExpressionsInAggregateInitializers(limitTrivialInitializers);
-
- IASTTranslationUnit tu = parser.parse();
- assertTrue(tu.isFrozen());
- if (sValidateCopy)
- validateCopy(tu);
-
- if (parser.encounteredError() && expectNoProblems)
- throw new ParserException("FAILURE"); //$NON-NLS-1$
-
- if (lang == ParserLanguage.C && expectNoProblems) {
- assertEquals(CVisitor.getProblems(tu).length, 0);
- assertEquals(tu.getPreprocessorProblems().length, 0);
- } else if (lang == ParserLanguage.CPP && expectNoProblems) {
- assertEquals(CPPVisitor.getProblems(tu).length, 0);
- assertEquals(0, tu.getPreprocessorProblems().length);
- }
- if (expectNoProblems)
- assertEquals(0, tu.getPreprocessorProblems().length);
-
- return tu;
- }
+ return parse(code, lang, false, true);
+ }
+
+ protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions)
+ throws ParserException {
+ return parse(code, lang, useGNUExtensions, true);
+ }
+
+ protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions,
+ boolean expectNoProblems) throws ParserException {
+ return parse(code, lang, useGNUExtensions, expectNoProblems, Integer.MAX_VALUE);
+ }
+
+ protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions,
+ boolean expectNoProblems, int limitTrivialInitializers) throws ParserException {
+ IScanner scanner = createScanner(FileContent.create(TEST_CODE, code.toCharArray()), lang,
+ ParserMode.COMPLETE_PARSE, createScannerInfo(useGNUExtensions));
+ configureScanner(scanner);
+ AbstractGNUSourceCodeParser parser = null;
+ if (lang == ParserLanguage.CPP) {
+ ICPPParserExtensionConfiguration config = null;
+ if (useGNUExtensions) {
+ config = new GPPParserExtensionConfiguration();
+ } else {
+ config = new ANSICPPParserExtensionConfiguration();
+ }
+ parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null);
+ } else {
+ ICParserExtensionConfiguration config = null;
+
+ if (useGNUExtensions) {
+ config = new GCCParserExtensionConfiguration();
+ } else {
+ config = new ANSICParserExtensionConfiguration();
+ }
+
+ parser = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null);
+ }
+ parser.setMaximumTrivialExpressionsInAggregateInitializers(limitTrivialInitializers);
+
+ IASTTranslationUnit tu = parser.parse();
+ assertTrue(tu.isFrozen());
+ if (sValidateCopy)
+ validateCopy(tu);
+
+ if (parser.encounteredError() && expectNoProblems)
+ throw new ParserException("FAILURE"); //$NON-NLS-1$
+
+ if (lang == ParserLanguage.C && expectNoProblems) {
+ assertEquals(CVisitor.getProblems(tu).length, 0);
+ assertEquals(tu.getPreprocessorProblems().length, 0);
+ } else if (lang == ParserLanguage.CPP && expectNoProblems) {
+ assertEquals(CPPVisitor.getProblems(tu).length, 0);
+ assertEquals(0, tu.getPreprocessorProblems().length);
+ }
+ if (expectNoProblems)
+ assertEquals(0, tu.getPreprocessorProblems().length);
+
+ return tu;
+ }
public ScannerInfo createScannerInfo(boolean useGnu) {
if (useGnu)
@@ -215,134 +216,137 @@ public class AST2TestBase extends SemanticTestBase {
public static IScanner createScanner(FileContent codeReader, ParserLanguage lang, ParserMode mode,
IScannerInfo scannerInfo) {
IScannerExtensionConfiguration configuration = null;
- if (lang == ParserLanguage.C) {
- configuration= GCCScannerExtensionConfiguration.getInstance(scannerInfo);
- } else {
- configuration= GPPScannerExtensionConfiguration.getInstance(scannerInfo);
- }
- IScanner scanner;
- scanner= new CPreprocessor(codeReader, scannerInfo, lang, NULL_LOG, configuration,
- IncludeFileContentProvider.getSavedFilesProvider());
+ if (lang == ParserLanguage.C) {
+ configuration = GCCScannerExtensionConfiguration.getInstance(scannerInfo);
+ } else {
+ configuration = GPPScannerExtensionConfiguration.getInstance(scannerInfo);
+ }
+ IScanner scanner;
+ scanner = new CPreprocessor(codeReader, scannerInfo, lang, NULL_LOG, configuration,
+ IncludeFileContentProvider.getSavedFilesProvider());
return scanner;
}
- protected void validateSimplePostfixInitializerExpressionC(String code) throws ParserException {
- ICASTTypeIdInitializerExpression e = (ICASTTypeIdInitializerExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
- assertNotNull(e);
- assertNotNull(e.getTypeId());
- assertNotNull(e.getInitializer());
- }
-
- protected void validateSimpleUnaryTypeIdExpression(String code, int op) throws ParserException {
- IASTCastExpression e = (IASTCastExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
- assertNotNull(e);
- assertEquals(e.getOperator(), op);
- assertNotNull(e.getTypeId());
- IASTIdExpression x = (IASTIdExpression) e.getOperand();
- assertEquals(x.getName().toString(), "x"); //$NON-NLS-1$
- }
-
- protected void validateSimpleTypeIdExpressionC(String code, int op) throws ParserException {
- IASTTypeIdExpression e = (IASTTypeIdExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
- assertNotNull(e);
- assertEquals(e.getOperator(), op);
- assertNotNull(e.getTypeId());
- }
-
- protected void validateSimpleUnaryExpressionC(String code, int operator) throws ParserException {
- IASTUnaryExpression e = (IASTUnaryExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
- assertNotNull(e);
- assertEquals(e.getOperator(), operator);
- IASTIdExpression x = (IASTIdExpression) e.getOperand();
- assertEquals(x.getName().toString(), "x"); //$NON-NLS-1$
- }
-
- protected void validateConditionalExpressionC(String code) throws ParserException {
- IASTConditionalExpression e = (IASTConditionalExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
- assertNotNull(e);
- IASTIdExpression x = (IASTIdExpression) e.getLogicalConditionExpression();
- assertEquals(x.getName().toString(), "x"); //$NON-NLS-1$
- IASTIdExpression y = (IASTIdExpression) e.getPositiveResultExpression();
- assertEquals(y.getName().toString(), "y"); //$NON-NLS-1$
- IASTIdExpression x2 = (IASTIdExpression) e.getNegativeResultExpression();
- assertEquals(x.getName().toString(), x2.getName().toString());
- }
-
- protected void validateSimpleBinaryExpressionC(String code, int operand) throws ParserException {
- IASTBinaryExpression e = (IASTBinaryExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
- assertNotNull(e);
- assertEquals(e.getOperator(), operand);
- IASTIdExpression x = (IASTIdExpression) e.getOperand1();
- assertEquals(x.getName().toString(), "x"); //$NON-NLS-1$
- IASTIdExpression y = (IASTIdExpression) e.getOperand2();
- assertEquals(y.getName().toString(), "y"); //$NON-NLS-1$
- }
-
- protected IASTExpression getExpressionFromStatementInCode(String code, ParserLanguage language) throws ParserException {
- StringBuilder buffer = new StringBuilder("void f() { "); //$NON-NLS-1$
- buffer.append("int x, y;\n"); //$NON-NLS-1$
- buffer.append(code);
- buffer.append(";\n}"); //$NON-NLS-1$
- IASTTranslationUnit tu = parse(buffer.toString(), language);
- IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement cs = (IASTCompoundStatement) f.getBody();
- IASTExpressionStatement s = (IASTExpressionStatement) cs.getStatements()[1];
- return s.getExpression();
- }
-
- protected <T extends IASTNode> T validateCopy(T tu) {
+ protected void validateSimplePostfixInitializerExpressionC(String code) throws ParserException {
+ ICASTTypeIdInitializerExpression e = (ICASTTypeIdInitializerExpression) getExpressionFromStatementInCode(code,
+ ParserLanguage.C);
+ assertNotNull(e);
+ assertNotNull(e.getTypeId());
+ assertNotNull(e.getInitializer());
+ }
+
+ protected void validateSimpleUnaryTypeIdExpression(String code, int op) throws ParserException {
+ IASTCastExpression e = (IASTCastExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
+ assertNotNull(e);
+ assertEquals(e.getOperator(), op);
+ assertNotNull(e.getTypeId());
+ IASTIdExpression x = (IASTIdExpression) e.getOperand();
+ assertEquals(x.getName().toString(), "x"); //$NON-NLS-1$
+ }
+
+ protected void validateSimpleTypeIdExpressionC(String code, int op) throws ParserException {
+ IASTTypeIdExpression e = (IASTTypeIdExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
+ assertNotNull(e);
+ assertEquals(e.getOperator(), op);
+ assertNotNull(e.getTypeId());
+ }
+
+ protected void validateSimpleUnaryExpressionC(String code, int operator) throws ParserException {
+ IASTUnaryExpression e = (IASTUnaryExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
+ assertNotNull(e);
+ assertEquals(e.getOperator(), operator);
+ IASTIdExpression x = (IASTIdExpression) e.getOperand();
+ assertEquals(x.getName().toString(), "x"); //$NON-NLS-1$
+ }
+
+ protected void validateConditionalExpressionC(String code) throws ParserException {
+ IASTConditionalExpression e = (IASTConditionalExpression) getExpressionFromStatementInCode(code,
+ ParserLanguage.C);
+ assertNotNull(e);
+ IASTIdExpression x = (IASTIdExpression) e.getLogicalConditionExpression();
+ assertEquals(x.getName().toString(), "x"); //$NON-NLS-1$
+ IASTIdExpression y = (IASTIdExpression) e.getPositiveResultExpression();
+ assertEquals(y.getName().toString(), "y"); //$NON-NLS-1$
+ IASTIdExpression x2 = (IASTIdExpression) e.getNegativeResultExpression();
+ assertEquals(x.getName().toString(), x2.getName().toString());
+ }
+
+ protected void validateSimpleBinaryExpressionC(String code, int operand) throws ParserException {
+ IASTBinaryExpression e = (IASTBinaryExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
+ assertNotNull(e);
+ assertEquals(e.getOperator(), operand);
+ IASTIdExpression x = (IASTIdExpression) e.getOperand1();
+ assertEquals(x.getName().toString(), "x"); //$NON-NLS-1$
+ IASTIdExpression y = (IASTIdExpression) e.getOperand2();
+ assertEquals(y.getName().toString(), "y"); //$NON-NLS-1$
+ }
+
+ protected IASTExpression getExpressionFromStatementInCode(String code, ParserLanguage language)
+ throws ParserException {
+ StringBuilder buffer = new StringBuilder("void f() { "); //$NON-NLS-1$
+ buffer.append("int x, y;\n"); //$NON-NLS-1$
+ buffer.append(code);
+ buffer.append(";\n}"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), language);
+ IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement cs = (IASTCompoundStatement) f.getBody();
+ IASTExpressionStatement s = (IASTExpressionStatement) cs.getStatements()[1];
+ return s.getExpression();
+ }
+
+ protected <T extends IASTNode> T validateCopy(T tu) {
IASTNode copy = tu.copy();
assertFalse(copy.isFrozen());
ASTComparer.assertCopy(tu, copy);
return (T) copy;
}
- static protected class NameCollector extends ASTVisitor {
- public NameCollector() {
- this(false); // don't visit implicit names by default
- }
+ static protected class NameCollector extends ASTVisitor {
+ public NameCollector() {
+ this(false); // don't visit implicit names by default
+ }
- public NameCollector(boolean shouldVisitImplicitNames) {
- this.shouldVisitNames = true;
- this.shouldVisitImplicitNames = shouldVisitImplicitNames;
- }
+ public NameCollector(boolean shouldVisitImplicitNames) {
+ this.shouldVisitNames = true;
+ this.shouldVisitImplicitNames = shouldVisitImplicitNames;
+ }
- public List<IASTName> nameList = new ArrayList<>();
+ public List<IASTName> nameList = new ArrayList<>();
- @Override
+ @Override
public int visit(IASTName name) {
- nameList.add(name);
- return PROCESS_CONTINUE;
- }
-
- public IASTName getName(int idx) {
- if (idx < 0 || idx >= nameList.size())
- return null;
- return nameList.get(idx);
- }
-
- public int size() {
- return nameList.size();
- }
-
- public void dump() {
- for (int i= 0; i < size(); i++) {
- IASTName name= getName(i);
- String parent= name.getParent() != null ? name.getParent().getRawSignature() : "";
- System.out.println(i + ": #" + name.getRawSignature() + "# " + parent);
- }
- }
- }
-
- protected void assertInstances(NameCollector collector, IBinding binding, int num) throws Exception {
- int count = 0;
- for (int i = 0; i < collector.size(); i++) {
- if (collector.getName(i).resolveBinding() == binding)
- count++;
- }
-
- assertEquals(num, count);
- }
+ nameList.add(name);
+ return PROCESS_CONTINUE;
+ }
+
+ public IASTName getName(int idx) {
+ if (idx < 0 || idx >= nameList.size())
+ return null;
+ return nameList.get(idx);
+ }
+
+ public int size() {
+ return nameList.size();
+ }
+
+ public void dump() {
+ for (int i = 0; i < size(); i++) {
+ IASTName name = getName(i);
+ String parent = name.getParent() != null ? name.getParent().getRawSignature() : "";
+ System.out.println(i + ": #" + name.getRawSignature() + "# " + parent);
+ }
+ }
+ }
+
+ protected void assertInstances(NameCollector collector, IBinding binding, int num) throws Exception {
+ int count = 0;
+ for (int i = 0; i < collector.size(); i++) {
+ if (collector.getName(i).resolveBinding() == binding)
+ count++;
+ }
+
+ assertEquals(num, count);
+ }
protected void isExpressionStringEqual(IASTInitializerClause exp, String str) {
String expressionString = ASTStringUtil.getExpressionString((IASTExpression) exp);
@@ -361,7 +365,7 @@ public class AST2TestBase extends SemanticTestBase {
}
protected void isSignatureEqual(IASTDeclarator declarator, String expected) {
- String signature= ASTStringUtil.getSignatureString(declarator);
+ String signature = ASTStringUtil.getSignatureString(declarator);
assertEquals(expected, signature);
}
@@ -461,11 +465,11 @@ public class AST2TestBase extends SemanticTestBase {
}
protected static void assertField(IBinding binding, String fieldName, String ownerName) {
- assertInstance(binding, IField.class);
- assertEquals(fieldName, binding.getName());
- ICompositeType struct = ((IField) binding).getCompositeTypeOwner();
- assertEquals(ownerName, struct.getName());
- }
+ assertInstance(binding, IField.class);
+ assertEquals(fieldName, binding.getName());
+ ICompositeType struct = ((IField) binding).getCompositeTypeOwner();
+ assertEquals(ownerName, struct.getName());
+ }
protected static void assertConstantValue(long expected, IVariable constant) {
IValue value = constant.getInitialValue();
@@ -478,13 +482,13 @@ public class AST2TestBase extends SemanticTestBase {
protected class AST2AssertionHelper extends BindingAssertionHelper {
protected boolean isCPP;
- public AST2AssertionHelper(String contents, boolean isCPP) throws ParserException {
- this(contents, isCPP ? ParserLanguage.CPP : ParserLanguage.C);
+ public AST2AssertionHelper(String contents, boolean isCPP) throws ParserException {
+ this(contents, isCPP ? ParserLanguage.CPP : ParserLanguage.C);
}
- public AST2AssertionHelper(String contents, ParserLanguage lang) throws ParserException {
- super(contents, parse(contents, lang, true, false));
- this.isCPP= lang.isCPP();
+ public AST2AssertionHelper(String contents, ParserLanguage lang) throws ParserException {
+ super(contents, parse(contents, lang, true, false));
+ this.isCPP = lang.isCPP();
}
}
@@ -492,19 +496,20 @@ public class AST2TestBase extends SemanticTestBase {
return parseAndCheckBindings(code, lang, false);
}
- final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang, boolean useGnuExtensions) throws Exception {
+ final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang,
+ boolean useGnuExtensions) throws Exception {
return parseAndCheckBindings(code, lang, useGnuExtensions, Integer.MAX_VALUE);
}
- final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang, boolean useGnuExtensions,
- int limitTrivialInitializers) throws Exception {
+ final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang,
+ boolean useGnuExtensions, int limitTrivialInitializers) throws Exception {
IASTTranslationUnit tu = parse(code, lang, useGnuExtensions, true, limitTrivialInitializers);
NameCollector col = new NameCollector();
tu.accept(col);
assertNoProblemBindings(col);
return tu;
}
-
+
final protected IASTTranslationUnit parseAndCheckImplicitNameBindings() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP, false, true);
NameCollector col = new NameCollector(true /* Visit implicit names */);
@@ -514,7 +519,7 @@ public class AST2TestBase extends SemanticTestBase {
}
protected BindingAssertionHelper getAssertionHelper(ParserLanguage lang) throws ParserException, IOException {
- String code= getAboveComment();
+ String code = getAboveComment();
return new AST2AssertionHelper(code, lang);
}
@@ -535,34 +540,34 @@ public class AST2TestBase extends SemanticTestBase {
final protected <T extends IASTDeclaration> T getDeclaration(IASTTranslationUnit tu, int i_decl) {
Class<T> tclass;
- IASTDeclaration[] decls= tu.getDeclarations();
+ IASTDeclaration[] decls = tu.getDeclarations();
assertTrue(decls.length > i_decl);
return (T) decls[i_decl];
}
final protected <T extends IASTDeclaration> T getDeclaration(ICPPASTNamespaceDefinition ns, int i_decl) {
Class<T> tclass;
- IASTDeclaration[] decls= ns.getDeclarations();
+ IASTDeclaration[] decls = ns.getDeclarations();
assertTrue(decls.length > i_decl);
return (T) decls[i_decl];
}
final protected <T extends IASTDeclaration> T getDeclaration(ICPPASTLinkageSpecification ls, int i_decl) {
Class<T> tclass;
- IASTDeclaration[] decls= ls.getDeclarations();
+ IASTDeclaration[] decls = ls.getDeclarations();
assertTrue(decls.length > i_decl);
return (T) decls[i_decl];
}
final protected <T extends IASTDeclaration> T getDeclaration(IASTCompositeTypeSpecifier ct, int i_decl) {
Class<T> tclass;
- IASTDeclaration[] decls= ct.getMembers();
+ IASTDeclaration[] decls = ct.getMembers();
assertTrue(decls.length > i_decl);
return (T) decls[i_decl];
}
final protected <T extends IASTCompositeTypeSpecifier> T getCompositeType(IASTTranslationUnit tu, int i_decl) {
- IASTSimpleDeclaration sdecl= getDeclaration(tu, i_decl);
+ IASTSimpleDeclaration sdecl = getDeclaration(tu, i_decl);
return (T) sdecl.getDeclSpecifier();
}
@@ -571,17 +576,17 @@ public class AST2TestBase extends SemanticTestBase {
}
final protected <T extends IASTStatement> T getStatement(IASTCompoundStatement compound, int i_stmt) {
- IASTStatement[] stmts= compound.getStatements();
+ IASTStatement[] stmts = compound.getStatements();
assertTrue(stmts.length > i_stmt);
return (T) stmts[i_stmt];
}
final protected <T extends IASTExpression> T getExpressionOfStatement(IASTFunctionDefinition fdef, int i) {
- IASTStatement stmt= getStatement(fdef, i);
+ IASTStatement stmt = getStatement(fdef, i);
assertInstance(stmt, IASTExpressionStatement.class);
return (T) ((IASTExpressionStatement) stmt).getExpression();
}
-
+
/**
* Sort the given array of AST names lexicographically.
*/
@@ -590,6 +595,7 @@ public class AST2TestBase extends SemanticTestBase {
@Override
public int compare(IASTName a, IASTName b) {
return a.toString().compareTo(b.toString());
- }});
+ }
+ });
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
index 86c625f9d1d..3f42935de6f 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
@@ -160,7 +160,7 @@ public class AST2Tests extends AST2TestBase {
}
private void parseAndCheckBindings(boolean useGnuExtensions) throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code, C, useGnuExtensions);
parseAndCheckBindings(code, CPP, useGnuExtensions);
}
@@ -235,8 +235,7 @@ public class AST2Tests extends AST2TestBase {
// function - void f()
IASTFunctionDefinition funcdef_f = (IASTFunctionDefinition) declarations[1];
- IASTSimpleDeclSpecifier declspec_f =
- (IASTSimpleDeclSpecifier) funcdef_f.getDeclSpecifier();
+ IASTSimpleDeclSpecifier declspec_f = (IASTSimpleDeclSpecifier) funcdef_f.getDeclSpecifier();
assertEquals(IASTSimpleDeclSpecifier.t_void, declspec_f.getType());
IASTFunctionDeclarator declor_f = funcdef_f.getDeclarator();
IASTName name_f = declor_f.getName();
@@ -244,8 +243,7 @@ public class AST2Tests extends AST2TestBase {
// parameter - int y
assertTrue(declor_f instanceof IASTStandardFunctionDeclarator);
- IASTParameterDeclaration decl_y =
- ((IASTStandardFunctionDeclarator) declor_f).getParameters()[0];
+ IASTParameterDeclaration decl_y = ((IASTStandardFunctionDeclarator) declor_f).getParameters()[0];
IASTSimpleDeclSpecifier declspec_y = (IASTSimpleDeclSpecifier) decl_y.getDeclSpecifier();
assertEquals(IASTSimpleDeclSpecifier.t_int, declspec_y.getType());
IASTDeclarator declor_y = decl_y.getDeclarator();
@@ -254,11 +252,9 @@ public class AST2Tests extends AST2TestBase {
// int z
IASTCompoundStatement body_f = (IASTCompoundStatement) funcdef_f.getBody();
- IASTDeclarationStatement declstmt_z =
- (IASTDeclarationStatement) body_f.getStatements()[0];
+ IASTDeclarationStatement declstmt_z = (IASTDeclarationStatement) body_f.getStatements()[0];
IASTSimpleDeclaration decl_z = (IASTSimpleDeclaration) declstmt_z.getDeclaration();
- IASTSimpleDeclSpecifier declspec_z =
- (IASTSimpleDeclSpecifier) decl_z.getDeclSpecifier();
+ IASTSimpleDeclSpecifier declspec_z = (IASTSimpleDeclSpecifier) decl_z.getDeclSpecifier();
assertEquals(IASTSimpleDeclSpecifier.t_int, declspec_z.getType());
IASTDeclarator declor_z = decl_z.getDeclarators()[0];
IASTName name_z = declor_z.getName();
@@ -283,8 +279,7 @@ public class AST2Tests extends AST2TestBase {
IFunction func_f = (IFunction) name_f.resolveBinding();
assertEquals(globalScope, func_f.getScope());
IParameter var_y = (IParameter) name_y.resolveBinding();
- assertEquals(((IASTCompoundStatement) funcdef_f.getBody()).getScope(),
- var_y.getScope());
+ assertEquals(((IASTCompoundStatement) funcdef_f.getBody()).getScope(), var_y.getScope());
IVariable var_z = (IVariable) name_z.resolveBinding();
assertEquals(((ICFunctionScope) func_f.getFunctionScope()).getBodyScope(), var_z.getScope());
@@ -472,63 +467,40 @@ public class AST2Tests extends AST2TestBase {
validateSimpleUnaryExpressionC("~x", IASTUnaryExpression.op_tilde); //$NON-NLS-1$
validateSimpleUnaryExpressionC("*x", IASTUnaryExpression.op_star); //$NON-NLS-1$
validateSimpleUnaryExpressionC("&x", IASTUnaryExpression.op_amper); //$NON-NLS-1$
- validateSimpleUnaryExpressionC(
- "sizeof x", IASTUnaryExpression.op_sizeof); //$NON-NLS-1$
- validateSimpleTypeIdExpressionC(
- "sizeof(int)", IASTTypeIdExpression.op_sizeof); //$NON-NLS-1$
- validateSimpleUnaryTypeIdExpression(
- "(int)x", IASTCastExpression.op_cast); //$NON-NLS-1$
+ validateSimpleUnaryExpressionC("sizeof x", IASTUnaryExpression.op_sizeof); //$NON-NLS-1$
+ validateSimpleTypeIdExpressionC("sizeof(int)", IASTTypeIdExpression.op_sizeof); //$NON-NLS-1$
+ validateSimpleUnaryTypeIdExpression("(int)x", IASTCastExpression.op_cast); //$NON-NLS-1$
validateSimplePostfixInitializerExpressionC("(int) { 5 }"); //$NON-NLS-1$
validateSimplePostfixInitializerExpressionC("(int) { 5, }"); //$NON-NLS-1$
validateSimpleBinaryExpressionC("x=y", IASTBinaryExpression.op_assign); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x*=y", IASTBinaryExpression.op_multiplyAssign); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x/=y", IASTBinaryExpression.op_divideAssign); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x%=y", IASTBinaryExpression.op_moduloAssign); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x+=y", IASTBinaryExpression.op_plusAssign); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x-=y", IASTBinaryExpression.op_minusAssign); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x<<=y", IASTBinaryExpression.op_shiftLeftAssign); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x>>=y", IASTBinaryExpression.op_shiftRightAssign); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x&=y", IASTBinaryExpression.op_binaryAndAssign); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x^=y", IASTBinaryExpression.op_binaryXorAssign); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x|=y", IASTBinaryExpression.op_binaryOrAssign); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x*=y", IASTBinaryExpression.op_multiplyAssign); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x/=y", IASTBinaryExpression.op_divideAssign); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x%=y", IASTBinaryExpression.op_moduloAssign); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x+=y", IASTBinaryExpression.op_plusAssign); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x-=y", IASTBinaryExpression.op_minusAssign); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x<<=y", IASTBinaryExpression.op_shiftLeftAssign); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x>>=y", IASTBinaryExpression.op_shiftRightAssign); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x&=y", IASTBinaryExpression.op_binaryAndAssign); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x^=y", IASTBinaryExpression.op_binaryXorAssign); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x|=y", IASTBinaryExpression.op_binaryOrAssign); //$NON-NLS-1$
validateSimpleBinaryExpressionC("x-y", IASTBinaryExpression.op_minus); //$NON-NLS-1$
validateSimpleBinaryExpressionC("x+y", IASTBinaryExpression.op_plus); //$NON-NLS-1$
validateSimpleBinaryExpressionC("x/y", IASTBinaryExpression.op_divide); //$NON-NLS-1$
validateSimpleBinaryExpressionC("x*y", IASTBinaryExpression.op_multiply); //$NON-NLS-1$
validateSimpleBinaryExpressionC("x%y", IASTBinaryExpression.op_modulo); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x<<y", IASTBinaryExpression.op_shiftLeft); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x>>y", IASTBinaryExpression.op_shiftRight); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x<<y", IASTBinaryExpression.op_shiftLeft); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x>>y", IASTBinaryExpression.op_shiftRight); //$NON-NLS-1$
validateSimpleBinaryExpressionC("x<y", IASTBinaryExpression.op_lessThan); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x>y", IASTBinaryExpression.op_greaterThan); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x<=y", IASTBinaryExpression.op_lessEqual); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x>=y", IASTBinaryExpression.op_greaterEqual); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x>y", IASTBinaryExpression.op_greaterThan); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x<=y", IASTBinaryExpression.op_lessEqual); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x>=y", IASTBinaryExpression.op_greaterEqual); //$NON-NLS-1$
validateSimpleBinaryExpressionC("x==y", IASTBinaryExpression.op_equals); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x!=y", IASTBinaryExpression.op_notequals); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x&y", IASTBinaryExpression.op_binaryAnd); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x^y", IASTBinaryExpression.op_binaryXor); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x!=y", IASTBinaryExpression.op_notequals); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x&y", IASTBinaryExpression.op_binaryAnd); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x^y", IASTBinaryExpression.op_binaryXor); //$NON-NLS-1$
validateSimpleBinaryExpressionC("x|y", IASTBinaryExpression.op_binaryOr); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x&&y", IASTBinaryExpression.op_logicalAnd); //$NON-NLS-1$
- validateSimpleBinaryExpressionC(
- "x||y", IASTBinaryExpression.op_logicalOr); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x&&y", IASTBinaryExpression.op_logicalAnd); //$NON-NLS-1$
+ validateSimpleBinaryExpressionC("x||y", IASTBinaryExpression.op_logicalOr); //$NON-NLS-1$
validateConditionalExpressionC("x ? y : x"); //$NON-NLS-1$
}
@@ -1154,8 +1126,7 @@ public class AST2Tests extends AST2TestBase {
IASTForStatement for_stmt = (IASTForStatement) compound.getStatements()[0];
// int i = 0;
- IASTDeclarationStatement declStatement =
- (IASTDeclarationStatement) for_stmt.getInitializerStatement();
+ IASTDeclarationStatement declStatement = (IASTDeclarationStatement) for_stmt.getInitializerStatement();
IASTSimpleDeclaration initDecl = (IASTSimpleDeclaration) declStatement.getDeclaration();
IASTDeclarator dtor = initDecl.getDeclarators()[0];
IASTName name_i = dtor.getName();
@@ -1250,9 +1221,10 @@ public class AST2Tests extends AST2TestBase {
assertEquals(decls[0], fdef.getDeclarator().getName());
fieldRef = (IASTFieldReference) expStatement.getExpression();
- IASTCastExpression castExpression =
- (IASTCastExpression) ((IASTUnaryExpression) fieldRef.getFieldOwner()).getOperand();
- IASTElaboratedTypeSpecifier elaboratedTypeSpecifier = ((IASTElaboratedTypeSpecifier) castExpression.getTypeId().getDeclSpecifier());
+ IASTCastExpression castExpression = (IASTCastExpression) ((IASTUnaryExpression) fieldRef.getFieldOwner())
+ .getOperand();
+ IASTElaboratedTypeSpecifier elaboratedTypeSpecifier = ((IASTElaboratedTypeSpecifier) castExpression
+ .getTypeId().getDeclSpecifier());
decls = tu.getDeclarationsInAST(elaboratedTypeSpecifier.getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], compType.getName());
@@ -1315,10 +1287,8 @@ public class AST2Tests extends AST2TestBase {
IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) tu.getDeclarations()[1];
IASTName name_X1 = decl1.getDeclarators()[0].getName();
IASTName name_f = decl2.getDeclarators()[0].getName();
- IASTStandardFunctionDeclarator functionDecl =
- (IASTStandardFunctionDeclarator) decl2.getDeclarators()[0];
- IASTName name_X2 =
- ((IASTNamedTypeSpecifier) functionDecl.getParameters()[0].getDeclSpecifier()).getName();
+ IASTStandardFunctionDeclarator functionDecl = (IASTStandardFunctionDeclarator) decl2.getDeclarators()[0];
+ IASTName name_X2 = ((IASTNamedTypeSpecifier) functionDecl.getParameters()[0].getDeclSpecifier()).getName();
IASTName name_x = functionDecl.getParameters()[0].getDeclarator().getName();
IASTName[] decls = tu.getDeclarationsInAST(name_X1.resolveBinding());
@@ -1627,10 +1597,14 @@ public class AST2Tests extends AST2TestBase {
public void testBug270275_int_is_equivalent_to_signed_int() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), C);
IASTDeclaration[] declarations = tu.getDeclarations();
- IType plainInt = ((IVariable)((IASTSimpleDeclaration) declarations[0]).getDeclarators()[0].getName().resolveBinding()).getType();
- IType signedInt = ((IVariable)((IASTSimpleDeclaration) declarations[1]).getDeclarators()[0].getName().resolveBinding()).getType();
- IType unsignedInt = ((IVariable)((IASTSimpleDeclaration) declarations[2]).getDeclarators()[0].getName().resolveBinding()).getType();
- IType noSpec = ((IVariable)((IASTSimpleDeclaration) declarations[3]).getDeclarators()[0].getName().resolveBinding()).getType();
+ IType plainInt = ((IVariable) ((IASTSimpleDeclaration) declarations[0]).getDeclarators()[0].getName()
+ .resolveBinding()).getType();
+ IType signedInt = ((IVariable) ((IASTSimpleDeclaration) declarations[1]).getDeclarators()[0].getName()
+ .resolveBinding()).getType();
+ IType unsignedInt = ((IVariable) ((IASTSimpleDeclaration) declarations[2]).getDeclarators()[0].getName()
+ .resolveBinding()).getType();
+ IType noSpec = ((IVariable) ((IASTSimpleDeclaration) declarations[3]).getDeclarators()[0].getName()
+ .resolveBinding()).getType();
assertTrue(plainInt.isSameType(signedInt));
assertFalse(plainInt.isSameType(unsignedInt));
assertFalse(signedInt.isSameType(unsignedInt));
@@ -1812,20 +1786,25 @@ public class AST2Tests extends AST2TestBase {
decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
IFunction f = (IFunction) decl.getDeclarators()[0].getName().resolveBinding();
IASTName name_f = decl.getDeclarators()[0].getName();
- IASTName name_i = ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getParameters()[0].getDeclarator().getName();
- IASTName name_c = ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getParameters()[1].getDeclarator().getName();
+ IASTName name_i = ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getParameters()[0]
+ .getDeclarator().getName();
+ IASTName name_c = ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getParameters()[1]
+ .getDeclarator().getName();
decl = (IASTSimpleDeclaration) tu.getDeclarations()[2];
IVariable g = (IVariable) decl.getDeclarators()[0].getNestedDeclarator().getName().resolveBinding();
IASTName name_g = decl.getDeclarators()[0].getNestedDeclarator().getName();
- IASTName name_A2 = ((IASTElaboratedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getParameters()[0].getDeclSpecifier()).getName();
+ IASTName name_A2 = ((IASTElaboratedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl
+ .getDeclarators()[0]).getParameters()[0].getDeclSpecifier()).getName();
decl = (IASTSimpleDeclaration) tu.getDeclarations()[3];
- IVariable h = (IVariable) decl.getDeclarators()[0].getNestedDeclarator().getNestedDeclarator().getName().resolveBinding();
+ IVariable h = (IVariable) decl.getDeclarators()[0].getNestedDeclarator().getNestedDeclarator().getName()
+ .resolveBinding();
IASTName name_h = decl.getDeclarators()[0].getNestedDeclarator().getNestedDeclarator().getName();
- IASTName name_A3 = ((IASTElaboratedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0].getNestedDeclarator()).getParameters()[0]
- .getDeclSpecifier()).getName();
- IASTName name_d = ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getParameters()[0].getDeclarator().getName();
+ IASTName name_A3 = ((IASTElaboratedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]
+ .getNestedDeclarator()).getParameters()[0].getDeclSpecifier()).getName();
+ IASTName name_d = ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getParameters()[0]
+ .getDeclarator().getName();
IFunctionType t_f = f.getType();
IType t_f_return = t_f.getReturnType();
@@ -1907,7 +1886,7 @@ public class AST2Tests extends AST2TestBase {
assertEquals(decls.length, 1);
assertEquals(decls[0], name_A1);
- assertNull("Expected null, got "+name_d.resolveBinding(), name_d.resolveBinding());
+ assertNull("Expected null, got " + name_d.resolveBinding(), name_d.resolveBinding());
tu = validateCopy(tu);
}
@@ -1933,34 +1912,47 @@ public class AST2Tests extends AST2TestBase {
assertNotNull(tu);
IASTDeclaration[] declarations = tu.getDeclarations();
IASTName name_Coord = ((IASTSimpleDeclaration) declarations[0]).getDeclarators()[0].getName();
- IASTName name_x = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[0]).getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
- IASTName name_y = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[0]).getDeclSpecifier()).getMembers()[1]).getDeclarators()[0].getName();
+ IASTName name_x = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[0])
+ .getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
+ IASTName name_y = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[0])
+ .getDeclSpecifier()).getMembers()[1]).getDeclarators()[0].getName();
IASTName name_Point = ((IASTSimpleDeclaration) declarations[1]).getDeclarators()[0].getName();
- IASTName name_pos = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[1]).getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
- IASTName name_width = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[1]).getDeclSpecifier()).getMembers()[1]).getDeclarators()[0].getName();
+ IASTName name_pos = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[1])
+ .getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
+ IASTName name_width = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[1])
+ .getDeclSpecifier()).getMembers()[1]).getDeclarators()[0].getName();
IASTFunctionDefinition main = (IASTFunctionDefinition) declarations[2];
IASTStatement[] statements = ((IASTCompoundStatement) main.getBody()).getStatements();
- IASTSimpleDeclaration xy = (IASTSimpleDeclaration) ((IASTDeclarationStatement) statements[0]).getDeclaration();
+ IASTSimpleDeclaration xy = (IASTSimpleDeclaration) ((IASTDeclarationStatement) statements[0])
+ .getDeclaration();
IASTName name_Coord2 = ((IASTNamedTypeSpecifier) xy.getDeclSpecifier()).getName();
IASTName name_xy = xy.getDeclarators()[0].getName();
IASTDeclarator declarator_xy = xy.getDeclarators()[0];
- IASTInitializer[] initializers1 = ((IASTInitializerList) ((IASTEqualsInitializer) declarator_xy.getInitializer()).getInitializerClause()).getInitializers();
- IASTName name_y2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers1[0]).getDesignators()[0]).getName();
+ IASTInitializer[] initializers1 = ((IASTInitializerList) ((IASTEqualsInitializer) declarator_xy
+ .getInitializer()).getInitializerClause()).getInitializers();
+ IASTName name_y2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers1[0])
+ .getDesignators()[0]).getName();
// test bug 87649
assertEquals(((ASTNode) (ICASTDesignatedInitializer) initializers1[0]).getLength(), 7);
- IASTName name_x2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers1[1]).getDesignators()[0]).getName();
+ IASTName name_x2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers1[1])
+ .getDesignators()[0]).getName();
- IASTSimpleDeclaration point = (IASTSimpleDeclaration) ((IASTDeclarationStatement) statements[1]).getDeclaration();
+ IASTSimpleDeclaration point = (IASTSimpleDeclaration) ((IASTDeclarationStatement) statements[1])
+ .getDeclaration();
IASTName name_Point2 = ((IASTNamedTypeSpecifier) point.getDeclSpecifier()).getName();
IASTName name_point = point.getDeclarators()[0].getName();
IASTDeclarator declarator_point = point.getDeclarators()[0];
- IASTInitializer[] initializers2 = ((IASTInitializerList) ((IASTEqualsInitializer) declarator_point.getInitializer()).getInitializerClause()).getInitializers();
- IASTName name_width2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers2[0]).getDesignators()[0]).getName();
- IASTName name_pos2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers2[1]).getDesignators()[0]).getName();
- IASTName name_xy2 = ((IASTIdExpression) ((IASTUnaryExpression) ((IASTEqualsInitializer) ((ICASTDesignatedInitializer) initializers2[1]).getOperandInitializer()).getInitializerClause()).getOperand()).getName();
+ IASTInitializer[] initializers2 = ((IASTInitializerList) ((IASTEqualsInitializer) declarator_point
+ .getInitializer()).getInitializerClause()).getInitializers();
+ IASTName name_width2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers2[0])
+ .getDesignators()[0]).getName();
+ IASTName name_pos2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers2[1])
+ .getDesignators()[0]).getName();
+ IASTName name_xy2 = ((IASTIdExpression) ((IASTUnaryExpression) ((IASTEqualsInitializer) ((ICASTDesignatedInitializer) initializers2[1])
+ .getOperandInitializer()).getInitializerClause()).getOperand()).getName();
for (int j = 0; j < 2; ++j) {
ICASTDesignatedInitializer designatedInitializer = (ICASTDesignatedInitializer) initializers1[j];
@@ -2024,12 +2016,18 @@ public class AST2Tests extends AST2TestBase {
IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTFunctionDefinition f_def = (IASTFunctionDefinition) tu.getDeclarations()[1];
- IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
- IASTName b1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier()).getMembers()[1]).getDeclarators()[0].getName();
- final IASTDeclarator dtor = ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) f_def.getBody()).getStatements()[0]).getDeclaration()).getDeclarators()[0];
- final IASTInitializerList initializerList = (IASTInitializerList) ((IASTEqualsInitializer) dtor.getInitializer()).getInitializerClause();
- IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializerList.getInitializers()[0]).getDesignators()[0]).getName();
- IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializerList.getInitializers()[1]).getDesignators()[0]).getName();
+ IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier())
+ .getMembers()[0]).getDeclarators()[0].getName();
+ IASTName b1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier())
+ .getMembers()[1]).getDeclarators()[0].getName();
+ final IASTDeclarator dtor = ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) f_def
+ .getBody()).getStatements()[0]).getDeclaration()).getDeclarators()[0];
+ final IASTInitializerList initializerList = (IASTInitializerList) ((IASTEqualsInitializer) dtor
+ .getInitializer()).getInitializerClause();
+ IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializerList.getInitializers()[0])
+ .getDesignators()[0]).getName();
+ IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializerList.getInitializers()[1])
+ .getDesignators()[0]).getName();
assertEquals(a1.resolveBinding(), a2.resolveBinding());
assertEquals(b1.resolveBinding(), b2.resolveBinding());
@@ -2056,11 +2054,16 @@ public class AST2Tests extends AST2TestBase {
for (int i = 0; i < NUM_TESTS; i++) {
IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
- IASTName b1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier()).getMembers()[1]).getDeclarators()[0].getName();
- final IASTInitializer[] initializers = ((IASTInitializerList) ((IASTEqualsInitializer) S_decl.getDeclarators()[0].getInitializer()).getInitializerClause()).getInitializers();
- IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers[0]).getDesignators()[0]).getName();
- IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers[1]).getDesignators()[0]).getName();
+ IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier())
+ .getMembers()[0]).getDeclarators()[0].getName();
+ IASTName b1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier())
+ .getMembers()[1]).getDeclarators()[0].getName();
+ final IASTInitializer[] initializers = ((IASTInitializerList) ((IASTEqualsInitializer) S_decl
+ .getDeclarators()[0].getInitializer()).getInitializerClause()).getInitializers();
+ IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers[0]).getDesignators()[0])
+ .getName();
+ IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers[1]).getDesignators()[0])
+ .getName();
assertEquals(a1.resolveBinding(), a2.resolveBinding());
assertEquals(b1.resolveBinding(), b2.resolveBinding());
@@ -2091,12 +2094,16 @@ public class AST2Tests extends AST2TestBase {
IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTSimpleDeclaration x_decl = (IASTSimpleDeclaration) tu.getDeclarations()[3];
- IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
- IASTName b1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier()).getMembers()[1]).getDeclarators()[0].getName();
+ IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier())
+ .getMembers()[0]).getDeclarators()[0].getName();
+ IASTName b1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl.getDeclSpecifier())
+ .getMembers()[1]).getDeclarators()[0].getName();
IASTInitializer initializer = x_decl.getDeclarators()[0].getInitializer();
- initializer= (IASTInitializer) ((IASTEqualsInitializer) initializer).getInitializerClause();
- IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) initializer).getInitializers()[0]).getDesignators()[0]).getName();
- IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) initializer).getInitializers()[1]).getDesignators()[0]).getName();
+ initializer = (IASTInitializer) ((IASTEqualsInitializer) initializer).getInitializerClause();
+ IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) initializer)
+ .getInitializers()[0]).getDesignators()[0]).getName();
+ IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) initializer)
+ .getInitializers()[1]).getDesignators()[0]).getName();
assertEquals(a1.resolveBinding(), a2.resolveBinding());
assertEquals(b1.resolveBinding(), b2.resolveBinding());
@@ -2114,8 +2121,7 @@ public class AST2Tests extends AST2TestBase {
}
public void testFnReturningPtrToFn() throws Exception {
- IASTTranslationUnit tu = parse(
- "void (* f(int))() {}", C); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse("void (* f(int))() {}", C); //$NON-NLS-1$
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
IASTFunctionDefinition def = (IASTFunctionDefinition) tu.getDeclarations()[0];
@@ -2142,8 +2148,7 @@ public class AST2Tests extends AST2TestBase {
// [ and ] of the
// array type derivation.
public void testArrayTypeToQualifiedPointerTypeParm() throws Exception {
- IASTTranslationUnit tu = parse(
- "void f(int parm[const 3]);", C); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse("void f(int parm[const 3]);", C); //$NON-NLS-1$
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
IASTSimpleDeclaration def = (IASTSimpleDeclaration) tu.getDeclarations()[0];
@@ -2154,7 +2159,8 @@ public class AST2Tests extends AST2TestBase {
assertTrue(((IPointerType) ft.getParameterTypes()[0]).isConst());
// test tu.getDeclarationsInAST(IBinding)
- IASTName name_parm = ((IASTStandardFunctionDeclarator) def.getDeclarators()[0]).getParameters()[0].getDeclarator().getName();
+ IASTName name_parm = ((IASTStandardFunctionDeclarator) def.getDeclarators()[0]).getParameters()[0]
+ .getDeclarator().getName();
IASTName[] decls = tu.getDeclarationsInAST(name_parm.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_parm);
@@ -2169,11 +2175,11 @@ public class AST2Tests extends AST2TestBase {
// func(&a);
// }
public void testArrayPointer_261417() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper baC= new AST2AssertionHelper(code, false);
- baC.assertNonProblem("func(&a)", 4, IFunction.class);
- BindingAssertionHelper baCpp= new AST2AssertionHelper(code, true);
- baCpp.assertNonProblem("func(&a)", 4, ICPPFunction.class);
+ String code = getAboveComment();
+ BindingAssertionHelper baC = new AST2AssertionHelper(code, false);
+ baC.assertNonProblem("func(&a)", 4, IFunction.class);
+ BindingAssertionHelper baCpp = new AST2AssertionHelper(code, true);
+ baCpp.assertNonProblem("func(&a)", 4, ICPPFunction.class);
}
// int f() {}
@@ -2200,8 +2206,8 @@ public class AST2Tests extends AST2TestBase {
assertTrue(((IPointerType) ft2.getReturnType()).getType() instanceof IBasicType);
assertTrue(ft3.getReturnType() instanceof IPointerType);
assertTrue(((IPointerType) ft3.getReturnType()).getType() instanceof IFunctionType);
- assertTrue(((IFunctionType) ((IPointerType) ft3.getReturnType()).getType()).getReturnType()
- instanceof IBasicType);
+ assertTrue(((IFunctionType) ((IPointerType) ft3.getReturnType()).getType())
+ .getReturnType() instanceof IBasicType);
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(def1.getDeclarator().getName().resolveBinding());
@@ -2242,9 +2248,10 @@ public class AST2Tests extends AST2TestBase {
// test tu.getDeclarationsInAST(IBinding)
assertTrue(def.getDeclarator() instanceof IASTStandardFunctionDeclarator);
- IASTName name_g = ((IASTStandardFunctionDeclarator) def.getDeclarator()).getParameters()[0].getDeclarator().getName();
- IASTName name_g_call =
- ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTReturnStatement) ((IASTCompoundStatement) def.getBody()).getStatements()[0]).getReturnValue()).getFunctionNameExpression()).getName();
+ IASTName name_g = ((IASTStandardFunctionDeclarator) def.getDeclarator()).getParameters()[0].getDeclarator()
+ .getName();
+ IASTName name_g_call = ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTReturnStatement) ((IASTCompoundStatement) def
+ .getBody()).getStatements()[0]).getReturnValue()).getFunctionNameExpression()).getName();
IASTName[] decls = tu.getDeclarationsInAST(name_g_call.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_g);
@@ -2259,7 +2266,8 @@ public class AST2Tests extends AST2TestBase {
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IVariable v = (IVariable) ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getNestedDeclarator().getName().resolveBinding();
+ IVariable v = (IVariable) ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getNestedDeclarator()
+ .getName().resolveBinding();
IType vt_1 = v.getType();
assertTrue(vt_1 instanceof IArrayType);
@@ -2283,9 +2291,11 @@ public class AST2Tests extends AST2TestBase {
assertEquals(((IBasicType) vpt_2_2).getType(), IBasicType.t_int);
// test tu.getDeclarationsInAST(IBinding)
- IASTName[] decls = tu.getDeclarationsInAST(((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getNestedDeclarator().getName().resolveBinding());
+ IASTName[] decls = tu.getDeclarationsInAST(((IASTStandardFunctionDeclarator) decl.getDeclarators()[0])
+ .getNestedDeclarator().getName().resolveBinding());
assertEquals(decls.length, 1);
- assertEquals(decls[0], ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getNestedDeclarator().getName());
+ assertEquals(decls[0],
+ ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0]).getNestedDeclarator().getName());
tu = validateCopy(tu);
}
@@ -2332,11 +2342,13 @@ public class AST2Tests extends AST2TestBase {
assertEquals(decls.length, 1);
assertEquals(decls[0], name_DWORD);
- decls = tu.getDeclarationsInAST(((IASTNamedTypeSpecifier) decl2.getDeclSpecifier()).getName().resolveBinding());
+ decls = tu.getDeclarationsInAST(
+ ((IASTNamedTypeSpecifier) decl2.getDeclSpecifier()).getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_DWORD);
- decls = tu.getDeclarationsInAST(((IASTNamedTypeSpecifier) decl3.getDeclSpecifier()).getName().resolveBinding());
+ decls = tu.getDeclarationsInAST(
+ ((IASTNamedTypeSpecifier) decl3.getDeclSpecifier()).getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_v);
@@ -2386,7 +2398,7 @@ public class AST2Tests extends AST2TestBase {
assertTrue(signal_ret_ret_1 instanceof ITypedef);
IType signal_ret_ret_2 = ((ITypedef) signal_ret_ret_1).getType();
assertTrue(signal_ret_ret_2 instanceof IBasicType);
- assertEquals(((IBasicType) signal_ret_ret_2).getType(), IBasicType.t_void);
+ assertEquals(((IBasicType) signal_ret_ret_2).getType(), IBasicType.t_void);
assertTrue(((ITypedef) signal_ret_ret_1).getName().equals("DWORD")); //$NON-NLS-1$
IType signal_parm_t1 = signal_t.getParameterTypes()[0];
@@ -2402,15 +2414,14 @@ public class AST2Tests extends AST2TestBase {
assertTrue(signal_parm_t2_ret_1 instanceof ITypedef);
IType signal_parm_t2_ret_2 = ((ITypedef) signal_parm_t2_ret_1).getType();
assertTrue(signal_parm_t2_ret_2 instanceof IBasicType);
- assertEquals(((IBasicType) signal_parm_t2_ret_2).getType(),
- IBasicType.t_void);
+ assertEquals(((IBasicType) signal_parm_t2_ret_2).getType(), IBasicType.t_void);
assertTrue(((ITypedef) signal_parm_t2_ret_1).getName().equals("DWORD")); //$NON-NLS-1$
// test tu.getDeclarationsInAST(IBinding)
IASTName name_pfv = decl2.getDeclarators()[0].getNestedDeclarator().getName();
IASTName name_pfv1 = ((IASTNamedTypeSpecifier) decl3.getDeclSpecifier()).getName();
- IASTName name_pfv2 = ((IASTNamedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl3
- .getDeclarators()[0]).getParameters()[1].getDeclSpecifier()).getName();
+ IASTName name_pfv2 = ((IASTNamedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl3.getDeclarators()[0])
+ .getParameters()[1].getDeclSpecifier()).getName();
IASTName[] decls = tu.getDeclarationsInAST(name_pfv1.resolveBinding());
assertEquals(decls.length, 1);
@@ -2439,16 +2450,15 @@ public class AST2Tests extends AST2TestBase {
ITypedef pfv = (ITypedef) declarators[1].getNestedDeclarator().getName().resolveBinding();
IType fv_t = fv.getType();
- assertEquals(((IBasicType) ((IFunctionType) fv_t).getReturnType()).getType(),
- IBasicType.t_void);
- assertEquals(((IBasicType) ((IFunctionType) fv_t).getParameterTypes()[0]).getType(),
- IBasicType.t_int);
+ assertEquals(((IBasicType) ((IFunctionType) fv_t).getReturnType()).getType(), IBasicType.t_void);
+ assertEquals(((IBasicType) ((IFunctionType) fv_t).getParameterTypes()[0]).getType(), IBasicType.t_int);
IType pfv_t = pfv.getType();
- assertEquals(((IBasicType) ((IFunctionType) ((IPointerType) pfv_t)
- .getType()).getReturnType()).getType(), IBasicType.t_void);
- assertEquals(((IBasicType) ((IFunctionType) ((IPointerType) pfv
- .getType()).getType()).getParameterTypes()[0]).getType(),
+ assertEquals(((IBasicType) ((IFunctionType) ((IPointerType) pfv_t).getType()).getReturnType()).getType(),
+ IBasicType.t_void);
+ assertEquals(
+ ((IBasicType) ((IFunctionType) ((IPointerType) pfv.getType()).getType()).getParameterTypes()[0])
+ .getType(),
IBasicType.t_int);
decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
@@ -2466,50 +2476,41 @@ public class AST2Tests extends AST2TestBase {
IFunction signal3 = (IFunction) declarators[0].getName().resolveBinding();
IType signal3_t = signal3.getType();
+ assertEquals(((IBasicType) ((IFunctionType) ((IPointerType) ((IFunctionType) signal1_t).getReturnType())
+ .getType()).getReturnType()).getType(), IBasicType.t_void);
+ assertEquals(((IBasicType) ((IFunctionType) signal1_t).getParameterTypes()[0]).getType(), IBasicType.t_int);
assertEquals(
- ((IBasicType) ((IFunctionType) ((IPointerType) ((IFunctionType) signal1_t)
- .getReturnType()).getType()).getReturnType()).getType(),
- IBasicType.t_void);
- assertEquals(((IBasicType) ((IFunctionType) signal1_t)
- .getParameterTypes()[0]).getType(), IBasicType.t_int);
- assertEquals(
- ((IBasicType) ((IFunctionType) ((IPointerType) ((IFunctionType) signal1_t)
- .getParameterTypes()[1]).getType()).getReturnType())
- .getType(), IBasicType.t_void);
- assertEquals(
- ((IBasicType) ((IFunctionType) ((IPointerType) ((IFunctionType) signal1_t)
- .getParameterTypes()[1]).getType()).getParameterTypes()[0])
- .getType(), IBasicType.t_int);
-
+ ((IBasicType) ((IFunctionType) ((IPointerType) ((IFunctionType) signal1_t).getParameterTypes()[1])
+ .getType()).getReturnType()).getType(),
+ IBasicType.t_void);
assertEquals(
- ((IBasicType) ((IFunctionType) ((ITypedef) ((IPointerType) ((IFunctionType) signal2_t)
- .getReturnType()).getType()).getType()).getReturnType())
- .getType(), IBasicType.t_void);
- assertEquals(((IBasicType) ((IFunctionType) signal2_t).getParameterTypes()[0]).getType(),
+ ((IBasicType) ((IFunctionType) ((IPointerType) ((IFunctionType) signal1_t).getParameterTypes()[1])
+ .getType()).getParameterTypes()[0]).getType(),
IBasicType.t_int);
+
+ assertEquals(((IBasicType) ((IFunctionType) ((ITypedef) ((IPointerType) ((IFunctionType) signal2_t)
+ .getReturnType()).getType()).getType()).getReturnType()).getType(), IBasicType.t_void);
+ assertEquals(((IBasicType) ((IFunctionType) signal2_t).getParameterTypes()[0]).getType(), IBasicType.t_int);
assertEquals(
((IBasicType) ((IFunctionType) ((ITypedef) ((IPointerType) ((IFunctionType) signal2_t)
- .getParameterTypes()[1]).getType()).getType())
- .getReturnType()).getType(), IBasicType.t_void);
+ .getParameterTypes()[1]).getType()).getType()).getReturnType()).getType(),
+ IBasicType.t_void);
assertEquals(
((IBasicType) ((IFunctionType) ((ITypedef) ((IPointerType) ((IFunctionType) signal2_t)
- .getParameterTypes()[1]).getType()).getType())
- .getParameterTypes()[0]).getType(), IBasicType.t_int);
+ .getParameterTypes()[1]).getType()).getType()).getParameterTypes()[0]).getType(),
+ IBasicType.t_int);
+ assertEquals(((IBasicType) ((IFunctionType) ((IPointerType) ((ITypedef) ((IFunctionType) signal3_t)
+ .getReturnType()).getType()).getType()).getReturnType()).getType(), IBasicType.t_void);
+ assertEquals(((IBasicType) ((IFunctionType) signal3_t).getParameterTypes()[0]).getType(), IBasicType.t_int);
assertEquals(
((IBasicType) ((IFunctionType) ((IPointerType) ((ITypedef) ((IFunctionType) signal3_t)
- .getReturnType()).getType()).getType()).getReturnType())
- .getType(), IBasicType.t_void);
- assertEquals(((IBasicType) ((IFunctionType) signal3_t)
- .getParameterTypes()[0]).getType(), IBasicType.t_int);
- assertEquals(
- ((IBasicType) ((IFunctionType) ((IPointerType) ((ITypedef) ((IFunctionType) signal3_t)
- .getParameterTypes()[1]).getType()).getType())
- .getReturnType()).getType(), IBasicType.t_void);
+ .getParameterTypes()[1]).getType()).getType()).getReturnType()).getType(),
+ IBasicType.t_void);
assertEquals(
((IBasicType) ((IFunctionType) ((IPointerType) ((ITypedef) ((IFunctionType) signal3_t)
- .getParameterTypes()[1]).getType()).getType())
- .getParameterTypes()[0]).getType(), IBasicType.t_int);
+ .getParameterTypes()[1]).getType()).getType()).getParameterTypes()[0]).getType(),
+ IBasicType.t_int);
tu = validateCopy(tu);
}
@@ -2519,8 +2520,7 @@ public class AST2Tests extends AST2TestBase {
// int y [ const static x ];
public void testBug80992() throws Exception {
ICASTArrayModifier mod = (ICASTArrayModifier) ((IASTArrayDeclarator) ((IASTSimpleDeclaration) parse(
- getAboveComment(), C).getDeclarations()[1])
- .getDeclarators()[0]).getArrayModifiers()[0];
+ getAboveComment(), C).getDeclarations()[1]).getDeclarators()[0]).getArrayModifiers()[0];
assertTrue(mod.isConst());
assertTrue(mod.isStatic());
assertFalse(mod.isRestrict());
@@ -2528,13 +2528,11 @@ public class AST2Tests extends AST2TestBase {
assertFalse(mod.isVariableSized());
}
-
// int y (int [ const *]);
public void testBug80978() throws Exception {
ICASTArrayModifier mod = (ICASTArrayModifier) ((IASTArrayDeclarator) ((IASTStandardFunctionDeclarator) ((IASTSimpleDeclaration) parse(
- getAboveComment(), C).getDeclarations()[0])
- .getDeclarators()[0]).getParameters()[0].getDeclarator())
- .getArrayModifiers()[0];
+ getAboveComment(), C).getDeclarations()[0]).getDeclarators()[0]).getParameters()[0].getDeclarator())
+ .getArrayModifiers()[0];
assertTrue(mod.isConst());
assertTrue(mod.isVariableSized());
assertFalse(mod.isStatic());
@@ -2649,18 +2647,13 @@ public class AST2Tests extends AST2TestBase {
for (int i = 0; i < NUM_TESTS; i++) {
IASTIfStatement if_statement = (IASTIfStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
.getDeclarations()[0]).getBody()).getStatements()[0];
- assertEquals(((IASTBinaryExpression) if_statement
- .getConditionExpression()).getOperator(),
+ assertEquals(((IASTBinaryExpression) if_statement.getConditionExpression()).getOperator(),
IASTBinaryExpression.op_equals);
- IASTIfStatement second_if_statement = (IASTIfStatement) if_statement
- .getElseClause();
- assertEquals(((IASTBinaryExpression) second_if_statement
- .getConditionExpression()).getOperator(),
+ IASTIfStatement second_if_statement = (IASTIfStatement) if_statement.getElseClause();
+ assertEquals(((IASTBinaryExpression) second_if_statement.getConditionExpression()).getOperator(),
IASTBinaryExpression.op_lessThan);
- IASTIfStatement third_if_statement = (IASTIfStatement) second_if_statement
- .getElseClause();
- assertEquals(((IASTBinaryExpression) third_if_statement
- .getConditionExpression()).getOperator(),
+ IASTIfStatement third_if_statement = (IASTIfStatement) second_if_statement.getElseClause();
+ assertEquals(((IASTBinaryExpression) third_if_statement.getConditionExpression()).getOperator(),
IASTBinaryExpression.op_greaterThan);
tu = validateCopy(tu);
@@ -2712,8 +2705,7 @@ public class AST2Tests extends AST2TestBase {
}
public void testBug84096_FieldDesignatorRef() throws Exception {
- IASTTranslationUnit tu = parse(
- "struct s { int a; } ss = { .a = 1 }; \n", C); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse("struct s { int a; } ss = { .a = 1 }; \n", C); //$NON-NLS-1$
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
NameCollector collector = new NameCollector();
@@ -2731,8 +2723,7 @@ public class AST2Tests extends AST2TestBase {
}
public void testProblems() throws Exception {
- IASTTranslationUnit tu = parse(
- " a += ;", C, true, false); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(" a += ;", C, true, false); //$NON-NLS-1$
IASTProblem[] ps = CVisitor.getProblems(tu);
assertEquals(1, ps.length);
ps[0].getMessage();
@@ -2853,7 +2844,8 @@ public class AST2Tests extends AST2TestBase {
public void testBug84250() throws Exception {
assertTrue(((IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) parse(
- "void f() { int (*p) [2]; }", C).getDeclarations()[0]).getBody()).getStatements()[0]).getDeclaration() instanceof IASTSimpleDeclaration); //$NON-NLS-1$
+ "void f() { int (*p) [2]; }", C).getDeclarations()[0]).getBody()).getStatements()[0]) //$NON-NLS-1$
+ .getDeclaration() instanceof IASTSimpleDeclaration);
}
// struct s1 { struct s2 *s2p; /* ... */ }; // D1
@@ -2870,7 +2862,6 @@ public class AST2Tests extends AST2TestBase {
ICompositeType s_decl = (ICompositeType) col.getName(3).resolveBinding();
assertSame(s_ref, s_decl);
-
tu = parse(code, lang);
col = new NameCollector();
tu.accept(col);
@@ -2940,10 +2931,8 @@ public class AST2Tests extends AST2TestBase {
public void testBug84236() throws Exception {
String code = "double maximum(double a[ ][*]);"; //$NON-NLS-1$
- IASTSimpleDeclaration d = (IASTSimpleDeclaration) parse(code,
- C).getDeclarations()[0];
- IASTStandardFunctionDeclarator fd = (IASTStandardFunctionDeclarator) d
- .getDeclarators()[0];
+ IASTSimpleDeclaration d = (IASTSimpleDeclaration) parse(code, C).getDeclarations()[0];
+ IASTStandardFunctionDeclarator fd = (IASTStandardFunctionDeclarator) d.getDeclarators()[0];
IASTParameterDeclaration p = fd.getParameters()[0];
IASTArrayDeclarator a = (IASTArrayDeclarator) p.getDeclarator();
ICASTArrayModifier star = (ICASTArrayModifier) a.getArrayModifiers()[1];
@@ -2961,28 +2950,24 @@ public class AST2Tests extends AST2TestBase {
IASTCompoundStatement body = (IASTCompoundStatement) g.getBody();
final IASTStatement statement = body.getStatements()[0];
assertTrue(statement instanceof IASTDeclarationStatement);
- IASTSimpleDeclaration bp = (IASTSimpleDeclaration) ((IASTDeclarationStatement) statement)
- .getDeclaration();
+ IASTSimpleDeclaration bp = (IASTSimpleDeclaration) ((IASTDeclarationStatement) statement).getDeclaration();
assertTrue(bp.getDeclarators()[0].getName().resolveBinding() instanceof IVariable);
}
public void testBug86766() throws Exception {
- IASTTranslationUnit tu = parse(
- "char foo; void foo() {}", C); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse("char foo; void foo() {}", C); //$NON-NLS-1$
NameCollector col = new NameCollector();
tu.accept(col);
IVariable foo = (IVariable) col.getName(0).resolveBinding();
- IProblemBinding prob = (IProblemBinding) col.getName(1)
- .resolveBinding();
+ IProblemBinding prob = (IProblemBinding) col.getName(1).resolveBinding();
assertEquals(prob.getID(), IProblemBinding.SEMANTIC_INVALID_OVERLOAD);
assertNotNull(foo);
}
public void testBug88338_C() throws Exception {
- IASTTranslationUnit tu = parse(
- "struct A; struct A* a;", C); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse("struct A; struct A* a;", C); //$NON-NLS-1$
NameCollector col = new NameCollector();
tu.accept(col);
@@ -3022,7 +3007,7 @@ public class AST2Tests extends AST2TestBase {
IParameter p = (IParameter) col.getName(1).resolveBinding();
IVariable v1 = (IVariable) col.getName(2).resolveBinding();
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
IScope scope = ((IASTCompoundStatement) fdef.getBody()).getScope();
IBinding[] bs = scope.find("par", tu); //$NON-NLS-1$
@@ -3053,7 +3038,7 @@ public class AST2Tests extends AST2TestBase {
IVariable S3 = (IVariable) col.getName(3).resolveBinding();
ILabel S4 = (ILabel) col.getName(4).resolveBinding();
- IASTFunctionDefinition fdef= getDeclaration(tu, 2);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 2);
IScope scope = ((IASTCompoundStatement) fdef.getBody()).getScope();
IBinding[] bs = scope.find("S", tu); //$NON-NLS-1$
@@ -3066,15 +3051,13 @@ public class AST2Tests extends AST2TestBase {
}
public void test92791() throws Exception {
- IASTTranslationUnit tu = parse(
- "void f() { int x, y; x * y; }", C); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse("void f() { int x, y; x * y; }", C); //$NON-NLS-1$
NameCollector col = new NameCollector();
tu.accept(col);
for (int i = 0; i < col.size(); ++i)
assertFalse(col.getName(i).resolveBinding() instanceof IProblemBinding);
- tu = parse(
- "int y; void f() { typedef int x; x * y; }", C); //$NON-NLS-1$
+ tu = parse("int y; void f() { typedef int x; x * y; }", C); //$NON-NLS-1$
col = new NameCollector();
tu.accept(col);
for (int i = 0; i < col.size(); ++i)
@@ -3082,8 +3065,7 @@ public class AST2Tests extends AST2TestBase {
}
public void testBug85786() throws Exception {
- IASTTranslationUnit tu = parse(
- "void f(int); void foo () { void * p = &f; ((void (*) (int)) p) (1); }", C); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse("void f(int); void foo () { void * p = &f; ((void (*) (int)) p) (1); }", C); //$NON-NLS-1$
NameCollector nameResolver = new NameCollector();
tu.accept(nameResolver);
assertNoProblemBindings(nameResolver);
@@ -3123,10 +3105,9 @@ public class AST2Tests extends AST2TestBase {
assertEquals(declarations.length, 1);
assertNotNull(declarations[0]);
assertTrue(declarations[0] instanceof IASTFunctionDefinition);
- assertEquals(((IASTFunctionDefinition) declarations[0]).getDeclarator()
- .getName().toString(), "main"); //$NON-NLS-1$
- assertTrue(((IASTCompoundStatement) ((IASTFunctionDefinition) declarations[0])
- .getBody()).getStatements()[0] instanceof IASTNullStatement);
+ assertEquals(((IASTFunctionDefinition) declarations[0]).getDeclarator().getName().toString(), "main"); //$NON-NLS-1$
+ assertTrue(((IASTCompoundStatement) ((IASTFunctionDefinition) declarations[0]).getBody())
+ .getStatements()[0] instanceof IASTNullStatement);
}
// #define MACRO(a)
@@ -3139,10 +3120,9 @@ public class AST2Tests extends AST2TestBase {
assertEquals(declarations.length, 1);
assertNotNull(declarations[0]);
assertTrue(declarations[0] instanceof IASTFunctionDefinition);
- assertEquals(((IASTFunctionDefinition) declarations[0]).getDeclarator()
- .getName().toString(), "main"); //$NON-NLS-1$
- assertTrue(((IASTCompoundStatement) ((IASTFunctionDefinition) declarations[0])
- .getBody()).getStatements()[0] instanceof IASTNullStatement);
+ assertEquals(((IASTFunctionDefinition) declarations[0]).getDeclarator().getName().toString(), "main"); //$NON-NLS-1$
+ assertTrue(((IASTCompoundStatement) ((IASTFunctionDefinition) declarations[0]).getBody())
+ .getStatements()[0] instanceof IASTNullStatement);
}
// typedef long _TYPE;
@@ -3158,10 +3138,12 @@ public class AST2Tests extends AST2TestBase {
IASTTranslationUnit tu = parse(getAboveComment(), C, true, true);
IASTDeclaration[] decls = tu.getDeclarations();
- assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration) decls[0]).getDeclSpecifier()).isComplex());
- assertEquals(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration) decls[0]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_float);
- assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration) decls[1]).getDeclSpecifier()).isComplex());
- assertEquals(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration) decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double);
+ assertTrue(((ICASTSimpleDeclSpecifier) ((IASTSimpleDeclaration) decls[0]).getDeclSpecifier()).isComplex());
+ assertEquals(((ICASTSimpleDeclSpecifier) ((IASTSimpleDeclaration) decls[0]).getDeclSpecifier()).getType(),
+ IASTSimpleDeclSpecifier.t_float);
+ assertTrue(((ICASTSimpleDeclSpecifier) ((IASTSimpleDeclaration) decls[1]).getDeclSpecifier()).isComplex());
+ assertEquals(((ICASTSimpleDeclSpecifier) ((IASTSimpleDeclaration) decls[1]).getDeclSpecifier()).getType(),
+ IASTSimpleDeclSpecifier.t_double);
}
// int foo();
@@ -3223,7 +3205,7 @@ public class AST2Tests extends AST2TestBase {
// f1(__null);
// }
public void testBug240567() throws Exception {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), false);
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), false);
bh.assertNonProblem("f1(__null", 2, IFunction.class);
}
@@ -3245,7 +3227,7 @@ public class AST2Tests extends AST2TestBase {
}
public void testBug100408() throws Exception {
- IASTTranslationUnit tu = parse("int foo() { int x=1; (x)*3; }", C); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse("int foo() { int x=1; (x)*3; }", C); //$NON-NLS-1$
NameCollector col = new NameCollector();
tu.accept(col);
assertNoProblemBindings(col);
@@ -3266,7 +3248,7 @@ public class AST2Tests extends AST2TestBase {
tu.accept(col);
IFunction free = (IFunction) col.getName(4).resolveBinding();
- IParameter [] ps = free.getParameters();
+ IParameter[] ps = free.getParameters();
assertEquals(ps.length, 1);
assertSame(free, col.getName(6).resolveBinding());
@@ -3324,7 +3306,7 @@ public class AST2Tests extends AST2TestBase {
public void test1043290() throws Exception {
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment());
IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[0];
- IASTStatement [] statements = ((IASTCompoundStatement) fd.getBody()).getStatements();
+ IASTStatement[] statements = ((IASTCompoundStatement) fd.getBody()).getStatements();
IASTWhileStatement whileStmt = (IASTWhileStatement) statements[1];
IASTLabelStatement labelStmt = (IASTLabelStatement) whileStmt.getBody();
assertTrue(labelStmt.getNestedStatement() instanceof IASTExpressionStatement);
@@ -3385,9 +3367,9 @@ public class AST2Tests extends AST2TestBase {
buffer.append("((int arg1)) {\n"); //$NON-NLS-1$
buffer.append("return 0;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- tu= parse(buffer.toString(), C);
+ tu = parse(buffer.toString(), C);
assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration);
- tu= parse(buffer.toString(), CPP);
+ tu = parse(buffer.toString(), CPP);
assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration);
}
@@ -3401,7 +3383,7 @@ public class AST2Tests extends AST2TestBase {
buffer.append("((int arg1)) {\r\n"); //$NON-NLS-1$
buffer.append("return 0;\r\n"); //$NON-NLS-1$
buffer.append("}\r\n"); //$NON-NLS-1$
- IASTTranslationUnit tu= parse(buffer.toString(), C);
+ IASTTranslationUnit tu = parse(buffer.toString(), C);
assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration);
tu = parse(buffer.toString(), CPP);
@@ -3478,17 +3460,17 @@ public class AST2Tests extends AST2TestBase {
// z= (a)%z;
// }
public void testBracketAroundIdentifier_168924() throws IOException, ParserException {
- String content= getAboveComment();
- IASTTranslationUnit tu= parse(content, C, true, true);
- IASTFunctionDefinition func= (IASTFunctionDefinition) tu.getDeclarations()[0];
- IASTParameterDeclaration[] params= ((IASTStandardFunctionDeclarator) func.getDeclarator()).getParameters();
- IBinding binding= params[0].getDeclarator().getName().resolveBinding();
+ String content = getAboveComment();
+ IASTTranslationUnit tu = parse(content, C, true, true);
+ IASTFunctionDefinition func = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTParameterDeclaration[] params = ((IASTStandardFunctionDeclarator) func.getDeclarator()).getParameters();
+ IBinding binding = params[0].getDeclarator().getName().resolveBinding();
assertEquals(7, tu.getReferences(binding).length);
- tu= parse(content, CPP, true, true);
- func= (IASTFunctionDefinition) tu.getDeclarations()[0];
- params= ((IASTStandardFunctionDeclarator) func.getDeclarator()).getParameters();
- binding= params[0].getDeclarator().getName().resolveBinding();
+ tu = parse(content, CPP, true, true);
+ func = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ params = ((IASTStandardFunctionDeclarator) func.getDeclarator()).getParameters();
+ binding = params[0].getDeclarator().getName().resolveBinding();
assertEquals(7, tu.getReferences(binding).length);
}
@@ -3506,34 +3488,19 @@ public class AST2Tests extends AST2TestBase {
*/
public void testMacroCommentsBug_177154() throws Exception {
// simple case
- String simple =
- "#define LIT 1 // my value\r\n" +
- "int func(int x) {\r\n" +
- "}\r\n" +
- "int main() {\r\n" +
- " return func(LIT); // fails to parse\r\n" +
- "}\r\n";
+ String simple = "#define LIT 1 // my value\r\n" + "int func(int x) {\r\n" + "}\r\n" + "int main() {\r\n"
+ + " return func(LIT); // fails to parse\r\n" + "}\r\n";
IASTTranslationUnit tu = parse(simple, CPP, true, true);
// actual reduced test case, plus extra cases
- String text =
- "#define KBOOT 1 //0x00000002\r\n" +
- "#define KBOOT2 /* value */ 1 /* another */ //0x00000002\r\n" +
- "#define KBOOT3 /* value \r\n" +
- " multi line\r\n"+
- " comment */ 1 \\\r\n"+
- "/* another */ + \\\r\n"+
- "2 //0x00000002\r\n" +
- "#define DEBUGNUM(x) (KDebugNum(x))\r\n" +
- "bool KDebugNum(int aBitNum);\r\n" +
- "#define __KTRACE_OPT(a,p) {if ((DEBUGNUM(a)))p;}\r\n" +
- "void fail();\r\n"+
- "void test() {\r\n"+
- "__KTRACE_OPT(KBOOT,fail());\r\n" +
- "__KTRACE_OPT(KBOOT2,fail());\r\n" +
- "}\r\n"
- ;
+ String text = "#define KBOOT 1 //0x00000002\r\n"
+ + "#define KBOOT2 /* value */ 1 /* another */ //0x00000002\r\n"
+ + "#define KBOOT3 /* value \r\n" + " multi line\r\n" + " comment */ 1 \\\r\n"
+ + "/* another */ + \\\r\n" + "2 //0x00000002\r\n" + "#define DEBUGNUM(x) (KDebugNum(x))\r\n"
+ + "bool KDebugNum(int aBitNum);\r\n" + "#define __KTRACE_OPT(a,p) {if ((DEBUGNUM(a)))p;}\r\n"
+ + "void fail();\r\n" + "void test() {\r\n" + "__KTRACE_OPT(KBOOT,fail());\r\n"
+ + "__KTRACE_OPT(KBOOT2,fail());\r\n" + "}\r\n";
// essential test: this code should be parseable
tu = parse(text, CPP, true, true);
@@ -3544,7 +3511,7 @@ public class AST2Tests extends AST2TestBase {
assertEquals("1", macroDefinitions[0].getExpansion());
assertEquals("1", macroDefinitions[1].getExpansion());
// regression test for #64268 and #71733 which also handle comments
- String expectExpansion= "1 + 2";
+ String expectExpansion = "1 + 2";
assertEquals(expectExpansion, macroDefinitions[2].getExpansion());
assertEquals("(KDebugNum(x))", macroDefinitions[3].getExpansion());
assertEquals("{if ((DEBUGNUM(a)))p;}", macroDefinitions[4].getExpansion());
@@ -3562,12 +3529,12 @@ public class AST2Tests extends AST2TestBase {
// check class
IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[1];
- IASTCompoundStatement comp_stmt= (IASTCompoundStatement) fd.getBody();
- IASTExpressionStatement expr_stmt= (IASTExpressionStatement) comp_stmt.getStatements()[0];
- IASTFunctionCallExpression expr= (IASTFunctionCallExpression) expr_stmt.getExpression();
- IASTIdExpression idExpr= (IASTIdExpression) expr.getFunctionNameExpression();
- IBinding binding= idExpr.getName().resolveBinding();
- assertTrue(lang.toString(), binding instanceof IFunction);
+ IASTCompoundStatement comp_stmt = (IASTCompoundStatement) fd.getBody();
+ IASTExpressionStatement expr_stmt = (IASTExpressionStatement) comp_stmt.getStatements()[0];
+ IASTFunctionCallExpression expr = (IASTFunctionCallExpression) expr_stmt.getExpression();
+ IASTIdExpression idExpr = (IASTIdExpression) expr.getFunctionNameExpression();
+ IBinding binding = idExpr.getName().resolveBinding();
+ assertTrue(lang.toString(), binding instanceof IFunction);
assertFalse(lang.toString(), binding instanceof IProblemBinding);
assertEquals(binding.getName(), "decl");
}
@@ -3583,22 +3550,19 @@ public class AST2Tests extends AST2TestBase {
// check class
IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[1];
- IASTCompoundStatement comp_stmt= (IASTCompoundStatement) fd.getBody();
- IASTExpressionStatement expr_stmt= (IASTExpressionStatement) comp_stmt.getStatements()[0];
- IASTFunctionCallExpression expr= (IASTFunctionCallExpression) expr_stmt.getExpression();
- IASTIdExpression idExpr= (IASTIdExpression) expr.getFunctionNameExpression();
- IBinding binding= idExpr.getName().resolveBinding();
- assertTrue(lang.toString(), binding instanceof IVariable);
+ IASTCompoundStatement comp_stmt = (IASTCompoundStatement) fd.getBody();
+ IASTExpressionStatement expr_stmt = (IASTExpressionStatement) comp_stmt.getStatements()[0];
+ IASTFunctionCallExpression expr = (IASTFunctionCallExpression) expr_stmt.getExpression();
+ IASTIdExpression idExpr = (IASTIdExpression) expr.getFunctionNameExpression();
+ IBinding binding = idExpr.getName().resolveBinding();
+ assertTrue(lang.toString(), binding instanceof IVariable);
assertFalse(lang.toString(), binding instanceof IProblemBinding);
}
}
public void testBug181735() throws Exception {
- String code=
- "int (*f)(int);\n"
- + "int g(int n) {return n;}\n"
- + "int g(int n, int m) {return n;}\n"
- + "void foo() { f=g; }";
+ String code = "int (*f)(int);\n" + "int g(int n) {return n;}\n" + "int g(int n, int m) {return n;}\n"
+ + "void foo() { f=g; }";
for (ParserLanguage lang : ParserLanguage.values())
parseAndCheckBindings(code, lang);
@@ -3613,24 +3577,19 @@ public class AST2Tests extends AST2TestBase {
}
public void testMacroCommentsBug_177154_2() throws Exception {
- String noCommentMacro =
- "#define Sonar16G(x) ((Sonr16G(x)<<16)|0xff000000L)\r\n";
- String commentMacro =
- "#define Sonar16G(x) ((Sonr16G(x)<<16)|0xff000000L) // add the varf value\r\n";
-
- String textTail = "\r\n" +
- "const int snd16SonarR[32] = {\r\n" +
- " 0xFF000000L, Sonar16G(0x01), Sonar16G(0x02), Sonar16G(0x03),\r\n" +
- " Sonar16G(0x04), Sonar16G(0x05), Sonar16G(0x06), Sonar16G(0x07),\r\n" +
- " Sonar16G(0x08), Sonar16G(0x09), Sonar16G(0x0A), Sonar16G(0x0B),\r\n" +
- " Sonar16G(0x0C), Sonar16G(0x0D), Sonar16G(0x0E), Sonar16G(0x0F),\r\n" +
- " Sonar16G(0x10), Sonar16G(0x11), Sonar16G(0x12), Sonar16G(0x13),\r\n" +
- " Sonar16G(0x14), Sonar16G(0x15), Sonar16G(0x16), Sonar16G(0x17),\r\n" +
- " Sonar16G(0x18), Sonar16G(0x19), Sonar16G(0x1A), Sonar16G(0x1B),\r\n" +
- " Sonar16G(0x1C), Sonar16G(0x1D), Sonar16G(0x1E), Sonar16G(0x1F),\r\n" +
- " };\r\n" +
- "\r\n" +
- "";
+ String noCommentMacro = "#define Sonar16G(x) ((Sonr16G(x)<<16)|0xff000000L)\r\n";
+ String commentMacro = "#define Sonar16G(x) ((Sonr16G(x)<<16)|0xff000000L) // add the varf value\r\n";
+
+ String textTail = "\r\n" + "const int snd16SonarR[32] = {\r\n"
+ + " 0xFF000000L, Sonar16G(0x01), Sonar16G(0x02), Sonar16G(0x03),\r\n"
+ + " Sonar16G(0x04), Sonar16G(0x05), Sonar16G(0x06), Sonar16G(0x07),\r\n"
+ + " Sonar16G(0x08), Sonar16G(0x09), Sonar16G(0x0A), Sonar16G(0x0B),\r\n"
+ + " Sonar16G(0x0C), Sonar16G(0x0D), Sonar16G(0x0E), Sonar16G(0x0F),\r\n"
+ + " Sonar16G(0x10), Sonar16G(0x11), Sonar16G(0x12), Sonar16G(0x13),\r\n"
+ + " Sonar16G(0x14), Sonar16G(0x15), Sonar16G(0x16), Sonar16G(0x17),\r\n"
+ + " Sonar16G(0x18), Sonar16G(0x19), Sonar16G(0x1A), Sonar16G(0x1B),\r\n"
+ + " Sonar16G(0x1C), Sonar16G(0x1D), Sonar16G(0x1E), Sonar16G(0x1F),\r\n" + " };\r\n" + "\r\n"
+ + "";
// this should work
String textNoComment = noCommentMacro + textTail;
@@ -3649,14 +3608,8 @@ public class AST2Tests extends AST2TestBase {
}
public void testBug186018() throws Exception {
- String code =
- "int main() { \n" +
- " switch(1) { \n" +
- " case 1 : \n" +
- " case 2 : \n" +
- " printf(\"pantera rules\"); \n" +
- " } \n" +
- "}\n";
+ String code = "int main() { \n" + " switch(1) { \n" + " case 1 : \n" + " case 2 : \n"
+ + " printf(\"pantera rules\"); \n" + " } \n" + "}\n";
parseAndCheckBindings(code, C);
}
@@ -3686,13 +3639,13 @@ public class AST2Tests extends AST2TestBase {
// }
// };
public void test186736() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), CPP);
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), CPP);
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
NameCollector col = new NameCollector();
tu.accept(col);
- IBinding methodb= col.getName(27).resolveBinding();
- IBinding methodc= col.getName(30).resolveBinding();
+ IBinding methodb = col.getName(27).resolveBinding();
+ IBinding methodc = col.getName(30).resolveBinding();
assertEquals("method", methodb.getName());
assertEquals("method", methodc.getName());
assertInstance(methodb, ICPPMethod.class);
@@ -3738,13 +3691,13 @@ public class AST2Tests extends AST2TestBase {
// }
// };
public void test186736_variant1() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), CPP);
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), CPP);
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
NameCollector col = new NameCollector();
tu.accept(col);
- IBinding methodA= col.getName(30).resolveBinding();
- IBinding methodAA= col.getName(33).resolveBinding();
+ IBinding methodA = col.getName(30).resolveBinding();
+ IBinding methodAA = col.getName(33).resolveBinding();
assertEquals("method", methodA.getName());
assertEquals("method", methodAA.getName());
assertInstance(methodA, ICPPMethod.class);
@@ -3776,7 +3729,7 @@ public class AST2Tests extends AST2TestBase {
// (&a)->foo();
// }
public void test186736_variant2() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), CPP);
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), CPP);
validateCopy(tu);
}
@@ -3848,17 +3801,17 @@ public class AST2Tests extends AST2TestBase {
}
public void test195943() throws Exception {
- final int depth= 100;
+ final int depth = 100;
StringBuilder buffer = new StringBuilder();
buffer.append("#define M0 1\n");
for (int i = 1; i < depth; i++) {
- buffer.append("#define M").append(i).append(" (M").append(i-1).append("+1)\n");
+ buffer.append("#define M").append(i).append(" (M").append(i - 1).append("+1)\n");
}
- buffer.append("int a= M").append(depth-1).append(";\n");
- long time= System.currentTimeMillis();
+ buffer.append("int a= M").append(depth - 1).append(";\n");
+ long time = System.currentTimeMillis();
parse(buffer.toString(), CPP);
parse(buffer.toString(), C);
- assertTrue(System.currentTimeMillis()-time < 2000);
+ assertTrue(System.currentTimeMillis() - time < 2000);
}
// int array[12]= {};
@@ -3903,7 +3856,7 @@ public class AST2Tests extends AST2TestBase {
// namespace NameClash2 {};
// class NameClash2 {};
public void testBug202271_nameClash() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), CPP, true);
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), CPP, true);
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
NameCollector col = new NameCollector();
@@ -3922,21 +3875,21 @@ public class AST2Tests extends AST2TestBase {
// int a= MACRO;
// int b= WRAP(MACRO);
public void testBug94673_refsForMacrosAsArguments() throws Exception {
- String content= getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(content, CPP, true);
- IASTPreprocessorMacroDefinition[] defs= tu.getMacroDefinitions();
+ String content = getAboveComment();
+ IASTTranslationUnit tu = parseAndCheckBindings(content, CPP, true);
+ IASTPreprocessorMacroDefinition[] defs = tu.getMacroDefinitions();
assertEquals(2, defs.length);
- IASTPreprocessorMacroDefinition md= defs[1];
+ IASTPreprocessorMacroDefinition md = defs[1];
assertEquals("MACRO", md.getName().toString());
- IMacroBinding binding= (IMacroBinding) md.getName().resolveBinding();
+ IMacroBinding binding = (IMacroBinding) md.getName().resolveBinding();
assertNotNull(binding);
- IASTName[] refs= tu.getReferences(binding);
+ IASTName[] refs = tu.getReferences(binding);
assertEquals(2, refs.length);
- IASTFileLocation loc= refs[1].getFileLocation();
+ IASTFileLocation loc = refs[1].getFileLocation();
final int idx = content.indexOf("WRAP(MACRO)");
assertEquals(idx, loc.getNodeOffset());
- IASTImageLocation iloc= refs[1].getImageLocation();
- assertEquals(idx+5, iloc.getNodeOffset());
+ IASTImageLocation iloc = refs[1].getImageLocation();
+ assertEquals(idx + 5, iloc.getNodeOffset());
}
// void OSi_Panic(const char *file, int line) {};
@@ -3988,7 +3941,6 @@ public class AST2Tests extends AST2TestBase {
parse(content2, C);
}
-
// typedef struct Point {
// int x;
// int y;
@@ -4030,7 +3982,7 @@ public class AST2Tests extends AST2TestBase {
assertField(col.getName(27).resolveBinding(), "tag", "Tag");
// Line l2
- assertField(col.getName(30).resolveBinding(), "t", "Line");
+ assertField(col.getName(30).resolveBinding(), "t", "Line");
assertField(col.getName(31).resolveBinding(), "tag", "Tag");
assertField(col.getName(32).resolveBinding(), "p1", "Line");
assertField(col.getName(33).resolveBinding(), "x", "Point");
@@ -4048,7 +4000,6 @@ public class AST2Tests extends AST2TestBase {
assertField(col.getName(45).resolveBinding(), "y", "Point");
}
-
// struct S1 {
// int i;
// float f;
@@ -4164,13 +4115,13 @@ public class AST2Tests extends AST2TestBase {
// foux = (foux) - bhar1;
// }
public void testBug100641_106279_castAmbiguity() throws Exception {
- boolean cpp= false;
+ boolean cpp = false;
do {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), cpp);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), cpp);
ba.assertNonProblem("field)", 5);
ba.assertNonProblem("bit))", 3);
ba.assertNonProblem("foux)", 4);
- cpp= !cpp;
+ cpp = !cpp;
} while (cpp);
}
@@ -4206,26 +4157,26 @@ public class AST2Tests extends AST2TestBase {
// f4(cvi);
// }
public void testBug222418_a() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
- ba.assertNonProblem("f1(i)",2);
- ba.assertProblem("f1(ci)", 2);
- ba.assertProblem("f1(vi)", 2);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
+ ba.assertNonProblem("f1(i)", 2);
+ ba.assertProblem("f1(ci)", 2);
+ ba.assertProblem("f1(vi)", 2);
ba.assertProblem("f1(cvi)", 2);
ba.assertNonProblem("f2(i)", 2);
- ba.assertNonProblem("f2(ci)",2);
- ba.assertProblem("f2(vi)", 2);
- ba.assertProblem("f2(cvi)", 2);
+ ba.assertNonProblem("f2(ci)", 2);
+ ba.assertProblem("f2(vi)", 2);
+ ba.assertProblem("f2(cvi)", 2);
ba.assertNonProblem("f3(i)", 2);
- ba.assertProblem("f3(ci)", 2);
- ba.assertNonProblem("f3(vi)",2);
- ba.assertProblem("f3(cvi)", 2);
+ ba.assertProblem("f3(ci)", 2);
+ ba.assertNonProblem("f3(vi)", 2);
+ ba.assertProblem("f3(cvi)", 2);
- ba.assertNonProblem("f4(i)", 2);
+ ba.assertNonProblem("f4(i)", 2);
ba.assertNonProblem("f4(ci)", 2);
ba.assertNonProblem("f4(vi)", 2);
- ba.assertNonProblem("f4(cvi)",2);
+ ba.assertNonProblem("f4(cvi)", 2);
}
// void f1(int& r) {} // 1
@@ -4245,12 +4196,12 @@ public class AST2Tests extends AST2TestBase {
// f1(cvi); // (4)
// }
public void testBug222418_b() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
- ICPPFunction f1_1= ba.assertNonProblem("f1(i)", 2, ICPPFunction.class);
- ICPPFunction f1_2= ba.assertNonProblem("f1(ci)", 2, ICPPFunction.class);
- ICPPFunction f1_3= ba.assertNonProblem("f1(vi)", 2, ICPPFunction.class);
- ICPPFunction f1_4= ba.assertNonProblem("f1(cvi)",2, ICPPFunction.class);
+ ICPPFunction f1_1 = ba.assertNonProblem("f1(i)", 2, ICPPFunction.class);
+ ICPPFunction f1_2 = ba.assertNonProblem("f1(ci)", 2, ICPPFunction.class);
+ ICPPFunction f1_3 = ba.assertNonProblem("f1(vi)", 2, ICPPFunction.class);
+ ICPPFunction f1_4 = ba.assertNonProblem("f1(cvi)", 2, ICPPFunction.class);
assertEquals(ASTTypeUtil.getParameterTypeString(f1_1.getType()), "(int &)");
assertEquals(ASTTypeUtil.getParameterTypeString(f1_2.getType()), "(const int &)");
@@ -4263,11 +4214,11 @@ public class AST2Tests extends AST2TestBase {
// void f1(volatile int r) {} // 3
// void f1(const volatile int r) {} // 4
public void testBug222418_b_regression() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
- ba.assertNonProblem("f1(int", 2, ICPPFunction.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
+ ba.assertNonProblem("f1(int", 2, ICPPFunction.class);
ba.assertProblem("f1(const i", 2);
ba.assertProblem("f1(vol", 2);
- ba.assertProblem("f1(const v",2);
+ ba.assertProblem("f1(const v", 2);
}
// void fa(int& r) {}
@@ -4289,20 +4240,20 @@ public class AST2Tests extends AST2TestBase {
// fd(five()); // should be an error
// }
public void testBug222418_c() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
- ICPPFunction fn= ba.assertNonProblem("five() {", 4, ICPPFunction.class);
+ ICPPFunction fn = ba.assertNonProblem("five() {", 4, ICPPFunction.class);
assertFalse(fn.getType().getReturnType() instanceof IProblemBinding);
- ba.assertProblem("fa(5", 2);
- ICPPFunction fb= ba.assertNonProblem("fb(5", 2, ICPPFunction.class);
+ ba.assertProblem("fa(5", 2);
+ ICPPFunction fb = ba.assertNonProblem("fb(5", 2, ICPPFunction.class);
ba.assertProblem("fc(5", 2);
- ba.assertProblem("fd(5",2);
+ ba.assertProblem("fd(5", 2);
- ICPPFunction fb2= ba.assertNonProblem("fb(f", 2, ICPPFunction.class);
- ba.assertProblem("fa(f",2);
- ba.assertProblem("fc(f",2);
- ba.assertProblem("fd(f",2);
+ ICPPFunction fb2 = ba.assertNonProblem("fb(f", 2, ICPPFunction.class);
+ ba.assertProblem("fa(f", 2);
+ ba.assertProblem("fc(f", 2);
+ ba.assertProblem("fd(f", 2);
assertEquals(ASTTypeUtil.getParameterTypeString(fb.getType()), "(const int &)");
assertEquals(ASTTypeUtil.getParameterTypeString(fb2.getType()), "(const int &)");
@@ -4321,9 +4272,9 @@ public class AST2Tests extends AST2TestBase {
// f_nonconst(2); // should be an error
// }
public void testBug222418_d() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
- ba.assertNonProblem("f_const(2", 7, ICPPFunction.class);
- ba.assertProblem("f_nonconst(2", 10);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
+ ba.assertNonProblem("f_const(2", 7, ICPPFunction.class);
+ ba.assertProblem("f_nonconst(2", 10);
}
// class A {};
@@ -4360,26 +4311,26 @@ public class AST2Tests extends AST2TestBase {
// f4(cvi);
// }
public void testBug222418_e() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
- ba.assertNonProblem("f1(i)",2);
- ba.assertProblem("f1(ci)", 2);
- ba.assertProblem("f1(vi)", 2);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
+ ba.assertNonProblem("f1(i)", 2);
+ ba.assertProblem("f1(ci)", 2);
+ ba.assertProblem("f1(vi)", 2);
ba.assertProblem("f1(cvi)", 2);
ba.assertNonProblem("f2(i)", 2);
- ba.assertNonProblem("f2(ci)",2);
- ba.assertProblem("f2(vi)", 2);
- ba.assertProblem("f2(cvi)", 2);
+ ba.assertNonProblem("f2(ci)", 2);
+ ba.assertProblem("f2(vi)", 2);
+ ba.assertProblem("f2(cvi)", 2);
ba.assertNonProblem("f3(i)", 2);
- ba.assertProblem("f3(ci)", 2);
- ba.assertNonProblem("f3(vi)",2);
- ba.assertProblem("f3(cvi)", 2);
+ ba.assertProblem("f3(ci)", 2);
+ ba.assertNonProblem("f3(vi)", 2);
+ ba.assertProblem("f3(cvi)", 2);
- ba.assertNonProblem("f4(i)", 2);
+ ba.assertNonProblem("f4(i)", 2);
ba.assertNonProblem("f4(ci)", 2);
ba.assertNonProblem("f4(vi)", 2);
- ba.assertNonProblem("f4(cvi)",2);
+ ba.assertNonProblem("f4(cvi)", 2);
}
// class B {};
@@ -4435,7 +4386,7 @@ public class AST2Tests extends AST2TestBase {
// return 0;
// }
public void testBug222418_f() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
ba.assertNonProblem("foo1(a)", 4);
ba.assertNonProblem("foo2(a)", 4);
ba.assertNonProblem("foo1(3)", 4);
@@ -4450,7 +4401,6 @@ public class AST2Tests extends AST2TestBase {
ba.assertProblem("foo2(b)", 4);
}
-
// class A {};
// class B : public A {};
//
@@ -4461,7 +4411,7 @@ public class AST2Tests extends AST2TestBase {
// f(b2);
// }
public void testBug222418_g_regression() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
ba.assertNonProblem("f(b2)", 1);
}
@@ -4472,7 +4422,7 @@ public class AST2Tests extends AST2TestBase {
// f(r);
// }
public void testBug222418_h_regression() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
ba.assertNonProblem("f(r)", 1);
}
@@ -4485,7 +4435,7 @@ public class AST2Tests extends AST2TestBase {
// f(b2);
// }
public void testBug222418_i_regression() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
ba.assertNonProblem("f(b2)", 1);
}
@@ -4524,7 +4474,7 @@ public class AST2Tests extends AST2TestBase {
// return ri;
// }
public void testBug222418_j() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
ba.assertNonProblem("fi(ri)", 2);
ba.assertNonProblem("fp(&rwi)", 2);
@@ -4563,7 +4513,7 @@ public class AST2Tests extends AST2TestBase {
// a.foo();
// }
public void testBug222418_k_regression() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
ba.assertNonProblem("foo();", 3);
}
@@ -4584,9 +4534,9 @@ public class AST2Tests extends AST2TestBase {
// foo(c);
// }
public void testBug222444_a() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
- ICPPFunction foo1= ba.assertNonProblem("foo(b", 3, ICPPFunction.class);
- ICPPFunction foo2= ba.assertNonProblem("foo(c", 3, ICPPFunction.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
+ ICPPFunction foo1 = ba.assertNonProblem("foo(b", 3, ICPPFunction.class);
+ ICPPFunction foo2 = ba.assertNonProblem("foo(c", 3, ICPPFunction.class);
}
// class A {};
@@ -4605,8 +4555,8 @@ public class AST2Tests extends AST2TestBase {
// foo(c);
// }
public void testBug222444_b() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
- ICPPFunction foo2= ba.assertNonProblem("foo(c", 3, ICPPFunction.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
+ ICPPFunction foo2 = ba.assertNonProblem("foo(c", 3, ICPPFunction.class);
}
// class A {};
@@ -4625,8 +4575,8 @@ public class AST2Tests extends AST2TestBase {
// foo(c);
// }
public void testBug222444_c() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
- ICPPFunction foo2= ba.assertNonProblem("foo(c", 3, ICPPFunction.class);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
+ ICPPFunction foo2 = ba.assertNonProblem("foo(c", 3, ICPPFunction.class);
}
// int a, b, c;
@@ -4703,7 +4653,7 @@ public class AST2Tests extends AST2TestBase {
parseAndCheckBindings(code, C, true);
parseAndCheckBindings(code, CPP, true);
}
-
+
// struct test {
// int field;
// };
@@ -4713,9 +4663,9 @@ public class AST2Tests extends AST2TestBase {
// const typeof(t) x;
// x.field;
// }
- public void testTypeofInsideQualifier_471907() throws Exception {
- parseAndCheckBindings(getAboveComment(), C);
- }
+ public void testTypeofInsideQualifier_471907() throws Exception {
+ parseAndCheckBindings(getAboveComment(), C);
+ }
// void test(int count) {
// switch(count) {
@@ -4726,9 +4676,11 @@ public class AST2Tests extends AST2TestBase {
final String code = getAboveComment();
{
IASTTranslationUnit tu = parseAndCheckBindings(code, C, true);
- IASTCompoundStatement body = (IASTCompoundStatement)((IASTFunctionDefinition) tu.getDeclarations()[0]).getBody();
+ IASTCompoundStatement body = (IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[0])
+ .getBody();
IASTSwitchStatement switchStmt = (IASTSwitchStatement) body.getStatements()[0];
- IASTCaseStatement caseStmt = (IASTCaseStatement)((IASTCompoundStatement) switchStmt.getBody()).getStatements()[0];
+ IASTCaseStatement caseStmt = (IASTCaseStatement) ((IASTCompoundStatement) switchStmt.getBody())
+ .getStatements()[0];
IASTBinaryExpression binExpr = (IASTBinaryExpression) caseStmt.getExpression();
assertTrue(binExpr.getOperator() == IASTBinaryExpression.op_ellipses);
assertTrue(binExpr.getOperand1() instanceof IASTLiteralExpression);
@@ -4736,9 +4688,11 @@ public class AST2Tests extends AST2TestBase {
}
{
IASTTranslationUnit tu = parseAndCheckBindings(code, CPP, true);
- IASTCompoundStatement body = (IASTCompoundStatement)((IASTFunctionDefinition) tu.getDeclarations()[0]).getBody();
+ IASTCompoundStatement body = (IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[0])
+ .getBody();
IASTSwitchStatement switchStmt = (IASTSwitchStatement) body.getStatements()[0];
- IASTCaseStatement caseStmt = (IASTCaseStatement)((IASTCompoundStatement) switchStmt.getBody()).getStatements()[0];
+ IASTCaseStatement caseStmt = (IASTCaseStatement) ((IASTCompoundStatement) switchStmt.getBody())
+ .getStatements()[0];
IASTBinaryExpression binExpr = (IASTBinaryExpression) caseStmt.getExpression();
assertTrue(binExpr.getOperator() == IASTBinaryExpression.op_ellipses);
assertTrue(binExpr.getOperand1() instanceof IASTLiteralExpression);
@@ -4750,7 +4704,7 @@ public class AST2Tests extends AST2TestBase {
// int x(int (int * a));
// int x(int(TIntPtr));
public void testInfiniteRecursion_269052() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code, C, true);
parseAndCheckBindings(code, CPP, true);
}
@@ -4801,539 +4755,540 @@ public class AST2Tests extends AST2TestBase {
parseAndCheckBindings(code, CPP);
}
- // int f(x) {
- // return 0;
- // }
- public void testBug228422_noKnrParam() throws Exception {
- CharSequence buffer = getContents(1)[0];
- parse(buffer.toString(), C, false);
- }
-
- // struct {
- // char foo;
- // } myStruct, *myStructPointer;
- //
- // union {
- // char foo;
- // } myUnion, *myUnionPointer;
- //
- // void test() {
- // myStruct.foo=1;
- // myStructPointer->foo=2;
- // myUnion.foo=3;
- // myUnionPointer->foo=4;
- //
- // myStruct.bar=1;
- // myStructPointer->bar=2;
- // myUnion.bar=3;
- // myUnionPointer->bar=4;
- // }
- public void testBug228504_nonExistingMembers() throws Exception {
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), lang);
- for (int i= 1; i < 5; i++) {
+ // int f(x) {
+ // return 0;
+ // }
+ public void testBug228422_noKnrParam() throws Exception {
+ CharSequence buffer = getContents(1)[0];
+ parse(buffer.toString(), C, false);
+ }
+
+ // struct {
+ // char foo;
+ // } myStruct, *myStructPointer;
+ //
+ // union {
+ // char foo;
+ // } myUnion, *myUnionPointer;
+ //
+ // void test() {
+ // myStruct.foo=1;
+ // myStructPointer->foo=2;
+ // myUnion.foo=3;
+ // myUnionPointer->foo=4;
+ //
+ // myStruct.bar=1;
+ // myStructPointer->bar=2;
+ // myUnion.bar=3;
+ // myUnionPointer->bar=4;
+ // }
+ public void testBug228504_nonExistingMembers() throws Exception {
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), lang);
+ for (int i = 1; i < 5; i++) {
ba.assertNonProblem("foo=" + i, 3);
ba.assertProblem("bar=" + i, 3);
}
}
- }
-
- // struct S {
- // int value;
- // };
- // typedef struct S *PtrS;
- // struct T {
- // PtrS ptrS;
- // };
- //
- // void testint(int x);
- // void testptr(struct T* x);
- //
- // void test() {
- // struct T* t;
- // t->ptrS->value;
- // (t->ptrS+1)->value;
- // testptr(t-0);
- // testint(t-t);
- // testint(0-t);
- // }
- public void testTypeOfPointerOperations() throws Exception {
- String code= getAboveComment();
- parseAndCheckBindings(code, C);
- parseAndCheckBindings(code, CPP);
- }
-
- // int globalArray[4] = {1,2,3,4};
- // void function1(); // decl
- //
- // void function1() {
- // getArray()[0] = 1;
- // }
- //
- // void function2() {
- // function1(); // ref
- // }
- public void testOutOfOrderResolution_232300() throws Exception {
- String code= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(code, lang);
- IBinding b1= ba.assertNonProblem("function1(); // decl", 9);
- IBinding b2= ba.assertNonProblem("function1() {", 9);
- IBinding b3= ba.assertNonProblem("function1(); // ref", 9);
- assertSame(b1, b2);
- assertSame(b2, b3);
- }
- }
-
- // #define foo __typeof__((int*)0 - (int*)0)
- // typedef foo ptrdiff_t;
- public void testRedefinePtrdiff_230895() throws Exception {
- String code= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(code, lang);
- IBinding b1= ba.assertNonProblem("ptrdiff_t", 9);
- assertInstance(b1, ITypedef.class);
- ITypedef td= (ITypedef) b1;
- IType t= td.getType();
- assertFalse(t instanceof ITypedef);
- }
- }
-
- // int a;
- // int b= a; // ref
- // struct S;
- // typedef struct S S; // td
- public void testRedefineStructInScopeThatIsFullyResolved() throws Exception {
- String code= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(code, lang);
- ba.assertNonProblem("a; // ref", 1);
- // now scope is fully resolved
- ICompositeType ct= ba.assertNonProblem("S;", 1, ICompositeType.class);
- ITypedef td= ba.assertNonProblem("S; // td", 1, ITypedef.class);
- IType t= td.getType();
- assertFalse(t instanceof IProblemBinding);
- assertSame(t, ct);
- }
- }
-
- // void checkLong(long);
- // void test() {
- // checkLong(__builtin_expect(1, 1));
- // }
- public void testReturnTypeOfBuiltin_234309() throws Exception {
- String code= getAboveComment();
- parseAndCheckBindings(code, C, true);
- parseAndCheckBindings(code, CPP, true);
- }
-
- // typedef void VOID;
- // VOID func(void) {
- // }
- public void testTypedefVoid_221567() throws Exception {
- String code= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(code, lang);
- ITypedef td= ba.assertNonProblem("VOID;", 4, ITypedef.class);
-
- IFunction func= ba.assertNonProblem("func", 4, IFunction.class);
- IFunctionType ft= func.getType();
- IType rt= ft.getReturnType();
- IType[] pts= ft.getParameterTypes();
- assertEquals(0, pts.length);
+ }
+
+ // struct S {
+ // int value;
+ // };
+ // typedef struct S *PtrS;
+ // struct T {
+ // PtrS ptrS;
+ // };
+ //
+ // void testint(int x);
+ // void testptr(struct T* x);
+ //
+ // void test() {
+ // struct T* t;
+ // t->ptrS->value;
+ // (t->ptrS+1)->value;
+ // testptr(t-0);
+ // testint(t-t);
+ // testint(0-t);
+ // }
+ public void testTypeOfPointerOperations() throws Exception {
+ String code = getAboveComment();
+ parseAndCheckBindings(code, C);
+ parseAndCheckBindings(code, CPP);
+ }
+
+ // int globalArray[4] = {1,2,3,4};
+ // void function1(); // decl
+ //
+ // void function1() {
+ // getArray()[0] = 1;
+ // }
+ //
+ // void function2() {
+ // function1(); // ref
+ // }
+ public void testOutOfOrderResolution_232300() throws Exception {
+ String code = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, lang);
+ IBinding b1 = ba.assertNonProblem("function1(); // decl", 9);
+ IBinding b2 = ba.assertNonProblem("function1() {", 9);
+ IBinding b3 = ba.assertNonProblem("function1(); // ref", 9);
+ assertSame(b1, b2);
+ assertSame(b2, b3);
+ }
+ }
+
+ // #define foo __typeof__((int*)0 - (int*)0)
+ // typedef foo ptrdiff_t;
+ public void testRedefinePtrdiff_230895() throws Exception {
+ String code = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, lang);
+ IBinding b1 = ba.assertNonProblem("ptrdiff_t", 9);
+ assertInstance(b1, ITypedef.class);
+ ITypedef td = (ITypedef) b1;
+ IType t = td.getType();
+ assertFalse(t instanceof ITypedef);
+ }
+ }
+
+ // int a;
+ // int b= a; // ref
+ // struct S;
+ // typedef struct S S; // td
+ public void testRedefineStructInScopeThatIsFullyResolved() throws Exception {
+ String code = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, lang);
+ ba.assertNonProblem("a; // ref", 1);
+ // now scope is fully resolved
+ ICompositeType ct = ba.assertNonProblem("S;", 1, ICompositeType.class);
+ ITypedef td = ba.assertNonProblem("S; // td", 1, ITypedef.class);
+ IType t = td.getType();
+ assertFalse(t instanceof IProblemBinding);
+ assertSame(t, ct);
+ }
+ }
+
+ // void checkLong(long);
+ // void test() {
+ // checkLong(__builtin_expect(1, 1));
+ // }
+ public void testReturnTypeOfBuiltin_234309() throws Exception {
+ String code = getAboveComment();
+ parseAndCheckBindings(code, C, true);
+ parseAndCheckBindings(code, CPP, true);
+ }
+
+ // typedef void VOID;
+ // VOID func(void) {
+ // }
+ public void testTypedefVoid_221567() throws Exception {
+ String code = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, lang);
+ ITypedef td = ba.assertNonProblem("VOID;", 4, ITypedef.class);
+
+ IFunction func = ba.assertNonProblem("func", 4, IFunction.class);
+ IFunctionType ft = func.getType();
+ IType rt = ft.getReturnType();
+ IType[] pts = ft.getParameterTypes();
+ assertEquals(0, pts.length);
assertInstance(rt, ITypedef.class);
- rt= ((ITypedef) rt).getType();
+ rt = ((ITypedef) rt).getType();
assertTrue(rt instanceof IBasicType);
- assertEquals(IBasicType.Kind.eVoid, ((IBasicType) rt).getKind());
- }
- }
-
- // #define str(s) # s
- //
- // void foo() {
- // printf(str(this is a // this should go away
- // string));
- // }
- public void testCommentInExpansion_84276() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment());
- IASTFunctionDefinition func= (IASTFunctionDefinition) tu.getDeclarations()[0];
-
- IASTFunctionCallExpression fcall= (IASTFunctionCallExpression) ((IASTExpressionStatement)((IASTCompoundStatement) func.getBody()).getStatements()[0]).getExpression();
- IASTLiteralExpression lit= (IASTLiteralExpression) fcall.getArguments()[0];
- assertEquals("\"this is a string\"", lit.toString());
- }
-
- // typedef int tint;
- // tint f1(tint (tint));
- // int f2(int (int));
- // int f3(int (tint));
- // int f4(int (identifier));
- // int f5(int *(tint[10]));
- public void testParamWithFunctionType_84242() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(comment, lang);
-
- IFunction f= ba.assertNonProblem("f1", 2, IFunction.class);
- isTypeEqual(f.getType(), "int (int (*)(int))");
-
- f= ba.assertNonProblem("f2", 2, IFunction.class);
- isTypeEqual(f.getType(), "int (int (*)(int))");
-
- f= ba.assertNonProblem("f3", 2, IFunction.class);
- isTypeEqual(f.getType(), "int (int (*)(int))");
-
- f= ba.assertNonProblem("f4", 2, IFunction.class);
- isTypeEqual(f.getType(), "int (int)");
-
- f= ba.assertNonProblem("f5", 2, IFunction.class);
- isTypeEqual(f.getType(), "int (int * (*)(int *))");
- }
- }
-
- // class C { };
- // void f1(int(C)) { }
- public void testParamWithFunctionTypeCpp_84242() throws Exception {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
-
- IFunction f= ba.assertNonProblem("f1", 2, IFunction.class);
- isTypeEqual(f.getType(), "void (int (*)(C))");
- }
-
- // int (*f1(int par))[5] {};
- // int (*f1 (int par))[5];
- public void testFunctionReturningPtrToArray_216609() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), lang);
-
- IFunction f= ba.assertNonProblem("f1", 2, IFunction.class);
- isTypeEqual(f.getType(), "int (* (int))[5]");
-
- f= ba.assertNonProblem("f1 ", 2, IFunction.class);
- isTypeEqual(f.getType(), "int (* (int))[5]");
- }
- }
-
- // void f1() {}
- // void (f2)() {}
- // void (f3()) {}
- // void ((f4)()) {}
- // void f1();
- // void (f2)();
- // void (f3());
- // void ((f4)());
- public void testNestedFunctionDeclarators() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- IASTTranslationUnit tu= parseAndCheckBindings(comment, lang);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- IASTDeclarator dtor= fdef.getDeclarator();
- assertNull(dtor.getNestedDeclarator());
- assertInstance(dtor.getParent(), IASTFunctionDefinition.class);
- assertInstance(dtor.getName().resolveBinding(), IFunction.class);
-
- fdef= getDeclaration(tu, 1);
- dtor= fdef.getDeclarator();
- assertNotNull(dtor.getNestedDeclarator());
- assertInstance(dtor.getParent(), IASTFunctionDefinition.class);
- assertInstance(dtor.getNestedDeclarator().getName().resolveBinding(), IFunction.class);
-
- fdef= getDeclaration(tu, 2);
- dtor= fdef.getDeclarator();
- assertNull(dtor.getNestedDeclarator());
- assertInstance(dtor.getParent().getParent(), IASTFunctionDefinition.class);
- assertInstance(dtor.getName().resolveBinding(), IFunction.class);
-
- fdef= getDeclaration(tu, 3);
- dtor= fdef.getDeclarator();
- assertNotNull(dtor.getNestedDeclarator());
- assertInstance(dtor.getParent().getParent(), IASTFunctionDefinition.class);
- assertInstance(dtor.getNestedDeclarator().getName().resolveBinding(), IFunction.class);
-
- IASTSimpleDeclaration sdef= getDeclaration(tu, 4);
- IBinding binding= sdef.getDeclarators()[0].getName().resolveBinding();
- assertInstance(binding, IFunction.class);
- assertEquals(2, tu.getDeclarationsInAST(binding).length);
-
- sdef= getDeclaration(tu, 5);
- binding= sdef.getDeclarators()[0].getNestedDeclarator().getName().resolveBinding();
- assertInstance(binding, IFunction.class);
- assertEquals(2, tu.getDeclarationsInAST(binding).length);
-
- sdef= getDeclaration(tu, 6);
- binding= sdef.getDeclarators()[0].getNestedDeclarator().getName().resolveBinding();
- assertInstance(binding, IFunction.class);
- assertEquals(2, tu.getDeclarationsInAST(binding).length);
-
- sdef= getDeclaration(tu, 7);
- binding= sdef.getDeclarators()[0].getNestedDeclarator().getNestedDeclarator().getName().resolveBinding();
- assertInstance(binding, IFunction.class);
- assertEquals(2, tu.getDeclarationsInAST(binding).length);
- }
- }
-
- // void f() {
- // int a,b;
- // { b; a; int a; }
- // }
- public void testLocalVariableResolution_235831() throws Exception {
- final String comment= getAboveComment();
- final boolean[] isCpps= {false, true};
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(comment, lang);
-
- ba.assertNonProblem("b; a", 1, IVariable.class); // fill cache of inner block
- IVariable v3= ba.assertNonProblem("a; }", 1, IVariable.class);
- IVariable v2= ba.assertNonProblem("a; int", 1, IVariable.class);
- IVariable v1= ba.assertNonProblem("a,", 1, IVariable.class);
- assertSame(v1, v2);
- assertNotSame(v2, v3);
- }
- }
-
- // int foo(int (*ptr) (int, int));
- public void testComplexParameterBinding_214482() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(comment, lang);
- IParameter p= ba.assertNonProblem("ptr", 3, IParameter.class);
- assertEquals("ptr", p.getName());
- }
- }
-
- // void test() {}
- // +
- public void testTrailingSyntaxErrorInTU() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTDeclaration decl= getDeclaration(tu, 0);
- IASTProblemDeclaration pdecl= getDeclaration(tu, 1);
- assertEquals("+", pdecl.getRawSignature());
- }
- }
-
- // struct X {
- // int test;
- // +
- // };
- public void testTrailingSyntaxErrorInCompositeType() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTCompositeTypeSpecifier ct= getCompositeType(tu, 0);
- IASTDeclaration decl= getDeclaration(ct, 0);
- IASTProblemDeclaration pdecl= getDeclaration(ct, 1);
- assertEquals("+", pdecl.getRawSignature());
- }
- }
-
- // void func() {
- // {
- // int test;
- // +
- // }
- // }
- public void testTrailingSyntaxErrorInCompoundStatements() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTFunctionDefinition def= getDeclaration(tu, 0);
- IASTCompoundStatement compStmt= getStatement(def, 0);
- IASTDeclarationStatement dstmt= getStatement(compStmt, 0);
- IASTProblemStatement pstmt= getStatement(compStmt, 1);
- assertEquals("+", pstmt.getRawSignature());
- }
- }
-
- // struct X {
- // ;
- // };
- // ;
- public void testEmptyDeclarations() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTCompositeTypeSpecifier ct= getCompositeType(tu, 0);
- IASTDeclaration empty= getDeclaration(ct, 0);
- assertEquals(";", empty.getRawSignature());
- empty= getDeclaration(tu, 1);
- assertEquals(";", empty.getRawSignature());
- }
- }
-
- // void test() {
- // int foux = 3;
- // switch(foux) // no brace!
- // case 0:
- // case 1:
- // foux= 0;
- // foux= 1;
- // }
- public void testSwitchWithoutCompound_105334() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- IASTSwitchStatement sw= getStatement(fdef, 1);
- IASTStatement stmt= getStatement(fdef, 2);
- assertEquals("foux= 1;", stmt.getRawSignature());
- }
- }
-
- // typedef int t;
- // int a,b;
- // void test() {
-
- // b* (t)+a *b // b,t,a,unary+,cast,*,b,*
- // b*(a) + a*b // b,a,*,a,b,*,+
- // b* (t)-a *b // b,t,a,unary-,cast,*,b,*
- // b*(a) - a*b // b,a,*,a,b,*,-
- // b* (t)*a *b // b,t,a,unary*,cast,*,b,*
- // b*(a) * a * b // b,a,*,a,*,b,*
- // b == (t)&a < b // b,t,a,unary&,cast,b,<,==
- // b < (t)&a == b // b,t,a,unary&,cast,<,b,==
- // b==(a) & a<b // b,a,==,a,b,<,&
- // +(t)+1 // t,1,unary+,cast,unary+
- // +(a)+1 // a,unary+,1,+
- // sizeof +(t)+1 // t,1,unary+,cast,unary+,sizeof
- // sizeof +(a)+1 // a,unary+,sizeof,1,+
- // b* (t)(t)+a * b // b,t,t,a,unary+,cast,cast,*,b,*
- // b* (t)(a)+a * b // b,t,a,cast,*,a,b,*,+
- // (int)(t)+1 // int,t,1,unary+,cast,cast
- // (int)(a)+1 // int,a,cast,1,+
- // a*a*(t)+a*a*a // a,a,*,t,a,unary+,cast,*,a,*,a,*
- // (typeof a)(t)-a // typeof a,t,a,unary-,cast,cast
- // (typeof a)(a)-a // typeof a,a,cast,a,-
- public void testBinaryVsCastAmbiguities_237057() throws Exception {
- CharSequence[] input= getContents(2);
- String code= input[0].toString();
- String[] samples= input[1].toString().split("\n");
- for (ParserLanguage lang : ParserLanguage.values()) {
- for (String s : samples) {
- final String[] io= s.split("//");
- final String exprStr = io[0].trim();
- final IASTTranslationUnit tu= parse(code + exprStr + ";}", lang);
- final IASTFunctionDefinition fdef= getDeclaration(tu, 2);
- IASTExpression expr= getExpressionOfStatement(fdef, 0);
+ assertEquals(IBasicType.Kind.eVoid, ((IBasicType) rt).getKind());
+ }
+ }
+
+ // #define str(s) # s
+ //
+ // void foo() {
+ // printf(str(this is a // this should go away
+ // string));
+ // }
+ public void testCommentInExpansion_84276() throws Exception {
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment());
+ IASTFunctionDefinition func = (IASTFunctionDefinition) tu.getDeclarations()[0];
+
+ IASTFunctionCallExpression fcall = (IASTFunctionCallExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) func
+ .getBody()).getStatements()[0]).getExpression();
+ IASTLiteralExpression lit = (IASTLiteralExpression) fcall.getArguments()[0];
+ assertEquals("\"this is a string\"", lit.toString());
+ }
+
+ // typedef int tint;
+ // tint f1(tint (tint));
+ // int f2(int (int));
+ // int f3(int (tint));
+ // int f4(int (identifier));
+ // int f5(int *(tint[10]));
+ public void testParamWithFunctionType_84242() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(comment, lang);
+
+ IFunction f = ba.assertNonProblem("f1", 2, IFunction.class);
+ isTypeEqual(f.getType(), "int (int (*)(int))");
+
+ f = ba.assertNonProblem("f2", 2, IFunction.class);
+ isTypeEqual(f.getType(), "int (int (*)(int))");
+
+ f = ba.assertNonProblem("f3", 2, IFunction.class);
+ isTypeEqual(f.getType(), "int (int (*)(int))");
+
+ f = ba.assertNonProblem("f4", 2, IFunction.class);
+ isTypeEqual(f.getType(), "int (int)");
+
+ f = ba.assertNonProblem("f5", 2, IFunction.class);
+ isTypeEqual(f.getType(), "int (int * (*)(int *))");
+ }
+ }
+
+ // class C { };
+ // void f1(int(C)) { }
+ public void testParamWithFunctionTypeCpp_84242() throws Exception {
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
+
+ IFunction f = ba.assertNonProblem("f1", 2, IFunction.class);
+ isTypeEqual(f.getType(), "void (int (*)(C))");
+ }
+
+ // int (*f1(int par))[5] {};
+ // int (*f1 (int par))[5];
+ public void testFunctionReturningPtrToArray_216609() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), lang);
+
+ IFunction f = ba.assertNonProblem("f1", 2, IFunction.class);
+ isTypeEqual(f.getType(), "int (* (int))[5]");
+
+ f = ba.assertNonProblem("f1 ", 2, IFunction.class);
+ isTypeEqual(f.getType(), "int (* (int))[5]");
+ }
+ }
+
+ // void f1() {}
+ // void (f2)() {}
+ // void (f3()) {}
+ // void ((f4)()) {}
+ // void f1();
+ // void (f2)();
+ // void (f3());
+ // void ((f4)());
+ public void testNestedFunctionDeclarators() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parseAndCheckBindings(comment, lang);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ IASTDeclarator dtor = fdef.getDeclarator();
+ assertNull(dtor.getNestedDeclarator());
+ assertInstance(dtor.getParent(), IASTFunctionDefinition.class);
+ assertInstance(dtor.getName().resolveBinding(), IFunction.class);
+
+ fdef = getDeclaration(tu, 1);
+ dtor = fdef.getDeclarator();
+ assertNotNull(dtor.getNestedDeclarator());
+ assertInstance(dtor.getParent(), IASTFunctionDefinition.class);
+ assertInstance(dtor.getNestedDeclarator().getName().resolveBinding(), IFunction.class);
+
+ fdef = getDeclaration(tu, 2);
+ dtor = fdef.getDeclarator();
+ assertNull(dtor.getNestedDeclarator());
+ assertInstance(dtor.getParent().getParent(), IASTFunctionDefinition.class);
+ assertInstance(dtor.getName().resolveBinding(), IFunction.class);
+
+ fdef = getDeclaration(tu, 3);
+ dtor = fdef.getDeclarator();
+ assertNotNull(dtor.getNestedDeclarator());
+ assertInstance(dtor.getParent().getParent(), IASTFunctionDefinition.class);
+ assertInstance(dtor.getNestedDeclarator().getName().resolveBinding(), IFunction.class);
+
+ IASTSimpleDeclaration sdef = getDeclaration(tu, 4);
+ IBinding binding = sdef.getDeclarators()[0].getName().resolveBinding();
+ assertInstance(binding, IFunction.class);
+ assertEquals(2, tu.getDeclarationsInAST(binding).length);
+
+ sdef = getDeclaration(tu, 5);
+ binding = sdef.getDeclarators()[0].getNestedDeclarator().getName().resolveBinding();
+ assertInstance(binding, IFunction.class);
+ assertEquals(2, tu.getDeclarationsInAST(binding).length);
+
+ sdef = getDeclaration(tu, 6);
+ binding = sdef.getDeclarators()[0].getNestedDeclarator().getName().resolveBinding();
+ assertInstance(binding, IFunction.class);
+ assertEquals(2, tu.getDeclarationsInAST(binding).length);
+
+ sdef = getDeclaration(tu, 7);
+ binding = sdef.getDeclarators()[0].getNestedDeclarator().getNestedDeclarator().getName().resolveBinding();
+ assertInstance(binding, IFunction.class);
+ assertEquals(2, tu.getDeclarationsInAST(binding).length);
+ }
+ }
+
+ // void f() {
+ // int a,b;
+ // { b; a; int a; }
+ // }
+ public void testLocalVariableResolution_235831() throws Exception {
+ final String comment = getAboveComment();
+ final boolean[] isCpps = { false, true };
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(comment, lang);
+
+ ba.assertNonProblem("b; a", 1, IVariable.class); // fill cache of inner block
+ IVariable v3 = ba.assertNonProblem("a; }", 1, IVariable.class);
+ IVariable v2 = ba.assertNonProblem("a; int", 1, IVariable.class);
+ IVariable v1 = ba.assertNonProblem("a,", 1, IVariable.class);
+ assertSame(v1, v2);
+ assertNotSame(v2, v3);
+ }
+ }
+
+ // int foo(int (*ptr) (int, int));
+ public void testComplexParameterBinding_214482() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(comment, lang);
+ IParameter p = ba.assertNonProblem("ptr", 3, IParameter.class);
+ assertEquals("ptr", p.getName());
+ }
+ }
+
+ // void test() {}
+ // +
+ public void testTrailingSyntaxErrorInTU() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTDeclaration decl = getDeclaration(tu, 0);
+ IASTProblemDeclaration pdecl = getDeclaration(tu, 1);
+ assertEquals("+", pdecl.getRawSignature());
+ }
+ }
+
+ // struct X {
+ // int test;
+ // +
+ // };
+ public void testTrailingSyntaxErrorInCompositeType() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTCompositeTypeSpecifier ct = getCompositeType(tu, 0);
+ IASTDeclaration decl = getDeclaration(ct, 0);
+ IASTProblemDeclaration pdecl = getDeclaration(ct, 1);
+ assertEquals("+", pdecl.getRawSignature());
+ }
+ }
+
+ // void func() {
+ // {
+ // int test;
+ // +
+ // }
+ // }
+ public void testTrailingSyntaxErrorInCompoundStatements() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTFunctionDefinition def = getDeclaration(tu, 0);
+ IASTCompoundStatement compStmt = getStatement(def, 0);
+ IASTDeclarationStatement dstmt = getStatement(compStmt, 0);
+ IASTProblemStatement pstmt = getStatement(compStmt, 1);
+ assertEquals("+", pstmt.getRawSignature());
+ }
+ }
+
+ // struct X {
+ // ;
+ // };
+ // ;
+ public void testEmptyDeclarations() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTCompositeTypeSpecifier ct = getCompositeType(tu, 0);
+ IASTDeclaration empty = getDeclaration(ct, 0);
+ assertEquals(";", empty.getRawSignature());
+ empty = getDeclaration(tu, 1);
+ assertEquals(";", empty.getRawSignature());
+ }
+ }
+
+ // void test() {
+ // int foux = 3;
+ // switch(foux) // no brace!
+ // case 0:
+ // case 1:
+ // foux= 0;
+ // foux= 1;
+ // }
+ public void testSwitchWithoutCompound_105334() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ IASTSwitchStatement sw = getStatement(fdef, 1);
+ IASTStatement stmt = getStatement(fdef, 2);
+ assertEquals("foux= 1;", stmt.getRawSignature());
+ }
+ }
+
+ // typedef int t;
+ // int a,b;
+ // void test() {
+
+ // b* (t)+a *b // b,t,a,unary+,cast,*,b,*
+ // b*(a) + a*b // b,a,*,a,b,*,+
+ // b* (t)-a *b // b,t,a,unary-,cast,*,b,*
+ // b*(a) - a*b // b,a,*,a,b,*,-
+ // b* (t)*a *b // b,t,a,unary*,cast,*,b,*
+ // b*(a) * a * b // b,a,*,a,*,b,*
+ // b == (t)&a < b // b,t,a,unary&,cast,b,<,==
+ // b < (t)&a == b // b,t,a,unary&,cast,<,b,==
+ // b==(a) & a<b // b,a,==,a,b,<,&
+ // +(t)+1 // t,1,unary+,cast,unary+
+ // +(a)+1 // a,unary+,1,+
+ // sizeof +(t)+1 // t,1,unary+,cast,unary+,sizeof
+ // sizeof +(a)+1 // a,unary+,sizeof,1,+
+ // b* (t)(t)+a * b // b,t,t,a,unary+,cast,cast,*,b,*
+ // b* (t)(a)+a * b // b,t,a,cast,*,a,b,*,+
+ // (int)(t)+1 // int,t,1,unary+,cast,cast
+ // (int)(a)+1 // int,a,cast,1,+
+ // a*a*(t)+a*a*a // a,a,*,t,a,unary+,cast,*,a,*,a,*
+ // (typeof a)(t)-a // typeof a,t,a,unary-,cast,cast
+ // (typeof a)(a)-a // typeof a,a,cast,a,-
+ public void testBinaryVsCastAmbiguities_237057() throws Exception {
+ CharSequence[] input = getContents(2);
+ String code = input[0].toString();
+ String[] samples = input[1].toString().split("\n");
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ for (String s : samples) {
+ final String[] io = s.split("//");
+ final String exprStr = io[0].trim();
+ final IASTTranslationUnit tu = parse(code + exprStr + ";}", lang);
+ final IASTFunctionDefinition fdef = getDeclaration(tu, 2);
+ IASTExpression expr = getExpressionOfStatement(fdef, 0);
assertEquals("expr: " + exprStr, io[1].trim(), polishNotation(expr));
- assertEquals(exprStr, expr.getRawSignature());
- checkOffsets(exprStr, expr);
+ assertEquals(exprStr, expr.getRawSignature());
+ checkOffsets(exprStr, expr);
}
- }
- }
-
- // struct s {int b;};
- // typedef int t;
- // struct s* a;
- // struct s* f(struct s*);
- // void test() {
-
- // (t)(a) // t,a,cast
- // (f)(a) // f,a,()
- // (t)(t)(a) // t,t,a,cast,cast
- // (t)(f)(a) // t,f,a,(),cast
- // (f)(a)(a) // f,a,(),a,()
- // (t)(f)(a)++ // t,f,a,(),++,cast
- // (t)(t)(a)++ // t,t,a,++,cast,cast
- // (t)(f)(a)-- // t,f,a,(),--,cast
- // (t)(t)(a)-- // t,t,a,--,cast,cast
- // (t)(f)(a)[0] // t,f,a,(),0,[],cast
- // (t)(t)(a)[0] // t,t,a,0,[],cast,cast
- // (t)(f)(a)->b // t,f,a,(),b,->,cast
- // (t)(t)(a)->b // t,t,a,b,->,cast,cast
- // (t)(a)+1 // t,a,cast,1,+
- // (f)(a)+1 // f,a,(),1,+
- // (t)(t)+1 // t,t,1,unary+,cast,cast
- public void testCastVsFunctionCallAmbiguities_237057() throws Exception {
- CharSequence[] input= getContents(2);
- String code= input[0].toString();
- String[] samples= input[1].toString().split("\n");
- for (ParserLanguage lang : ParserLanguage.values()) {
- for (String s : samples) {
- final String[] io= s.split("//");
- final String exprStr = io[0].trim();
- final IASTTranslationUnit tu= parse(code + exprStr + ";}", lang);
- final IASTFunctionDefinition fdef= getDeclaration(tu, 4);
- IASTExpression expr= getExpressionOfStatement(fdef, 0);
+ }
+ }
+
+ // struct s {int b;};
+ // typedef int t;
+ // struct s* a;
+ // struct s* f(struct s*);
+ // void test() {
+
+ // (t)(a) // t,a,cast
+ // (f)(a) // f,a,()
+ // (t)(t)(a) // t,t,a,cast,cast
+ // (t)(f)(a) // t,f,a,(),cast
+ // (f)(a)(a) // f,a,(),a,()
+ // (t)(f)(a)++ // t,f,a,(),++,cast
+ // (t)(t)(a)++ // t,t,a,++,cast,cast
+ // (t)(f)(a)-- // t,f,a,(),--,cast
+ // (t)(t)(a)-- // t,t,a,--,cast,cast
+ // (t)(f)(a)[0] // t,f,a,(),0,[],cast
+ // (t)(t)(a)[0] // t,t,a,0,[],cast,cast
+ // (t)(f)(a)->b // t,f,a,(),b,->,cast
+ // (t)(t)(a)->b // t,t,a,b,->,cast,cast
+ // (t)(a)+1 // t,a,cast,1,+
+ // (f)(a)+1 // f,a,(),1,+
+ // (t)(t)+1 // t,t,1,unary+,cast,cast
+ public void testCastVsFunctionCallAmbiguities_237057() throws Exception {
+ CharSequence[] input = getContents(2);
+ String code = input[0].toString();
+ String[] samples = input[1].toString().split("\n");
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ for (String s : samples) {
+ final String[] io = s.split("//");
+ final String exprStr = io[0].trim();
+ final IASTTranslationUnit tu = parse(code + exprStr + ";}", lang);
+ final IASTFunctionDefinition fdef = getDeclaration(tu, 4);
+ IASTExpression expr = getExpressionOfStatement(fdef, 0);
assertEquals("expr: " + exprStr, io[1].trim(), polishNotation(expr));
- assertEquals(exprStr, expr.getRawSignature());
- checkOffsets(exprStr, expr);
+ assertEquals(exprStr, expr.getRawSignature());
+ checkOffsets(exprStr, expr);
}
- }
- }
-
- // int a,b;
- // void test() {
-
- // 1+2+3 // 1,2,+,3,+
- // a=b=1 // a,b,1,=,=
- // 0, a= 1 ? 2,3 : b= 4, 5 // 0,a,1,2,3,,,b,4,=,?,=,5,,
- // 1 ? 2 ? 3 : 4 ? 5 : 6 : 7 // 1,2,3,4,5,6,?,?,7,?
- public void testBinaryExpressionBinding() throws Exception {
- CharSequence[] input= getContents(2);
- String code= input[0].toString();
- String[] samples= input[1].toString().split("\n");
- for (ParserLanguage lang : ParserLanguage.values()) {
- for (String s : samples) {
- final String[] io= s.split("//");
- final String exprStr = io[0].trim();
- final IASTTranslationUnit tu= parse(code + exprStr + ";}", lang);
- final IASTFunctionDefinition fdef= getDeclaration(tu, 1);
- IASTExpression expr= getExpressionOfStatement(fdef, 0);
+ }
+ }
+
+ // int a,b;
+ // void test() {
+
+ // 1+2+3 // 1,2,+,3,+
+ // a=b=1 // a,b,1,=,=
+ // 0, a= 1 ? 2,3 : b= 4, 5 // 0,a,1,2,3,,,b,4,=,?,=,5,,
+ // 1 ? 2 ? 3 : 4 ? 5 : 6 : 7 // 1,2,3,4,5,6,?,?,7,?
+ public void testBinaryExpressionBinding() throws Exception {
+ CharSequence[] input = getContents(2);
+ String code = input[0].toString();
+ String[] samples = input[1].toString().split("\n");
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ for (String s : samples) {
+ final String[] io = s.split("//");
+ final String exprStr = io[0].trim();
+ final IASTTranslationUnit tu = parse(code + exprStr + ";}", lang);
+ final IASTFunctionDefinition fdef = getDeclaration(tu, 1);
+ IASTExpression expr = getExpressionOfStatement(fdef, 0);
assertEquals("expr: " + exprStr, io[1].trim(), polishNotation(expr));
- assertEquals(exprStr, expr.getRawSignature());
- checkOffsets(exprStr, expr);
+ assertEquals(exprStr, expr.getRawSignature());
+ checkOffsets(exprStr, expr);
}
- }
- }
-
- // int a,b;
- // void test(int a=
-
- // 1+2+3 // 1,2,+,3,+
- // a=b=1 // a,b,1,=,=
- // 1 ? 2,3 : b= 4 // 1,2,3,,,b,4,=,?
- // 1 ? 2 ? 3 : 4 ? 5 : 6 : 7 // 1,2,3,4,5,6,?,?,7,?
- public void testConstantExpressionBinding() throws Exception {
- CharSequence[] input= getContents(2);
- String code= input[0].toString();
- String[] samples= input[1].toString().split("\n");
- for (ParserLanguage lang : ParserLanguage.values()) {
- for (String s : samples) {
- final String[] io= s.split("//");
- final String exprStr = io[0].trim();
- final IASTTranslationUnit tu= parse(code + exprStr + "){}", lang);
- final IASTFunctionDefinition fdef= getDeclaration(tu, 1);
- IASTFunctionDeclarator fdtor= fdef.getDeclarator();
- IASTParameterDeclaration pdecl= (IASTParameterDeclaration) fdtor.getChildren()[1];
- IASTExpression expr= (IASTExpression) ((IASTEqualsInitializer) pdecl.getDeclarator().getInitializer()).getInitializerClause();
+ }
+ }
+
+ // int a,b;
+ // void test(int a=
+
+ // 1+2+3 // 1,2,+,3,+
+ // a=b=1 // a,b,1,=,=
+ // 1 ? 2,3 : b= 4 // 1,2,3,,,b,4,=,?
+ // 1 ? 2 ? 3 : 4 ? 5 : 6 : 7 // 1,2,3,4,5,6,?,?,7,?
+ public void testConstantExpressionBinding() throws Exception {
+ CharSequence[] input = getContents(2);
+ String code = input[0].toString();
+ String[] samples = input[1].toString().split("\n");
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ for (String s : samples) {
+ final String[] io = s.split("//");
+ final String exprStr = io[0].trim();
+ final IASTTranslationUnit tu = parse(code + exprStr + "){}", lang);
+ final IASTFunctionDefinition fdef = getDeclaration(tu, 1);
+ IASTFunctionDeclarator fdtor = fdef.getDeclarator();
+ IASTParameterDeclaration pdecl = (IASTParameterDeclaration) fdtor.getChildren()[1];
+ IASTExpression expr = (IASTExpression) ((IASTEqualsInitializer) pdecl.getDeclarator().getInitializer())
+ .getInitializerClause();
assertEquals("expr: " + exprStr, io[1].trim(), polishNotation(expr));
- assertEquals(exprStr, expr.getRawSignature());
- checkOffsets(exprStr, expr);
+ assertEquals(exprStr, expr.getRawSignature());
+ checkOffsets(exprStr, expr);
}
- }
- }
-
+ }
+ }
private void checkOffsets(String exprStr, IASTExpression expr) {
if (expr instanceof IASTBinaryExpression) {
- IASTBinaryExpression bexpr= (IASTBinaryExpression) expr;
+ IASTBinaryExpression bexpr = (IASTBinaryExpression) expr;
checkOffsets(exprStr, bexpr.getOperand1());
checkOffsets(exprStr, bexpr.getOperand2());
assertEquals("in expr: " + exprStr, offset(bexpr), offset(bexpr.getOperand1()));
assertTrue("in expr: " + exprStr, endOffset(bexpr.getOperand1()) < offset(bexpr.getOperand2()));
assertEquals("in expr: " + exprStr, endOffset(bexpr), endOffset(bexpr.getOperand2()));
} else if (expr instanceof IASTCastExpression) {
- IASTCastExpression castExpr= (IASTCastExpression) expr;
+ IASTCastExpression castExpr = (IASTCastExpression) expr;
checkOffsets(exprStr, castExpr.getOperand());
assertTrue("in expr: " + exprStr, offset(castExpr) < offset(castExpr.getTypeId()));
assertTrue("in expr: " + exprStr, endOffset(castExpr.getTypeId()) < offset(castExpr.getOperand()));
assertEquals("in expr: " + exprStr, endOffset(castExpr), endOffset(castExpr.getOperand()));
} else if (expr instanceof IASTUnaryExpression) {
- IASTUnaryExpression unaryExpr= (IASTUnaryExpression) expr;
+ IASTUnaryExpression unaryExpr = (IASTUnaryExpression) expr;
checkOffsets(exprStr, unaryExpr.getOperand());
switch (unaryExpr.getOperator()) {
case IASTUnaryExpression.op_bracketedPrimary:
@@ -5362,14 +5317,14 @@ public class AST2Tests extends AST2TestBase {
}
private String polishNotation(IASTInitializerClause expr) {
- StringBuilder buf= new StringBuilder();
+ StringBuilder buf = new StringBuilder();
polishNotation(expr, buf);
return buf.toString();
}
private void polishNotation(IASTInitializerClause expr, StringBuilder buf) {
if (expr instanceof IASTConditionalExpression) {
- IASTConditionalExpression bexpr= (IASTConditionalExpression) expr;
+ IASTConditionalExpression bexpr = (IASTConditionalExpression) expr;
polishNotation(bexpr.getLogicalConditionExpression(), buf);
buf.append(',');
polishNotation(bexpr.getPositiveResultExpression(), buf);
@@ -5378,7 +5333,7 @@ public class AST2Tests extends AST2TestBase {
buf.append(',');
buf.append('?');
} else if (expr instanceof IASTExpressionList) {
- IASTExpressionList bexpr= (IASTExpressionList) expr;
+ IASTExpressionList bexpr = (IASTExpressionList) expr;
IASTExpression[] args = bexpr.getExpressions();
for (IASTExpression e : args) {
polishNotation(e, buf);
@@ -5386,20 +5341,20 @@ public class AST2Tests extends AST2TestBase {
}
buf.append(',');
} else if (expr instanceof IASTBinaryExpression) {
- IASTBinaryExpression bexpr= (IASTBinaryExpression) expr;
+ IASTBinaryExpression bexpr = (IASTBinaryExpression) expr;
polishNotation(bexpr.getOperand1(), buf);
buf.append(',');
polishNotation(bexpr.getOperand2(), buf);
buf.append(',');
buf.append(ASTStringUtil.getBinaryOperatorString(bexpr));
} else if (expr instanceof IASTCastExpression) {
- IASTCastExpression castExpr= (IASTCastExpression) expr;
+ IASTCastExpression castExpr = (IASTCastExpression) expr;
buf.append(castExpr.getTypeId().getRawSignature());
buf.append(',');
polishNotation(castExpr.getOperand(), buf);
buf.append(",cast");
} else if (expr instanceof IASTFunctionCallExpression) {
- IASTFunctionCallExpression f= (IASTFunctionCallExpression) expr;
+ IASTFunctionCallExpression f = (IASTFunctionCallExpression) expr;
polishNotation(f.getFunctionNameExpression(), buf);
buf.append(',');
for (IASTInitializerClause arg : f.getArguments()) {
@@ -5408,20 +5363,20 @@ public class AST2Tests extends AST2TestBase {
}
buf.append("()");
} else if (expr instanceof IASTArraySubscriptExpression) {
- IASTArraySubscriptExpression f= (IASTArraySubscriptExpression) expr;
+ IASTArraySubscriptExpression f = (IASTArraySubscriptExpression) expr;
polishNotation(f.getArrayExpression(), buf);
buf.append(',');
polishNotation(f.getArgument(), buf);
buf.append(",[]");
} else if (expr instanceof IASTFieldReference) {
- IASTFieldReference f= (IASTFieldReference) expr;
+ IASTFieldReference f = (IASTFieldReference) expr;
polishNotation(f.getFieldOwner(), buf);
buf.append(',');
buf.append(f.getFieldName().toString());
buf.append(',');
buf.append(f.isPointerDereference() ? "->" : ".");
} else if (expr instanceof IASTUnaryExpression) {
- IASTUnaryExpression unaryExpr= (IASTUnaryExpression) expr;
+ IASTUnaryExpression unaryExpr = (IASTUnaryExpression) expr;
polishNotation(unaryExpr.getOperand(), buf);
switch (unaryExpr.getOperator()) {
case IASTUnaryExpression.op_amper:
@@ -5453,13 +5408,13 @@ public class AST2Tests extends AST2TestBase {
// int x;
// } spinlock_t;
// spinlock_t _lock = (spinlock_t) { };
- public void testCompoundInitializer_145387() throws Exception {
+ public void testCompoundInitializer_145387() throws Exception {
// valid in C99, not in C++.
parseAndCheckBindings(getAboveComment(), C, true);
}
// enum __declspec(uuid("uuid")) bla { a, b};
- public void testDeclspecInEnumSpecifier_241203() throws Exception {
+ public void testDeclspecInEnumSpecifier_241203() throws Exception {
for (ParserLanguage lang : ParserLanguage.values()) {
parseAndCheckBindings(getAboveComment(), lang, true);
}
@@ -5474,9 +5429,9 @@ public class AST2Tests extends AST2TestBase {
// o.a1=0; o.a2=0; o.a3=0;
// }
public void testAnonymousUnionMember() throws Exception {
- final boolean[] isCpps= {false, true};
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper bh= new AST2AssertionHelper(getAboveComment(), lang);
+ final boolean[] isCpps = { false, true };
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), lang);
bh.assertNonProblem("a1=", 2);
bh.assertProblem("a2=", 2);
bh.assertNonProblem("a3=", 2);
@@ -5488,7 +5443,7 @@ public class AST2Tests extends AST2TestBase {
// if (__builtin_types_compatible_p(typeof(p), char[])) {
// }
// }
- public void testBuiltinTypesCompatible_241570() throws Exception {
+ public void testBuiltinTypesCompatible_241570() throws Exception {
for (ParserLanguage lang : ParserLanguage.values()) {
parseAndCheckBindings(getAboveComment(), lang, true);
}
@@ -5529,63 +5484,88 @@ public class AST2Tests extends AST2TestBase {
// #define IF_COND if (1)
// void test() {
public void testLeadingSyntax_250251() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code + "if (1) {};}");
- IASTFunctionDefinition f= getDeclaration(tu, 0);
+ IASTTranslationUnit tu = parseAndCheckBindings(code + "if (1) {};}");
+ IASTFunctionDefinition f = getDeclaration(tu, 0);
IASTIfStatement i = getStatement(f, 0);
- IASTExpression x= i.getConditionExpression();
- IToken syntax= x.getLeadingSyntax();
- checkToken(syntax, "if", -4); syntax= syntax.getNext();
- checkToken(syntax, "(", -1); syntax= syntax.getNext();
+ IASTExpression x = i.getConditionExpression();
+ IToken syntax = x.getLeadingSyntax();
+ checkToken(syntax, "if", -4);
+ syntax = syntax.getNext();
+ checkToken(syntax, "(", -1);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "if( 1) {}}");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
- syntax= x.getLeadingSyntax();
- checkToken(syntax, "if", -5); syntax= syntax.getNext();
- checkToken(syntax, "(", -3); syntax= syntax.getNext();
+ tu = parseAndCheckBindings(code + "if( 1) {}}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ x = i.getConditionExpression();
+ syntax = x.getLeadingSyntax();
+ checkToken(syntax, "if", -5);
+ syntax = syntax.getNext();
+ checkToken(syntax, "(", -3);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "if(1) ; else ;}");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); IASTStatement est= i.getElseClause();
- syntax= est.getLeadingSyntax();
- checkToken(syntax, "else", -5); syntax= syntax.getNext();
+ tu = parseAndCheckBindings(code + "if(1) ; else ;}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ IASTStatement est = i.getElseClause();
+ syntax = est.getLeadingSyntax();
+ checkToken(syntax, "else", -5);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "IF(1) {}}");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
- syntax= x.getLeadingSyntax();
- checkToken(syntax, "IF", -3); syntax= syntax.getNext();
- checkToken(syntax, "(", -1); syntax= syntax.getNext();
+ tu = parseAndCheckBindings(code + "IF(1) {}}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ x = i.getConditionExpression();
+ syntax = x.getLeadingSyntax();
+ checkToken(syntax, "IF", -3);
+ syntax = syntax.getNext();
+ checkToken(syntax, "(", -1);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "IF_P 1) {}}");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
- syntax= x.getLeadingSyntax();
- checkToken(syntax, "IF_P", -5); syntax= syntax.getNext();
+ tu = parseAndCheckBindings(code + "IF_P 1) {}}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ x = i.getConditionExpression();
+ syntax = x.getLeadingSyntax();
+ checkToken(syntax, "IF_P", -5);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "IF_P_T) {}}");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
+ tu = parseAndCheckBindings(code + "IF_P_T) {}}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ x = i.getConditionExpression();
try {
- syntax= x.getLeadingSyntax();
+ syntax = x.getLeadingSyntax();
fail();
- } catch (ExpansionOverlapsBoundaryException e) {}
+ } catch (ExpansionOverlapsBoundaryException e) {
+ }
- tu= parseAndCheckBindings(code + "SEMI_IF (1) {}}");
- f= getDeclaration(tu, 0); i= getStatement(f, 1); x= i.getConditionExpression();
+ tu = parseAndCheckBindings(code + "SEMI_IF (1) {}}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 1);
+ x = i.getConditionExpression();
try {
- syntax= x.getLeadingSyntax();
+ syntax = x.getLeadingSyntax();
fail();
- } catch (ExpansionOverlapsBoundaryException e) {}
+ } catch (ExpansionOverlapsBoundaryException e) {
+ }
- tu= parseAndCheckBindings(code + "IF_COND {}}");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
+ tu = parseAndCheckBindings(code + "IF_COND {}}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ x = i.getConditionExpression();
try {
- syntax= x.getLeadingSyntax();
+ syntax = x.getLeadingSyntax();
fail();
- } catch (ExpansionOverlapsBoundaryException e) {}
+ } catch (ExpansionOverlapsBoundaryException e) {
+ }
}
// #define P(x) )
@@ -5595,58 +5575,78 @@ public class AST2Tests extends AST2TestBase {
// #define IF_COND if (1)
// void test() {
public void testTrailingSyntax_250251() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code + "if (1) {};}");
- IASTFunctionDefinition f= getDeclaration(tu, 0);
+ IASTTranslationUnit tu = parseAndCheckBindings(code + "if (1) {};}");
+ IASTFunctionDefinition f = getDeclaration(tu, 0);
IASTIfStatement i = getStatement(f, 0);
- IASTExpression x= i.getConditionExpression();
- IToken syntax= x.getTrailingSyntax();
- checkToken(syntax, ")", 0); syntax= syntax.getNext();
+ IASTExpression x = i.getConditionExpression();
+ IToken syntax = x.getTrailingSyntax();
+ checkToken(syntax, ")", 0);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "do {} while(1 );}");
- f= getDeclaration(tu, 0); IASTDoStatement dstmt= getStatement(f, 0); x= dstmt.getCondition();
- syntax= x.getTrailingSyntax();
- checkToken(syntax, ")", 1); syntax= syntax.getNext();
- checkToken(syntax, ";", 2); syntax= syntax.getNext();
+ tu = parseAndCheckBindings(code + "do {} while(1 );}");
+ f = getDeclaration(tu, 0);
+ IASTDoStatement dstmt = getStatement(f, 0);
+ x = dstmt.getCondition();
+ syntax = x.getTrailingSyntax();
+ checkToken(syntax, ")", 1);
+ syntax = syntax.getNext();
+ checkToken(syntax, ";", 2);
+ syntax = syntax.getNext();
assertNull(syntax);
-
- tu= parseAndCheckBindings(code + "if(1 ) BLOCK()}");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
- syntax= x.getTrailingSyntax();
- checkToken(syntax, ")", 1); syntax= syntax.getNext();
+ tu = parseAndCheckBindings(code + "if(1 ) BLOCK()}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ x = i.getConditionExpression();
+ syntax = x.getTrailingSyntax();
+ checkToken(syntax, ")", 1);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "if(1 P(0) {}}");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
- syntax= x.getTrailingSyntax();
- checkToken(syntax, "P", 1); syntax= syntax.getNext();
- checkToken(syntax, "(", 2); syntax= syntax.getNext();
- checkToken(syntax, "0", 3); syntax= syntax.getNext();
- checkToken(syntax, ")", 4); syntax= syntax.getNext();
+ tu = parseAndCheckBindings(code + "if(1 P(0) {}}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ x = i.getConditionExpression();
+ syntax = x.getTrailingSyntax();
+ checkToken(syntax, "P", 1);
+ syntax = syntax.getNext();
+ checkToken(syntax, "(", 2);
+ syntax = syntax.getNext();
+ checkToken(syntax, "0", 3);
+ syntax = syntax.getNext();
+ checkToken(syntax, ")", 4);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "if (T_P {}}");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
+ tu = parseAndCheckBindings(code + "if (T_P {}}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ x = i.getConditionExpression();
try {
- syntax= x.getTrailingSyntax();
+ syntax = x.getTrailingSyntax();
fail();
- } catch (ExpansionOverlapsBoundaryException e) {}
+ } catch (ExpansionOverlapsBoundaryException e) {
+ }
- tu= parseAndCheckBindings(code + "if (1 P_BLOCK }");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
+ tu = parseAndCheckBindings(code + "if (1 P_BLOCK }");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ x = i.getConditionExpression();
try {
- syntax= x.getTrailingSyntax();
+ syntax = x.getTrailingSyntax();
fail();
} catch (ExpansionOverlapsBoundaryException e) {
}
- tu= parseAndCheckBindings(code + "IF_COND {}}");
- f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
+ tu = parseAndCheckBindings(code + "IF_COND {}}");
+ f = getDeclaration(tu, 0);
+ i = getStatement(f, 0);
+ x = i.getConditionExpression();
try {
- syntax= x.getTrailingSyntax();
+ syntax = x.getTrailingSyntax();
fail();
} catch (ExpansionOverlapsBoundaryException e) {
}
@@ -5659,46 +5659,67 @@ public class AST2Tests extends AST2TestBase {
// #define IF_COND if (1)
// void test() {
public void testSyntax_250251() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code + "if (1) {};}");
- IASTFunctionDefinition f= getDeclaration(tu, 0);
+ IASTTranslationUnit tu = parseAndCheckBindings(code + "if (1) {};}");
+ IASTFunctionDefinition f = getDeclaration(tu, 0);
IASTIfStatement x = getStatement(f, 0);
- IToken syntax= x.getSyntax();
- checkToken(syntax, "if", 0); syntax= syntax.getNext();
- checkToken(syntax, "(", 3); syntax= syntax.getNext();
- checkToken(syntax, "1", 4); syntax= syntax.getNext();
- checkToken(syntax, ")", 5); syntax= syntax.getNext();
- checkToken(syntax, "{", 7); syntax= syntax.getNext();
- checkToken(syntax, "}", 8); syntax= syntax.getNext();
+ IToken syntax = x.getSyntax();
+ checkToken(syntax, "if", 0);
+ syntax = syntax.getNext();
+ checkToken(syntax, "(", 3);
+ syntax = syntax.getNext();
+ checkToken(syntax, "1", 4);
+ syntax = syntax.getNext();
+ checkToken(syntax, ")", 5);
+ syntax = syntax.getNext();
+ checkToken(syntax, "{", 7);
+ syntax = syntax.getNext();
+ checkToken(syntax, "}", 8);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "if( 1) {}}");
- f= getDeclaration(tu, 0); x= getStatement(f, 0);
- syntax= x.getSyntax();
- checkToken(syntax, "if", 0); syntax= syntax.getNext();
- checkToken(syntax, "(", 2); syntax= syntax.getNext();
- checkToken(syntax, "1", 5); syntax= syntax.getNext();
- checkToken(syntax, ")", 6); syntax= syntax.getNext();
- checkToken(syntax, "{", 8); syntax= syntax.getNext();
- checkToken(syntax, "}", 9); syntax= syntax.getNext();
+ tu = parseAndCheckBindings(code + "if( 1) {}}");
+ f = getDeclaration(tu, 0);
+ x = getStatement(f, 0);
+ syntax = x.getSyntax();
+ checkToken(syntax, "if", 0);
+ syntax = syntax.getNext();
+ checkToken(syntax, "(", 2);
+ syntax = syntax.getNext();
+ checkToken(syntax, "1", 5);
+ syntax = syntax.getNext();
+ checkToken(syntax, ")", 6);
+ syntax = syntax.getNext();
+ checkToken(syntax, "{", 8);
+ syntax = syntax.getNext();
+ checkToken(syntax, "}", 9);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "IF(1) {}}");
- f= getDeclaration(tu, 0); x= getStatement(f, 0);
- syntax= x.getSyntax();
- checkToken(syntax, "IF", 0); syntax= syntax.getNext();
- checkToken(syntax, "(", 2); syntax= syntax.getNext();
- checkToken(syntax, "1", 3); syntax= syntax.getNext();
- checkToken(syntax, ")", 4); syntax= syntax.getNext();
- checkToken(syntax, "{", 6); syntax= syntax.getNext();
- checkToken(syntax, "}", 7); syntax= syntax.getNext();
+ tu = parseAndCheckBindings(code + "IF(1) {}}");
+ f = getDeclaration(tu, 0);
+ x = getStatement(f, 0);
+ syntax = x.getSyntax();
+ checkToken(syntax, "IF", 0);
+ syntax = syntax.getNext();
+ checkToken(syntax, "(", 2);
+ syntax = syntax.getNext();
+ checkToken(syntax, "1", 3);
+ syntax = syntax.getNext();
+ checkToken(syntax, ")", 4);
+ syntax = syntax.getNext();
+ checkToken(syntax, "{", 6);
+ syntax = syntax.getNext();
+ checkToken(syntax, "}", 7);
+ syntax = syntax.getNext();
assertNull(syntax);
- tu= parseAndCheckBindings(code + "SEMI_IF (1) {}}");
- f= getDeclaration(tu, 0); x= getStatement(f, 1);
+ tu = parseAndCheckBindings(code + "SEMI_IF (1) {}}");
+ f = getDeclaration(tu, 0);
+ x = getStatement(f, 1);
try {
- syntax= x.getSyntax();
+ syntax = x.getSyntax();
fail();
} catch (ExpansionOverlapsBoundaryException e) {
}
@@ -5717,30 +5738,35 @@ public class AST2Tests extends AST2TestBase {
// y;
// }
public void testSyntaxWithNL_280175() throws Exception {
- String code= getAboveComment();
- int offsetX= code.indexOf('x', code.indexOf('x')+1);
- int offsetShift= code.indexOf('<');
- int offsetY= code.indexOf('y', offsetX);
+ String code = getAboveComment();
+ int offsetX = code.indexOf('x', code.indexOf('x') + 1);
+ int offsetShift = code.indexOf('<');
+ int offsetY = code.indexOf('y', offsetX);
- IASTTranslationUnit tu= parseAndCheckBindings(code);
- IASTFunctionDefinition f= getDeclaration(tu, 0);
+ IASTTranslationUnit tu = parseAndCheckBindings(code);
+ IASTFunctionDefinition f = getDeclaration(tu, 0);
IASTExpressionStatement i = getStatement(f, 1);
final IASTBinaryExpression expr = (IASTBinaryExpression) i.getExpression();
- IASTExpression x= expr.getOperand1();
- IASTExpression y= expr.getOperand2();
+ IASTExpression x = expr.getOperand1();
+ IASTExpression y = expr.getOperand2();
- IToken syntax= x.getTrailingSyntax();
- checkToken(syntax, "<<", offsetShift-offsetX-1); syntax= syntax.getNext();
+ IToken syntax = x.getTrailingSyntax();
+ checkToken(syntax, "<<", offsetShift - offsetX - 1);
+ syntax = syntax.getNext();
assertNull(syntax);
- syntax= y.getLeadingSyntax();
- checkToken(syntax, "<<", offsetShift - offsetY); syntax= syntax.getNext();
+ syntax = y.getLeadingSyntax();
+ checkToken(syntax, "<<", offsetShift - offsetY);
+ syntax = syntax.getNext();
assertNull(syntax);
- syntax= expr.getSyntax();
- checkToken(syntax, "x", 0); syntax= syntax.getNext();
- checkToken(syntax, "<<", offsetShift-offsetX); syntax= syntax.getNext();
- checkToken(syntax, "y", offsetY-offsetX); syntax= syntax.getNext();
+ syntax = expr.getSyntax();
+ checkToken(syntax, "x", 0);
+ syntax = syntax.getNext();
+ checkToken(syntax, "<<", offsetShift - offsetX);
+ syntax = syntax.getNext();
+ checkToken(syntax, "y", offsetY - offsetX);
+ syntax = syntax.getNext();
assertNull(syntax);
}
@@ -5749,25 +5775,25 @@ public class AST2Tests extends AST2TestBase {
// int* c= &b;
// enum X {e0, e4=4, e5, e2=2, e3};
public void testValues() throws Exception {
- final String code= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper bh= new AST2AssertionHelper(code, lang);
- IVariable v= (IVariable) bh.assertNonProblem("a=", 1);
+ final String code = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, lang);
+ IVariable v = (IVariable) bh.assertNonProblem("a=", 1);
checkValue(v.getInitialValue(), -4);
- v= (IVariable) bh.assertNonProblem("b=", 1);
+ v = (IVariable) bh.assertNonProblem("b=", 1);
checkValue(v.getInitialValue(), 0);
- v= (IVariable) bh.assertNonProblem("c=", 1);
+ v = (IVariable) bh.assertNonProblem("c=", 1);
assertNull(v.getInitialValue().numberValue());
- IEnumerator e= (IEnumerator) bh.assertNonProblem("e0", 2);
+ IEnumerator e = (IEnumerator) bh.assertNonProblem("e0", 2);
checkValue(e.getValue(), 0);
- e= (IEnumerator) bh.assertNonProblem("e2", 2);
+ e = (IEnumerator) bh.assertNonProblem("e2", 2);
checkValue(e.getValue(), 2);
- e= (IEnumerator) bh.assertNonProblem("e3", 2);
+ e = (IEnumerator) bh.assertNonProblem("e3", 2);
checkValue(e.getValue(), 3);
- e= (IEnumerator) bh.assertNonProblem("e4", 2);
+ e = (IEnumerator) bh.assertNonProblem("e4", 2);
checkValue(e.getValue(), 4);
- e= (IEnumerator) bh.assertNonProblem("e5", 2);
+ e = (IEnumerator) bh.assertNonProblem("e5", 2);
checkValue(e.getValue(), 5);
}
}
@@ -5787,9 +5813,9 @@ public class AST2Tests extends AST2TestBase {
public void testReferencesInInitializer_251514() throws Exception {
final String code = getAboveComment();
for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parseAndCheckBindings(code, lang, true);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- IASTName name= fdef.getDeclarator().getName();
+ IASTTranslationUnit tu = parseAndCheckBindings(code, lang, true);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ IASTName name = fdef.getDeclarator().getName();
assertEquals(2, tu.getReferences(name.resolveBinding()).length);
}
}
@@ -5924,7 +5950,7 @@ public class AST2Tests extends AST2TestBase {
*/
private void intermittentTest(RunnableWithException test) throws Exception {
Exception lastException = null;
- for (int i = 0; i < RETRY_INTERMITTENT_COUNT ; i++) {
+ for (int i = 0; i < RETRY_INTERMITTENT_COUNT; i++) {
try {
test.run();
// no exception, success
@@ -5949,26 +5975,26 @@ public class AST2Tests extends AST2TestBase {
*/
private long memoryUsed() throws InterruptedException {
final Runtime runtime = Runtime.getRuntime();
- long mem= runtime.totalMemory()-runtime.freeMemory();
- long newMem= mem;
- int i=0;
+ long mem = runtime.totalMemory() - runtime.freeMemory();
+ long newMem = mem;
+ int i = 0;
do {
Thread.sleep(50);
System.gc();
- mem= newMem;
- newMem= runtime.totalMemory()-runtime.freeMemory();
- } while (newMem < mem && ++i<5);
+ mem = newMem;
+ newMem = runtime.totalMemory() - runtime.freeMemory();
+ } while (newMem < mem && ++i < 5);
return mem;
}
// int n= 0;
// int a[]= {0x00, sizeof(n)};
public void testNonTrivialInitializer_253690() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(code, lang, false, true, 0);
- IASTSimpleDeclaration d= getDeclaration(tu, 0);
- IBinding b= d.getDeclarators()[0].getName().resolveBinding();
+ IASTTranslationUnit tu = parse(code, lang, false, true, 0);
+ IASTSimpleDeclaration d = getDeclaration(tu, 0);
+ IBinding b = d.getDeclarators()[0].getName().resolveBinding();
IASTName[] refs = tu.getReferences(b);
assertEquals(1, refs.length);
}
@@ -5980,34 +6006,34 @@ public class AST2Tests extends AST2TestBase {
public void testGetChildren_256127() throws Exception {
final String code = getAboveComment();
for (ParserLanguage lang : ParserLanguage.values()) {
- IASTNode node= parseAndCheckBindings(code, lang);
+ IASTNode node = parseAndCheckBindings(code, lang);
- IASTNode[] children= node.getChildren();
+ IASTNode[] children = node.getChildren();
assertEquals(1, children.length);
assertInstance(children[0], IASTFunctionDefinition.class);
- children= children[0].getChildren();
+ children = children[0].getChildren();
assertEquals(3, children.length);
assertInstance(children[0], IASTDeclSpecifier.class);
assertInstance(children[1], IASTDeclarator.class);
assertInstance(children[2], IASTCompoundStatement.class);
- children= children[2].getChildren();
+ children = children[2].getChildren();
assertEquals(1, children.length);
assertInstance(children[0], IASTDeclarationStatement.class);
- children= children[0].getChildren()[0].getChildren(); // skip declaration
+ children = children[0].getChildren()[0].getChildren(); // skip declaration
assertEquals(2, children.length);
assertInstance(children[0], IASTDeclSpecifier.class);
assertInstance(children[1], IASTDeclarator.class);
- children= children[1].getChildren();
+ children = children[1].getChildren();
assertEquals(3, children.length);
assertInstance(children[0], IASTPointerOperator.class);
assertInstance(children[1], IASTName.class);
assertInstance(children[2], IASTInitializer.class);
- children= children[2].getChildren()[0].getChildren(); // skip binary expression
+ children = children[2].getChildren()[0].getChildren(); // skip binary expression
assertEquals(2, children.length);
assertInstance(children[0], IASTLiteralExpression.class);
assertInstance(children[1], IASTLiteralExpression.class);
@@ -6024,7 +6050,7 @@ public class AST2Tests extends AST2TestBase {
// v.mem = 1;
// }
public void testNestedDeclarator_257540() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code, C);
parseAndCheckBindings(code, CPP);
}
@@ -6038,7 +6064,7 @@ public class AST2Tests extends AST2TestBase {
// foo = ((cs) {1.2,1});
// }
public void testCompoundLiterals_258496() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code, C);
parseAndCheckBindings(code, CPP);
}
@@ -6047,7 +6073,7 @@ public class AST2Tests extends AST2TestBase {
// static __thread int j;
// extern __thread int k;
public void testThreadLocalVariables_260387() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code, C, true);
parseAndCheckBindings(code, CPP, true);
}
@@ -6057,12 +6083,12 @@ public class AST2Tests extends AST2TestBase {
// if ((a)+b);
// }
public void testAmbiguityResolutionInIfCondition_261043() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parseAndCheckBindings(code, lang, true);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- IASTIfStatement ifstmt= getStatement(fdef, 1);
- IASTExpression expr= ifstmt.getConditionExpression();
+ IASTTranslationUnit tu = parseAndCheckBindings(code, lang, true);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ IASTIfStatement ifstmt = getStatement(fdef, 1);
+ IASTExpression expr = ifstmt.getConditionExpression();
assertInstance(expr, IASTBinaryExpression.class);
}
}
@@ -6073,11 +6099,11 @@ public class AST2Tests extends AST2TestBase {
// const a; // declares a;
// };
public void testAmbiguousDeclaration_259373() throws Exception {
- final String code= getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code, C, true);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, false);
- ITypedef td= bh.assertNonProblem("TInt; //", 4);
- IField f= bh.assertNonProblem("a;", 1);
+ final String code = getAboveComment();
+ IASTTranslationUnit tu = parseAndCheckBindings(code, C, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, false);
+ ITypedef td = bh.assertNonProblem("TInt; //", 4);
+ IField f = bh.assertNonProblem("a;", 1);
}
// struct beta {
@@ -6095,9 +6121,9 @@ public class AST2Tests extends AST2TestBase {
// pl->loc= 1;
// }
public void testLocalVsGlobalStruct_255973() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parseAndCheckBindings(code, lang, true);
+ IASTTranslationUnit tu = parseAndCheckBindings(code, lang, true);
}
}
@@ -6105,14 +6131,14 @@ public class AST2Tests extends AST2TestBase {
// struct A; // struct
// struct A* a;
public void testTypedefWithSameName() throws Exception {
- final String code= getAboveComment();
+ final String code = getAboveComment();
for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parseAndCheckBindings(code, lang, true);
+ IASTTranslationUnit tu = parseAndCheckBindings(code, lang, true);
- BindingAssertionHelper ba= new AST2AssertionHelper(code, lang == CPP);
- ITypedef t= ba.assertNonProblem("A;", 1);
- ICompositeType s1= ba.assertNonProblem("A; // struct", 1);
- ICompositeType s2= ba.assertNonProblem("A*", 1);
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, lang == CPP);
+ ITypedef t = ba.assertNonProblem("A;", 1);
+ ICompositeType s1 = ba.assertNonProblem("A; // struct", 1);
+ ICompositeType s2 = ba.assertNonProblem("A*", 1);
assertSame(s1, s2);
assertSame(s1, t.getType());
}
@@ -6120,24 +6146,24 @@ public class AST2Tests extends AST2TestBase {
// typedef long unsigned int size_t;
//
- // size_t a = 0;
- // size_t x = a + 5;
- // size_t y = 2 + a;
- // size_t y = a * 2;
- public void testTypeOfExpressionWithTypedef_380498_1() throws Exception {
- String code= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(code, lang);
- IASTExpression exp = ba.assertNode("a + 5", IASTExpression.class);
- assertTrue(exp.getExpressionType() instanceof ITypedef);
- assertEquals("size_t", ((ITypedef) exp.getExpressionType()).getName());
- exp = ba.assertNode("2 + a", IASTExpression.class);
- assertTrue(exp.getExpressionType() instanceof ITypedef);
- assertEquals("size_t", ((ITypedef) exp.getExpressionType()).getName());
- exp = ba.assertNode("a * 2", IASTExpression.class);
- assertTrue(exp.getExpressionType() instanceof ITypedef);
- assertEquals("size_t", ((ITypedef) exp.getExpressionType()).getName());
- }
+ // size_t a = 0;
+ // size_t x = a + 5;
+ // size_t y = 2 + a;
+ // size_t y = a * 2;
+ public void testTypeOfExpressionWithTypedef_380498_1() throws Exception {
+ String code = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, lang);
+ IASTExpression exp = ba.assertNode("a + 5", IASTExpression.class);
+ assertTrue(exp.getExpressionType() instanceof ITypedef);
+ assertEquals("size_t", ((ITypedef) exp.getExpressionType()).getName());
+ exp = ba.assertNode("2 + a", IASTExpression.class);
+ assertTrue(exp.getExpressionType() instanceof ITypedef);
+ assertEquals("size_t", ((ITypedef) exp.getExpressionType()).getName());
+ exp = ba.assertNode("a * 2", IASTExpression.class);
+ assertTrue(exp.getExpressionType() instanceof ITypedef);
+ assertEquals("size_t", ((ITypedef) exp.getExpressionType()).getName());
+ }
}
// typedef void* VoidPtr;
@@ -6146,64 +6172,65 @@ public class AST2Tests extends AST2TestBase {
// void test(Func f) {
// f();
// }
- public void testTypeOfExpressionWithTypedef_380498_2() throws Exception {
- String code= getAboveComment();
- for (ParserLanguage lang: ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(code, lang);
- IASTExpression exp = ba.assertNode("f()", IASTExpression.class);
- assertTrue(exp.getExpressionType() instanceof ITypedef);
- assertEquals("VoidPtr", ((ITypedef) exp.getExpressionType()).getName());
- }
- }
- // typedef int TInt;
- // int a= TInt; //ref
- public void testTypeAsExpressionIsProblem_261175() throws Exception {
- final String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ public void testTypeOfExpressionWithTypedef_380498_2() throws Exception {
+ String code = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, lang);
+ IASTExpression exp = ba.assertNode("f()", IASTExpression.class);
+ assertTrue(exp.getExpressionType() instanceof ITypedef);
+ assertEquals("VoidPtr", ((ITypedef) exp.getExpressionType()).getName());
+ }
+ }
+
+ // typedef int TInt;
+ // int a= TInt; //ref
+ public void testTypeAsExpressionIsProblem_261175() throws Exception {
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertProblem("TInt; //ref", 4);
- bh= new AST2AssertionHelper(code, false);
+ bh = new AST2AssertionHelper(code, false);
bh.assertProblem("TInt; //ref", 4);
- }
-
- // typedef int x, y;
- // void func(int c) {
- // c= sizeof(x(y));
- // x(y);
- // }
- public void testSizeofFunctionType_252243() throws Exception {
- final String code= getAboveComment();
+ }
+
+ // typedef int x, y;
+ // void func(int c) {
+ // c= sizeof(x(y));
+ // x(y);
+ // }
+ public void testSizeofFunctionType_252243() throws Exception {
+ final String code = getAboveComment();
for (ParserLanguage lang : ParserLanguage.values()) {
- BindingAssertionHelper ba= new AST2AssertionHelper(code, lang == CPP);
+ BindingAssertionHelper ba = new AST2AssertionHelper(code, lang == CPP);
ba.assertProblem("y));", 1);
- IVariable v= ba.assertNonProblem("y);", 1);
+ IVariable v = ba.assertNonProblem("y);", 1);
}
- }
+ }
- // int* v;
- public void testPointerOperatorsAsChildren_260461() throws Exception {
- final String code= getAboveComment();
+ // int* v;
+ public void testPointerOperatorsAsChildren_260461() throws Exception {
+ final String code = getAboveComment();
for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parseAndCheckBindings(code, lang, true);
- IASTSimpleDeclaration decl= getDeclaration(tu, 0);
- IASTDeclarator dtor= decl.getDeclarators()[0];
+ IASTTranslationUnit tu = parseAndCheckBindings(code, lang, true);
+ IASTSimpleDeclaration decl = getDeclaration(tu, 0);
+ IASTDeclarator dtor = decl.getDeclarators()[0];
IASTNode[] nodes = dtor.getChildren();
assertEquals(2, nodes.length);
assertInstance(nodes[0], IASTPointerOperator.class);
}
- }
+ }
- // int a = -142;
- // int b = 456L;
- // int c = 100000LL;
- // int d = 0U;
- // int e = 1UL;
- // int f = 9u;
- // int g = 1234l;
- // int h = -123ll;
- // int i = 8888uL;
- public void testBug269705_int_literal() throws Exception {
- final String code= getAboveComment();
+ // int a = -142;
+ // int b = 456L;
+ // int c = 100000LL;
+ // int d = 0U;
+ // int e = 1UL;
+ // int f = 9u;
+ // int g = 1234l;
+ // int h = -123ll;
+ // int i = 8888uL;
+ public void testBug269705_int_literal() throws Exception {
+ final String code = getAboveComment();
for (ParserLanguage lang : ParserLanguage.values()) {
IASTTranslationUnit tu = parseAndCheckBindings(code, lang);
@@ -6211,7 +6238,7 @@ public class AST2Tests extends AST2TestBase {
// int a = -142;
{
- IBasicType t = getTypeForDeclaration(declarations, 0);
+ IBasicType t = getTypeForDeclaration(declarations, 0);
assertTrue(t.getType() == IBasicType.t_int);
assertFalse(t.isUnsigned());
assertFalse(t.isSigned());
@@ -6221,7 +6248,7 @@ public class AST2Tests extends AST2TestBase {
// int b = 456L;
{
- IBasicType t = getTypeForDeclaration(declarations, 1);
+ IBasicType t = getTypeForDeclaration(declarations, 1);
assertTrue(t.getType() == IBasicType.t_int);
assertFalse(t.isUnsigned());
assertFalse(t.isSigned());
@@ -6231,7 +6258,7 @@ public class AST2Tests extends AST2TestBase {
// int c = 100000LL;
{
- IBasicType t = getTypeForDeclaration(declarations, 2);
+ IBasicType t = getTypeForDeclaration(declarations, 2);
assertTrue(t.getType() == IBasicType.t_int);
assertFalse(t.isUnsigned());
assertFalse(t.isSigned());
@@ -6241,7 +6268,7 @@ public class AST2Tests extends AST2TestBase {
// int d = 0U;
{
- IBasicType t = getTypeForDeclaration(declarations, 3);
+ IBasicType t = getTypeForDeclaration(declarations, 3);
assertTrue(t.getType() == IBasicType.t_int);
assertTrue(t.isUnsigned());
assertFalse(t.isSigned());
@@ -6252,7 +6279,7 @@ public class AST2Tests extends AST2TestBase {
// int e = 1UL;
{
- IBasicType t = getTypeForDeclaration(declarations, 4);
+ IBasicType t = getTypeForDeclaration(declarations, 4);
assertTrue(t.getType() == IBasicType.t_int);
assertTrue(t.isUnsigned());
assertFalse(t.isSigned());
@@ -6262,7 +6289,7 @@ public class AST2Tests extends AST2TestBase {
// int f = 9u;
{
- IBasicType t = getTypeForDeclaration(declarations, 5);
+ IBasicType t = getTypeForDeclaration(declarations, 5);
assertTrue(t.getType() == IBasicType.t_int);
assertTrue(t.isUnsigned());
assertFalse(t.isSigned());
@@ -6273,7 +6300,7 @@ public class AST2Tests extends AST2TestBase {
// int g = 1234l;
{
- IBasicType t = getTypeForDeclaration(declarations, 6);
+ IBasicType t = getTypeForDeclaration(declarations, 6);
assertTrue(t.getType() == IBasicType.t_int);
assertFalse(t.isUnsigned());
assertFalse(t.isSigned());
@@ -6283,7 +6310,7 @@ public class AST2Tests extends AST2TestBase {
// int h = -123ll;
{
- IBasicType t = getTypeForDeclaration(declarations, 7);
+ IBasicType t = getTypeForDeclaration(declarations, 7);
assertTrue(t.getType() == IBasicType.t_int);
assertFalse(t.isUnsigned());
assertFalse(t.isSigned());
@@ -6293,7 +6320,7 @@ public class AST2Tests extends AST2TestBase {
// int i = 8888uL;
{
- IBasicType t = getTypeForDeclaration(declarations, 8);
+ IBasicType t = getTypeForDeclaration(declarations, 8);
assertTrue(t.getType() == IBasicType.t_int);
assertTrue(t.isUnsigned());
assertFalse(t.isSigned());
@@ -6301,82 +6328,83 @@ public class AST2Tests extends AST2TestBase {
assertFalse(isLongLong(t));
}
}
- }
-
- // int a = -142.0;
- // int b = 456.1f;
- // int c = 100000.99F;
- // int d = 0.123l;
- // int e = 1.3L;
- public void testBug269705_float_literal() throws Exception {
- final String code= getAboveComment();
-
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu = parseAndCheckBindings(code, lang);
- IASTDeclaration[] declarations = tu.getDeclarations();
-
- // int a = -142.0;
- {
- IBasicType t = getTypeForDeclaration(declarations, 0);
- assertTrue(t.getType() == IBasicType.t_double);
- assertFalse(t.isSigned());
- assertFalse(t.isUnsigned());
- assertFalse(t.isLong());
- assertFalse(isLongLong(t));
- }
-
- // int b = 456.1f;
- {
- IBasicType t = getTypeForDeclaration(declarations, 1);
- assertTrue(t.getType() == IBasicType.t_float);
- assertFalse(t.isSigned());
- assertFalse(t.isUnsigned());
- assertFalse(t.isLong());
- assertFalse(isLongLong(t));
- }
-
- // int c = 100000.99F;
- {
- IBasicType t = getTypeForDeclaration(declarations, 2);
- assertTrue(t.getType() == IBasicType.t_float);
- assertFalse(t.isSigned());
- assertFalse(t.isUnsigned());
- assertFalse(t.isLong());
- assertFalse(isLongLong(t));
- }
-
- // int d = 0.123l;
- {
- IBasicType t = getTypeForDeclaration(declarations, 3);
- assertTrue(t.getType() == IBasicType.t_double);
- assertFalse(t.isSigned());
- assertFalse(t.isUnsigned());
- assertFalse(isLongLong(t));
- assertTrue(t.isLong());
- }
-
- // int e = 1.3L;
- {
- IBasicType t = getTypeForDeclaration(declarations, 4);
- assertTrue(t.getType() == IBasicType.t_double);
- assertFalse(t.isSigned());
- assertFalse(t.isUnsigned());
- assertTrue(t.isLong());
- assertFalse(isLongLong(t));
- }
- }
- }
-
- boolean isLongLong(IType t) {
- if (t instanceof IBasicType) {
- return ((IBasicType) t).isLongLong();
- }
- return false;
- }
+ }
+
+ // int a = -142.0;
+ // int b = 456.1f;
+ // int c = 100000.99F;
+ // int d = 0.123l;
+ // int e = 1.3L;
+ public void testBug269705_float_literal() throws Exception {
+ final String code = getAboveComment();
+
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parseAndCheckBindings(code, lang);
+ IASTDeclaration[] declarations = tu.getDeclarations();
+
+ // int a = -142.0;
+ {
+ IBasicType t = getTypeForDeclaration(declarations, 0);
+ assertTrue(t.getType() == IBasicType.t_double);
+ assertFalse(t.isSigned());
+ assertFalse(t.isUnsigned());
+ assertFalse(t.isLong());
+ assertFalse(isLongLong(t));
+ }
+
+ // int b = 456.1f;
+ {
+ IBasicType t = getTypeForDeclaration(declarations, 1);
+ assertTrue(t.getType() == IBasicType.t_float);
+ assertFalse(t.isSigned());
+ assertFalse(t.isUnsigned());
+ assertFalse(t.isLong());
+ assertFalse(isLongLong(t));
+ }
+
+ // int c = 100000.99F;
+ {
+ IBasicType t = getTypeForDeclaration(declarations, 2);
+ assertTrue(t.getType() == IBasicType.t_float);
+ assertFalse(t.isSigned());
+ assertFalse(t.isUnsigned());
+ assertFalse(t.isLong());
+ assertFalse(isLongLong(t));
+ }
+
+ // int d = 0.123l;
+ {
+ IBasicType t = getTypeForDeclaration(declarations, 3);
+ assertTrue(t.getType() == IBasicType.t_double);
+ assertFalse(t.isSigned());
+ assertFalse(t.isUnsigned());
+ assertFalse(isLongLong(t));
+ assertTrue(t.isLong());
+ }
+
+ // int e = 1.3L;
+ {
+ IBasicType t = getTypeForDeclaration(declarations, 4);
+ assertTrue(t.getType() == IBasicType.t_double);
+ assertFalse(t.isSigned());
+ assertFalse(t.isUnsigned());
+ assertTrue(t.isLong());
+ assertFalse(isLongLong(t));
+ }
+ }
+ }
+
+ boolean isLongLong(IType t) {
+ if (t instanceof IBasicType) {
+ return ((IBasicType) t).isLongLong();
+ }
+ return false;
+ }
private IBasicType getTypeForDeclaration(IASTDeclaration[] declarations, int index) {
IASTInitializer init = ((IASTSimpleDeclaration) declarations[index]).getDeclarators()[0].getInitializer();
- return (IBasicType)((IASTExpression)((IASTEqualsInitializer) init).getInitializerClause()).getExpressionType();
+ return (IBasicType) ((IASTExpression) ((IASTEqualsInitializer) init).getInitializerClause())
+ .getExpressionType();
}
// void test() {
@@ -6900,15 +6928,15 @@ public class AST2Tests extends AST2TestBase {
public void testPromotionInUnaryExpressions() throws Exception {
for (ParserLanguage lang : ParserLanguage.values()) {
IASTTranslationUnit ast = parseAndCheckBindings(getAboveComment(), lang);
- IASTFunctionDefinition fdef= getDeclaration(ast, 1);
- IASTExpression expr= getExpressionOfStatement(fdef, 0);
- IBasicType t= (IBasicType) expr.getExpressionType();
+ IASTFunctionDefinition fdef = getDeclaration(ast, 1);
+ IASTExpression expr = getExpressionOfStatement(fdef, 0);
+ IBasicType t = (IBasicType) expr.getExpressionType();
assertEquals(Kind.eChar, t.getKind());
assertEquals(0, t.getModifiers());
for (int i = 1; i < 4; i++) {
- expr= getExpressionOfStatement(fdef, i);
- t= (IBasicType) expr.getExpressionType();
+ expr = getExpressionOfStatement(fdef, i);
+ t = (IBasicType) expr.getExpressionType();
assertEquals(Kind.eInt, t.getKind()); // promoted to int
assertEquals(0, t.getModifiers());
}
@@ -6943,7 +6971,8 @@ public class AST2Tests extends AST2TestBase {
public void testBug278797() throws Exception {
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), C);
IASTFunctionDefinition func = (IASTFunctionDefinition) tu.getDeclarations()[1];
- IASTExpressionStatement stmt = ((IASTExpressionStatement)((IASTCompoundStatement) func.getBody()).getStatements()[0]);
+ IASTExpressionStatement stmt = ((IASTExpressionStatement) ((IASTCompoundStatement) func.getBody())
+ .getStatements()[0]);
IType t = ((IASTCastExpression) stmt.getExpression()).getOperand().getExpressionType();
assertNotNull(t);
assertTrue(t instanceof IEnumeration);
@@ -6999,12 +7028,12 @@ public class AST2Tests extends AST2TestBase {
//void goo(my_buf in);
//
public void testBug284248() throws Exception {
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), lang);
- assertTrue(tu.isFrozen());
- IASTName n = ((IASTSimpleDeclaration) tu.getDeclarations()[1]).getDeclarators()[0].getName();
- assertTrue(((IFunction) n.resolveBinding()).getType().getParameterTypes()[0] instanceof IPointerType);
- }
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), lang);
+ assertTrue(tu.isFrozen());
+ IASTName n = ((IASTSimpleDeclaration) tu.getDeclarations()[1]).getDeclarators()[0].getName();
+ assertTrue(((IFunction) n.resolveBinding()).getType().getParameterTypes()[0] instanceof IPointerType);
+ }
}
//
@@ -7018,16 +7047,17 @@ public class AST2Tests extends AST2TestBase {
//};
//
public void testBug295851() throws Exception {
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), lang);
- IASTEnumerationSpecifier enumSpec = (IASTEnumerationSpecifier)((IASTSimpleDeclaration) tu.getDeclarations()[0]).getDeclSpecifier();
- IEnumerator enumeratorBinding = (IEnumerator) enumSpec.getEnumerators()[0].getName().resolveBinding();
- IValue value = enumeratorBinding.getValue();
- assertEquals(2, value.numberValue().longValue());
- IEnumerator enumeratorBinding2 = (IEnumerator) enumSpec.getEnumerators()[1].getName().resolveBinding();
- IValue value2 = enumeratorBinding2.getValue();
- assertEquals(1, value2.numberValue().longValue());
- }
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), lang);
+ IASTEnumerationSpecifier enumSpec = (IASTEnumerationSpecifier) ((IASTSimpleDeclaration) tu
+ .getDeclarations()[0]).getDeclSpecifier();
+ IEnumerator enumeratorBinding = (IEnumerator) enumSpec.getEnumerators()[0].getName().resolveBinding();
+ IValue value = enumeratorBinding.getValue();
+ assertEquals(2, value.numberValue().longValue());
+ IEnumerator enumeratorBinding2 = (IEnumerator) enumSpec.getEnumerators()[1].getName().resolveBinding();
+ IValue value2 = enumeratorBinding2.getValue();
+ assertEquals(1, value2.numberValue().longValue());
+ }
}
// extern void goo();
@@ -7041,98 +7071,106 @@ public class AST2Tests extends AST2TestBase {
// structure.ptr = goo;
// }
public void testBindingsOnFields() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), C, false);
- IASTCompoundStatement bodyStmt = (IASTCompoundStatement)((IASTFunctionDefinition) tu.getDeclarations()[2]).getBody();
-
- // Get the IFields bindings from the type used in the declaration of structure
- IASTName n = ((IASTSimpleDeclaration)((IASTDeclarationStatement) bodyStmt.getStatements()[0]).getDeclaration()).getDeclarators()[0].getName();
- ICompositeType t = (ICompositeType)((IVariable) n.resolveBinding()).getType();
- IField[] fields = t.getFields();
- assertTrue(fields.length == 2);
-
- // Get the IField for the first assignment
- IASTFieldReference ref1 = (IASTFieldReference)((IASTBinaryExpression)((IASTExpressionStatement) bodyStmt.getStatements()[1]).getExpression()).getOperand1();
- IBinding field1 = ref1.getFieldName().resolveBinding();
-
- // Get the IField for the second assignment
- IASTFieldReference ref2 = (IASTFieldReference)((IASTBinaryExpression)((IASTExpressionStatement) bodyStmt.getStatements()[2]).getExpression()).getOperand1();
- IBinding field2 = ref2.getFieldName().resolveBinding();
-
- // Compare the IField from the type and the assignments
- assertEquals(fields[0], field1);
- assertEquals(fields[1], field2); // fails
-
- assertEquals(1, ((ICInternalBinding) field1).getDeclarations().length);
- assertEquals(1, ((ICInternalBinding) field2).getDeclarations().length);
- }
-
- // /*
- // * Check that the type returned by CASTArraySubscriptExpression
- // * handles typedefs correctly.
- // */
- // struct s {
- // int a;
- // };
- // typedef struct s* ptr;
- // typedef struct s array[10];
+ IASTTranslationUnit tu = parse(getAboveComment(), C, false);
+ IASTCompoundStatement bodyStmt = (IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[2])
+ .getBody();
+
+ // Get the IFields bindings from the type used in the declaration of structure
+ IASTName n = ((IASTSimpleDeclaration) ((IASTDeclarationStatement) bodyStmt.getStatements()[0]).getDeclaration())
+ .getDeclarators()[0].getName();
+ ICompositeType t = (ICompositeType) ((IVariable) n.resolveBinding()).getType();
+ IField[] fields = t.getFields();
+ assertTrue(fields.length == 2);
+
+ // Get the IField for the first assignment
+ IASTFieldReference ref1 = (IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) bodyStmt
+ .getStatements()[1]).getExpression()).getOperand1();
+ IBinding field1 = ref1.getFieldName().resolveBinding();
+
+ // Get the IField for the second assignment
+ IASTFieldReference ref2 = (IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) bodyStmt
+ .getStatements()[2]).getExpression()).getOperand1();
+ IBinding field2 = ref2.getFieldName().resolveBinding();
+
+ // Compare the IField from the type and the assignments
+ assertEquals(fields[0], field1);
+ assertEquals(fields[1], field2); // fails
+
+ assertEquals(1, ((ICInternalBinding) field1).getDeclarations().length);
+ assertEquals(1, ((ICInternalBinding) field2).getDeclarations().length);
+ }
+
+ // /*
+ // * Check that the type returned by CASTArraySubscriptExpression
+ // * handles typedefs correctly.
+ // */
+ // struct s {
+ // int a;
+ // };
+ // typedef struct s* ptr;
+ // typedef struct s array[10];
// typedef array newArray;
- // ptr var1;
- // struct s* var2;
- // array var3;
- // struct s var4[10];
- // newArray var5;
- //
- // void foo() {
+ // ptr var1;
+ // struct s* var2;
+ // array var3;
+ // struct s var4[10];
+ // newArray var5;
+ //
+ // void foo() {
// /* The type of the array subscript expression should be struct s
// * each of the following statements
// */
- // var1[1].a = 1;
- // var2[1].a = 1;
- // var3[1].a = 1;
- // var4[1].a = 1;
+ // var1[1].a = 1;
+ // var2[1].a = 1;
+ // var3[1].a = 1;
+ // var4[1].a = 1;
// var5[1].a = 1;
- // }
+ // }
public void testArraySubscriptExpressionGetExpressionType() throws Exception {
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), lang);
- assertTrue(tu.isFrozen());
- for (IASTDeclaration d : tu.getDeclarations()) {
- if (d instanceof IASTFunctionDefinition) {
- for (IASTStatement s : ((IASTCompoundStatement) ((IASTFunctionDefinition) d).getBody()).getStatements()) {
- IASTExpression op1 = ((IASTBinaryExpression) ((IASTExpressionStatement) s).getExpression()).getOperand1();
- IASTExpression owner = ((IASTFieldReference) op1).getFieldOwner();
- IType t = owner.getExpressionType();
- assertTrue(t instanceof ICompositeType);
- assertEquals("s", ((ICompositeType) t).getName());
- }
- }
- }
- }
- }
-
- // char array[10];
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), lang);
+ assertTrue(tu.isFrozen());
+ for (IASTDeclaration d : tu.getDeclarations()) {
+ if (d instanceof IASTFunctionDefinition) {
+ for (IASTStatement s : ((IASTCompoundStatement) ((IASTFunctionDefinition) d).getBody())
+ .getStatements()) {
+ IASTExpression op1 = ((IASTBinaryExpression) ((IASTExpressionStatement) s).getExpression())
+ .getOperand1();
+ IASTExpression owner = ((IASTFieldReference) op1).getFieldOwner();
+ IType t = owner.getExpressionType();
+ assertTrue(t instanceof ICompositeType);
+ assertEquals("s", ((ICompositeType) t).getName());
+ }
+ }
+ }
+ }
+ }
+
+ // char array[10];
// char* ptr;
- //
- // void test() {
- // array + 1;
- // 1 + array;
- // ptr + 1;
- // 1 + ptr;
- // }
+ //
+ // void test() {
+ // array + 1;
+ // 1 + array;
+ // ptr + 1;
+ // 1 + ptr;
+ // }
public void testPointerExpression_131037() throws Exception {
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), lang);
- assertTrue(tu.isFrozen());
- for (IASTDeclaration d : tu.getDeclarations()) {
- if (d instanceof IASTFunctionDefinition) {
- for (IASTStatement s : ((IASTCompoundStatement) ((IASTFunctionDefinition) d).getBody()).getStatements()) {
- IType t = ((IASTBinaryExpression) ((IASTExpressionStatement) s).getExpression()).getExpressionType();
- assertTrue(t instanceof IPointerType || t instanceof IArrayType);
- assertEquals("char", ((IPointerType) t).getType().toString());
- }
- }
- }
- }
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), lang);
+ assertTrue(tu.isFrozen());
+ for (IASTDeclaration d : tu.getDeclarations()) {
+ if (d instanceof IASTFunctionDefinition) {
+ for (IASTStatement s : ((IASTCompoundStatement) ((IASTFunctionDefinition) d).getBody())
+ .getStatements()) {
+ IType t = ((IASTBinaryExpression) ((IASTExpressionStatement) s).getExpression())
+ .getExpressionType();
+ assertTrue(t instanceof IPointerType || t instanceof IArrayType);
+ assertEquals("char", ((IPointerType) t).getType().toString());
+ }
+ }
+ }
+ }
}
// extern int a[];
@@ -7147,24 +7185,24 @@ public class AST2Tests extends AST2TestBase {
// void f2(const int* p) {}
public void testDroppingOfStorageDecl_293322() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, false);
- IFunction f= bh.assertNonProblem("f1", 2);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, false);
+ IFunction f = bh.assertNonProblem("f1", 2);
assertEquals("const int *", ASTTypeUtil.getType(f.getParameters()[0].getType()));
- f= bh.assertNonProblem("f2", 2);
+ f = bh.assertNonProblem("f2", 2);
assertEquals("const int *", ASTTypeUtil.getType(f.getParameters()[0].getType()));
}
// typedef int f(int);
// f ff;
public void testFunctionDeclViaTypedef_86495() throws Exception {
- final String code = getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
+ final String code = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
IASTTranslationUnit tu = parseAndCheckBindings(code, lang);
- IASTSimpleDeclaration decl= getDeclaration(tu, 1);
- IFunction ff= (IFunction) decl.getDeclarators()[0].getName().resolveBinding();
+ IASTSimpleDeclaration decl = getDeclaration(tu, 1);
+ IFunction ff = (IFunction) decl.getDeclarators()[0].getName().resolveBinding();
assertNotNull(ff.getType());
assertEquals(1, ff.getParameters().length);
- }
+ }
}
// void f() {
@@ -7172,27 +7210,27 @@ public class AST2Tests extends AST2TestBase {
public void testLargeExpression_294029() throws Exception {
// when running the test in a suite, it cannot handle more than 160 parenthesis.
// run as a single test it does > 500.
- sValidateCopy= false;
- StringBuilder buf= new StringBuilder();
- buf.append(getAboveComment());
- final int depth= 160;
- for (int i = 0; i < depth; i++) {
- buf.append('(');
- }
- buf.append('1');
- for (int i = 0; i < depth; i++) {
- buf.append(")+1");
- }
- buf.append(";}");
- String code= buf.toString();
- for (ParserLanguage lang : ParserLanguage.values()) {
+ sValidateCopy = false;
+ StringBuilder buf = new StringBuilder();
+ buf.append(getAboveComment());
+ final int depth = 160;
+ for (int i = 0; i < depth; i++) {
+ buf.append('(');
+ }
+ buf.append('1');
+ for (int i = 0; i < depth; i++) {
+ buf.append(")+1");
+ }
+ buf.append(";}");
+ String code = buf.toString();
+ for (ParserLanguage lang : ParserLanguage.values()) {
IASTTranslationUnit tu = parseAndCheckBindings(code, lang);
- }
+ }
}
// static a[2]= {0,0};
public void testSkipAggregateInitializer_297550() throws Exception {
- final String code = getAboveComment();
+ final String code = getAboveComment();
IASTTranslationUnit tu = parseAndCheckBindings(code, C, false, 0);
assertTrue(tu.hasNodesOmitted());
}
@@ -7214,42 +7252,42 @@ public class AST2Tests extends AST2TestBase {
// typeof(b(1)) b(int);
public void testRecursiveFunctionType_321856() throws Exception {
- final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, false);
- IFunction f= bh.assertNonProblem("b(1)", 1);
- f= bh.assertNonProblem("b(int)", 1);
- f.getType();
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, false);
+ IFunction f = bh.assertNonProblem("b(1)", 1);
+ f = bh.assertNonProblem("b(int)", 1);
+ f.getType();
}
public void testDeepBinaryExpression_294969() throws Exception {
- sValidateCopy= false;
- StringBuilder buf= new StringBuilder("void f() {0");
+ sValidateCopy = false;
+ StringBuilder buf = new StringBuilder("void f() {0");
for (int i = 0; i < 150000; i++) {
buf.append('+').append(i);
}
buf.append(";}");
- String code= buf.toString();
- for (ParserLanguage lang : ParserLanguage.values()) {
+ String code = buf.toString();
+ for (ParserLanguage lang : ParserLanguage.values()) {
IASTTranslationUnit tu = parseAndCheckBindings(code, lang);
- }
+ }
}
public void testDeepElseif_298455() throws Exception {
- sValidateCopy= false;
- StringBuilder buf= new StringBuilder("void f() {if (0) {}");
+ sValidateCopy = false;
+ StringBuilder buf = new StringBuilder("void f() {if (0) {}");
for (int i = 0; i < 75000; i++) {
buf.append("else if (0) {}");
}
buf.append("}");
- String code= buf.toString();
- for (ParserLanguage lang : ParserLanguage.values()) {
+ String code = buf.toString();
+ for (ParserLanguage lang : ParserLanguage.values()) {
IASTTranslationUnit tu = parseAndCheckBindings(code, lang);
- }
+ }
}
// void f () __attribute__ ((int));
public void testAttributeSyntax_298841() throws Exception {
- final String code = getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code, C, true);
parseAndCheckBindings(code, CPP, true);
}
@@ -7258,13 +7296,13 @@ public class AST2Tests extends AST2TestBase {
// int* obj = 0;
// }
public void testParameterRedeclaration_301779() throws Exception {
- final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
- bh.assertNonProblem("obj", 3, IParameter.class);
- bh.assertProblem("obj =", 3);
- bh= new AST2AssertionHelper(code, false);
- bh.assertNonProblem("obj", 3, IParameter.class);
- bh.assertProblem("obj =", 3);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
+ bh.assertNonProblem("obj", 3, IParameter.class);
+ bh.assertProblem("obj =", 3);
+ bh = new AST2AssertionHelper(code, false);
+ bh.assertNonProblem("obj", 3, IParameter.class);
+ bh.assertProblem("obj =", 3);
}
// #define ONCE() PRAGMA(once)
@@ -7273,21 +7311,21 @@ public class AST2Tests extends AST2TestBase {
// _Pragma ("once")
// ONCE()
public void testPragmaOperator_294730() throws Exception {
- final String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code, C);
+ final String code = getAboveComment();
+ IASTTranslationUnit tu = parseAndCheckBindings(code, C);
IASTPreprocessorStatement[] stmts = tu.getAllPreprocessorStatements();
assertEquals(5, stmts.length);
for (int i = 2; i < stmts.length; i++) {
IASTPreprocessorStatement stmt = stmts[i];
assertInstance(stmt, IASTPreprocessorPragmaStatement.class);
- assertEquals(i>2, ((IASTPreprocessorPragmaStatement) stmt).isPragmaOperator());
+ assertEquals(i > 2, ((IASTPreprocessorPragmaStatement) stmt).isPragmaOperator());
}
- tu= parseAndCheckBindings(code, CPP);
+ tu = parseAndCheckBindings(code, CPP);
assertEquals(5, stmts.length);
for (int i = 2; i < stmts.length; i++) {
IASTPreprocessorStatement stmt = stmts[i];
assertInstance(stmt, IASTPreprocessorPragmaStatement.class);
- assertEquals(i>2, ((IASTPreprocessorPragmaStatement) stmt).isPragmaOperator());
+ assertEquals(i > 2, ((IASTPreprocessorPragmaStatement) stmt).isPragmaOperator());
}
}
@@ -7296,7 +7334,7 @@ public class AST2Tests extends AST2TestBase {
// int a= (min)(1, 2);
// }
public void testFunctionNameExpression() throws Exception {
- final String code = getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code, C, true);
parseAndCheckBindings(code, CPP, true);
}
@@ -7306,15 +7344,15 @@ public class AST2Tests extends AST2TestBase {
// }
// MACRO
public void testEmptyTrailingMacro_303152() throws Exception {
- final String code = getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parseAndCheckBindings(code, lang);
- IASTPreprocessorMacroExpansion[] expansions = tu.getMacroExpansions();
- assertEquals(1, expansions.length);
- IToken t= tu.getSyntax();
- while (t.getNext() != null)
- t= t.getNext();
- assertEquals("MACRO", t.getImage());
+ final String code = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parseAndCheckBindings(code, lang);
+ IASTPreprocessorMacroExpansion[] expansions = tu.getMacroExpansions();
+ assertEquals(1, expansions.length);
+ IToken t = tu.getSyntax();
+ while (t.getNext() != null)
+ t = t.getNext();
+ assertEquals("MACRO", t.getImage());
}
}
@@ -7326,7 +7364,7 @@ public class AST2Tests extends AST2TestBase {
// x = va_arg(list, int(*)[3]);
// }
public void testVaArgWithFunctionPtr_311030() throws Exception {
- final String code = getAboveComment();
+ final String code = getAboveComment();
parseAndCheckBindings(code, C, true);
parseAndCheckBindings(code, CPP, true);
}
@@ -7335,30 +7373,30 @@ public class AST2Tests extends AST2TestBase {
// __builtin_va_list result;
// }
public void testLocalVariableOfTypeVaList_313270() throws Exception {
- final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, false);
- IBinding var= bh.assertNonProblem("result", 0);
- assertInstance(var, IVariable.class);
- assertTrue(var.getScope().getKind() == EScopeKind.eLocal);
+ final String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, false);
+ IBinding var = bh.assertNonProblem("result", 0);
+ assertInstance(var, IVariable.class);
+ assertTrue(var.getScope().getKind() == EScopeKind.eLocal);
- bh= new AST2AssertionHelper(code, true);
- var= bh.assertNonProblem("result", 0);
- assertInstance(var, IVariable.class);
- assertTrue(var.getScope().getKind() == EScopeKind.eLocal);
+ bh = new AST2AssertionHelper(code, true);
+ var = bh.assertNonProblem("result", 0);
+ assertInstance(var, IVariable.class);
+ assertTrue(var.getScope().getKind() == EScopeKind.eLocal);
}
// void foo(int i);
// void foo(int j) { }
public void testParameterBindings_316931() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseAndCheckBindings(code);
for (ParserLanguage lang : ParserLanguage.values()) {
- BindingAssertionHelper bh= new AST2AssertionHelper(code, lang);
- IParameter i= bh.assertNonProblem("i)", 1);
- IParameter j= bh.assertNonProblem("j)", 1);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, lang);
+ IParameter i = bh.assertNonProblem("i)", 1);
+ IParameter j = bh.assertNonProblem("j)", 1);
assertSame(i, j);
- IASTTranslationUnit tu= bh.getTranslationUnit();
+ IASTTranslationUnit tu = bh.getTranslationUnit();
IASTName[] decls = tu.getDeclarationsInAST(i);
assertEquals(2, decls.length);
decls = tu.getDeclarationsInAST(j);
@@ -7369,21 +7407,21 @@ public class AST2Tests extends AST2TestBase {
// typedef __typeof__((int*)0-(int*)0) ptrdiff_t;
// typedef __typeof__(sizeof(int)) size_t;
public void testPtrDiffRecursion_317004() throws Exception {
- final String comment = getAboveComment();
- String code= comment;
+ final String comment = getAboveComment();
+ String code = comment;
parseAndCheckBindings(code, C, true);
- BindingAssertionHelper bh= new AST2AssertionHelper(code, false);
- ITypedef td= bh.assertNonProblem("ptrdiff_t", 0);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, false);
+ ITypedef td = bh.assertNonProblem("ptrdiff_t", 0);
assertEquals("long int", ASTTypeUtil.getType(td.getType()));
- td= bh.assertNonProblem("size_t", 0);
+ td = bh.assertNonProblem("size_t", 0);
assertEquals("unsigned long int", ASTTypeUtil.getType(td.getType()));
- code= "namespace std {" + comment + "}";
+ code = "namespace std {" + comment + "}";
parseAndCheckBindings(code, CPP, true);
- bh= new AST2AssertionHelper(code, true);
- td= bh.assertNonProblem("ptrdiff_t", 0);
+ bh = new AST2AssertionHelper(code, true);
+ td = bh.assertNonProblem("ptrdiff_t", 0);
assertEquals("long int", ASTTypeUtil.getType(td.getType()));
- td= bh.assertNonProblem("size_t", 0);
+ td = bh.assertNonProblem("size_t", 0);
assertEquals("unsigned long int", ASTTypeUtil.getType(td.getType()));
}
@@ -7394,12 +7432,12 @@ public class AST2Tests extends AST2TestBase {
public void testParameterResolution() throws Exception {
final String code = getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, true);
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("f(int a)", 1);
bh.assertNonProblem("f(int)", 1);
bh.assertNonProblem("a;", 1);
- bh= new AST2AssertionHelper(code, false);
+ bh = new AST2AssertionHelper(code, false);
bh.assertNonProblem("f(int a)", 1);
bh.assertNonProblem("f(int)", 1);
bh.assertNonProblem("a;", 1);
@@ -7410,8 +7448,8 @@ public class AST2Tests extends AST2TestBase {
// #endif // inactive
// #endif // active
public void testInactivePreprocessingStatements() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment());
- IASTPreprocessorStatement[] stmts= tu.getAllPreprocessorStatements();
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment());
+ IASTPreprocessorStatement[] stmts = tu.getAllPreprocessorStatements();
assertTrue(stmts[0].isActive());
assertFalse(stmts[1].isActive());
assertFalse(stmts[2].isActive());
@@ -7428,18 +7466,18 @@ public class AST2Tests extends AST2TestBase {
// }
public void testTypeOfSizeof_355052() throws Exception {
final String code = getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code, CPP);
- IASTFunctionDefinition a= getDeclaration(tu, 0);
- IASTExpressionStatement es= getStatement(a, 1);
+ IASTTranslationUnit tu = parseAndCheckBindings(code, CPP);
+ IASTFunctionDefinition a = getDeclaration(tu, 0);
+ IASTExpressionStatement es = getStatement(a, 1);
assertEquals("unsigned long int", ASTTypeUtil.getType(es.getExpression().getExpressionType()));
- es= getStatement(a, 2);
+ es = getStatement(a, 2);
assertEquals("unsigned long int", ASTTypeUtil.getType(es.getExpression().getExpressionType()));
- tu= parseAndCheckBindings(code, C);
- a= getDeclaration(tu, 0);
- es= getStatement(a, 1);
+ tu = parseAndCheckBindings(code, C);
+ a = getDeclaration(tu, 0);
+ es = getStatement(a, 1);
assertEquals("unsigned long int", ASTTypeUtil.getType(es.getExpression().getExpressionType()));
- es= getStatement(a, 2);
+ es = getStatement(a, 2);
assertEquals("unsigned long int", ASTTypeUtil.getType(es.getExpression().getExpressionType()));
}
@@ -7453,13 +7491,13 @@ public class AST2Tests extends AST2TestBase {
// typedef int T[sizeof(int)];
public void testSizeofExpression_362464() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
for (ParserLanguage l : ParserLanguage.values()) {
- IASTTranslationUnit tu= parseAndCheckBindings(code, l);
- IASTSimpleDeclaration sdecl= getDeclaration(tu, 0);
- ITypedef tdef= (ITypedef) sdecl.getDeclarators()[0].getName().resolveBinding();
- IArrayType at= (IArrayType) tdef.getType();
- IValue v= at.getSize();
+ IASTTranslationUnit tu = parseAndCheckBindings(code, l);
+ IASTSimpleDeclaration sdecl = getDeclaration(tu, 0);
+ ITypedef tdef = (ITypedef) sdecl.getDeclarators()[0].getName().resolveBinding();
+ IArrayType at = (IArrayType) tdef.getType();
+ IValue v = at.getSize();
assertNotNull(v.numberValue());
assertTrue(v.numberValue().longValue() == 4);
}
@@ -7470,8 +7508,8 @@ public class AST2Tests extends AST2TestBase {
// NULL_STATEMENT_MACRO //comment
// }
public void testCommentAfterMacroExpansion_367827() throws Exception {
- IASTTranslationUnit tu= parse(getAboveComment(), CPP);
- IASTComment comment= tu.getComments()[0];
+ IASTTranslationUnit tu = parse(getAboveComment(), CPP);
+ IASTComment comment = tu.getComments()[0];
assertEquals("//comment", new String(comment.getComment()));
assertEquals("//comment", comment.getRawSignature());
}
@@ -7489,20 +7527,20 @@ public class AST2Tests extends AST2TestBase {
public void testNoRawStringInPlainC_397127() throws Exception {
parseAndCheckBindings(getAboveComment(), C, true);
}
-
- // #define X
+
+ // #define X
// int a=X-1;X
public void testMacroReferences_399394() throws Exception {
- IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment());
+ IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment());
assertEquals(2, countMacroRefs(tu));
-
- IASTSimpleDeclaration decl= getDeclaration(tu, 0);
+
+ IASTSimpleDeclaration decl = getDeclaration(tu, 0);
assertEquals(1, countMacroRefs(decl));
-
- IASTEqualsInitializer init= (IASTEqualsInitializer) decl.getDeclarators()[0].getInitializer();
+
+ IASTEqualsInitializer init = (IASTEqualsInitializer) decl.getDeclarators()[0].getInitializer();
assertEquals(1, countMacroRefs(init));
-
- IASTUnaryExpression expr= (IASTUnaryExpression) init.getInitializerClause();
+
+ IASTUnaryExpression expr = (IASTUnaryExpression) init.getInitializerClause();
assertEquals(0, countMacroRefs(expr));
}
@@ -7514,7 +7552,7 @@ public class AST2Tests extends AST2TestBase {
}
return count;
}
-
+
// typedef struct { int x; } A;
//
// void (*function(A *a))(void) {
@@ -7523,28 +7561,25 @@ public class AST2Tests extends AST2TestBase {
public void testFunctionReturningFunctionPointer_413204() throws Exception {
parseAndCheckBindings();
}
-
+
// double d = 00.9;
public void testOctalFloatingPointLiteral_394048() throws Exception {
parseAndCheckBindings();
}
-
+
public void testMacOS9LineEnding_151329a() throws Exception {
parseAndCheckBindings("int waldo;\r#define bar");
}
-
+
public void testMaxOS9LineEnding_151329b() throws Exception {
// This tests that if there is an \r\n in a macro continuation,
// the \r is not treated as an extra newline. The code
// stringifies the macro expansion and arranges for the string
// length to show up in a template parameter, whose value is
// checked by the test.
- String code = "#define MACRO foo\\\r\n"
- + "bar\r\n"
- + "#define STRINGIFY_(x) #x\r\n"
- + "#define STRINGIFY(x) STRINGIFY_(x)\r\n"
- + "template <int N> void f(const char (&)[N]);\r\n"
- + "int main() { f(STRINGIFY(MACRO)); }\r\n";
+ String code = "#define MACRO foo\\\r\n" + "bar\r\n" + "#define STRINGIFY_(x) #x\r\n"
+ + "#define STRINGIFY(x) STRINGIFY_(x)\r\n" + "template <int N> void f(const char (&)[N]);\r\n"
+ + "int main() { f(STRINGIFY(MACRO)); }\r\n";
BindingAssertionHelper helper = new AST2AssertionHelper(code, true);
ICPPTemplateInstance f = helper.assertNonProblem("f(STRINGIFY", "f");
// 7 characters for "foobar" + the null terminator.
@@ -7572,7 +7607,7 @@ public class AST2Tests extends AST2TestBase {
public void testExpressionLabelReference_84144() throws Exception {
parseAndCheckBindings(true);
}
-
+
// void f() {
// unsigned long long labelPtr;
// labelPtr = (unsigned long long) &&L;
@@ -7598,7 +7633,7 @@ public class AST2Tests extends AST2TestBase {
// syntactically valid, but the correct parse is the cast-expression.
parseAndCheckBindings(true);
}
-
+
// int test(int waldo, int other) {
// return (waldo) && other;
// }
@@ -7607,35 +7642,35 @@ public class AST2Tests extends AST2TestBase {
// valid, but this time the correct parse is binary-expression.
parseAndCheckBindings(true);
}
-
+
// int version = 0;
// int NextVersion() {
// return __atomic_add_fetch(&version, 1, 5);
// }
- public void testAtomicBuiltin_bug456131() throws Exception {
- parseAndCheckBindings(true);
- }
-
- // void waldo(...);
- public void testVariadicCFunction_452416() throws Exception {
- BindingAssertionHelper bh= getAssertionHelper(C);
+ public void testAtomicBuiltin_bug456131() throws Exception {
+ parseAndCheckBindings(true);
+ }
+
+ // void waldo(...);
+ public void testVariadicCFunction_452416() throws Exception {
+ BindingAssertionHelper bh = getAssertionHelper(C);
IFunction waldo = bh.assertNonProblem("waldo");
- assertTrue(waldo.getType().takesVarArgs());
- }
-
+ assertTrue(waldo.getType().takesVarArgs());
+ }
+
// struct Foo {
// struct Foo* a;
// };
- //
+ //
// int main() {
// struct Foo * f = 0;
// (f ? f->a : ((void*) 0))->a; // second 'a' cannot be resolved
// return 0;
// }
- public void testVoidPointerInTernaryOperator_460741() throws Exception {
- parseAndCheckBindings(getAboveComment(), C);
- }
-
+ public void testVoidPointerInTernaryOperator_460741() throws Exception {
+ parseAndCheckBindings(getAboveComment(), C);
+ }
+
// struct MyStruct {
// char* str;
// };
@@ -7643,12 +7678,12 @@ public class AST2Tests extends AST2TestBase {
// const struct MyStruct a, b;
// (0 ? a : b).str;
// }
- public void testCVQualifiedTypesInConversionOperator_495423() throws Exception {
- parseAndCheckBindings(getAboveComment(), C);
- }
-
- // _Alignas(8) int x;
- // _Alignas(int) char y;
+ public void testCVQualifiedTypesInConversionOperator_495423() throws Exception {
+ parseAndCheckBindings(getAboveComment(), C);
+ }
+
+ // _Alignas(8) int x;
+ // _Alignas(int) char y;
// _Alignas(16) struct { int x; int y; };
// _Alignas(8) enum { A, B, C };
// struct S {
@@ -7656,35 +7691,35 @@ public class AST2Tests extends AST2TestBase {
// _Alignas(8) int y;
// };
// _Alignas(32) struct S s;
- // _Alignas(struct S) int t;
- public void testAlignas_451082() throws Exception {
- parseAndCheckBindings(getAboveComment(), C);
- }
-
+ // _Alignas(struct S) int t;
+ public void testAlignas_451082() throws Exception {
+ parseAndCheckBindings(getAboveComment(), C);
+ }
+
// void foo(int waldo) {
// (waldo = 5) && waldo;
// }
- public void testTypeIdWithEqualsInitializer_484824() throws Exception {
- // Test that 'waldo = 5' is not parsed as a type-id, causing
- // the entire expression to be parsed as a cast-expression.
- // See also bug 471174, which is about the broader problem of
- // binary && expressions with a parenthesized left operand
- // being incorrectly parsed as cast-expressions.
- parseAndCheckBindings(getAboveComment(), C);
- }
-
- private void labelResolutionHelper(BindingAssertionHelper helper) {
- // Make sure existing labels are resolved correctly.
- ILabel label = helper.assertNonProblem("goto existent", "existent");
- assertEquals(1, helper.tu.getDeclarationsInAST(label).length);
- label = helper.assertNonProblem("&& existent", "existent");
- assertEquals(1, helper.tu.getDeclarationsInAST(label).length);
-
- // Make sure non-existent labels are not resolved.
- helper.assertProblem("goto nonexistent", "nonexistent");
- helper.assertProblem("&& nonexistent", "nonexistent");
- }
-
+ public void testTypeIdWithEqualsInitializer_484824() throws Exception {
+ // Test that 'waldo = 5' is not parsed as a type-id, causing
+ // the entire expression to be parsed as a cast-expression.
+ // See also bug 471174, which is about the broader problem of
+ // binary && expressions with a parenthesized left operand
+ // being incorrectly parsed as cast-expressions.
+ parseAndCheckBindings(getAboveComment(), C);
+ }
+
+ private void labelResolutionHelper(BindingAssertionHelper helper) {
+ // Make sure existing labels are resolved correctly.
+ ILabel label = helper.assertNonProblem("goto existent", "existent");
+ assertEquals(1, helper.tu.getDeclarationsInAST(label).length);
+ label = helper.assertNonProblem("&& existent", "existent");
+ assertEquals(1, helper.tu.getDeclarationsInAST(label).length);
+
+ // Make sure non-existent labels are not resolved.
+ helper.assertProblem("goto nonexistent", "nonexistent");
+ helper.assertProblem("&& nonexistent", "nonexistent");
+ }
+
// int main() {
// existent:
// int x;
@@ -7693,22 +7728,22 @@ public class AST2Tests extends AST2TestBase {
// void* ref1 = && existent;
// void* ref2 = && nonexistent;
// }
- public void testLabelResolution_484979() throws Exception {
- labelResolutionHelper(getAssertionHelper(C));
- labelResolutionHelper(getAssertionHelper(CPP));
- }
-
- // int arr1[5];
- // int arr2[5];
- // void foo(bool cond) {
- // cond ? arr1 : arr2;
- // }
- public void testArrayTypesInConditionalExpression_520049() throws Exception {
- BindingAssertionHelper helper = getAssertionHelper(C);
- IASTConditionalExpression expr = helper.assertNode("cond ? arr1 : arr2");
- assertSameType(expr.getExpressionType(), CommonCTypes.pointerToInt);
- }
-
+ public void testLabelResolution_484979() throws Exception {
+ labelResolutionHelper(getAssertionHelper(C));
+ labelResolutionHelper(getAssertionHelper(CPP));
+ }
+
+ // int arr1[5];
+ // int arr2[5];
+ // void foo(bool cond) {
+ // cond ? arr1 : arr2;
+ // }
+ public void testArrayTypesInConditionalExpression_520049() throws Exception {
+ BindingAssertionHelper helper = getAssertionHelper(C);
+ IASTConditionalExpression expr = helper.assertNode("cond ? arr1 : arr2");
+ assertSameType(expr.getExpressionType(), CommonCTypes.pointerToInt);
+ }
+
// struct S {
// int waldo;
// };
@@ -7716,11 +7751,11 @@ public class AST2Tests extends AST2TestBase {
// struct S* s;
// s.waldo;
// }
- public void testMemberAccessOnPointerType_526857() throws Exception {
- BindingAssertionHelper helper = getAssertionHelper(C);
- helper.assertProblem("s.waldo", "waldo");
- }
-
+ public void testMemberAccessOnPointerType_526857() throws Exception {
+ BindingAssertionHelper helper = getAssertionHelper(C);
+ helper.assertProblem("s.waldo", "waldo");
+ }
+
// struct gendisk {
// struct request_queue *queue;
// };
@@ -7742,10 +7777,10 @@ public class AST2Tests extends AST2TestBase {
//
// return 0;
// }
- public void testProblemExpressionType_403153() throws Exception {
- BindingAssertionHelper helper = getAssertionHelper(C);
- IASTExpression expr = helper.assertNode("*gd->queue->request_fn");
- assertNotNull(expr);
- assertFalse(expr.getExpressionType() instanceof IProblemType);
- }
+ public void testProblemExpressionType_403153() throws Exception {
+ BindingAssertionHelper helper = getAssertionHelper(C);
+ IASTExpression expr = helper.assertNode("*gd->queue->request_fn");
+ assertNotNull(expr);
+ assertFalse(expr.getExpressionType() instanceof IProblemType);
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilOldTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilOldTests.java
index 3407c5a16f9..819eaef340a 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilOldTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilOldTests.java
@@ -23,430 +23,675 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
public class AST2UtilOldTests extends AST2TestBase {
public AST2UtilOldTests() {
}
+
public AST2UtilOldTests(String name) {
super(name);
}
+
// Kind PRIMARY_EMPTY : void
- public void testPrimaryEmpty() throws Exception
- {
+ public void testPrimaryEmpty() throws Exception {
IASTTranslationUnit tu = parse("int x = f();".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f()" ); //$NON-NLS-1$
- }
- // Kind PRIMARY_INTEGER_LITERAL : int
- public void testPrimaryIntegerLiteral() throws Exception
- {
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f()"); //$NON-NLS-1$
+ }
+
+ // Kind PRIMARY_INTEGER_LITERAL : int
+ public void testPrimaryIntegerLiteral() throws Exception {
IASTTranslationUnit tu = parse("int x = f(1, 2+3);".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(1, 2 + 3)" ); //$NON-NLS-1$
- }
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(1, 2 + 3)"); //$NON-NLS-1$
+ }
+
// Kind PRIMARY_CHAR_LITERAL : char
- public void testPrimaryCharLiteral() throws Exception
- {
+ public void testPrimaryCharLiteral() throws Exception {
IASTTranslationUnit tu = parse("int x = f('c');".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f('c')" ); //$NON-NLS-1$
- }
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f('c')"); //$NON-NLS-1$
+ }
+
// Kind PRIMARY_FLOAT_LITERAL : float
- public void testPrimaryFloatLiteral() throws Exception
- {
+ public void testPrimaryFloatLiteral() throws Exception {
IASTTranslationUnit tu = parse("int x = f(1.13);".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(1.13)" ); //$NON-NLS-1$
- }
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(1.13)"); //$NON-NLS-1$
+ }
+
// Kind PRIMARY_STRING_LITERAL : char*
- public void testPrimaryStringLiteral() throws Exception
- {
+ public void testPrimaryStringLiteral() throws Exception {
IASTTranslationUnit tu = parse("int x = f(\"str\");".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(\"str\")" ); //$NON-NLS-1$
- }
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(\"str\")"); //$NON-NLS-1$
+ }
+
// Kind PRIMARY_BOOLEAN_LITERAL : bool
- public void testPrimaryBooleanLiteral() throws Exception
- {
+ public void testPrimaryBooleanLiteral() throws Exception {
IASTTranslationUnit tu = parse("int x = f(true);".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(true)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(true)"); //$NON-NLS-1$
}
+
// Kind PRIMARY_THIS : type of inner most enclosing structure scope
- public void testPrimaryThis() throws Exception
- {
+ public void testPrimaryThis() throws Exception {
IASTTranslationUnit tu = parse("int x = f(this);".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(this)" ); //$NON-NLS-1$
- }
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(this)"); //$NON-NLS-1$
+ }
+
// Kind PRIMARY_BRACKETED_EXPRESSION : LHS
- public void testPrimaryBracketedExpression() throws Exception
- {
+ public void testPrimaryBracketedExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = f(1, (2+3));".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(1, (2 + 3))" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(1, (2 + 3))"); //$NON-NLS-1$
}
+
// Kind ID_EXPRESSION : type of the ID
- public void testIdExpression() throws Exception
- {
+ public void testIdExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = f(a);".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(a)" ); //$NON-NLS-1$
- }
- // Kind POSTFIX_SUBSCRIPT
- public void testPostfixSubscript() throws Exception
- {
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(a)"); //$NON-NLS-1$
+ }
+
+ // Kind POSTFIX_SUBSCRIPT
+ public void testPostfixSubscript() throws Exception {
IASTTranslationUnit tu = parse("int x = f(pa[1]);".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(pa[1])" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(pa[1])"); //$NON-NLS-1$
}
-
- public void testPostfixSubscriptA() throws Exception
- {
+
+ public void testPostfixSubscriptA() throws Exception {
IASTTranslationUnit tu = parse("int x = f(pa[1][2]);".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(pa[1][2])" ); //$NON-NLS-1$
- }
-
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(pa[1][2])"); //$NON-NLS-1$
+ }
+
// Kind POSTFIX_FUNCTIONCALL : return type of called function
- public void testPostfixFunctioncallBug42822() throws Exception
- {
+ public void testPostfixFunctioncallBug42822() throws Exception {
IASTTranslationUnit tu = parse("int x = bar( foo( 3.0 ), foo( 5.0 ) ) ;".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "bar(foo(3.0), foo(5.0))" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "bar(foo(3.0), foo(5.0))"); //$NON-NLS-1$
}
+
// Kind POSTFIX_SIMPLETYPE_* : simple type
- public void testPostfixSimpletypesBug42823() throws Exception
- {
- IASTTranslationUnit tu = parse("int someInt = foo( int(3), short(4), double(3.0), float(4.0), char( 'a'), wchar_t( 'a' ), signed( 2 ), unsigned( 3 ), bool( false ), long( 3L ) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
+ public void testPostfixSimpletypesBug42823() throws Exception {
+ IASTTranslationUnit tu = parse(
+ "int someInt = foo( int(3), short(4), double(3.0), float(4.0), char( 'a'), wchar_t( 'a' ), signed( 2 ), unsigned( 3 ), bool( false ), long( 3L ) );" //$NON-NLS-1$
+ .toString(),
+ ParserLanguage.CPP);
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(int(3), short(4), double(3.0), float(4.0), char('a'), wchar_t('a'), signed(2), unsigned(3), bool(false), long(3L))" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(int(3), short(4), double(3.0), float(4.0), char('a'), wchar_t('a'), signed(2), unsigned(3), bool(false), long(3L))"); //$NON-NLS-1$
}
-
+
// Kind POSTFIX_DOT_IDEXPRESSION : type of member in the scope of the container
- public void testPostfixDotExpression() throws Exception{
- IASTTranslationUnit tu = parse("class A {int m;}; \n A a; \n int foo(char); int foo( int ); \n int x = foo( a.m );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
+ public void testPostfixDotExpression() throws Exception {
+ IASTTranslationUnit tu = parse(
+ "class A {int m;}; \n A a; \n int foo(char); int foo( int ); \n int x = foo( a.m );".toString(), //$NON-NLS-1$
+ ParserLanguage.CPP);
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[4]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a.m)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[4]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a.m)"); //$NON-NLS-1$
}
+
// Kind POSTFIX_ARROW_IDEXPRESSION : type of member in the scope of the container
- public void testPostfixArrowExpression() throws Exception{
- IASTTranslationUnit tu = parse("class A {int m;}; \n A * a; \n int foo(char); int foo( int ); \n int x = foo( a->m );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
+ public void testPostfixArrowExpression() throws Exception {
+ IASTTranslationUnit tu = parse(
+ "class A {int m;}; \n A * a; \n int foo(char); int foo( int ); \n int x = foo( a->m );".toString(), //$NON-NLS-1$
+ ParserLanguage.CPP);
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[4]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a->m)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[4]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a->m)"); //$NON-NLS-1$
}
- // Kind POSTFIX_INCREMENT : LHS
- public void testPostfixIncrement() throws Exception
- {
+
+ // Kind POSTFIX_INCREMENT : LHS
+ public void testPostfixIncrement() throws Exception {
IASTTranslationUnit tu = parse("int y = foo( x++ );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(x++)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(x++)"); //$NON-NLS-1$
}
+
// Kind POSTFIX_DECREMENT : LHS
- public void testPostfixDecrement() throws Exception
- {
+ public void testPostfixDecrement() throws Exception {
IASTTranslationUnit tu = parse("int y = foo( x-- );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(x--)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(x--)"); //$NON-NLS-1$
}
- // Kind POSTFIX_DYNAMIC_CAST
- public void testPostfixDynamicCast() throws Exception{
+
+ // Kind POSTFIX_DYNAMIC_CAST
+ public void testPostfixDynamicCast() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( dynamic_cast<B*>(a) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(dynamic_cast<B*>(a))" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(dynamic_cast<B*>(a))"); //$NON-NLS-1$
}
+
// Kind POSTFIX_REINTERPRET_CAST
- public void testPostfixReinterpretCast() throws Exception{
+ public void testPostfixReinterpretCast() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( reinterpret_cast<double *>(a) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(reinterpret_cast<double *>(a))" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(reinterpret_cast<double *>(a))"); //$NON-NLS-1$
}
+
// Kind POSTFIX_STATIC_CAST
- public void testPostfixStaticCast() throws Exception{
+ public void testPostfixStaticCast() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( static_cast<char>(a) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(static_cast<char>(a))" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(static_cast<char>(a))"); //$NON-NLS-1$
}
+
// Kind POSTFIX_CONST_CAST
- public void testPostfixConstCast() throws Exception{
+ public void testPostfixConstCast() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( const_cast<int *>(&a) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(const_cast<int *>(&a))" ); //$NON-NLS-1$
- }
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(const_cast<int *>(&a))"); //$NON-NLS-1$
+ }
+
// Kind POSTFIX_TYPEID_EXPRESSION : LHS
- public void testPostfixTypeIdExpression() throws Exception{
+ public void testPostfixTypeIdExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( typeid(5) );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(typeid(5))" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(typeid(5))"); //$NON-NLS-1$
}
+
// Kind POSTFIX_TYPEID_EXPRESSION : type of the ID
- public void testPostfixTypeIdExpression2() throws Exception{
+ public void testPostfixTypeIdExpression2() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( typeid(a) );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(typeid(a))" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(typeid(a))"); //$NON-NLS-1$
}
// Kind POSTFIX_TYPEID_TYPEID : type of the ID
- public void testPostfixTypeIdTypeId2() throws Exception{
- IASTTranslationUnit tu = parse("class A { }; int foo( int ); int x = foo( typeid(const A) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
+ public void testPostfixTypeIdTypeId2() throws Exception {
+ IASTTranslationUnit tu = parse("class A { }; int foo( int ); int x = foo( typeid(const A) );".toString(), //$NON-NLS-1$
+ ParserLanguage.CPP);
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[2]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(typeid(const A))" ); //$NON-NLS-1$
- }
- // Kind UNARY_INCREMENT : LHS
- public void testUnaryIncrement() throws Exception
- {
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[2]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(typeid(const A))"); //$NON-NLS-1$
+ }
+
+ // Kind UNARY_INCREMENT : LHS
+ public void testUnaryIncrement() throws Exception {
IASTTranslationUnit tu = parse("int y = foo( ++x );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(++x)" ); //$NON-NLS-1$
- }
- // Kind UNARY_DECREMENT : LHS
- public void testUnaryDecrement() throws Exception
- {
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(++x)"); //$NON-NLS-1$
+ }
+
+ // Kind UNARY_DECREMENT : LHS
+ public void testUnaryDecrement() throws Exception {
IASTTranslationUnit tu = parse("int y = foo( --x );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(--x)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(--x)"); //$NON-NLS-1$
}
- // Kind UNARY_STAR_CASTEXPRESSION : LHS + t_pointer
- public void testUnaryStarCastExpression() throws Exception
- {
+
+ // Kind UNARY_STAR_CASTEXPRESSION : LHS + t_pointer
+ public void testUnaryStarCastExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = f(*pa);".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(*pa)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(*pa)"); //$NON-NLS-1$
}
+
// Kind UNARY_AMPSND_CASTEXPRESSION : LHS + t_reference
- public void testUnaryAmpersandCastExpression() throws Exception
- {
+ public void testUnaryAmpersandCastExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = f(&pa);".toString(), ParserLanguage.CPP); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(&pa)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "f(&pa)"); //$NON-NLS-1$
}
+
// Kind UNARY_PLUS_CASTEXPRESSION : LHS
- public void testUnaryPlusCastExpression() throws Exception {
+ public void testUnaryPlusCastExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( +5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(+5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(+5)"); //$NON-NLS-1$
}
+
// Kind UNARY_MINUS_CASTEXPRESSION : LHS
- public void testUnaryMinusCastExpression() throws Exception {
+ public void testUnaryMinusCastExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( -5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(-5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(-5)"); //$NON-NLS-1$
}
- // Kind UNARY_NOT_CASTEXPRESSION : LHS
- public void testUnaryNotCastExpression() throws Exception {
+
+ // Kind UNARY_NOT_CASTEXPRESSION : LHS
+ public void testUnaryNotCastExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( !b );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(!b)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(!b)"); //$NON-NLS-1$
}
- // Kind UNARY_TILDE_CASTEXPRESSION : LHS
- public void testTildeNotCastExpression() throws Exception {
+
+ // Kind UNARY_TILDE_CASTEXPRESSION : LHS
+ public void testTildeNotCastExpression() throws Exception {
IASTTranslationUnit tu = parse("int y = foo( ~x );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(~x)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(~x)"); //$NON-NLS-1$
}
- // Kind UNARY_SIZEOF_UNARYEXPRESSION : unsigned int
- public void testUnarySizeofUnaryExpression() throws Exception {
+
+ // Kind UNARY_SIZEOF_UNARYEXPRESSION : unsigned int
+ public void testUnarySizeofUnaryExpression() throws Exception {
IASTTranslationUnit tu = parse("int y = foo( sizeof(5) );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(sizeof (5))" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(sizeof (5))"); //$NON-NLS-1$
}
- // Kind UNARY_SIZEOF_TYPEID : unsigned int
- public void testUnarySizeofTypeId() throws Exception {
+
+ // Kind UNARY_SIZEOF_TYPEID : unsigned int
+ public void testUnarySizeofTypeId() throws Exception {
IASTTranslationUnit tu = parse("int x, y = foo( sizeof(x) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- final IASTInitializerClause expression = ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[1].getInitializer()).getInitializerClause();
- isExpressionStringEqual( expression, "foo(sizeof (x))" ); //$NON-NLS-1$
+ final IASTInitializerClause expression = ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0])
+ .getDeclarators()[1].getInitializer()).getInitializerClause();
+ isExpressionStringEqual(expression, "foo(sizeof (x))"); //$NON-NLS-1$
}
- // Kind NEW_TYPEID
- public void testNewTypeId() throws Exception {
+
+ // Kind NEW_TYPEID
+ public void testNewTypeId() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( new A() );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(new A())" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(new A())"); //$NON-NLS-1$
}
- // Kind CASTEXPRESSION
- public void testCastExpression() throws Exception{
+ // Kind CASTEXPRESSION
+ public void testCastExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( (A*)b );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo((A*)b)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo((A*)b)"); //$NON-NLS-1$
}
-
+
// Kind MULTIPLICATIVE_MULTIPLY : usual arithmetic conversions
- public void testMultiplicativeMultiply() throws Exception {
+ public void testMultiplicativeMultiply() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a * b );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a * b)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a * b)"); //$NON-NLS-1$
}
- // Kind MULTIPLICATIVE_DIVIDE : usual arithmetic conversions
- public void testMultiplicativeDivide() throws Exception {
+
+ // Kind MULTIPLICATIVE_DIVIDE : usual arithmetic conversions
+ public void testMultiplicativeDivide() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( b / a );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b / a)" ); //$NON-NLS-1$
- }
- // Kind MULTIPLICATIVE_MODULUS : usual arithmetic conversions
- public void testMultiplicativeModulus() throws Exception {
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(b / a)"); //$NON-NLS-1$
+ }
+
+ // Kind MULTIPLICATIVE_MODULUS : usual arithmetic conversions
+ public void testMultiplicativeModulus() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( b % a );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b % a)" ); //$NON-NLS-1$
- }
- // Kind ADDITIVE_PLUS : usual arithmetic conversions
- public void testAdditivePlus() throws Exception {
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(b % a)"); //$NON-NLS-1$
+ }
+
+ // Kind ADDITIVE_PLUS : usual arithmetic conversions
+ public void testAdditivePlus() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( b + a );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b + a)" ); //$NON-NLS-1$
- }
- // Kind ADDITIVE_MINUS : usual arithmetic conversions
- public void testAdditiveMinus() throws Exception {
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(b + a)"); //$NON-NLS-1$
+ }
+
+ // Kind ADDITIVE_MINUS : usual arithmetic conversions
+ public void testAdditiveMinus() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( b - a );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b - a)" ); //$NON-NLS-1$
- }
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(b - a)"); //$NON-NLS-1$
+ }
+
// Kind SHIFT_LEFT : LHS
- public void testShiftLeft() throws Exception {
+ public void testShiftLeft() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a << 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a << 5)" ); //$NON-NLS-1$
- }
- // Kind SHIFT_RIGHT : LHS
- public void testShiftRight() throws Exception {
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a << 5)"); //$NON-NLS-1$
+ }
+
+ // Kind SHIFT_RIGHT : LHS
+ public void testShiftRight() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a >> 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a >> 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a >> 5)"); //$NON-NLS-1$
}
- // Kind RELATIONAL_LESSTHAN : bool
- public void testRelationalLessThan() throws Exception {
+
+ // Kind RELATIONAL_LESSTHAN : bool
+ public void testRelationalLessThan() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( b < 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b < 3)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(b < 3)"); //$NON-NLS-1$
}
- // Kind RELATIONAL_GREATERTHAN : bool
- public void testRelationalGreaterThan() throws Exception {
+
+ // Kind RELATIONAL_GREATERTHAN : bool
+ public void testRelationalGreaterThan() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( b > 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b > 3)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(b > 3)"); //$NON-NLS-1$
}
- // Kind RELATIONAL_LESSTHANEQUALTO : bool
- public void testRelationalLessThanOrEqual() throws Exception {
+
+ // Kind RELATIONAL_LESSTHANEQUALTO : bool
+ public void testRelationalLessThanOrEqual() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( b <= 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b <= 3)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(b <= 3)"); //$NON-NLS-1$
}
+
// Kind RELATIONAL_GREATERTHANEQUALTO : bool
- public void testRelationalGreaterThanOrEqual() throws Exception {
+ public void testRelationalGreaterThanOrEqual() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( b >= 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b >= 3)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(b >= 3)"); //$NON-NLS-1$
}
- // Kind EQUALITY_EQUALS : bool
- public void testEqualityEquals() throws Exception {
+
+ // Kind EQUALITY_EQUALS : bool
+ public void testEqualityEquals() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( b == 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b == 3)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(b == 3)"); //$NON-NLS-1$
}
- // Kind EQUALITY_NOTEQUALS : bool
- public void testEqualityNotEquals() throws Exception {
+
+ // Kind EQUALITY_NOTEQUALS : bool
+ public void testEqualityNotEquals() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( b != 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b != 3)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(b != 3)"); //$NON-NLS-1$
}
- // Kind ANDEXPRESSION : usual arithmetic conversions
- public void testAndExpression() throws Exception {
+
+ // Kind ANDEXPRESSION : usual arithmetic conversions
+ public void testAndExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a & b );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a & b)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a & b)"); //$NON-NLS-1$
}
- // Kind EXCLUSIVEOREXPRESSION : usual arithmetic conversions
- public void testExclusiveOrExpression() throws Exception {
+
+ // Kind EXCLUSIVEOREXPRESSION : usual arithmetic conversions
+ public void testExclusiveOrExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a ^ b );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a ^ b)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a ^ b)"); //$NON-NLS-1$
}
- // Kind INCLUSIVEOREXPRESSION : : usual arithmetic conversions
- public void testInclusiveOrExpression() throws Exception {
+
+ // Kind INCLUSIVEOREXPRESSION : : usual arithmetic conversions
+ public void testInclusiveOrExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a | b );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a | b)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a | b)"); //$NON-NLS-1$
}
- // Kind LOGICALANDEXPRESSION : bool
- public void testLogicalAndExpression() throws Exception {
+
+ // Kind LOGICALANDEXPRESSION : bool
+ public void testLogicalAndExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a && b );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a && b)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a && b)"); //$NON-NLS-1$
}
- // Kind LOGICALOREXPRESSION : bool
- public void testLogicalOrExpression() throws Exception {
+
+ // Kind LOGICALOREXPRESSION : bool
+ public void testLogicalOrExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a || b );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a || b)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a || b)"); //$NON-NLS-1$
}
- // Kind CONDITIONALEXPRESSION : conditional Expression Conversions
- public void testConditionalExpression() throws Exception {
+
+ // Kind CONDITIONALEXPRESSION : conditional Expression Conversions
+ public void testConditionalExpression() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a > 5 ? b : c );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a > 5 ? b : c)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a > 5 ? b : c)"); //$NON-NLS-1$
}
-
+
// Kind ASSIGNMENTEXPRESSION_NORMAL : LHS
- public void testAssignmentExpressionNormal() throws Exception {
+ public void testAssignmentExpressionNormal() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a = 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a = 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a = 5)"); //$NON-NLS-1$
}
- // Kind ASSIGNMENTEXPRESSION_PLUS : LHS
- public void testAssignmentExpressionPlus() throws Exception {
+
+ // Kind ASSIGNMENTEXPRESSION_PLUS : LHS
+ public void testAssignmentExpressionPlus() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a += 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a += 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a += 5)"); //$NON-NLS-1$
}
- // Kind ASSIGNMENTEXPRESSION_MINUS : LHS
- public void testAssignmentExpressionMinus() throws Exception {
+
+ // Kind ASSIGNMENTEXPRESSION_MINUS : LHS
+ public void testAssignmentExpressionMinus() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a -= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a -= 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a -= 5)"); //$NON-NLS-1$
}
- // Kind ASSIGNMENTEXPRESSION_MULT : LHS
- public void testAssignmentExpressionMulti() throws Exception {
+
+ // Kind ASSIGNMENTEXPRESSION_MULT : LHS
+ public void testAssignmentExpressionMulti() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a *= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a *= 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a *= 5)"); //$NON-NLS-1$
}
- // Kind ASSIGNMENTEXPRESSION_DIV : LHS
- public void testAssignmentExpressionDiv() throws Exception {
+
+ // Kind ASSIGNMENTEXPRESSION_DIV : LHS
+ public void testAssignmentExpressionDiv() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a /= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a /= 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a /= 5)"); //$NON-NLS-1$
}
- // Kind ASSIGNMENTEXPRESSION_MOD : LHS
- public void testAssignmentExpressionMod() throws Exception {
+
+ // Kind ASSIGNMENTEXPRESSION_MOD : LHS
+ public void testAssignmentExpressionMod() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a %= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a %= 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a %= 5)"); //$NON-NLS-1$
}
+
// Kind ASSIGNMENTEXPRESSION_LSHIFT : LHS
- public void testAssignmentExpressionLShift() throws Exception {
+ public void testAssignmentExpressionLShift() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a >>= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a >>= 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a >>= 5)"); //$NON-NLS-1$
}
+
// Kind ASSIGNMENTEXPRESSION_RSHIFT : LHS
- public void testAssignmentExpressionRShift() throws Exception {
+ public void testAssignmentExpressionRShift() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a <<= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a <<= 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a <<= 5)"); //$NON-NLS-1$
}
+
// Kind ASSIGNMENTEXPRESSION_AND : LHS
- public void testAssignmentExpressionAnd() throws Exception {
+ public void testAssignmentExpressionAnd() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a &= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a &= 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a &= 5)"); //$NON-NLS-1$
}
- // Kind ASSIGNMENTEXPRESSION_OR : LHS
- public void testAssignmentExpressionOr() throws Exception {
+
+ // Kind ASSIGNMENTEXPRESSION_OR : LHS
+ public void testAssignmentExpressionOr() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a |= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a |= 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a |= 5)"); //$NON-NLS-1$
}
+
// Kind ASSIGNMENTEXPRESSION_XOR : LHS
- public void testAssignmentExpressionXOr() throws Exception {
+ public void testAssignmentExpressionXOr() throws Exception {
IASTTranslationUnit tu = parse("int x = foo( a ^= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
IASTDeclaration[] d = tu.getDeclarations();
- isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a ^= 5)" ); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "foo(a ^= 5)"); //$NON-NLS-1$
}
-
+
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java
index 1e603734647..c533a173631 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java
@@ -39,8 +39,8 @@ public class AST2UtilTests extends AST2TestBase {
}
public void testSimpleSignature() throws Exception {
- StringBuilder buff = new StringBuilder();
- buff.append("int l, m, n=0;\n"); //$NON-NLS-1$
+ StringBuilder buff = new StringBuilder();
+ buff.append("int l, m, n=0;\n"); //$NON-NLS-1$
buff.append("int j = l ? m : n;\n"); //$NON-NLS-1$
buff.append("int i = l^m;\n"); //$NON-NLS-1$
buff.append("int g = i<<=j;\n"); //$NON-NLS-1$
@@ -50,124 +50,188 @@ public class AST2UtilTests extends AST2TestBase {
buff.append("int b = d++;\n"); //$NON-NLS-1$
buff.append("int c = sizeof b;\n"); //$NON-NLS-1$
buff.append("int a = b + c;\n"); //$NON-NLS-1$
-
- IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C);
+
+ IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C);
IASTDeclaration[] d = tu.getDeclarations();
-
- isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[2].getInitializer()).getInitializerClause(), "0"); //$NON-NLS-1$
- isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[1]).getDeclarators()[0].getInitializer()).getInitializerClause(), "l ? m : n"); //$NON-NLS-1$
- isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[2]).getDeclarators()[0].getInitializer()).getInitializerClause(), "l ^ m"); //$NON-NLS-1$
- isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[3]).getDeclarators()[0].getInitializer()).getInitializerClause(), "i <<= j"); //$NON-NLS-1$
- isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[4]).getDeclarators()[0].getInitializer()).getInitializerClause(), "sizeof(int)"); //$NON-NLS-1$
- isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[5]).getDeclarators()[0].getInitializer()).getInitializerClause(), "~f"); //$NON-NLS-1$
- isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[6]).getDeclarators()[0].getInitializer()).getInitializerClause(), "++e"); //$NON-NLS-1$
- isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[7]).getDeclarators()[0].getInitializer()).getInitializerClause(), "d++"); //$NON-NLS-1$
- isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[8]).getDeclarators()[0].getInitializer()).getInitializerClause(), "sizeof b"); //$NON-NLS-1$
- isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[9]).getDeclarators()[0].getInitializer()).getInitializerClause(), "b + c"); //$NON-NLS-1$
+
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[2].getInitializer())
+ .getInitializerClause(),
+ "0"); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[1]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "l ? m : n"); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[2]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "l ^ m"); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[3]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "i <<= j"); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[4]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "sizeof(int)"); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[5]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "~f"); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[6]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "++e"); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[7]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "d++"); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[8]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "sizeof b"); //$NON-NLS-1$
+ isExpressionStringEqual(
+ ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[9]).getDeclarators()[0].getInitializer())
+ .getInitializerClause(),
+ "b + c"); //$NON-NLS-1$
}
-
+
public void testSimpleParameter() throws Exception {
- StringBuilder buff = new StringBuilder();
- buff.append("int a(int x);\n"); //$NON-NLS-1$
+ StringBuilder buff = new StringBuilder();
+ buff.append("int a(int x);\n"); //$NON-NLS-1$
buff.append("int * b(char y, int x);\n"); //$NON-NLS-1$
buff.append("void c(int * z, float **b);\n"); //$NON-NLS-1$
buff.append("static int d(int a[restrict]);\n"); //$NON-NLS-1$
- buff.append("void e(const char* const);\n"); //$NON-NLS-1$
-
- IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C);
+ buff.append("void e(const char* const);\n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C);
IASTDeclaration[] d = tu.getDeclarations();
-
- isParameterSignatureEqual(((IASTSimpleDeclaration)d[0]).getDeclarators()[0], "(int)"); //$NON-NLS-1$
- isParameterSignatureEqual(((IASTSimpleDeclaration)d[1]).getDeclarators()[0], "(char, int)"); //$NON-NLS-1$
- isParameterSignatureEqual(((IASTSimpleDeclaration)d[2]).getDeclarators()[0], "(int*, float**)"); //$NON-NLS-1$
- isParameterSignatureEqual(((IASTSimpleDeclaration)d[3]).getDeclarators()[0], "(int[])"); //$NON-NLS-1$
- isParameterSignatureEqual(((IASTSimpleDeclaration)d[4]).getDeclarators()[0], "(const char* const)"); //$NON-NLS-1$
-
- isSignatureEqual(((IASTSimpleDeclaration)d[0]).getDeclarators()[0], "int(int)"); //$NON-NLS-1$
- isSignatureEqual(((IASTSimpleDeclaration)d[1]).getDeclarators()[0], "int*(char, int)"); //$NON-NLS-1$
- isSignatureEqual(((IASTSimpleDeclaration)d[2]).getDeclarators()[0], "void(int*, float**)"); //$NON-NLS-1$
- isSignatureEqual(((IASTSimpleDeclaration)d[3]).getDeclarators()[0], "int(int[])"); //$NON-NLS-1$
- isSignatureEqual(((IASTSimpleDeclaration)d[4]).getDeclarators()[0], "void(const char* const)"); //$NON-NLS-1$
-
- isSignatureEqual(((IASTSimpleDeclaration)d[0]).getDeclSpecifier(), "int"); //$NON-NLS-1$
- isSignatureEqual(((IASTSimpleDeclaration)d[1]).getDeclSpecifier(), "int"); //$NON-NLS-1$
- isSignatureEqual(((IASTSimpleDeclaration)d[2]).getDeclSpecifier(), "void"); //$NON-NLS-1$
- isSignatureEqual(((IASTSimpleDeclaration)d[3]).getDeclSpecifier(), "int"); //$NON-NLS-1$
- isSignatureEqual(((IASTSimpleDeclaration)d[4]).getDeclSpecifier(), "void"); //$NON-NLS-1$
-
- isTypeEqual(((IASTSimpleDeclaration)d[0]).getDeclarators()[0], "int (int)"); //$NON-NLS-1$
- isTypeEqual(((IASTSimpleDeclaration)d[1]).getDeclarators()[0], "int * (char, int)"); //$NON-NLS-1$
- isTypeEqual(((IASTSimpleDeclaration)d[2]).getDeclarators()[0], "void (int *, float * *)"); //$NON-NLS-1$
- isTypeEqual(((IASTSimpleDeclaration)d[3]).getDeclarators()[0], "int (int * restrict)"); //$NON-NLS-1$
- isTypeEqual(((IASTSimpleDeclaration)d[4]).getDeclarators()[0], "void (const char * const)"); //$NON-NLS-1$
-
- isTypeEqual(((IFunction)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getName().resolveBinding()).getType(), "int (int)"); //$NON-NLS-1$
- isTypeEqual(((IFunction)((IASTSimpleDeclaration)d[1]).getDeclarators()[0].getName().resolveBinding()).getType(), "int * (char, int)"); //$NON-NLS-1$
- isTypeEqual(((IFunction)((IASTSimpleDeclaration)d[2]).getDeclarators()[0].getName().resolveBinding()).getType(), "void (int *, float * *)"); //$NON-NLS-1$
- isTypeEqual(((IFunction)((IASTSimpleDeclaration)d[3]).getDeclarators()[0].getName().resolveBinding()).getType(), "int (int * restrict)"); //$NON-NLS-1$
- isTypeEqual(((IFunction)((IASTSimpleDeclaration)d[4]).getDeclarators()[0].getName().resolveBinding()).getType(), "void (const char * const)"); //$NON-NLS-1$
-
- isParameterTypeEqual(((IFunction)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getName().resolveBinding()).getType(), "(int)"); //$NON-NLS-1$
- isParameterTypeEqual(((IFunction)((IASTSimpleDeclaration)d[1]).getDeclarators()[0].getName().resolveBinding()).getType(), "(char, int)"); //$NON-NLS-1$
- isParameterTypeEqual(((IFunction)((IASTSimpleDeclaration)d[2]).getDeclarators()[0].getName().resolveBinding()).getType(), "(int *, float * *)"); //$NON-NLS-1$
- isParameterTypeEqual(((IFunction)((IASTSimpleDeclaration)d[3]).getDeclarators()[0].getName().resolveBinding()).getType(), "(int * restrict)"); //$NON-NLS-1$
- isParameterTypeEqual(((IFunction)((IASTSimpleDeclaration)d[4]).getDeclarators()[0].getName().resolveBinding()).getType(), "(const char * const)"); //$NON-NLS-1$
+
+ isParameterSignatureEqual(((IASTSimpleDeclaration) d[0]).getDeclarators()[0], "(int)"); //$NON-NLS-1$
+ isParameterSignatureEqual(((IASTSimpleDeclaration) d[1]).getDeclarators()[0], "(char, int)"); //$NON-NLS-1$
+ isParameterSignatureEqual(((IASTSimpleDeclaration) d[2]).getDeclarators()[0], "(int*, float**)"); //$NON-NLS-1$
+ isParameterSignatureEqual(((IASTSimpleDeclaration) d[3]).getDeclarators()[0], "(int[])"); //$NON-NLS-1$
+ isParameterSignatureEqual(((IASTSimpleDeclaration) d[4]).getDeclarators()[0], "(const char* const)"); //$NON-NLS-1$
+
+ isSignatureEqual(((IASTSimpleDeclaration) d[0]).getDeclarators()[0], "int(int)"); //$NON-NLS-1$
+ isSignatureEqual(((IASTSimpleDeclaration) d[1]).getDeclarators()[0], "int*(char, int)"); //$NON-NLS-1$
+ isSignatureEqual(((IASTSimpleDeclaration) d[2]).getDeclarators()[0], "void(int*, float**)"); //$NON-NLS-1$
+ isSignatureEqual(((IASTSimpleDeclaration) d[3]).getDeclarators()[0], "int(int[])"); //$NON-NLS-1$
+ isSignatureEqual(((IASTSimpleDeclaration) d[4]).getDeclarators()[0], "void(const char* const)"); //$NON-NLS-1$
+
+ isSignatureEqual(((IASTSimpleDeclaration) d[0]).getDeclSpecifier(), "int"); //$NON-NLS-1$
+ isSignatureEqual(((IASTSimpleDeclaration) d[1]).getDeclSpecifier(), "int"); //$NON-NLS-1$
+ isSignatureEqual(((IASTSimpleDeclaration) d[2]).getDeclSpecifier(), "void"); //$NON-NLS-1$
+ isSignatureEqual(((IASTSimpleDeclaration) d[3]).getDeclSpecifier(), "int"); //$NON-NLS-1$
+ isSignatureEqual(((IASTSimpleDeclaration) d[4]).getDeclSpecifier(), "void"); //$NON-NLS-1$
+
+ isTypeEqual(((IASTSimpleDeclaration) d[0]).getDeclarators()[0], "int (int)"); //$NON-NLS-1$
+ isTypeEqual(((IASTSimpleDeclaration) d[1]).getDeclarators()[0], "int * (char, int)"); //$NON-NLS-1$
+ isTypeEqual(((IASTSimpleDeclaration) d[2]).getDeclarators()[0], "void (int *, float * *)"); //$NON-NLS-1$
+ isTypeEqual(((IASTSimpleDeclaration) d[3]).getDeclarators()[0], "int (int * restrict)"); //$NON-NLS-1$
+ isTypeEqual(((IASTSimpleDeclaration) d[4]).getDeclarators()[0], "void (const char * const)"); //$NON-NLS-1$
+
+ isTypeEqual(
+ ((IFunction) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getName().resolveBinding()).getType(),
+ "int (int)"); //$NON-NLS-1$
+ isTypeEqual(
+ ((IFunction) ((IASTSimpleDeclaration) d[1]).getDeclarators()[0].getName().resolveBinding()).getType(),
+ "int * (char, int)"); //$NON-NLS-1$
+ isTypeEqual(
+ ((IFunction) ((IASTSimpleDeclaration) d[2]).getDeclarators()[0].getName().resolveBinding()).getType(),
+ "void (int *, float * *)"); //$NON-NLS-1$
+ isTypeEqual(
+ ((IFunction) ((IASTSimpleDeclaration) d[3]).getDeclarators()[0].getName().resolveBinding()).getType(),
+ "int (int * restrict)"); //$NON-NLS-1$
+ isTypeEqual(
+ ((IFunction) ((IASTSimpleDeclaration) d[4]).getDeclarators()[0].getName().resolveBinding()).getType(),
+ "void (const char * const)"); //$NON-NLS-1$
+
+ isParameterTypeEqual(
+ ((IFunction) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0].getName().resolveBinding()).getType(),
+ "(int)"); //$NON-NLS-1$
+ isParameterTypeEqual(
+ ((IFunction) ((IASTSimpleDeclaration) d[1]).getDeclarators()[0].getName().resolveBinding()).getType(),
+ "(char, int)"); //$NON-NLS-1$
+ isParameterTypeEqual(
+ ((IFunction) ((IASTSimpleDeclaration) d[2]).getDeclarators()[0].getName().resolveBinding()).getType(),
+ "(int *, float * *)"); //$NON-NLS-1$
+ isParameterTypeEqual(
+ ((IFunction) ((IASTSimpleDeclaration) d[3]).getDeclarators()[0].getName().resolveBinding()).getType(),
+ "(int * restrict)"); //$NON-NLS-1$
+ isParameterTypeEqual(
+ ((IFunction) ((IASTSimpleDeclaration) d[4]).getDeclarators()[0].getName().resolveBinding()).getType(),
+ "(const char * const)"); //$NON-NLS-1$
}
-
+
public void testSimpleCParameterSignature() throws Exception {
- StringBuilder buff = new StringBuilder();
- buff.append("int a(int x);\n"); //$NON-NLS-1$
+ StringBuilder buff = new StringBuilder();
+ buff.append("int a(int x);\n"); //$NON-NLS-1$
buff.append("int * b(char y, int x);\n"); //$NON-NLS-1$
buff.append("void c(int * z, float **b);\n"); //$NON-NLS-1$
buff.append("static int d(int a[restrict]);\n"); //$NON-NLS-1$
-
- IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C);
+
+ IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C);
IASTDeclaration[] d = tu.getDeclarations();
-
- isParameterSignatureEqual(((IASTSimpleDeclaration)d[0]).getDeclarators()[0], "(int)"); //$NON-NLS-1$
- isParameterSignatureEqual(((IASTSimpleDeclaration)d[1]).getDeclarators()[0], "(char, int)"); //$NON-NLS-1$
- isParameterSignatureEqual(((IASTSimpleDeclaration)d[2]).getDeclarators()[0], "(int*, float**)"); //$NON-NLS-1$
- isParameterSignatureEqual(((IASTSimpleDeclaration)d[3]).getDeclarators()[0], "(int[])"); //$NON-NLS-1$
+
+ isParameterSignatureEqual(((IASTSimpleDeclaration) d[0]).getDeclarators()[0], "(int)"); //$NON-NLS-1$
+ isParameterSignatureEqual(((IASTSimpleDeclaration) d[1]).getDeclarators()[0], "(char, int)"); //$NON-NLS-1$
+ isParameterSignatureEqual(((IASTSimpleDeclaration) d[2]).getDeclarators()[0], "(int*, float**)"); //$NON-NLS-1$
+ isParameterSignatureEqual(((IASTSimpleDeclaration) d[3]).getDeclarators()[0], "(int[])"); //$NON-NLS-1$
}
-
+
public void testSimpleTypeId() throws Exception {
StringBuilder buff = new StringBuilder();
- buff.append("int x = sizeof( int );\n"); //$NON-NLS-1$
+ buff.append("int x = sizeof( int );\n"); //$NON-NLS-1$
buff.append("union Squaw { int x; double u; };\n"); //$NON-NLS-1$
buff.append("int main(int argc, char **argv) {\n"); //$NON-NLS-1$
buff.append("return sizeof( union Squaw );\n}\n"); //$NON-NLS-1$
buff.append("typedef short Z; typedef Z jc;\n"); //$NON-NLS-1$
buff.append("int y = 4;\n"); //$NON-NLS-1$
buff.append("jc myJc = (jc)y;\n"); //$NON-NLS-1$
-
- IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C);
+
+ IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C);
IASTDeclaration[] d = tu.getDeclarations();
-
+
// verify signatures
- isSignatureEqual( ((IASTTypeIdExpression)((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause()).getTypeId(), "int"); //$NON-NLS-1$
- isSignatureEqual( ((IASTTypeIdExpression)((IASTReturnStatement)((IASTCompoundStatement)((IASTFunctionDefinition)d[2]).getBody()).getStatements()[0]).getReturnValue()).getTypeId(), "union Squaw"); //$NON-NLS-1$
- isSignatureEqual( ((IASTCastExpression)((IASTEqualsInitializer)((IASTSimpleDeclaration)d[6]).getDeclarators()[0].getInitializer()).getInitializerClause()).getTypeId() , "jc"); //$NON-NLS-1$
-
+ isSignatureEqual(
+ ((IASTTypeIdExpression) ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0]
+ .getInitializer()).getInitializerClause()).getTypeId(),
+ "int"); //$NON-NLS-1$
+ isSignatureEqual(
+ ((IASTTypeIdExpression) ((IASTReturnStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) d[2])
+ .getBody()).getStatements()[0]).getReturnValue()).getTypeId(),
+ "union Squaw"); //$NON-NLS-1$
+ isSignatureEqual(
+ ((IASTCastExpression) ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[6]).getDeclarators()[0]
+ .getInitializer()).getInitializerClause()).getTypeId(),
+ "jc"); //$NON-NLS-1$
+
// verify types
- isTypeEqual( ((IASTTypeIdExpression)((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause()).getTypeId(), "int"); //$NON-NLS-1$
- isTypeEqual( ((IASTTypeIdExpression)((IASTReturnStatement)((IASTCompoundStatement)((IASTFunctionDefinition)d[2]).getBody()).getStatements()[0]).getReturnValue()).getTypeId(), "Squaw"); //$NON-NLS-1$
- isTypeEqual( ((IASTCastExpression)((IASTEqualsInitializer)((IASTSimpleDeclaration)d[6]).getDeclarators()[0].getInitializer()).getInitializerClause()).getTypeId() , "short int"); //$NON-NLS-1$
+ isTypeEqual(((IASTTypeIdExpression) ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[0]).getDeclarators()[0]
+ .getInitializer()).getInitializerClause()).getTypeId(), "int"); //$NON-NLS-1$
+ isTypeEqual(
+ ((IASTTypeIdExpression) ((IASTReturnStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) d[2])
+ .getBody()).getStatements()[0]).getReturnValue()).getTypeId(),
+ "Squaw"); //$NON-NLS-1$
+ isTypeEqual(((IASTCastExpression) ((IASTEqualsInitializer) ((IASTSimpleDeclaration) d[6]).getDeclarators()[0]
+ .getInitializer()).getInitializerClause()).getTypeId(), "short int"); //$NON-NLS-1$
}
-
+
public void testKnRC() throws Exception {
StringBuilder buff = new StringBuilder();
- buff.append("int foo(x, y) char x; int y; {}\n"); //$NON-NLS-1$
+ buff.append("int foo(x, y) char x; int y; {}\n"); //$NON-NLS-1$
buff.append("int foo2(char x, int y) {}\n"); //$NON-NLS-1$
-
+
IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C, true);
IASTDeclaration[] d = tu.getDeclarations();
-
- String fooSignature = ASTStringUtil.getSignatureString(((IASTFunctionDefinition)d[0]).getDeclarator());
- String foo2Signature = ASTStringUtil.getSignatureString(((IASTFunctionDefinition)d[1]).getDeclarator());
-
+
+ String fooSignature = ASTStringUtil.getSignatureString(((IASTFunctionDefinition) d[0]).getDeclarator());
+ String foo2Signature = ASTStringUtil.getSignatureString(((IASTFunctionDefinition) d[1]).getDeclarator());
+
assertEquals(fooSignature, foo2Signature);
}
-
+
public void testParseIntegral() throws Exception {
assertEquals(0, ExpressionEvaluator.getNumber("0".toCharArray()));
assertEquals(0, ExpressionEvaluator.getNumber("0x0".toCharArray()));
@@ -175,11 +239,11 @@ public class AST2UtilTests extends AST2TestBase {
assertEquals(0, ExpressionEvaluator.getNumber("000".toCharArray()));
assertEquals(0, ExpressionEvaluator.getNumber("0L".toCharArray()));
assertEquals(0, ExpressionEvaluator.getNumber("0LL".toCharArray()));
-
+
assertEquals(1, ExpressionEvaluator.getNumber("1".toCharArray()));
assertEquals(1, ExpressionEvaluator.getNumber("01".toCharArray()));
assertEquals(1, ExpressionEvaluator.getNumber("0x1".toCharArray()));
-
+
assertEquals(10, ExpressionEvaluator.getNumber("10".toCharArray()));
assertEquals(8, ExpressionEvaluator.getNumber("010".toCharArray()));
assertEquals(16, ExpressionEvaluator.getNumber("0x10".toCharArray()));
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTCPPSpecDefectTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTCPPSpecDefectTests.java
index c18e6b70cc6..27e33057060 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTCPPSpecDefectTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTCPPSpecDefectTests.java
@@ -19,31 +19,31 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.parser.ParserLanguage;
public class ASTCPPSpecDefectTests extends AST2TestBase {
-
+
public ASTCPPSpecDefectTests() {
}
-
+
public ASTCPPSpecDefectTests(String name) {
super(name);
}
-
+
public static TestSuite suite() {
return suite(ASTCPPSpecDefectTests.class);
}
-
+
protected IASTTranslationUnit parseAndCheckBindings(String code) throws Exception {
IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
NameCollector col = new NameCollector();
tu.accept(col);
assertNoProblemBindings(col);
return tu;
- }
-
+ }
+
private IASTTranslationUnit parseAndCheckBindings() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
return parseAndCheckBindings(code);
}
-
+
// // C++ defect #33
// namespace ns {
// struct S {};
@@ -53,12 +53,12 @@ public class ASTCPPSpecDefectTests extends AST2TestBase {
// void f0(int);
//
// void test() {
- // fp(f0);
+ // fp(f0);
// }
public void test33_ADLForOverloadSet_324842() throws Exception {
parseAndCheckBindings();
}
-
+
// // C++ defect #38
// template<typename T> T operator+(T&);
// struct A {
@@ -67,7 +67,7 @@ public class ASTCPPSpecDefectTests extends AST2TestBase {
public void test38_templateArgForOperator() throws Exception {
parseAndCheckBindings();
}
-
+
// template <class T1, class ...Z> class S; // #1
// template <class T1, class ...Z> class S<T1, const Z&...> {}; // #2
// template <class T1, class T2> class S<T1, const T2&> {};; // #3
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTInactiveCodeTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTInactiveCodeTests.java
index c66127a5819..659d659b01f 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTInactiveCodeTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTInactiveCodeTests.java
@@ -32,15 +32,15 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
* Testcases for inactive code in ast.
*/
public class ASTInactiveCodeTests extends AST2TestBase {
-
+
public static TestSuite suite() {
return suite(ASTInactiveCodeTests.class);
}
-
+
public ASTInactiveCodeTests() {
super();
}
-
+
public ASTInactiveCodeTests(String name) {
super(name);
}
@@ -68,11 +68,11 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// #endif
// int a7;
public void testIfBranches() throws Exception {
- String codeTmpl= getAboveComment();
- for (int i= 0; i < (1<<4); i++) {
+ String codeTmpl = getAboveComment();
+ for (int i = 0; i < (1 << 4); i++) {
testBranches(codeTmpl, ParserLanguage.C, i);
}
- for (int i= 0; i < (1<<4); i++) {
+ for (int i = 0; i < (1 << 4); i++) {
testBranches(codeTmpl, ParserLanguage.CPP, i);
}
}
@@ -80,26 +80,27 @@ public class ASTInactiveCodeTests extends AST2TestBase {
private void testBranches(String codeTmpl, ParserLanguage lang, int bits) throws Exception {
testBranches(codeTmpl, lang, bits, 0);
}
+
private void testBranches(String codeTmpl, ParserLanguage lang, int bits, int level) throws Exception {
- BitSet bs= convert(bits);
- char[] chars= codeTmpl.toCharArray();
- int pos= codeTmpl.indexOf('%', 0);
- int i= 0;
+ BitSet bs = convert(bits);
+ char[] chars = codeTmpl.toCharArray();
+ int pos = codeTmpl.indexOf('%', 0);
+ int i = 0;
while (pos >= 0) {
- chars[pos]= bs.get(i++) ? '1' : '0';
- pos= codeTmpl.indexOf('%', pos+1);
+ chars[pos] = bs.get(i++) ? '1' : '0';
+ pos = codeTmpl.indexOf('%', pos + 1);
}
- IASTDeclarationListOwner tu= parse(new String(chars), lang);
+ IASTDeclarationListOwner tu = parse(new String(chars), lang);
while (level-- > 0) {
final IASTDeclaration decl = tu.getDeclarations(true)[0];
if (decl instanceof IASTSimpleDeclaration) {
- tu= (IASTDeclarationListOwner) ((IASTSimpleDeclaration) decl).getDeclSpecifier();
+ tu = (IASTDeclarationListOwner) ((IASTSimpleDeclaration) decl).getDeclSpecifier();
} else {
- tu= (IASTDeclarationListOwner) decl;
+ tu = (IASTDeclarationListOwner) decl;
}
}
-
- IASTDeclaration[] decl= tu.getDeclarations(true);
+
+ IASTDeclaration[] decl = tu.getDeclarations(true);
assertEquals(8, decl.length);
assertEquals(bs.get(0), decl[0].isActive());
assertEquals(!bs.get(0) && bs.get(1), decl[1].isActive());
@@ -112,7 +113,7 @@ public class ASTInactiveCodeTests extends AST2TestBase {
}
private BitSet convert(int bits) {
- BitSet result= new BitSet(32);
+ BitSet result = new BitSet(32);
for (int i = 0; i < 32; i++) {
if ((bits & (1 << i)) != 0) {
result.set(i);
@@ -139,11 +140,11 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// #endif
// int a7;
public void testIfdefBranches() throws Exception {
- String codeTmpl= getAboveComment();
- for (int i= 0; i < (1<<4); i++) {
+ String codeTmpl = getAboveComment();
+ for (int i = 0; i < (1 << 4); i++) {
testBranches(codeTmpl, ParserLanguage.C, i);
}
- for (int i= 0; i < (1<<4); i++) {
+ for (int i = 0; i < (1 << 4); i++) {
testBranches(codeTmpl, ParserLanguage.CPP, i);
}
}
@@ -166,11 +167,11 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// #endif
// int a7;
public void testIfndefBranches() throws Exception {
- String codeTmpl= getAboveComment();
- for (int i= 0; i < (1<<4); i++) {
+ String codeTmpl = getAboveComment();
+ for (int i = 0; i < (1 << 4); i++) {
testBranches(codeTmpl, ParserLanguage.C, i);
}
- for (int i= 0; i < (1<<4); i++) {
+ for (int i = 0; i < (1 << 4); i++) {
testBranches(codeTmpl, ParserLanguage.CPP, i);
}
}
@@ -194,11 +195,11 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// int a7;
// };
public void testStructs() throws Exception {
- String codeTmpl= getAboveComment();
- for (int i= 0; i < (1<<4); i++) {
+ String codeTmpl = getAboveComment();
+ for (int i = 0; i < (1 << 4); i++) {
testBranches(codeTmpl, ParserLanguage.C, i, 1);
}
- for (int i= 0; i < (1<<4); i++) {
+ for (int i = 0; i < (1 << 4); i++) {
testBranches(codeTmpl, ParserLanguage.CPP, i, 1);
}
}
@@ -222,8 +223,8 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// int a7;
// };
public void testExternC() throws Exception {
- String codeTmpl= getAboveComment();
- for (int i= 0; i < (1<<4); i++) {
+ String codeTmpl = getAboveComment();
+ for (int i = 0; i < (1 << 4); i++) {
testBranches(codeTmpl, ParserLanguage.CPP, i, 1);
}
}
@@ -247,12 +248,12 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// int a7;
// }
public void testNamespace() throws Exception {
- String codeTmpl= getAboveComment();
- for (int i= 0; i < (1<<4); i++) {
+ String codeTmpl = getAboveComment();
+ for (int i = 0; i < (1 << 4); i++) {
testBranches(codeTmpl, ParserLanguage.CPP, i, 1);
}
}
-
+
// typedef int TInt;
// const int value= 12;
// #if 0
@@ -260,15 +261,15 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// int g(value);
// #endif
public void testAmbiguity() throws Exception {
- String code= getAboveComment();
- IASTTranslationUnit tu= parseAndCheckBindings(code, ParserLanguage.CPP);
+ String code = getAboveComment();
+ IASTTranslationUnit tu = parseAndCheckBindings(code, ParserLanguage.CPP);
IASTDeclaration[] decls = tu.getDeclarations(true);
- IASTSimpleDeclaration decl= (IASTSimpleDeclaration) decls[2];
+ IASTSimpleDeclaration decl = (IASTSimpleDeclaration) decls[2];
assertTrue(decl.getDeclarators()[0] instanceof IASTFunctionDeclarator);
- decl= (IASTSimpleDeclaration) decls[3];
+ decl = (IASTSimpleDeclaration) decls[3];
assertFalse(decl.getDeclarators()[0] instanceof IASTFunctionDeclarator);
}
-
+
// int a; // 1
// #if 0
// int a; // 2
@@ -279,15 +280,15 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// #endif
// int b; // 2
public void testDuplicateDefinition() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, false);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, false);
bh.assertNonProblem("a; // 1", 1);
bh.assertNonProblem("a; // 2", 1);
bh.assertNonProblem("a; // 3", 1);
bh.assertNonProblem("b; // 1", 1);
bh.assertNonProblem("b; // 2", 1);
- bh= new AST2AssertionHelper(code, true);
+ bh = new AST2AssertionHelper(code, true);
bh.assertNonProblem("a; // 1", 1);
bh.assertNonProblem("a; // 2", 1);
bh.assertNonProblem("a; // 3", 1);
@@ -297,7 +298,7 @@ public class ASTInactiveCodeTests extends AST2TestBase {
parseAndCheckBindings(code, ParserLanguage.C);
parseAndCheckBindings(code, ParserLanguage.CPP);
}
-
+
// struct S {
// #if 0
// int a;
@@ -307,19 +308,19 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// };
// #endif
public void testInactiveClosingBrace() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, false);
- IField a= bh.assertNonProblem("a;", 1);
- IField b= bh.assertNonProblem("b;", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, false);
+ IField a = bh.assertNonProblem("a;", 1);
+ IField b = bh.assertNonProblem("b;", 1);
assertSame(a.getOwner(), b.getOwner());
- bh= new AST2AssertionHelper(code, true);
- a= bh.assertNonProblem("a;", 1);
- b= bh.assertNonProblem("b;", 1);
+ bh = new AST2AssertionHelper(code, true);
+ a = bh.assertNonProblem("a;", 1);
+ b = bh.assertNonProblem("b;", 1);
assertSame(a.getOwner(), b.getOwner());
}
-
- // struct S
+
+ // struct S
// #if 1
// {
// int a;
@@ -332,26 +333,26 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// #endif
// };
public void testOpenBraceInActiveBranch() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, false);
- IField a= bh.assertNonProblem("a;", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, false);
+ IField a = bh.assertNonProblem("a;", 1);
bh.assertNoName("b;", 1);
- IField c= bh.assertNonProblem("c;", 1);
- IField d= bh.assertNonProblem("d;", 1);
+ IField c = bh.assertNonProblem("c;", 1);
+ IField d = bh.assertNonProblem("d;", 1);
assertSame(a.getOwner(), c.getOwner());
assertSame(a.getOwner(), d.getOwner());
- bh= new AST2AssertionHelper(code, true);
- a= bh.assertNonProblem("a;", 1);
+ bh = new AST2AssertionHelper(code, true);
+ a = bh.assertNonProblem("a;", 1);
bh.assertNoName("b;", 1);
- c= bh.assertNonProblem("c;", 1);
- d= bh.assertNonProblem("d;", 1);
+ c = bh.assertNonProblem("c;", 1);
+ d = bh.assertNonProblem("d;", 1);
assertSame(a.getOwner(), c.getOwner());
assertSame(a.getOwner(), d.getOwner());
}
// #if 0
- // struct S {
+ // struct S {
// #if 1
// int a;
// #else
@@ -362,26 +363,26 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// #endif
// int d;
public void testOpenBraceInInactiveBranch() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, false);
- IField a= bh.assertNonProblem("a;", 1);
- IField b= bh.assertNonProblem("b;", 1);
- IVariable c= bh.assertNonProblem("c;", 1); // part of a different non-nested branch
- IVariable d= bh.assertNonProblem("d;", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, false);
+ IField a = bh.assertNonProblem("a;", 1);
+ IField b = bh.assertNonProblem("b;", 1);
+ IVariable c = bh.assertNonProblem("c;", 1); // part of a different non-nested branch
+ IVariable d = bh.assertNonProblem("d;", 1);
assertSame(a.getOwner(), b.getOwner());
assertNull(c.getOwner());
assertNull(d.getOwner());
- bh= new AST2AssertionHelper(code, true);
- a= bh.assertNonProblem("a;", 1);
- b= bh.assertNonProblem("b;", 1);
- c= bh.assertNonProblem("c;", 1); // part of a different non-nested branch
- d= bh.assertNonProblem("d;", 1);
+ bh = new AST2AssertionHelper(code, true);
+ a = bh.assertNonProblem("a;", 1);
+ b = bh.assertNonProblem("b;", 1);
+ c = bh.assertNonProblem("c;", 1); // part of a different non-nested branch
+ d = bh.assertNonProblem("d;", 1);
assertSame(a.getOwner(), b.getOwner());
assertNull(c.getOwner());
assertNull(d.getOwner());
}
-
+
// #if 0
// void f() {
// #if 1
@@ -392,14 +393,14 @@ public class ASTInactiveCodeTests extends AST2TestBase {
// }
// #endif
public void testUnexpectedBranchesInInactiveCode() throws Exception {
- String code= getAboveComment();
- BindingAssertionHelper bh= new AST2AssertionHelper(code, false);
- IFunction f= bh.assertNonProblem("f()", 1);
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, false);
+ IFunction f = bh.assertNonProblem("f()", 1);
bh.assertNoName("a;", 1);
bh.assertNoName("b;", 1);
- bh= new AST2AssertionHelper(code, true);
- f= bh.assertNonProblem("f()", 1);
+ bh = new AST2AssertionHelper(code, true);
+ f = bh.assertNonProblem("f()", 1);
bh.assertNoName("a;", 1);
bh.assertNoName("b;", 1);
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTNodeSelectorTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTNodeSelectorTest.java
index 0547b33c61d..fba3e4f2c50 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTNodeSelectorTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTNodeSelectorTest.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2;
import java.io.IOException;
@@ -40,14 +40,14 @@ public class ASTNodeSelectorTest extends AST2TestBase {
protected String fCode;
protected IASTTranslationUnit fTu;
protected IASTNodeSelector fSelector;
-
+
public ASTNodeSelectorTest() {
}
public ASTNodeSelectorTest(String name) {
super(name);
}
-
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -55,13 +55,15 @@ public class ASTNodeSelectorTest extends AST2TestBase {
}
protected void createTranslationUnit() throws IOException {
- fCode= getContents(1)[0].toString();
- FileContent codeReader = FileContent.create("<test-code>", fCode.toCharArray());
- ScannerInfo scannerInfo = new ScannerInfo();
- IScanner scanner= AST2TestBase.createScanner(codeReader, ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, scannerInfo);
- GNUCPPSourceParser parser= new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, new NullLogService(), new GPPParserExtensionConfiguration());
- fTu= parser.parse();
- fSelector= fTu.getNodeSelector(null);
+ fCode = getContents(1)[0].toString();
+ FileContent codeReader = FileContent.create("<test-code>", fCode.toCharArray());
+ ScannerInfo scannerInfo = new ScannerInfo();
+ IScanner scanner = AST2TestBase.createScanner(codeReader, ParserLanguage.CPP, ParserMode.COMPLETE_PARSE,
+ scannerInfo);
+ GNUCPPSourceParser parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, new NullLogService(),
+ new GPPParserExtensionConfiguration());
+ fTu = parser.parse();
+ fSelector = fTu.getNodeSelector(null);
}
@Override
@@ -70,52 +72,50 @@ public class ASTNodeSelectorTest extends AST2TestBase {
}
private void testContainedName(int from, int to, String sig) {
- IASTName name= fSelector.findFirstContainedName(from, to-from);
+ IASTName name = fSelector.findFirstContainedName(from, to - from);
verify(sig, name);
}
private void verify(String sig, IASTNode node) {
if (sig == null) {
assertNull("unexpexted selection: " + (node == null ? "" : node.getRawSignature()), node);
- }
- else {
+ } else {
assertNotNull("unable to select " + sig, node);
if (node instanceof IASTName) {
assertEquals(sig, ((IASTName) node).toString());
- }
- else {
+ } else {
assertEquals(sig, node.getRawSignature());
}
}
}
private void testContainedNode(int from, int to, String sig) {
- IASTNode node= fSelector.findFirstContainedNode(from, to-from);
+ IASTNode node = fSelector.findFirstContainedNode(from, to - from);
verify(sig, node);
}
private void testName(int from, int to, String sig) {
- IASTName name= fSelector.findName(from, to-from);
+ IASTName name = fSelector.findName(from, to - from);
verify(sig, name);
}
private void testNode(int from, int to, String sig) {
- IASTNode node= fSelector.findNode(from, to-from);
+ IASTNode node = fSelector.findNode(from, to - from);
verify(sig, node);
}
private void testEnclosingName(int from, int to, String sig) {
- IASTName name= fSelector.findEnclosingName(from, to-from);
+ IASTName name = fSelector.findEnclosingName(from, to - from);
verify(sig, name);
}
private void testEnclosingNode(int from, int to, String sig) {
- IASTNode node= fSelector.findEnclosingNode(from, to-from);
+ IASTNode node = fSelector.findEnclosingNode(from, to - from);
verify(sig, node);
}
private void testExpansion(int from, int to, String sig) {
- IASTPreprocessorMacroExpansion exp= fSelector.findEnclosingMacroExpansion(from, to-from);
+ IASTPreprocessorMacroExpansion exp = fSelector.findEnclosingMacroExpansion(from, to - from);
verify(sig, exp);
}
@@ -125,33 +125,33 @@ public class ASTNodeSelectorTest extends AST2TestBase {
// #include <test>
// int a;
public void testInclusion() {
- int include_start= fCode.indexOf("#include");
- int name_start= fCode.indexOf("test");
- int include_end= fCode.indexOf(">") + 1;
-
- testContainedName(include_start-1, include_end+1, "test");
+ int include_start = fCode.indexOf("#include");
+ int name_start = fCode.indexOf("test");
+ int include_end = fCode.indexOf(">") + 1;
+
+ testContainedName(include_start - 1, include_end + 1, "test");
testContainedName(name_start, include_end, "test");
- testContainedName(include_start+1, name_start+1, null);
- testContainedName(name_start+1, name_start+7, null);
+ testContainedName(include_start + 1, name_start + 1, null);
+ testContainedName(name_start + 1, name_start + 7, null);
- testContainedNode(include_start-1, include_end+1, "#include <test>");
+ testContainedNode(include_start - 1, include_end + 1, "#include <test>");
testContainedNode(name_start, include_end, "test");
- testContainedNode(include_start+1, name_start+1, null);
- testContainedNode(name_start+1, name_start+7, null);
-
- testEnclosingName(name_start, name_start+4, "test");
+ testContainedNode(include_start + 1, name_start + 1, null);
+ testContainedNode(name_start + 1, name_start + 7, null);
+
+ testEnclosingName(name_start, name_start + 4, "test");
testEnclosingName(name_start, name_start, "test");
- testEnclosingName(name_start+4, name_start+4, "test");
- testEnclosingName(name_start-1, name_start+1, null);
- testEnclosingName(name_start+4, name_start+5, null);
+ testEnclosingName(name_start + 4, name_start + 4, "test");
+ testEnclosingName(name_start - 1, name_start + 1, null);
+ testEnclosingName(name_start + 4, name_start + 5, null);
- testEnclosingNode(name_start, name_start+4, "test");
+ testEnclosingNode(name_start, name_start + 4, "test");
testEnclosingNode(name_start, name_start, "test");
- testEnclosingNode(name_start+4, name_start+4, "test");
- testEnclosingNode(name_start-1, name_start+1, "#include <test>");
- testEnclosingNode(name_start+4-1, name_start+4+1, "#include <test>");
-
- testExpansion(name_start, name_start+4, null);
+ testEnclosingNode(name_start + 4, name_start + 4, "test");
+ testEnclosingNode(name_start - 1, name_start + 1, "#include <test>");
+ testEnclosingNode(name_start + 4 - 1, name_start + 4 + 1, "#include <test>");
+
+ testExpansion(name_start, name_start + 4, null);
}
// #define shift_offsets
@@ -163,64 +163,63 @@ public class ASTNodeSelectorTest extends AST2TestBase {
// #include EMPTY TEST_H
// }
public void testInclusionWithExpansions() {
- int inclusion_start= fCode.indexOf("#include");
- int empty_start= fCode.indexOf("EMPTY", inclusion_start);
- int testh_start= fCode.indexOf("TEST_H", empty_start);
- int file_end= fCode.length();
-
- testContainedName(inclusion_start-1, file_end-1, "EMPTY");
+ int inclusion_start = fCode.indexOf("#include");
+ int empty_start = fCode.indexOf("EMPTY", inclusion_start);
+ int testh_start = fCode.indexOf("TEST_H", empty_start);
+ int file_end = fCode.length();
+
+ testContainedName(inclusion_start - 1, file_end - 1, "EMPTY");
testContainedName(testh_start, file_end, "TEST_H");
- testContainedName(testh_start+1, file_end, null);
- testContainedName(testh_start, testh_start+5, null);
+ testContainedName(testh_start + 1, file_end, null);
+ testContainedName(testh_start, testh_start + 5, null);
- testContainedNode(inclusion_start-1, file_end+1, "#include EMPTY TEST_H");
+ testContainedNode(inclusion_start - 1, file_end + 1, "#include EMPTY TEST_H");
testContainedNode(testh_start, file_end, "TEST_H");
- testContainedNode(testh_start+1, file_end, null);
- testContainedNode(testh_start, testh_start+5, null);
-
- testName(empty_start, empty_start+5, "EMPTY");
- testName(empty_start-1, empty_start+5, null);
- testName(empty_start+1, empty_start+5, null);
- testName(empty_start, empty_start+4, null);
- testName(empty_start, empty_start+6, null);
-
- testNode(empty_start, empty_start+5, "EMPTY");
- testNode(empty_start-1, empty_start+5, null);
- testNode(empty_start+1, empty_start+5, null);
- testNode(empty_start, empty_start+4, null);
- testNode(empty_start, empty_start+6, null);
-
- testEnclosingName(empty_start, empty_start+5, "EMPTY");
+ testContainedNode(testh_start + 1, file_end, null);
+ testContainedNode(testh_start, testh_start + 5, null);
+
+ testName(empty_start, empty_start + 5, "EMPTY");
+ testName(empty_start - 1, empty_start + 5, null);
+ testName(empty_start + 1, empty_start + 5, null);
+ testName(empty_start, empty_start + 4, null);
+ testName(empty_start, empty_start + 6, null);
+
+ testNode(empty_start, empty_start + 5, "EMPTY");
+ testNode(empty_start - 1, empty_start + 5, null);
+ testNode(empty_start + 1, empty_start + 5, null);
+ testNode(empty_start, empty_start + 4, null);
+ testNode(empty_start, empty_start + 6, null);
+
+ testEnclosingName(empty_start, empty_start + 5, "EMPTY");
testEnclosingName(empty_start, empty_start, "EMPTY");
- testEnclosingName(empty_start+5, empty_start+5, "EMPTY");
- testEnclosingName(empty_start-1, empty_start, null);
- testEnclosingName(empty_start+5, empty_start+6, "test.h");
- testEnclosingName(testh_start, testh_start+6, "TEST_H");
+ testEnclosingName(empty_start + 5, empty_start + 5, "EMPTY");
+ testEnclosingName(empty_start - 1, empty_start, null);
+ testEnclosingName(empty_start + 5, empty_start + 6, "test.h");
+ testEnclosingName(testh_start, testh_start + 6, "TEST_H");
testEnclosingName(testh_start, testh_start, "TEST_H");
- testEnclosingName(testh_start+6, testh_start+6, "TEST_H");
- testEnclosingName(testh_start-1, testh_start+1, "test.h");
- testEnclosingName(testh_start+5, testh_start+7, null);
+ testEnclosingName(testh_start + 6, testh_start + 6, "TEST_H");
+ testEnclosingName(testh_start - 1, testh_start + 1, "test.h");
+ testEnclosingName(testh_start + 5, testh_start + 7, null);
- testEnclosingNode(empty_start, empty_start+5, "EMPTY");
+ testEnclosingNode(empty_start, empty_start + 5, "EMPTY");
testEnclosingNode(empty_start, empty_start, "EMPTY");
- testEnclosingNode(empty_start+5, empty_start+5, "EMPTY");
- testEnclosingNode(empty_start-1, empty_start, "#include EMPTY TEST_H");
- testEnclosingNode(empty_start+5, empty_start+6, "test.h");
- testEnclosingNode(testh_start, testh_start+6, "TEST_H");
+ testEnclosingNode(empty_start + 5, empty_start + 5, "EMPTY");
+ testEnclosingNode(empty_start - 1, empty_start, "#include EMPTY TEST_H");
+ testEnclosingNode(empty_start + 5, empty_start + 6, "test.h");
+ testEnclosingNode(testh_start, testh_start + 6, "TEST_H");
testEnclosingNode(testh_start, testh_start, "TEST_H");
- testEnclosingNode(testh_start+6, testh_start+6, "TEST_H");
- testEnclosingNode(testh_start-1, testh_start+1, "test.h");
- testEnclosingNode(testh_start+6-1, testh_start+6+1, "{\n #include EMPTY TEST_H\n }");
-
- testExpansion(empty_start, empty_start+5, "EMPTY");
+ testEnclosingNode(testh_start + 6, testh_start + 6, "TEST_H");
+ testEnclosingNode(testh_start - 1, testh_start + 1, "test.h");
+ testEnclosingNode(testh_start + 6 - 1, testh_start + 6 + 1, "{\n #include EMPTY TEST_H\n }");
+
+ testExpansion(empty_start, empty_start + 5, "EMPTY");
testExpansion(empty_start, empty_start, "EMPTY");
- testExpansion(empty_start+5, empty_start+5, "EMPTY");
- testExpansion(empty_start-1, empty_start, null);
- testExpansion(empty_start+5, empty_start+6, null);
- testExpansion(testh_start, testh_start+6, "TEST_H");
+ testExpansion(empty_start + 5, empty_start + 5, "EMPTY");
+ testExpansion(empty_start - 1, empty_start, null);
+ testExpansion(empty_start + 5, empty_start + 6, null);
+ testExpansion(testh_start, testh_start + 6, "TEST_H");
}
-
-
+
// #define shift_offsets
// int shift= shift_offsets;
//
@@ -229,37 +228,37 @@ public class ASTNodeSelectorTest extends AST2TestBase {
// #elif xx == 1
// #endif
public void testMacroInConditionalExpression() {
- int x1= fCode.indexOf("xx");
- int x2= fCode.indexOf("xx", x1+1);
- int x3= fCode.indexOf("xx", x2+1);
-
- testContainedName(x1, x1+2, "xx");
- testContainedName(x2-1, x2+2, "xx");
- testContainedName(x3, x3+3, "xx");
- testContainedName(x1, x1+1, null);
- testContainedName(x2+1, x2+2, null);
- testContainedName(x3+1, x3+1, null);
-
- testName(x1, x1+2, "xx");
- testName(x2, x2+2, "xx");
- testName(x3, x3+2, "xx");
- testName(x1+1, x1+2, null);
- testName(x2-1, x2+2, null);
- testName(x3, x3+3, null);
- testName(x3, x3+1, null);
-
- testEnclosingName(x1, x1+2, "xx");
- testEnclosingName(x2+2, x2+2, "xx");
+ int x1 = fCode.indexOf("xx");
+ int x2 = fCode.indexOf("xx", x1 + 1);
+ int x3 = fCode.indexOf("xx", x2 + 1);
+
+ testContainedName(x1, x1 + 2, "xx");
+ testContainedName(x2 - 1, x2 + 2, "xx");
+ testContainedName(x3, x3 + 3, "xx");
+ testContainedName(x1, x1 + 1, null);
+ testContainedName(x2 + 1, x2 + 2, null);
+ testContainedName(x3 + 1, x3 + 1, null);
+
+ testName(x1, x1 + 2, "xx");
+ testName(x2, x2 + 2, "xx");
+ testName(x3, x3 + 2, "xx");
+ testName(x1 + 1, x1 + 2, null);
+ testName(x2 - 1, x2 + 2, null);
+ testName(x3, x3 + 3, null);
+ testName(x3, x3 + 1, null);
+
+ testEnclosingName(x1, x1 + 2, "xx");
+ testEnclosingName(x2 + 2, x2 + 2, "xx");
testEnclosingName(x3, x3, "xx");
- testEnclosingName(x1-1, x1+2, null);
- testEnclosingName(x2+2, x2+3, null);
- testEnclosingName(x3-1, x3-1, null);
+ testEnclosingName(x1 - 1, x1 + 2, null);
+ testEnclosingName(x2 + 2, x2 + 3, null);
+ testEnclosingName(x3 - 1, x3 - 1, null);
- testExpansion(x1, x1+2, null);
- testExpansion(x2+2, x2+2, "xx");
+ testExpansion(x1, x1 + 2, null);
+ testExpansion(x2 + 2, x2 + 2, "xx");
testExpansion(x3, x3, "xx");
- testExpansion(x2+2, x2+3, null);
- testExpansion(x3-1, x3-1, null);
+ testExpansion(x2 + 2, x2 + 3, null);
+ testExpansion(x3 - 1, x3 - 1, null);
}
// #define shift_offsets
@@ -270,37 +269,37 @@ public class ASTNodeSelectorTest extends AST2TestBase {
// #elif defined(xx) == 1
// #endif
public void testMacroInDefinedExpression() {
- int x1= fCode.indexOf("xx");
- int x2= fCode.indexOf("xx", x1+1);
- int x3= fCode.indexOf("xx", x2+1);
-
- testContainedName(x1, x1+2, "xx");
- testContainedName(x2-1, x2+2, "xx");
- testContainedName(x3, x3+3, "xx");
- testContainedName(x1, x1+1, null);
- testContainedName(x2+1, x2+2, null);
- testContainedName(x3+1, x3+1, null);
-
- testName(x1, x1+2, "xx");
- testName(x2, x2+2, "xx");
- testName(x3, x3+2, "xx");
- testName(x1+1, x1+2, null);
- testName(x2-1, x2+2, null);
- testName(x3, x3+3, null);
- testName(x3, x3+1, null);
-
- testEnclosingName(x1, x1+2, "xx");
- testEnclosingName(x2+2, x2+2, "xx");
+ int x1 = fCode.indexOf("xx");
+ int x2 = fCode.indexOf("xx", x1 + 1);
+ int x3 = fCode.indexOf("xx", x2 + 1);
+
+ testContainedName(x1, x1 + 2, "xx");
+ testContainedName(x2 - 1, x2 + 2, "xx");
+ testContainedName(x3, x3 + 3, "xx");
+ testContainedName(x1, x1 + 1, null);
+ testContainedName(x2 + 1, x2 + 2, null);
+ testContainedName(x3 + 1, x3 + 1, null);
+
+ testName(x1, x1 + 2, "xx");
+ testName(x2, x2 + 2, "xx");
+ testName(x3, x3 + 2, "xx");
+ testName(x1 + 1, x1 + 2, null);
+ testName(x2 - 1, x2 + 2, null);
+ testName(x3, x3 + 3, null);
+ testName(x3, x3 + 1, null);
+
+ testEnclosingName(x1, x1 + 2, "xx");
+ testEnclosingName(x2 + 2, x2 + 2, "xx");
testEnclosingName(x3, x3, "xx");
- testEnclosingName(x1-1, x1+2, null);
- testEnclosingName(x2+2, x2+3, null);
- testEnclosingName(x3-1, x3-1, null);
+ testEnclosingName(x1 - 1, x1 + 2, null);
+ testEnclosingName(x2 + 2, x2 + 3, null);
+ testEnclosingName(x3 - 1, x3 - 1, null);
- testExpansion(x1, x1+2, null);
- testExpansion(x2+2, x2+2, null);
+ testExpansion(x1, x1 + 2, null);
+ testExpansion(x2 + 2, x2 + 2, null);
testExpansion(x3, x3, null);
- testExpansion(x2+2, x2+3, null);
- testExpansion(x3-1, x3-1, null);
+ testExpansion(x2 + 2, x2 + 3, null);
+ testExpansion(x3 - 1, x3 - 1, null);
}
// #define shift_offsets
@@ -313,40 +312,40 @@ public class ASTNodeSelectorTest extends AST2TestBase {
// #endif
// #undef xx
public void testMacroInConditional() {
- int x1= fCode.indexOf("xx");
- x1= fCode.indexOf("xx", x1+1);
- int x2= fCode.indexOf("xx", x1+1);
- int x3= fCode.indexOf("xx", x2+1);
-
- testContainedName(x1, x1+2, "xx");
- testContainedName(x2-1, x2+2, "xx");
- testContainedName(x3, x3+3, "xx");
- testContainedName(x1, x1+1, null);
- testContainedName(x2+1, x2+2, null);
- testContainedName(x3+1, x3+1, null);
-
- testName(x1, x1+2, "xx");
- testName(x2, x2+2, "xx");
- testName(x3, x3+2, "xx");
- testName(x1+1, x1+2, null);
- testName(x2-1, x2+2, null);
- testName(x3, x3+3, null);
- testName(x3, x3+1, null);
-
- testEnclosingName(x1, x1+2, "xx");
- testEnclosingName(x2+2, x2+2, "xx");
+ int x1 = fCode.indexOf("xx");
+ x1 = fCode.indexOf("xx", x1 + 1);
+ int x2 = fCode.indexOf("xx", x1 + 1);
+ int x3 = fCode.indexOf("xx", x2 + 1);
+
+ testContainedName(x1, x1 + 2, "xx");
+ testContainedName(x2 - 1, x2 + 2, "xx");
+ testContainedName(x3, x3 + 3, "xx");
+ testContainedName(x1, x1 + 1, null);
+ testContainedName(x2 + 1, x2 + 2, null);
+ testContainedName(x3 + 1, x3 + 1, null);
+
+ testName(x1, x1 + 2, "xx");
+ testName(x2, x2 + 2, "xx");
+ testName(x3, x3 + 2, "xx");
+ testName(x1 + 1, x1 + 2, null);
+ testName(x2 - 1, x2 + 2, null);
+ testName(x3, x3 + 3, null);
+ testName(x3, x3 + 1, null);
+
+ testEnclosingName(x1, x1 + 2, "xx");
+ testEnclosingName(x2 + 2, x2 + 2, "xx");
testEnclosingName(x3, x3, "xx");
- testEnclosingName(x1-1, x1+2, null);
- testEnclosingName(x2+2, x2+3, null);
- testEnclosingName(x3-1, x3-1, null);
+ testEnclosingName(x1 - 1, x1 + 2, null);
+ testEnclosingName(x2 + 2, x2 + 3, null);
+ testEnclosingName(x3 - 1, x3 - 1, null);
- testExpansion(x1, x1+2, null);
- testExpansion(x2+2, x2+2, null);
+ testExpansion(x1, x1 + 2, null);
+ testExpansion(x2 + 2, x2 + 2, null);
testExpansion(x3, x3, null);
- testExpansion(x2+2, x2+3, null);
- testExpansion(x3-1, x3-1, null);
+ testExpansion(x2 + 2, x2 + 3, null);
+ testExpansion(x3 - 1, x3 - 1, null);
}
-
+
// #define shift_offsets
// int shift= shift_offsets;
//
@@ -354,9 +353,9 @@ public class ASTNodeSelectorTest extends AST2TestBase {
// #define EXPLICIT IMPLICIT
// int a= EXPLICIT;
public void testUnreachableImplicitMacro() {
- int x1= fCode.indexOf("EXPLICIT;");
+ int x1 = fCode.indexOf("EXPLICIT;");
testContainedName(x1, fCode.length(), "EXPLICIT");
- testName(x1, x1+8, "EXPLICIT");
+ testName(x1, x1 + 8, "EXPLICIT");
testEnclosingName(x1, x1, "EXPLICIT");
}
@@ -367,34 +366,34 @@ public class ASTNodeSelectorTest extends AST2TestBase {
// #define EXPLICIT(x) x
// int a= EXPLICIT(NESTED);
public void testReachableNestedMacro() {
- int x1= fCode.indexOf("NESTED)");
+ int x1 = fCode.indexOf("NESTED)");
testContainedName(x1, fCode.length(), "NESTED");
- testName(x1, x1+6, "NESTED");
+ testName(x1, x1 + 6, "NESTED");
testEnclosingName(x1, x1, "NESTED");
}
-
+
// #define id(x,y) x y
// id(int a, =1);
// id(int b=, a);
public void testImageLocations() {
- int a1= fCode.indexOf("a");
- int a2= fCode.indexOf("a", a1+1);
- int b1= fCode.indexOf("b");
+ int a1 = fCode.indexOf("a");
+ int a2 = fCode.indexOf("a", a1 + 1);
+ int b1 = fCode.indexOf("b");
- testName(a1, a1+1, "a");
- testContainedName(a1-1, a2+2, "a");
+ testName(a1, a1 + 1, "a");
+ testContainedName(a1 - 1, a2 + 2, "a");
testEnclosingName(a1, a1, "a");
- testEnclosingName(a1+1, a1+1, "a");
+ testEnclosingName(a1 + 1, a1 + 1, "a");
- testName(a2, a2+1, "a");
- testContainedName(a2-1, a2+2, "a");
+ testName(a2, a2 + 1, "a");
+ testContainedName(a2 - 1, a2 + 2, "a");
testEnclosingName(a2, a2, "a");
- testEnclosingName(a2+1, a2+1, "a");
+ testEnclosingName(a2 + 1, a2 + 1, "a");
- testEnclosingNode(a1-1, a1+1, "id(int a, =1)");
- testContainedNode(a1-8, a1+1, "id");
+ testEnclosingNode(a1 - 1, a1 + 1, "id(int a, =1)");
+ testContainedNode(a1 - 8, a1 + 1, "id");
}
-
+
// namespace ns {int a;}
// int x= ns::a;
// #define M int b;
@@ -405,36 +404,39 @@ public class ASTNodeSelectorTest extends AST2TestBase {
// #define P()
// P()O
public void testOrdering() {
- int x1= fCode.indexOf("ns::a");
- int x2= x1 + "ns::a".length();
+ int x1 = fCode.indexOf("ns::a");
+ int x2 = x1 + "ns::a".length();
testContainedName(x1, x2, "ns");
- testEnclosingName(x2-1, x2-1, "a");
+ testEnclosingName(x2 - 1, x2 - 1, "a");
testEnclosingName(x2, x2, "a");
-
- x1= fCode.indexOf("M"); x1= fCode.indexOf("M", x1+1);
- testNode(x1, x1+1, "M");
+
+ x1 = fCode.indexOf("M");
+ x1 = fCode.indexOf("M", x1 + 1);
+ testNode(x1, x1 + 1, "M");
testEnclosingNode(x1, x1, "M");
- testEnclosingNode(x1+1, x1+1, "M");
- testContainedNode(x1-1, x1+2, "M");
+ testEnclosingNode(x1 + 1, x1 + 1, "M");
+ testContainedNode(x1 - 1, x1 + 2, "M");
- x1= fCode.indexOf("N"); x1= fCode.indexOf("N", x1+1);
- testNode(x1, x1+1, "N");
+ x1 = fCode.indexOf("N");
+ x1 = fCode.indexOf("N", x1 + 1);
+ testNode(x1, x1 + 1, "N");
testEnclosingNode(x1, x1, "N");
- testEnclosingNode(x1+1, x1+1, "N");
- testContainedNode(x1-1, x1+2, "N");
-
- x1= fCode.indexOf("O"); x1= fCode.indexOf("O", x1+1);
- testNode(x1, x1+1, "O");
+ testEnclosingNode(x1 + 1, x1 + 1, "N");
+ testContainedNode(x1 - 1, x1 + 2, "N");
+
+ x1 = fCode.indexOf("O");
+ x1 = fCode.indexOf("O", x1 + 1);
+ testNode(x1, x1 + 1, "O");
testEnclosingNode(x1, x1, "O");
- testEnclosingNode(x1+1, x1+1, "O");
- testContainedNode(x1-1, x1+2, "O");
+ testEnclosingNode(x1 + 1, x1 + 1, "O");
+ testContainedNode(x1 - 1, x1 + 2, "O");
}
-
+
// #define MACRO void m
// MACRO();
public void testEnclosingAMacro() {
- int x1= fCode.indexOf("MACRO(");
- int x2= x1 + "MACRO(".length();
+ int x1 = fCode.indexOf("MACRO(");
+ int x2 = x1 + "MACRO(".length();
testContainedName(x1, x2, "MACRO");
testEnclosingNode(x1, x2, "MACRO();");
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AccessControlTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AccessControlTests.java
index d81ac673d98..3d99d0cfc6c 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AccessControlTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AccessControlTests.java
@@ -25,34 +25,34 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.AccessContext;
import org.eclipse.cdt.internal.core.parser.ParserException;
public class AccessControlTests extends AST2TestBase {
-
+
protected class AccessAssertionHelper extends AST2AssertionHelper {
AccessAssertionHelper(String contents) throws ParserException {
super(contents, true);
}
-
+
void assertAccessible(String section, int len) {
IASTName name = findName(section, len);
IBinding binding = name.resolveBinding();
- assertNotNull(binding);
+ assertNotNull(binding);
assertTrue(AccessContext.isAccessible(binding, name));
}
-
+
void assertNotAccessible(String section, int len) {
IASTName name = findName(section, len);
IBinding binding = name.resolveBinding();
- assertNotNull(binding);
+ assertNotNull(binding);
assertFalse(AccessContext.isAccessible(binding, name));
}
}
-
+
public AccessControlTests() {
}
-
+
public AccessControlTests(String name) {
super(name);
}
-
+
public static TestSuite suite() {
return suite(AccessControlTests.class);
}
@@ -128,7 +128,7 @@ public class AccessControlTests extends AST2TestBase {
AccessAssertionHelper ah = getAssertionHelper();
ah.assertNotAccessible("a = 0", 1);
}
-
+
// class A0 {
// public:
// enum Ex {e1};
@@ -145,9 +145,9 @@ public class AccessControlTests extends AST2TestBase {
AccessAssertionHelper ah = getAssertionHelper();
ah.assertAccessible("Ex a;", 2);
}
-
+
// // Example from C++-specification 11.2-3
- // class B {
+ // class B {
// public:
// int mi;
// static int si;
@@ -159,7 +159,7 @@ public class AccessControlTests extends AST2TestBase {
//
// void DD::f() {
// mi=3; // private
- // si=3; // private
+ // si=3; // private
// B b;
// b.mi=4;
// b.si=4;
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CharArrayMapTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CharArrayMapTest.java
index 25ab9a7017f..3617853de35 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CharArrayMapTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CharArrayMapTest.java
@@ -34,11 +34,13 @@ public class CharArrayMapTest extends TestCase {
final char[] chars;
final int start;
final int length;
+
public Slice(char[] chars, int start, int length) {
this.chars = chars;
this.length = length;
this.start = start;
}
+
@Override
public String toString() {
return new String(chars, start, length);
@@ -49,7 +51,7 @@ public class CharArrayMapTest extends TestCase {
final int iterations = 10000;
// insert tons of keys
char[][] keys = new char[iterations][];
- for(int i = 0; i < keys.length; i++) {
+ for (int i = 0; i < keys.length; i++) {
keys[i] = String.valueOf(i).toCharArray();
}
@@ -67,11 +69,11 @@ public class CharArrayMapTest extends TestCase {
private static long timeMap(char[][] keys) {
long start = System.currentTimeMillis();
CharArrayMap<Integer> map = new CharArrayMap<Integer>(keys.length);
- for(int i = 0; i < keys.length; i++) {
+ for (int i = 0; i < keys.length; i++) {
map.put(keys[i], i);
}
assertEquals(keys.length, map.size());
- for(int i = 0; i < keys.length; i++) {
+ for (int i = 0; i < keys.length; i++) {
assertEquals(Integer.valueOf(i), map.get(keys[i]));
}
return System.currentTimeMillis() - start;
@@ -80,11 +82,11 @@ public class CharArrayMapTest extends TestCase {
private static long timeOldMap(char[][] keys) {
long start = System.currentTimeMillis();
CharArrayObjectMap oldMap = new CharArrayObjectMap(keys.length);
- for(int i = 0; i < keys.length; i++) {
+ for (int i = 0; i < keys.length; i++) {
oldMap.put(keys[i], Integer.valueOf(i));
}
assertEquals(keys.length, oldMap.size());
- for(int i = 0; i < keys.length; i++) {
+ for (int i = 0; i < keys.length; i++) {
assertEquals(Integer.valueOf(i), oldMap.get(keys[i]));
}
return System.currentTimeMillis() - start;
@@ -129,17 +131,17 @@ public class CharArrayMapTest extends TestCase {
values.add(3);
values.add(4);
- for(int i : map.values()) {
+ for (int i : map.values()) {
assertTrue(values.remove(i));
}
// remove a mapping
assertEquals(Integer.valueOf(1), map.remove(key1));
assertEquals(3, map.size());
- assertNull(map.get(key1));
- assertFalse(map.containsKey(key1));
- assertFalse(map.containsValue(1));
- assertNull(map.remove(key1)); // its already removed
+ assertNull(map.get(key1));
+ assertFalse(map.containsKey(key1));
+ assertFalse(map.containsValue(1));
+ assertNull(map.remove(key1)); // its already removed
map.clear();
assertTrue(map.isEmpty());
@@ -169,31 +171,18 @@ public class CharArrayMapTest extends TestCase {
public void testBasicUsage2() {
char[] chars = "pantera, megadeth, soulfly, metallica, in flames, lamb of god, carcass".toCharArray();
- Slice[] slices = {
- new Slice(chars, 0, 7),
- new Slice(chars, 9, 8),
- new Slice(chars, 19, 7),
- new Slice(chars, 28, 9),
- new Slice(chars, 39, 9),
- new Slice(chars, 50, 11),
- new Slice(chars, 63, 7)
- };
-
- char[][] keys = {
- "pantera".toCharArray(),
- "megadeth".toCharArray(),
- "soulfly".toCharArray(),
- "metallica".toCharArray(),
- "in flames".toCharArray(),
- "lamb of god".toCharArray(),
- "carcass".toCharArray()
- };
+ Slice[] slices = { new Slice(chars, 0, 7), new Slice(chars, 9, 8), new Slice(chars, 19, 7),
+ new Slice(chars, 28, 9), new Slice(chars, 39, 9), new Slice(chars, 50, 11), new Slice(chars, 63, 7) };
+
+ char[][] keys = { "pantera".toCharArray(), "megadeth".toCharArray(), "soulfly".toCharArray(),
+ "metallica".toCharArray(), "in flames".toCharArray(), "lamb of god".toCharArray(),
+ "carcass".toCharArray() };
CharArrayMap<Integer> map = new CharArrayMap<Integer>();
assertTrue(map.isEmpty());
assertEquals(0, map.size());
- for(int i = 0; i < slices.length; i++) {
+ for (int i = 0; i < slices.length; i++) {
Slice slice = slices[i];
map.put(slice.chars, slice.start, slice.length, i);
}
@@ -202,7 +191,7 @@ public class CharArrayMapTest extends TestCase {
assertEquals(7, map.size());
// should still work with equivalent keys
- for(int i = 0; i < keys.length; i++) {
+ for (int i = 0; i < keys.length; i++) {
Slice slice = slices[i];
assertEquals(Integer.valueOf(i), map.get(slice.chars, slice.start, slice.length));
assertEquals(Integer.valueOf(i), map.get(keys[i]));
@@ -212,11 +201,11 @@ public class CharArrayMapTest extends TestCase {
}
Set<Integer> values = new HashSet<Integer>();
- for(int i = 0; i < keys.length; i++) {
+ for (int i = 0; i < keys.length; i++) {
values.add(i);
}
- for(int i : map.values()) {
+ for (int i : map.values()) {
assertTrue(values.remove(i));
}
@@ -227,7 +216,7 @@ public class CharArrayMapTest extends TestCase {
assertEquals(5, map.size());
// remaining keys should still be there
- for(int i = 0; i < 5; i++) {
+ for (int i = 0; i < 5; i++) {
Slice slice = slices[i];
assertEquals(Integer.valueOf(i), map.get(slice.chars, slice.start, slice.length));
assertEquals(Integer.valueOf(i), map.get(keys[i]));
@@ -241,48 +230,41 @@ public class CharArrayMapTest extends TestCase {
assertEquals(0, map.size());
}
-
public void testOrderedMap() {
char[] chars = "alpha beta aaa cappa almost".toCharArray();
- Slice[] slices = {
- new Slice(chars, 0, 5),
- new Slice(chars, 6, 4),
- new Slice(chars, 11, 3),
- new Slice(chars, 15, 5),
- new Slice(chars, 21, 6)
- };
- int[] order = {3, 4, 1, 5, 2};
-
+ Slice[] slices = { new Slice(chars, 0, 5), new Slice(chars, 6, 4), new Slice(chars, 11, 3),
+ new Slice(chars, 15, 5), new Slice(chars, 21, 6) };
+ int[] order = { 3, 4, 1, 5, 2 };
+
CharArrayMap<Integer> map = CharArrayMap.createOrderedMap();
-
- for(int i = 0; i < slices.length; i++) {
+
+ for (int i = 0; i < slices.length; i++) {
Slice slice = slices[i];
map.put(slice.chars, slice.start, slice.length, order[i]);
}
-
+
List<String> properOrder = Arrays.asList("aaa", "almost", "alpha", "beta", "cappa");
-
+
Collection<char[]> keys = map.keys();
assertEquals(5, keys.size());
{
int i = 0;
- for(char[] key : keys) {
+ for (char[] key : keys) {
assertEquals(properOrder.get(i), String.valueOf(key));
i++;
}
}
-
+
Collection<Integer> values = map.values();
assertEquals(5, values.size());
{
int i = 1;
- for(int value : values) {
+ for (int value : values) {
assertEquals(i++, value);
}
}
}
-
-
+
public void testProperFail() {
char[] hello = "hello".toCharArray();
CharArrayMap<Integer> map = new CharArrayMap<Integer>();
@@ -291,85 +273,102 @@ public class CharArrayMapTest extends TestCase {
try {
map.put(null, value);
fail();
- } catch(NullPointerException expectedException) {}
+ } catch (NullPointerException expectedException) {
+ }
try {
map.put(hello, -1, 5, value);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.put(hello, 0, -1, value);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.put(hello, 0, 100, value);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.get(null);
fail();
- } catch(NullPointerException expectedException) {}
+ } catch (NullPointerException expectedException) {
+ }
try {
map.get(hello, -1, 5);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.get(hello, 0, -1);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.get(hello, 0, 100);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.remove(null);
fail();
- } catch(NullPointerException expectedException) {}
+ } catch (NullPointerException expectedException) {
+ }
try {
map.remove(hello, -1, 5);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.remove(hello, 0, -1);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.remove(hello, 0, 100);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.containsKey(null);
fail();
- } catch(NullPointerException expectedException) {}
+ } catch (NullPointerException expectedException) {
+ }
try {
map.containsKey(hello, -1, 5);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.containsKey(hello, 0, -1);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
map.containsKey(hello, 0, 100);
fail();
- } catch(IndexOutOfBoundsException expectedException) {}
+ } catch (IndexOutOfBoundsException expectedException) {
+ }
try {
new CharArrayMap<Integer>(-1);
- } catch(IllegalArgumentException expectedException) {}
+ } catch (IllegalArgumentException expectedException) {
+ }
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java
index e7f4f249bf5..3e3e57d52f8 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Emanuel Graf & Guido Zgraggen - initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Emanuel Graf & Guido Zgraggen - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2;
@@ -24,10 +24,10 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
/**
* @author Guido Zgraggen
- *
+ *
*/
public class CommentTests extends AST2TestBase {
-
+
public static TestSuite suite() {
return suite(CommentTests.class);
}
@@ -38,7 +38,7 @@ public class CommentTests extends AST2TestBase {
assertEquals(9, comments.length);
}
-
+
public void testCommentsInHeaderFile() throws ParserException {
IASTTranslationUnit tu = parse(getHSource(), ParserLanguage.CPP, false, true);
IASTComment[] comments = tu.getComments();
@@ -53,18 +53,18 @@ public class CommentTests extends AST2TestBase {
assertEquals("//value field", new String(comments[7].getComment()));
assertEquals("//Endcomment h", new String(comments[8].getComment()));
}
-
+
public void testCountCommentsInCPPFile() throws ParserException {
IASTTranslationUnit tu = parse(getCppSource(), ParserLanguage.CPP, false, true);
IASTComment[] comments = tu.getComments();
-
+
assertEquals(10, comments.length);
}
public void testCommentsInCPPFile() throws ParserException {
IASTTranslationUnit tu = parse(getCppSource(), ParserLanguage.CPP, false, true);
IASTComment[] comments = tu.getComments();
-
+
assertEquals("// Comment in cpp", new String(comments[0].getComment()));
assertEquals("/*The magic 5 */", new String(comments[1].getComment()));
assertEquals("// Another comment", new String(comments[2].getComment()));
@@ -76,18 +76,18 @@ public class CommentTests extends AST2TestBase {
assertEquals("//Last comment in cpp", new String(comments[8].getComment()));
assertEquals("//An integer", new String(comments[9].getComment()));
}
-
+
public void testCountCommentsInCFile() throws ParserException {
IASTTranslationUnit tu = parse(getCSource(), ParserLanguage.C, false, true);
IASTComment[] comments = tu.getComments();
-
+
assertEquals(4, comments.length);
}
-
+
public void testCommentsInCFile() throws ParserException {
IASTTranslationUnit tu = parse(getCSource(), ParserLanguage.C, false, true);
IASTComment[] comments = tu.getComments();
-
+
assertEquals("//A little input/output programm", new String(comments[0].getComment()));
assertEquals("//Read the number", new String(comments[1].getComment()));
assertEquals("/*\n * That is the answer ;-)\n */", new String(comments[2].getComment()));
@@ -119,8 +119,8 @@ public class CommentTests extends AST2TestBase {
buffer.append("};\n");
buffer.append("#endif\n");
return buffer.toString();
- }
-
+ }
+
private String getCppSource() {
StringBuilder buffer = new StringBuilder();
buffer.append("void CppClass()\n");
@@ -169,7 +169,7 @@ public class CommentTests extends AST2TestBase {
buffer.append("}\n");
return buffer.toString();
}
-
+
private String getCSource() {
StringBuilder buffer = new StringBuilder();
buffer.append("//A little input/output programm\n");
@@ -196,59 +196,59 @@ public class CommentTests extends AST2TestBase {
buffer.append(" return 0; //The end\n");
buffer.append("}\n");
return buffer.toString();
- }
-
+ }
+
// #ifdef xxx
// // comment1
- // #else
+ // #else
// // comment2
// #endif
public void testCommentsInInactiveCode_bug183930() throws Exception {
- CharSequence code= getContents(1)[0];
+ CharSequence code = getContents(1)[0];
IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, true);
IASTComment[] comments = tu.getComments();
-
+
assertEquals(2, comments.length);
assertEquals("// comment1", new String(comments[0].getComment()));
assertEquals("// comment2", new String(comments[1].getComment()));
}
-
+
// //comment
public void testCommentLocation_bug186337() throws Exception {
- CharSequence code= getContents(1)[0];
+ CharSequence code = getContents(1)[0];
IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, true);
IASTComment[] comments = tu.getComments();
-
+
assertEquals(1, comments.length);
assertNotNull(comments[0].getFileLocation());
assertNotNull(comments[0].getNodeLocations());
tu = parse(code.toString(), ParserLanguage.C, false, true);
comments = tu.getComments();
-
+
assertEquals(1, comments.length);
assertNotNull(comments[0].getFileLocation());
assertNotNull(comments[0].getNodeLocations());
}
-
- // // TODO: shows up in task list
+
+ // // TODO: shows up in task list
// #include "somefile.h" // TODO: ignored
- //
+ //
// #ifdef WHATEVA // TODO: ignored
// #endif // TODO: ignored
// // TODO: shows up in task list
public void testCommentInDirectives_bug192546() throws Exception {
- CharSequence code= getContents(1)[0];
+ CharSequence code = getContents(1)[0];
IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, false);
IASTComment[] comments = tu.getComments();
-
+
assertEquals(5, comments.length);
assertNotNull(comments[0].getFileLocation());
assertNotNull(comments[0].getNodeLocations());
for (IASTComment comment : comments) {
- IASTFileLocation loc= comment.getFileLocation();
- int idx= loc.getNodeOffset() + comment.getRawSignature().indexOf("TODO");
- assertEquals("TODO", code.subSequence(idx, idx + 4));
+ IASTFileLocation loc = comment.getFileLocation();
+ int idx = loc.getNodeOffset() + comment.getRawSignature().indexOf("TODO");
+ assertEquals("TODO", code.subSequence(idx, idx + 4));
}
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java
index 2102704166c..afb48b87188 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java
@@ -91,129 +91,127 @@ import junit.framework.TestSuite;
* @author jcamelon
*/
public class CompleteParser2Tests extends BaseTestCase {
- private static final NullLogService NULL_LOG = new NullLogService();
+ private static final NullLogService NULL_LOG = new NullLogService();
- public CompleteParser2Tests() {
+ public CompleteParser2Tests() {
}
+
public CompleteParser2Tests(String name) {
super(name);
}
- public static TestSuite suite() {
- return suite(CompleteParser2Tests.class);
- }
+ public static TestSuite suite() {
+ return suite(CompleteParser2Tests.class);
+ }
static private class NameCollector extends ASTVisitor {
- public List nameList = new ArrayList();
-
- public NameCollector() {
- this(false); // Don't visit implicit names by default
- }
-
- public NameCollector(boolean shouldVisitImplicitNames) {
- this.shouldVisitNames = true;
- this.shouldVisitImplicitNames = shouldVisitImplicitNames;
- }
-
- @Override
- public int visit(IASTName name){
- nameList.add(name);
- return PROCESS_CONTINUE;
- }
-
- public IASTName getName(int idx){
- if (idx < 0 || idx >= nameList.size())
- return null;
- return (IASTName) nameList.get(idx);
- }
-
- public int size() {
- return nameList.size();
- }
- }
-
- protected void assertInstances(NameCollector nameCollector, IBinding binding, int num) throws Exception {
- int count = 0;
- for (int i = 0; i < nameCollector.size(); i++) {
- if (nameCollector.getName(i).resolveBinding() == binding)
- count++;
- }
-
- assertEquals(num, count);
- }
-
- protected IASTTranslationUnit parse(String code, boolean expectedToPass,
- ParserLanguage lang) throws Exception {
- return parse(code, expectedToPass, lang, false);
- }
-
- protected IASTTranslationUnit parse(String code, boolean expectedToPass) throws Exception {
- return parse(code, expectedToPass, ParserLanguage.CPP);
- }
-
- /**
- * @param code
- */
- protected IASTTranslationUnit parse(String code) throws Exception {
- return parse(code, true, ParserLanguage.CPP);
- }
-
- protected IASTTranslationUnit parse(String code, boolean expectedToPass,
- ParserLanguage lang, boolean gcc) throws Exception {
- FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
- ScannerInfo scannerInfo = new ScannerInfo();
- ISourceCodeParser parser2 = null;
- IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
- if (lang == ParserLanguage.CPP) {
- ICPPParserExtensionConfiguration config = null;
- if (gcc) {
- config = new GPPParserExtensionConfiguration();
- } else {
- config = new ANSICPPParserExtensionConfiguration();
- }
- parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE,
- NULL_LOG, config);
- } else {
- ICParserExtensionConfiguration config = null;
- if (gcc) {
- config = new GCCParserExtensionConfiguration();
- } else {
- config = new ANSICParserExtensionConfiguration();
- }
-
- parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE,
- NULL_LOG, config);
- }
- IASTTranslationUnit tu = parser2.parse();
- if (parser2.encounteredError() && expectedToPass)
- throw new ParserException("FAILURE");
- if (expectedToPass) {
- if (lang == ParserLanguage.C) {
- IASTProblem[] problems = CVisitor.getProblems(tu);
- assertEquals(problems.length, 0);
- } else if (lang == ParserLanguage.CPP) {
- IASTProblem[] problems = CPPVisitor.getProblems(tu);
- assertEquals(problems.length, 0);
- }
- }
- return tu;
- }
-
- public void testEmptyCompilationUnit() throws Exception {
- parse("// no real code ");
- }
-
- public void testSimpleNamespace() throws Exception {
- IASTTranslationUnit tu = parse("namespace A { }");
- NameCollector col = new NameCollector();
+ public List nameList = new ArrayList();
+
+ public NameCollector() {
+ this(false); // Don't visit implicit names by default
+ }
+
+ public NameCollector(boolean shouldVisitImplicitNames) {
+ this.shouldVisitNames = true;
+ this.shouldVisitImplicitNames = shouldVisitImplicitNames;
+ }
+
+ @Override
+ public int visit(IASTName name) {
+ nameList.add(name);
+ return PROCESS_CONTINUE;
+ }
+
+ public IASTName getName(int idx) {
+ if (idx < 0 || idx >= nameList.size())
+ return null;
+ return (IASTName) nameList.get(idx);
+ }
+
+ public int size() {
+ return nameList.size();
+ }
+ }
+
+ protected void assertInstances(NameCollector nameCollector, IBinding binding, int num) throws Exception {
+ int count = 0;
+ for (int i = 0; i < nameCollector.size(); i++) {
+ if (nameCollector.getName(i).resolveBinding() == binding)
+ count++;
+ }
+
+ assertEquals(num, count);
+ }
+
+ protected IASTTranslationUnit parse(String code, boolean expectedToPass, ParserLanguage lang) throws Exception {
+ return parse(code, expectedToPass, lang, false);
+ }
+
+ protected IASTTranslationUnit parse(String code, boolean expectedToPass) throws Exception {
+ return parse(code, expectedToPass, ParserLanguage.CPP);
+ }
+
+ /**
+ * @param code
+ */
+ protected IASTTranslationUnit parse(String code) throws Exception {
+ return parse(code, true, ParserLanguage.CPP);
+ }
+
+ protected IASTTranslationUnit parse(String code, boolean expectedToPass, ParserLanguage lang, boolean gcc)
+ throws Exception {
+ FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
+ ScannerInfo scannerInfo = new ScannerInfo();
+ ISourceCodeParser parser2 = null;
+ IScanner scanner = AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
+ if (lang == ParserLanguage.CPP) {
+ ICPPParserExtensionConfiguration config = null;
+ if (gcc) {
+ config = new GPPParserExtensionConfiguration();
+ } else {
+ config = new ANSICPPParserExtensionConfiguration();
+ }
+ parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
+ } else {
+ ICParserExtensionConfiguration config = null;
+ if (gcc) {
+ config = new GCCParserExtensionConfiguration();
+ } else {
+ config = new ANSICParserExtensionConfiguration();
+ }
+
+ parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
+ }
+ IASTTranslationUnit tu = parser2.parse();
+ if (parser2.encounteredError() && expectedToPass)
+ throw new ParserException("FAILURE");
+ if (expectedToPass) {
+ if (lang == ParserLanguage.C) {
+ IASTProblem[] problems = CVisitor.getProblems(tu);
+ assertEquals(problems.length, 0);
+ } else if (lang == ParserLanguage.CPP) {
+ IASTProblem[] problems = CPPVisitor.getProblems(tu);
+ assertEquals(problems.length, 0);
+ }
+ }
+ return tu;
+ }
+
+ public void testEmptyCompilationUnit() throws Exception {
+ parse("// no real code ");
+ }
+
+ public void testSimpleNamespace() throws Exception {
+ IASTTranslationUnit tu = parse("namespace A { }");
+ NameCollector col = new NameCollector();
tu.accept(col);
assertEquals(col.size(), 1);
assertTrue(col.getName(0).resolveBinding() instanceof ICPPNamespace);
- }
+ }
public void testMultipleNamespaceDefinitions() throws Exception {
- IASTTranslationUnit tu = parse("namespace A { } namespace A { }");
+ IASTTranslationUnit tu = parse("namespace A { } namespace A { }");
NameCollector col = new NameCollector();
tu.accept(col);
@@ -222,8 +220,8 @@ public class CompleteParser2Tests extends BaseTestCase {
assertInstances(col, A, 2);
}
- public void testNestedNamespaceDefinitions() throws Exception {
- IASTTranslationUnit tu = parse("namespace A { namespace B { } }");
+ public void testNestedNamespaceDefinitions() throws Exception {
+ IASTTranslationUnit tu = parse("namespace A { namespace B { } }");
NameCollector col = new NameCollector();
tu.accept(col);
@@ -232,20 +230,20 @@ public class CompleteParser2Tests extends BaseTestCase {
ICPPNamespace B = (ICPPNamespace) col.getName(1).resolveBinding();
assertSame(A.getNamespaceScope(), B.getNamespaceScope().getParent());
- }
+ }
- public void testEmptyClassDeclaration() throws Exception {
- IASTTranslationUnit tu = parse("class A { };");
- NameCollector col = new NameCollector();
+ public void testEmptyClassDeclaration() throws Exception {
+ IASTTranslationUnit tu = parse("class A { };");
+ NameCollector col = new NameCollector();
tu.accept(col);
assertEquals(col.size(), 1);
assertTrue(col.getName(0).resolveBinding() instanceof ICPPClassType);
- }
+ }
- public void testSimpleSubclass() throws Exception {
- IASTTranslationUnit tu = parse("class A { }; class B : public A { };");
- NameCollector col = new NameCollector();
+ public void testSimpleSubclass() throws Exception {
+ IASTTranslationUnit tu = parse("class A { }; class B : public A { };");
+ NameCollector col = new NameCollector();
tu.accept(col);
assertEquals(col.size(), 3);
@@ -259,11 +257,11 @@ public class CompleteParser2Tests extends BaseTestCase {
assertSame(base.getBaseClass(), A);
assertEquals(base.getVisibility(), ICPPBase.v_public);
assertFalse(base.isVirtual());
- }
+ }
- public void testNestedSubclass() throws Exception {
- IASTTranslationUnit tu = parse("namespace N { class A { }; } class B : protected virtual N::A { };");
- NameCollector col = new NameCollector();
+ public void testNestedSubclass() throws Exception {
+ IASTTranslationUnit tu = parse("namespace N { class A { }; } class B : protected virtual N::A { };");
+ NameCollector col = new NameCollector();
tu.accept(col);
assertEquals(col.size(), 6);
@@ -281,319 +279,316 @@ public class CompleteParser2Tests extends BaseTestCase {
assertSame(base.getBaseClass(), A);
assertTrue(base.isVirtual());
assertEquals(base.getVisibility(), ICPPBase.v_protected);
- }
+ }
- public void testSimpleVariable() throws Exception {
- IASTTranslationUnit tu = parse("int x;");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ public void testSimpleVariable() throws Exception {
+ IASTTranslationUnit tu = parse("int x;");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 1);
- IVariable x = (IVariable) col.getName(0).resolveBinding();
+ assertEquals(col.size(), 1);
+ IVariable x = (IVariable) col.getName(0).resolveBinding();
- assertTrue(x.getType() instanceof IBasicType);
- IBasicType t = (IBasicType) x.getType();
- assertEquals(t.getType(), IBasicType.t_int);
- }
+ assertTrue(x.getType() instanceof IBasicType);
+ IBasicType t = (IBasicType) x.getType();
+ assertEquals(t.getType(), IBasicType.t_int);
+ }
public void testSimpleClassReferenceVariable() throws Exception {
- IASTTranslationUnit tu = parse("class A { }; A x;");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ IASTTranslationUnit tu = parse("class A { }; A x;");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 3);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- IVariable x = (IVariable) col.getName(2).resolveBinding();
+ assertEquals(col.size(), 3);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ IVariable x = (IVariable) col.getName(2).resolveBinding();
- assertInstances(col, A, 2);
- assertSame(x.getType(), A);
+ assertInstances(col, A, 2);
+ assertSame(x.getType(), A);
}
public void testNestedClassReferenceVariable() throws Exception {
- IASTTranslationUnit tu = parse("namespace N { class A { }; } N::A x;");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ IASTTranslationUnit tu = parse("namespace N { class A { }; } N::A x;");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 6);
- ICPPNamespace N = (ICPPNamespace) col.getName(0).resolveBinding();
- ICPPClassType A = (ICPPClassType) col.getName(1).resolveBinding();
- IVariable x = (IVariable) col.getName(5).resolveBinding();
+ assertEquals(col.size(), 6);
+ ICPPNamespace N = (ICPPNamespace) col.getName(0).resolveBinding();
+ ICPPClassType A = (ICPPClassType) col.getName(1).resolveBinding();
+ IVariable x = (IVariable) col.getName(5).resolveBinding();
- assertInstances(col, N, 2);
- assertInstances(col, A, 3);
- assertSame(x.getType(), A);
- assertSame(A.getScope(), N.getNamespaceScope());
+ assertInstances(col, N, 2);
+ assertInstances(col, A, 3);
+ assertSame(x.getType(), A);
+ assertSame(A.getScope(), N.getNamespaceScope());
}
public void testMultipleDeclaratorsVariable() throws Exception {
- IASTTranslationUnit tu = parse("class A { }; A x, y, z;");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ IASTTranslationUnit tu = parse("class A { }; A x, y, z;");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 5);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- IVariable x = (IVariable) col.getName(2).resolveBinding();
- IVariable y = (IVariable) col.getName(3).resolveBinding();
- IVariable z = (IVariable) col.getName(4).resolveBinding();
+ assertEquals(col.size(), 5);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ IVariable x = (IVariable) col.getName(2).resolveBinding();
+ IVariable y = (IVariable) col.getName(3).resolveBinding();
+ IVariable z = (IVariable) col.getName(4).resolveBinding();
- assertInstances(col, A, 2);
- assertSame(A, x.getType());
- assertSame(x.getType(), y.getType());
- assertSame(y.getType(), z.getType());
+ assertInstances(col, A, 2);
+ assertSame(A, x.getType());
+ assertSame(x.getType(), y.getType());
+ assertSame(y.getType(), z.getType());
}
public void testSimpleField() throws Exception {
- IASTTranslationUnit tu = parse("class A { double x; };");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ IASTTranslationUnit tu = parse("class A { double x; };");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 2);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPField x = (ICPPField) col.getName(1).resolveBinding();
+ assertEquals(col.size(), 2);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPField x = (ICPPField) col.getName(1).resolveBinding();
- assertSame(x.getScope(), A.getCompositeScope());
- IField[] fields = A.getFields();
- assertEquals(fields.length, 1);
- assertSame(fields[0], x);
- }
+ assertSame(x.getScope(), A.getCompositeScope());
+ IField[] fields = A.getFields();
+ assertEquals(fields.length, 1);
+ assertSame(fields[0], x);
+ }
public void testUsingClauses() throws Exception {
- IASTTranslationUnit tu = parse("namespace A { namespace B { int x; class C { static int y = 5; }; } } \n " +
- "using namespace A::B;\n " +
- "using A::B::x;" +
- "using A::B::C;" +
- "using A::B::C::y;");
- NameCollector col = new NameCollector();
- tu.accept(col);
-
- assertEquals(col.size(), 21);
- ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
- ICPPNamespace B = (ICPPNamespace) col.getName(1).resolveBinding();
- IVariable x = (IVariable) col.getName(2).resolveBinding();
- ICPPClassType C = (ICPPClassType) col.getName(3).resolveBinding();
- ICPPField y = (ICPPField) col.getName(4).resolveBinding();
-
- ICPPUsingDeclaration using_x = (ICPPUsingDeclaration) col.getName(11).resolveBinding();
- ICPPUsingDeclaration using_C = (ICPPUsingDeclaration) col.getName(15).resolveBinding();
- ICPPUsingDeclaration using_y = (ICPPUsingDeclaration) col.getName(20).resolveBinding();
-
- assertInstances(col, A, 5);
- assertInstances(col, B, 6);
- assertInstances(col, x, 1);
- assertInstances(col, C, 2);
- assertInstances(col, y, 1);
-
- IBinding[] ds = using_x.getDelegates();
- assertSame(ds[0], x);
- assertSame(using_C.getDelegates()[0], C);
- assertSame(using_y.getDelegates()[0], y);
+ IASTTranslationUnit tu = parse("namespace A { namespace B { int x; class C { static int y = 5; }; } } \n "
+ + "using namespace A::B;\n " + "using A::B::x;" + "using A::B::C;" + "using A::B::C::y;");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
+
+ assertEquals(col.size(), 21);
+ ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
+ ICPPNamespace B = (ICPPNamespace) col.getName(1).resolveBinding();
+ IVariable x = (IVariable) col.getName(2).resolveBinding();
+ ICPPClassType C = (ICPPClassType) col.getName(3).resolveBinding();
+ ICPPField y = (ICPPField) col.getName(4).resolveBinding();
+
+ ICPPUsingDeclaration using_x = (ICPPUsingDeclaration) col.getName(11).resolveBinding();
+ ICPPUsingDeclaration using_C = (ICPPUsingDeclaration) col.getName(15).resolveBinding();
+ ICPPUsingDeclaration using_y = (ICPPUsingDeclaration) col.getName(20).resolveBinding();
+
+ assertInstances(col, A, 5);
+ assertInstances(col, B, 6);
+ assertInstances(col, x, 1);
+ assertInstances(col, C, 2);
+ assertInstances(col, y, 1);
+
+ IBinding[] ds = using_x.getDelegates();
+ assertSame(ds[0], x);
+ assertSame(using_C.getDelegates()[0], C);
+ assertSame(using_y.getDelegates()[0], y);
}
public void testEnumerations() throws Exception {
- IASTTranslationUnit tu = parse("namespace A { enum E { e1, e2, e3 }; E varE;}");
- NameCollector col = new NameCollector();
- tu.accept(col);
-
- assertEquals(col.size(), 7);
- ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
- IEnumeration E = (IEnumeration) col.getName(1).resolveBinding();
- IEnumerator e1 = (IEnumerator) col.getName(2).resolveBinding();
- IEnumerator e2 = (IEnumerator) col.getName(3).resolveBinding();
- IEnumerator e3 = (IEnumerator) col.getName(4).resolveBinding();
- IVariable varE = (IVariable) col.getName(6).resolveBinding();
-
- assertInstances(col, E, 2);
- assertSame(E.getScope(), A.getNamespaceScope());
- assertSame(e1.getScope(), A.getNamespaceScope());
- assertNotNull(e2);
- assertNotNull(e3);
- assertNotNull(varE);
+ IASTTranslationUnit tu = parse("namespace A { enum E { e1, e2, e3 }; E varE;}");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
+
+ assertEquals(col.size(), 7);
+ ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
+ IEnumeration E = (IEnumeration) col.getName(1).resolveBinding();
+ IEnumerator e1 = (IEnumerator) col.getName(2).resolveBinding();
+ IEnumerator e2 = (IEnumerator) col.getName(3).resolveBinding();
+ IEnumerator e3 = (IEnumerator) col.getName(4).resolveBinding();
+ IVariable varE = (IVariable) col.getName(6).resolveBinding();
+
+ assertInstances(col, E, 2);
+ assertSame(E.getScope(), A.getNamespaceScope());
+ assertSame(e1.getScope(), A.getNamespaceScope());
+ assertNotNull(e2);
+ assertNotNull(e3);
+ assertNotNull(varE);
}
public void testSimpleFunction() throws Exception {
- IASTTranslationUnit tu = parse("void foo(void);");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ IASTTranslationUnit tu = parse("void foo(void);");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 2);
- IFunction foo = (IFunction) col.getName(0).resolveBinding();
- IParameter p = (IParameter) col.getName(1).resolveBinding();
+ assertEquals(col.size(), 2);
+ IFunction foo = (IFunction) col.getName(0).resolveBinding();
+ IParameter p = (IParameter) col.getName(1).resolveBinding();
- assertEquals(0, foo.getParameters().length);
- assertSame(p.getScope(), foo.getFunctionScope());
+ assertEquals(0, foo.getParameters().length);
+ assertSame(p.getScope(), foo.getFunctionScope());
}
public void testSimpleFunctionWithTypes() throws Exception {
- IASTTranslationUnit tu = parse("class A { public: \n class B { }; }; const A::B & foo(A * myParam);");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ IASTTranslationUnit tu = parse("class A { public: \n class B { }; }; const A::B & foo(A * myParam);");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 8);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPClassType B = (ICPPClassType) col.getName(1).resolveBinding();
- IFunction foo = (IFunction) col.getName(5).resolveBinding();
- IParameter p = (IParameter) col.getName(7).resolveBinding();
+ assertEquals(col.size(), 8);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPClassType B = (ICPPClassType) col.getName(1).resolveBinding();
+ IFunction foo = (IFunction) col.getName(5).resolveBinding();
+ IParameter p = (IParameter) col.getName(7).resolveBinding();
- assertInstances(col, A, 3);
- assertInstances(col, B, 3);
+ assertInstances(col, A, 3);
+ assertInstances(col, B, 3);
- IFunctionType ftype = foo.getType();
- assertTrue(ftype.getReturnType() instanceof ICPPReferenceType);
- ICPPReferenceType rt = (ICPPReferenceType) ftype.getReturnType();
- assertTrue(rt.getType() instanceof IQualifierType);
- assertSame(((IQualifierType)rt.getType()).getType(), B);
+ IFunctionType ftype = foo.getType();
+ assertTrue(ftype.getReturnType() instanceof ICPPReferenceType);
+ ICPPReferenceType rt = (ICPPReferenceType) ftype.getReturnType();
+ assertTrue(rt.getType() instanceof IQualifierType);
+ assertSame(((IQualifierType) rt.getType()).getType(), B);
- IType pt = ftype.getParameterTypes()[0];
- assertTrue(p.getType().isSameType(pt));
- assertTrue(pt instanceof IPointerType);
- assertSame(((IPointerType) pt).getType(), A);
+ IType pt = ftype.getParameterTypes()[0];
+ assertTrue(p.getType().isSameType(pt));
+ assertTrue(pt instanceof IPointerType);
+ assertSame(((IPointerType) pt).getType(), A);
}
public void testSimpleMethod() throws Exception {
- IASTTranslationUnit tu = parse("class A { void foo(); };");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ IASTTranslationUnit tu = parse("class A { void foo(); };");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 2);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPMethod foo = (ICPPMethod) col.getName(1).resolveBinding();
+ assertEquals(col.size(), 2);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPMethod foo = (ICPPMethod) col.getName(1).resolveBinding();
- assertSame(foo.getScope(), A.getCompositeScope());
+ assertSame(foo.getScope(), A.getCompositeScope());
}
public void testSimpleMethodWithTypes() throws Exception {
- IASTTranslationUnit tu = parse("class U { }; class A { U foo(U areDumb); };");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ IASTTranslationUnit tu = parse("class U { }; class A { U foo(U areDumb); };");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 6);
- ICPPClassType U = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPClassType A = (ICPPClassType) col.getName(1).resolveBinding();
- ICPPMethod foo = (ICPPMethod) col.getName(3).resolveBinding();
- IParameter p = (IParameter) col.getName(5).resolveBinding();
+ assertEquals(col.size(), 6);
+ ICPPClassType U = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPClassType A = (ICPPClassType) col.getName(1).resolveBinding();
+ ICPPMethod foo = (ICPPMethod) col.getName(3).resolveBinding();
+ IParameter p = (IParameter) col.getName(5).resolveBinding();
- assertInstances(col, U, 3);
- assertSame(foo.getScope(), A.getCompositeScope());
- IFunctionType ft = foo.getType();
- assertSame(ft.getReturnType(), U);
- assertSame(p.getType(), U);
+ assertInstances(col, U, 3);
+ assertSame(foo.getScope(), A.getCompositeScope());
+ IFunctionType ft = foo.getType();
+ assertSame(ft.getReturnType(), U);
+ assertSame(p.getType(), U);
}
public void testUsingDeclarationWithFunctionsAndMethods() throws Exception {
- IASTTranslationUnit tu = parse("namespace N { int foo(void); } class A { static int bar(void); }; using N::foo; using ::A::bar;");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ IASTTranslationUnit tu = parse(
+ "namespace N { int foo(void); } class A { static int bar(void); }; using N::foo; using ::A::bar;");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 12);
- ICPPNamespace N = (ICPPNamespace) col.getName(0).resolveBinding();
- IFunction foo = (IFunction) col.getName(1).resolveBinding();
- ICPPClassType A = (ICPPClassType) col.getName(3).resolveBinding();
- ICPPMethod bar = (ICPPMethod) col.getName(4).resolveBinding();
+ assertEquals(col.size(), 12);
+ ICPPNamespace N = (ICPPNamespace) col.getName(0).resolveBinding();
+ IFunction foo = (IFunction) col.getName(1).resolveBinding();
+ ICPPClassType A = (ICPPClassType) col.getName(3).resolveBinding();
+ ICPPMethod bar = (ICPPMethod) col.getName(4).resolveBinding();
- ICPPUsingDeclaration using_foo = (ICPPUsingDeclaration) col.getName(8).resolveBinding();
- ICPPUsingDeclaration using_bar = (ICPPUsingDeclaration) col.getName(11).resolveBinding();
+ ICPPUsingDeclaration using_foo = (ICPPUsingDeclaration) col.getName(8).resolveBinding();
+ ICPPUsingDeclaration using_bar = (ICPPUsingDeclaration) col.getName(11).resolveBinding();
- assertInstances(col, N, 2);
- assertInstances(col, foo, 1);
- assertInstances(col, A, 2);
- assertInstances(col, bar, 1);
+ assertInstances(col, N, 2);
+ assertInstances(col, foo, 1);
+ assertInstances(col, A, 2);
+ assertInstances(col, bar, 1);
- assertSame(using_foo.getDelegates()[0], foo);
- assertSame(using_bar.getDelegates()[0], bar);
+ assertSame(using_foo.getDelegates()[0], foo);
+ assertSame(using_bar.getDelegates()[0], bar);
}
public void testLinkageSpec() throws Exception {
IASTTranslationUnit tu = parse("extern \"C\" { int foo(); }");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 1);
- IFunction foo = (IFunction) col.getName(0).resolveBinding();
- assertNotNull(foo);
+ assertEquals(col.size(), 1);
+ IFunction foo = (IFunction) col.getName(0).resolveBinding();
+ assertNotNull(foo);
}
public void testBogdansExample() throws Exception {
- IASTTranslationUnit tu = parse("namespace A { namespace B { enum e1{e_1,e_2}; int x; class C { static int y = 5; }; }} ");
- NameCollector col = new NameCollector();
- tu.accept(col);
-
- assertEquals(col.size(), 8);
- ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
- ICPPNamespace B = (ICPPNamespace) col.getName(1).resolveBinding();
- IEnumeration e1 = (IEnumeration) col.getName(2).resolveBinding();
- IEnumerator e_1 = (IEnumerator) col.getName(3).resolveBinding();
- IEnumerator e_2 = (IEnumerator) col.getName(4).resolveBinding();
- IVariable x = (IVariable) col.getName(5).resolveBinding();
- ICPPClassType C = (ICPPClassType) col.getName(6).resolveBinding();
- ICPPField y = (ICPPField) col.getName(7).resolveBinding();
-
- assertSame(B.getScope(), A.getNamespaceScope());
- assertSame(e1.getScope(), B.getNamespaceScope());
- assertSame(e_1.getScope(), B.getNamespaceScope());
- assertSame(e_2.getType(), e1);
- assertNotNull(x);
- assertNotNull(C);
- assertNotNull(y);
+ IASTTranslationUnit tu = parse(
+ "namespace A { namespace B { enum e1{e_1,e_2}; int x; class C { static int y = 5; }; }} ");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
+
+ assertEquals(col.size(), 8);
+ ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
+ ICPPNamespace B = (ICPPNamespace) col.getName(1).resolveBinding();
+ IEnumeration e1 = (IEnumeration) col.getName(2).resolveBinding();
+ IEnumerator e_1 = (IEnumerator) col.getName(3).resolveBinding();
+ IEnumerator e_2 = (IEnumerator) col.getName(4).resolveBinding();
+ IVariable x = (IVariable) col.getName(5).resolveBinding();
+ ICPPClassType C = (ICPPClassType) col.getName(6).resolveBinding();
+ ICPPField y = (ICPPField) col.getName(7).resolveBinding();
+
+ assertSame(B.getScope(), A.getNamespaceScope());
+ assertSame(e1.getScope(), B.getNamespaceScope());
+ assertSame(e_1.getScope(), B.getNamespaceScope());
+ assertSame(e_2.getType(), e1);
+ assertNotNull(x);
+ assertNotNull(C);
+ assertNotNull(y);
}
public void testAndrewsExample() throws Exception {
IASTTranslationUnit tu = parse("namespace N{ class A {}; } using namespace N; class B: public A{};");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 5);
- ICPPNamespace N = (ICPPNamespace) col.getName(0).resolveBinding();
- ICPPClassType A = (ICPPClassType) col.getName(1).resolveBinding();
- ICPPClassType B = (ICPPClassType) col.getName(3).resolveBinding();
+ assertEquals(col.size(), 5);
+ ICPPNamespace N = (ICPPNamespace) col.getName(0).resolveBinding();
+ ICPPClassType A = (ICPPClassType) col.getName(1).resolveBinding();
+ ICPPClassType B = (ICPPClassType) col.getName(3).resolveBinding();
- assertInstances(col, N, 2);
- assertInstances(col, A, 2);
+ assertInstances(col, N, 2);
+ assertInstances(col, A, 2);
- ICPPBase base = B.getBases()[0];
- assertSame(base.getBaseClass(), A);
+ ICPPBase base = B.getBases()[0];
+ assertSame(base.getBaseClass(), A);
}
public void testSimpleTypedef() throws Exception {
IASTTranslationUnit tu = parse("typedef int myInt;\n myInt var;");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 3);
- ITypedef myInt = (ITypedef) col.getName(0).resolveBinding();
- IVariable var = (IVariable) col.getName(2).resolveBinding();
+ assertEquals(col.size(), 3);
+ ITypedef myInt = (ITypedef) col.getName(0).resolveBinding();
+ IVariable var = (IVariable) col.getName(2).resolveBinding();
- assertInstances(col, myInt, 2);
- assertTrue(myInt.getType() instanceof IBasicType);
- assertSame(var.getType(), myInt);
+ assertInstances(col, myInt, 2);
+ assertTrue(myInt.getType() instanceof IBasicType);
+ assertSame(var.getType(), myInt);
}
public void testComplexTypedef() throws Exception {
IASTTranslationUnit tu = parse("class A{ }; typedef A ** A_DOUBLEPTR;");
- NameCollector col = new NameCollector();
- tu.accept(col);
-
- assertEquals(col.size(), 3);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- ITypedef APTR = (ITypedef) col.getName(2).resolveBinding();
-
- assertInstances(col, A, 2);
- assertTrue(APTR.getType() instanceof IPointerType);
- IPointerType pt = (IPointerType) APTR.getType();
- assertTrue(pt.getType() instanceof IPointerType);
- pt = (IPointerType) pt.getType();
- assertSame(pt.getType(), A);
- }
-
- protected void assertQualifiedName(String[] fromAST, String[] theTruth)
- {
- assertNotNull(fromAST);
- assertNotNull(theTruth);
- assertEquals(fromAST.length, theTruth.length);
- for (int i = 0; i < fromAST.length; ++i)
- {
- assertEquals(fromAST[i], theTruth[i]);
- }
- }
+ NameCollector col = new NameCollector();
+ tu.accept(col);
+
+ assertEquals(col.size(), 3);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ ITypedef APTR = (ITypedef) col.getName(2).resolveBinding();
+
+ assertInstances(col, A, 2);
+ assertTrue(APTR.getType() instanceof IPointerType);
+ IPointerType pt = (IPointerType) APTR.getType();
+ assertTrue(pt.getType() instanceof IPointerType);
+ pt = (IPointerType) pt.getType();
+ assertSame(pt.getType(), A);
+ }
+
+ protected void assertQualifiedName(String[] fromAST, String[] theTruth) {
+ assertNotNull(fromAST);
+ assertNotNull(theTruth);
+ assertEquals(fromAST.length, theTruth.length);
+ for (int i = 0; i < fromAST.length; ++i) {
+ assertEquals(fromAST[i], theTruth[i]);
+ }
+ }
public void testBug40842() throws Exception {
Writer code = new StringWriter();
@@ -609,13 +604,13 @@ public class CompleteParser2Tests extends BaseTestCase {
public void testNestedClassname() throws Exception {
IASTTranslationUnit tu = parse("namespace A { \n class A::B { };}");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
- ICPPClassType B = (ICPPClassType) col.getName(1).resolveBinding();
- assertInstances(col, A, 2);
- assertEquals(B.getScope(), A.getNamespaceScope());
+ ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
+ ICPPClassType B = (ICPPClassType) col.getName(1).resolveBinding();
+ assertInstances(col, A, 2);
+ assertEquals(B.getScope(), A.getNamespaceScope());
}
public void testForwardDeclaration() throws Exception {
@@ -630,28 +625,28 @@ public class CompleteParser2Tests extends BaseTestCase {
public void testElaboratedType() throws Exception {
IASTTranslationUnit tu = parse("class A; class A * a;");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 3);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- IVariable a = (IVariable) col.getName(2).resolveBinding();
- IPointerType ptr = (IPointerType) a.getType();
- assertInstances(col, A, 2);
- assertSame(ptr.getType(), A);
+ assertEquals(col.size(), 3);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ IVariable a = (IVariable) col.getName(2).resolveBinding();
+ IPointerType ptr = (IPointerType) a.getType();
+ assertInstances(col, A, 2);
+ assertSame(ptr.getType(), A);
}
public void testForewardDeclarationWithUsage() throws Exception {
IASTTranslationUnit tu = parse("class A; A * anA;class A { };");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 4);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- IVariable anA = (IVariable) col.getName(2).resolveBinding();
- assertInstances(col, A, 3);
- IPointerType ptr = (IPointerType) anA.getType();
- assertSame(ptr.getType(), A);
+ assertEquals(col.size(), 4);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ IVariable anA = (IVariable) col.getName(2).resolveBinding();
+ assertInstances(col, A, 3);
+ IPointerType ptr = (IPointerType) anA.getType();
+ assertSame(ptr.getType(), A);
}
public void testASM() throws Exception {
@@ -677,146 +672,137 @@ public class CompleteParser2Tests extends BaseTestCase {
parse("asm (\"addl %%ebx,%%eax\" \"=a\"(foo) :\"a\"(foo) : \"b\"(bar));", false, ParserLanguage.CPP, true);//$NON-NLS-1$
// Code from bug 145389.
- parse("#define mb() __asm__ __volatile__ (\"sync\" : : : \"memory\")\r\n" +
- "\r\n" +
- "int main(int argc, char **argv) {\r\n" +
- " mb();\r\n" +
- "}");
+ parse("#define mb() __asm__ __volatile__ (\"sync\" : : : \"memory\")\r\n" + "\r\n"
+ + "int main(int argc, char **argv) {\r\n" + " mb();\r\n" + "}");
// Code from bug 117001
- parse("static inline long\r\n" +
- "div_ll_X_l_rem(long long divs, long div, long *rem)\r\n" +
- "{\r\n" +
- " long dum2;\r\n" +
- " __asm__(\"divl %2\":\"=a\"(dum2), \"=d\"(*rem) // syntax error indicated at \":\"\r\n" +
- " : \"rm\"(div), \"A\"(divs));\r\n" +
- "\r\n" +
- " return dum2;\r\n" +
- "\r\n" +
- "}");
+ parse("static inline long\r\n" + "div_ll_X_l_rem(long long divs, long div, long *rem)\r\n" + "{\r\n"
+ + " long dum2;\r\n"
+ + " __asm__(\"divl %2\":\"=a\"(dum2), \"=d\"(*rem) // syntax error indicated at \":\"\r\n"
+ + " : \"rm\"(div), \"A\"(divs));\r\n" + "\r\n" + " return dum2;\r\n" + "\r\n" + "}");
}
public void testOverride() throws Exception {
IASTTranslationUnit tu = parse("void foo();\n void foo(int);\n");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 3);
- IFunction foo1 = (IFunction) col.getName(0).resolveBinding();
- IFunction foo2 = (IFunction) col.getName(1).resolveBinding();
+ assertEquals(col.size(), 3);
+ IFunction foo1 = (IFunction) col.getName(0).resolveBinding();
+ IFunction foo2 = (IFunction) col.getName(1).resolveBinding();
- assertNotSame(foo1, foo2);
+ assertNotSame(foo1, foo2);
}
public void testSimpleExpression() throws Exception {
IASTTranslationUnit tu = parse("int x; int y = x;");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 3);
- IVariable x = (IVariable) col.getName(0).resolveBinding();
- IVariable y = (IVariable) col.getName(1).resolveBinding();
- assertInstances(col, x, 2);
- assertNotNull(y);
+ assertEquals(col.size(), 3);
+ IVariable x = (IVariable) col.getName(0).resolveBinding();
+ IVariable y = (IVariable) col.getName(1).resolveBinding();
+ assertInstances(col, x, 2);
+ assertNotNull(y);
}
public void testParameterExpressions() throws Exception {
IASTTranslationUnit tu = parse("int x = 5; void foo(int sub = x) { }");
- NameCollector col = new NameCollector();
- tu.accept(col);
+ NameCollector col = new NameCollector();
+ tu.accept(col);
- assertEquals(col.size(), 4);
- IVariable x = (IVariable) col.getName(0).resolveBinding();
- assertInstances(col, x, 2);
+ assertEquals(col.size(), 4);
+ IVariable x = (IVariable) col.getName(0).resolveBinding();
+ assertInstances(col, x, 2);
}
public void testNestedNamespaceExpression() throws Exception {
IASTTranslationUnit tu = parse("namespace A { int x = 666; } int y = A::x;");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 6);
- ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
- IVariable x = (IVariable) col.getName(1).resolveBinding();
- assertInstances(col, A, 2);
- assertInstances(col, x, 3);
+ assertEquals(col.size(), 6);
+ ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
+ IVariable x = (IVariable) col.getName(1).resolveBinding();
+ assertInstances(col, A, 2);
+ assertInstances(col, x, 3);
}
public void testConstructorChain() throws Exception {
IASTTranslationUnit tu = parse("int x = 5;\n class A \n{ public : \n int a; \n A() : a(x) { } };");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 6);
- IVariable x = (IVariable) col.getName(0).resolveBinding();
- ICPPField a = (ICPPField) col.getName(2).resolveBinding();
- ICPPConstructor A = (ICPPConstructor) col.getName(3).resolveBinding();
- assertNotNull(A);
- assertInstances(col, x, 2);
- assertInstances(col, a, 2);
+ assertEquals(col.size(), 6);
+ IVariable x = (IVariable) col.getName(0).resolveBinding();
+ ICPPField a = (ICPPField) col.getName(2).resolveBinding();
+ ICPPConstructor A = (ICPPConstructor) col.getName(3).resolveBinding();
+ assertNotNull(A);
+ assertInstances(col, x, 2);
+ assertInstances(col, a, 2);
}
public void testArrayModExpression() throws Exception {
IASTTranslationUnit tu = parse("const int x = 5; int y[ x ]; ");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 3);
- IVariable x = (IVariable) col.getName(0).resolveBinding();
- IVariable y = (IVariable) col.getName(1).resolveBinding();
- assertInstances(col, x, 2);
- assertTrue(y.getType() instanceof IArrayType);
- assertTrue(((IArrayType)y.getType()).getType() instanceof IBasicType);
+ assertEquals(col.size(), 3);
+ IVariable x = (IVariable) col.getName(0).resolveBinding();
+ IVariable y = (IVariable) col.getName(1).resolveBinding();
+ assertInstances(col, x, 2);
+ assertTrue(y.getType() instanceof IArrayType);
+ assertTrue(((IArrayType) y.getType()).getType() instanceof IBasicType);
}
public void testPointerVariable() throws Exception {
IASTTranslationUnit tu = parse("class A { }; A * anA;");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 3);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- IVariable anA = (IVariable) col.getName(2).resolveBinding();
- assertInstances(col, A, 2);
- assertTrue(anA.getType() instanceof IPointerType);
- assertSame(((IPointerType) anA.getType()).getType(), A);
+ assertEquals(col.size(), 3);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ IVariable anA = (IVariable) col.getName(2).resolveBinding();
+ assertInstances(col, A, 2);
+ assertTrue(anA.getType() instanceof IPointerType);
+ assertSame(((IPointerType) anA.getType()).getType(), A);
}
public void testExceptionSpecification() throws Exception {
IASTTranslationUnit tu = parse("class A { }; void foo(void) throw (A);");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 4);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- assertInstances(col, A, 2);
+ assertEquals(col.size(), 4);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ assertInstances(col, A, 2);
}
public void testNewExpressions() throws Exception {
IASTTranslationUnit tu = parse("typedef int A; int B; int C; int D; int P; int*p = new (P) (A[B][C][D]);");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 11);
- ITypedef A = (ITypedef) col.getName(0).resolveBinding();
- IVariable B = (IVariable) col.getName(1).resolveBinding();
- IVariable C = (IVariable) col.getName(2).resolveBinding();
- IVariable D = (IVariable) col.getName(3).resolveBinding();
- IVariable P = (IVariable) col.getName(4).resolveBinding();
- IVariable p = (IVariable) col.getName(5).resolveBinding();
+ assertEquals(col.size(), 11);
+ ITypedef A = (ITypedef) col.getName(0).resolveBinding();
+ IVariable B = (IVariable) col.getName(1).resolveBinding();
+ IVariable C = (IVariable) col.getName(2).resolveBinding();
+ IVariable D = (IVariable) col.getName(3).resolveBinding();
+ IVariable P = (IVariable) col.getName(4).resolveBinding();
+ IVariable p = (IVariable) col.getName(5).resolveBinding();
- assertInstances(col, A, 2);
- assertInstances(col, B, 2);
- assertInstances(col, C, 2);
- assertInstances(col, D, 2);
- assertInstances(col, P, 2);
+ assertInstances(col, A, 2);
+ assertInstances(col, B, 2);
+ assertInstances(col, C, 2);
+ assertInstances(col, D, 2);
+ assertInstances(col, P, 2);
- assertTrue(p.getType() instanceof IPointerType);
+ assertTrue(p.getType() instanceof IPointerType);
}
public void testBug41520() throws Exception {
IASTTranslationUnit tu = parse("int f() { const int x = 666; const int y(x); }");
- IASTCompoundStatement s = (IASTCompoundStatement) ((IASTFunctionDefinition)tu.getDeclarations()[0]).getBody();
- IASTDeclarationStatement ds = (IASTDeclarationStatement) s.getStatements()[1];
+ IASTCompoundStatement s = (IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[0]).getBody();
+ IASTDeclarationStatement ds = (IASTDeclarationStatement) s.getStatements()[1];
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) ds.getDeclaration();
IASTDeclarator dtor = decl.getDeclarators()[0];
@@ -824,145 +810,149 @@ public class CompleteParser2Tests extends BaseTestCase {
assertNotNull(dtor.getInitializer());
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 4);
- IVariable x = (IVariable) col.getName(1).resolveBinding();
- IVariable y = (IVariable) col.getName(2).resolveBinding();
- assertNotNull(y);
- assertInstances(col, x, 2);
+ assertEquals(col.size(), 4);
+ IVariable x = (IVariable) col.getName(1).resolveBinding();
+ IVariable y = (IVariable) col.getName(2).resolveBinding();
+ assertNotNull(y);
+ assertInstances(col, x, 2);
}
public void testNewXReferences() throws Exception {
IASTTranslationUnit tu = parse("const int max = 5;\n int * x = new int[max];");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 3);
- IVariable max = (IVariable) col.getName(0).resolveBinding();
- assertInstances(col, max, 2);
+ assertEquals(col.size(), 3);
+ IVariable max = (IVariable) col.getName(0).resolveBinding();
+ assertInstances(col, max, 2);
}
public void testQualifiedNameReferences() throws Exception {
// Used to cause AST Semantic exception
- IASTTranslationUnit tu = parse("class A{ class B{ class C { public: int cMethod(); }; }; }; \n int A::B::C::cMethod() {}; \n");
+ IASTTranslationUnit tu = parse(
+ "class A{ class B{ class C { public: int cMethod(); }; }; }; \n int A::B::C::cMethod() {}; \n");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 9);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPClassType B = (ICPPClassType) col.getName(1).resolveBinding();
- ICPPClassType C = (ICPPClassType) col.getName(2).resolveBinding();
- ICPPMethod cMethod = (ICPPMethod) col.getName(3).resolveBinding();
+ assertEquals(col.size(), 9);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPClassType B = (ICPPClassType) col.getName(1).resolveBinding();
+ ICPPClassType C = (ICPPClassType) col.getName(2).resolveBinding();
+ ICPPMethod cMethod = (ICPPMethod) col.getName(3).resolveBinding();
- assertInstances(col, A, 2);
- assertInstances(col, B, 2);
- assertInstances(col, C, 2);
- assertInstances(col, cMethod, 3);
- assertEquals(cMethod.getVisibility(), ICPPMember.v_public);
- assertSame(cMethod.getScope(), C.getCompositeScope());
- assertSame(C.getScope(), B.getCompositeScope());
- assertSame(B.getScope(), A.getCompositeScope());
+ assertInstances(col, A, 2);
+ assertInstances(col, B, 2);
+ assertInstances(col, C, 2);
+ assertInstances(col, cMethod, 3);
+ assertEquals(cMethod.getVisibility(), ICPPMember.v_public);
+ assertSame(cMethod.getScope(), C.getCompositeScope());
+ assertSame(C.getScope(), B.getCompositeScope());
+ assertSame(B.getScope(), A.getCompositeScope());
}
public void testIsConstructor() throws Exception {
IASTTranslationUnit tu = parse("class A{ public: A(); }; \n A::A() {}; \n");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 5);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPConstructor ctor = (ICPPConstructor) col.getName(1).resolveBinding();
+ assertEquals(col.size(), 5);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPConstructor ctor = (ICPPConstructor) col.getName(1).resolveBinding();
- assertInstances(col, A, 2);
- assertInstances(col, ctor, 3);
+ assertInstances(col, A, 2);
+ assertInstances(col, ctor, 3);
}
public void testIsDestructor() throws Exception {
IASTTranslationUnit tu = parse("class A{ public: ~A(); }; \n A::~A() {}; \n");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 5);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPMethod dtor = (ICPPMethod) col.getName(1).resolveBinding();
+ assertEquals(col.size(), 5);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPMethod dtor = (ICPPMethod) col.getName(1).resolveBinding();
- assertInstances(col, A, 2);
- assertInstances(col, dtor, 3);
+ assertInstances(col, A, 2);
+ assertInstances(col, dtor, 3);
}
public void testBug41445() throws Exception {
IASTTranslationUnit tu = parse("class A { }; namespace N { class B : public A { struct A {}; }; }");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 5);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPNamespace N = (ICPPNamespace) col.getName(1).resolveBinding();
- ICPPClassType B = (ICPPClassType) col.getName(2).resolveBinding();
- ICPPClassType A2 = (ICPPClassType) col.getName(4).resolveBinding();
+ assertEquals(col.size(), 5);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPNamespace N = (ICPPNamespace) col.getName(1).resolveBinding();
+ ICPPClassType B = (ICPPClassType) col.getName(2).resolveBinding();
+ ICPPClassType A2 = (ICPPClassType) col.getName(4).resolveBinding();
- assertInstances(col, A, 2);
- assertNotSame(A, A2);
- assertSame(A2.getScope(), B.getCompositeScope());
- assertSame(B.getScope(), N.getNamespaceScope());
- assertSame(B.getBases()[0].getBaseClass(), A);
+ assertInstances(col, A, 2);
+ assertNotSame(A, A2);
+ assertSame(A2.getScope(), B.getCompositeScope());
+ assertSame(B.getScope(), N.getNamespaceScope());
+ assertSame(B.getBases()[0].getBaseClass(), A);
}
public void testSimpleFunctionBody() throws Exception {
- IASTTranslationUnit tu = parse("class A { int f1(); }; const int x = 4; int f() { return x; } int A::f1() { return x; }");
+ IASTTranslationUnit tu = parse(
+ "class A { int f1(); }; const int x = 4; int f() { return x; } int A::f1() { return x; }");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 9);
- ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPMethod f1 = (ICPPMethod) col.getName(1).resolveBinding();
- IVariable x = (IVariable) col.getName(2).resolveBinding();
+ assertEquals(col.size(), 9);
+ ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPMethod f1 = (ICPPMethod) col.getName(1).resolveBinding();
+ IVariable x = (IVariable) col.getName(2).resolveBinding();
- assertInstances(col, A, 2);
- assertInstances(col, f1, 3);
- assertInstances(col, x, 3);
+ assertInstances(col, A, 2);
+ assertInstances(col, f1, 3);
+ assertInstances(col, x, 3);
}
public void testSimpleForLoop() throws Exception {
- IASTTranslationUnit tu = parse("const int FIVE = 5; void f() { int x = 0; for (int i = 0; i < FIVE; ++i) { x += i; } }");
+ IASTTranslationUnit tu = parse(
+ "const int FIVE = 5; void f() { int x = 0; for (int i = 0; i < FIVE; ++i) { x += i; } }");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 9);
- IVariable FIVE = (IVariable) col.getName(0).resolveBinding();
- IVariable x = (IVariable) col.getName(2).resolveBinding();
- IVariable i = (IVariable) col.getName(3).resolveBinding();
+ assertEquals(col.size(), 9);
+ IVariable FIVE = (IVariable) col.getName(0).resolveBinding();
+ IVariable x = (IVariable) col.getName(2).resolveBinding();
+ IVariable i = (IVariable) col.getName(3).resolveBinding();
- assertInstances(col, FIVE, 2);
- assertInstances(col, x, 2);
- assertInstances(col, i, 4);
+ assertInstances(col, FIVE, 2);
+ assertInstances(col, x, 2);
+ assertInstances(col, i, 4);
}
public void testBug42541() throws Exception {
IASTTranslationUnit tu = parse("union{ int v; char a; } id;");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 4);
+ assertEquals(col.size(), 4);
- ICPPClassType unnamed = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPField v = (ICPPField) col.getName(1).resolveBinding();
- ICPPField a = (ICPPField) col.getName(2).resolveBinding();
- IVariable id = (IVariable) col.getName(3).resolveBinding();
+ ICPPClassType unnamed = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPField v = (ICPPField) col.getName(1).resolveBinding();
+ ICPPField a = (ICPPField) col.getName(2).resolveBinding();
+ IVariable id = (IVariable) col.getName(3).resolveBinding();
- assertEquals(unnamed.getKey(), ICompositeType.k_union);
- assertSame(v.getScope(), unnamed.getCompositeScope());
- assertSame(a.getScope(), unnamed.getCompositeScope());
- assertSame(id.getType(), unnamed);
+ assertEquals(unnamed.getKey(), ICompositeType.k_union);
+ assertSame(v.getScope(), unnamed.getCompositeScope());
+ assertSame(a.getScope(), unnamed.getCompositeScope());
+ assertSame(id.getType(), unnamed);
}
public void testSimpleIfStatement() throws Exception {
- IASTTranslationUnit tu =parse("const bool T = true; int foo() { if (T) { return 5; } else if (! T) return 20; else { return 10; } }");
+ IASTTranslationUnit tu = parse(
+ "const bool T = true; int foo() { if (T) { return 5; } else if (! T) return 20; else { return 10; } }");
IASTFunctionDefinition foo = (IASTFunctionDefinition) tu.getDeclarations()[1];
- IASTCompoundStatement compound = (IASTCompoundStatement) foo.getBody();
+ IASTCompoundStatement compound = (IASTCompoundStatement) foo.getBody();
IASTIfStatement ifstmt = (IASTIfStatement) compound.getStatements()[0];
assertTrue(ifstmt.getConditionExpression() instanceof IASTIdExpression);
assertTrue(ifstmt.getThenClause() instanceof IASTCompoundStatement);
@@ -973,62 +963,58 @@ public class CompleteParser2Tests extends BaseTestCase {
assertTrue(ifstmt.getElseClause() instanceof IASTCompoundStatement);
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 4);
+ assertEquals(col.size(), 4);
- IVariable T = (IVariable) col.getName(0).resolveBinding();
- assertInstances(col, T, 3);
+ IVariable T = (IVariable) col.getName(0).resolveBinding();
+ assertInstances(col, T, 3);
}
public void testSimpleWhileStatement() throws Exception {
- IASTTranslationUnit tu = parse("const bool T = true; void foo() { int x = 0; while(T) { ++x; if (x == 100) break; } }");
+ IASTTranslationUnit tu = parse(
+ "const bool T = true; void foo() { int x = 0; while(T) { ++x; if (x == 100) break; } }");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 6);
- IVariable T = (IVariable) col.getName(0).resolveBinding();
- IVariable x = (IVariable) col.getName(2).resolveBinding();
- assertInstances(col, T, 2);
- assertInstances(col, x, 3);
+ assertEquals(col.size(), 6);
+ IVariable T = (IVariable) col.getName(0).resolveBinding();
+ IVariable x = (IVariable) col.getName(2).resolveBinding();
+ assertInstances(col, T, 2);
+ assertInstances(col, x, 3);
}
public void testSimpleSwitchStatement() throws Exception {
- IASTTranslationUnit tu = parse("const int x = 5; const int y = 10; " +
- "void foo() { " +
- " while(true) { " +
- " switch(x) { " +
- " case 1: break; " +
- " case 2: goto blah; " +
- " case y: continue; " +
- " default: break; " +
- " } " +
- " } " +
- " blah : ; " +
- "} ");
- NameCollector col = new NameCollector();
- tu.accept(col);
-
- assertEquals(col.size(), 7);
- IVariable x = (IVariable) col.getName(0).resolveBinding();
- IVariable y = (IVariable) col.getName(1).resolveBinding();
- ILabel blah = (ILabel) col.getName(4).resolveBinding();
- assertNotNull(blah);
- assertInstances(col, x, 2);
- assertInstances(col, y, 2);
- assertInstances(col, blah, 2);
+ IASTTranslationUnit tu = parse("const int x = 5; const int y = 10; " + "void foo() { "
+ + " while(true) { " + " switch(x) { "
+ + " case 1: break; " + " case 2: goto blah; "
+ + " case y: continue; " + " default: break; "
+ + " } " + " } "
+ + " blah : ; " + "} ");
+ NameCollector col = new NameCollector();
+ tu.accept(col);
+
+ assertEquals(col.size(), 7);
+ IVariable x = (IVariable) col.getName(0).resolveBinding();
+ IVariable y = (IVariable) col.getName(1).resolveBinding();
+ ILabel blah = (ILabel) col.getName(4).resolveBinding();
+ assertNotNull(blah);
+ assertInstances(col, x, 2);
+ assertInstances(col, y, 2);
+ assertInstances(col, blah, 2);
}
public void testSimpleDoStatement() throws Exception {
- IASTTranslationUnit tu = parse("const int x = 3; int counter = 0; void foo() { do { ++counter; } while(counter != x); } ");
+ IASTTranslationUnit tu = parse(
+ "const int x = 3; int counter = 0; void foo() { do { ++counter; } while(counter != x); } ");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 6);
- IVariable x = (IVariable) col.getName(0).resolveBinding();
- IVariable counter = (IVariable) col.getName(1).resolveBinding();
- assertInstances(col, x, 2);
- assertInstances(col, counter, 3);
+ assertEquals(col.size(), 6);
+ IVariable x = (IVariable) col.getName(0).resolveBinding();
+ IVariable counter = (IVariable) col.getName(1).resolveBinding();
+ assertInstances(col, x, 2);
+ assertInstances(col, counter, 3);
}
public void testThrowStatement() throws Exception {
@@ -1045,75 +1031,77 @@ public class CompleteParser2Tests extends BaseTestCase {
}
public void testScoping() throws Exception {
- IASTTranslationUnit tu = parse("void foo() { int x = 3; if (x == 1) { int x = 4; } else int x = 2; }");
+ IASTTranslationUnit tu = parse("void foo() { int x = 3; if (x == 1) { int x = 4; } else int x = 2; }");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 5);
- IVariable x1 = (IVariable) col.getName(1).resolveBinding();
- IVariable x2 = (IVariable) col.getName(3).resolveBinding();
- IVariable x3 = (IVariable) col.getName(4).resolveBinding();
+ assertEquals(col.size(), 5);
+ IVariable x1 = (IVariable) col.getName(1).resolveBinding();
+ IVariable x2 = (IVariable) col.getName(3).resolveBinding();
+ IVariable x3 = (IVariable) col.getName(4).resolveBinding();
- assertInstances(col, x1, 2);
- assertInstances(col, x2, 1);
- assertInstances(col, x3, 1);
+ assertInstances(col, x1, 2);
+ assertInstances(col, x2, 1);
+ assertInstances(col, x3, 1);
}
public void testEnumeratorReferences() throws Exception {
- IASTTranslationUnit tu = parse("enum E { e1, e2, e3 }; E anE = e1;");
+ IASTTranslationUnit tu = parse("enum E { e1, e2, e3 }; E anE = e1;");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 7);
- IEnumeration E = (IEnumeration) col.getName(0).resolveBinding();
- IEnumerator e1 = (IEnumerator) col.getName(1).resolveBinding();
- IEnumerator e2 = (IEnumerator) col.getName(2).resolveBinding();
- IEnumerator e3 = (IEnumerator) col.getName(3).resolveBinding();
- IVariable anE = (IVariable) col.getName(5).resolveBinding();
+ assertEquals(col.size(), 7);
+ IEnumeration E = (IEnumeration) col.getName(0).resolveBinding();
+ IEnumerator e1 = (IEnumerator) col.getName(1).resolveBinding();
+ IEnumerator e2 = (IEnumerator) col.getName(2).resolveBinding();
+ IEnumerator e3 = (IEnumerator) col.getName(3).resolveBinding();
+ IVariable anE = (IVariable) col.getName(5).resolveBinding();
- assertInstances(col, E, 2);
- assertInstances(col, e1, 2);
- assertInstances(col, e2, 1);
- assertInstances(col, e3, 1);
- assertInstances(col, anE, 1);
+ assertInstances(col, E, 2);
+ assertInstances(col, e1, 2);
+ assertInstances(col, e2, 1);
+ assertInstances(col, e3, 1);
+ assertInstances(col, anE, 1);
}
public void testBug42840() throws Exception {
- IASTTranslationUnit tu = parse("void foo(); void foo() { } class SearchMe { };");
+ IASTTranslationUnit tu = parse("void foo(); void foo() { } class SearchMe { };");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 3);
- IFunction foo = (IFunction) col.getName(0).resolveBinding();
+ assertEquals(col.size(), 3);
+ IFunction foo = (IFunction) col.getName(0).resolveBinding();
- assertInstances(col, foo, 2);
+ assertInstances(col, foo, 2);
}
public void testBug42872() throws Exception {
- IASTTranslationUnit tu = parse("struct B {}; struct D : B {}; void foo(D* dp) { B* bp = dynamic_cast<B*>(dp); }");
+ IASTTranslationUnit tu = parse(
+ "struct B {}; struct D : B {}; void foo(D* dp) { B* bp = dynamic_cast<B*>(dp); }");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 10);
- ICompositeType B = (ICompositeType) col.getName(0).resolveBinding();
- ICompositeType D = (ICompositeType) col.getName(1).resolveBinding();
+ assertEquals(col.size(), 10);
+ ICompositeType B = (ICompositeType) col.getName(0).resolveBinding();
+ ICompositeType D = (ICompositeType) col.getName(1).resolveBinding();
- assertInstances(col, B, 4);
- assertInstances(col, D, 2);
+ assertInstances(col, B, 4);
+ assertInstances(col, D, 2);
}
public void testBug43503A() throws Exception {
- IASTTranslationUnit tu = parse("class SD_01 { void f_SD_01() {}}; int main(){ SD_01 * a = new SD_01(); a->f_SD_01(); } ");
+ IASTTranslationUnit tu = parse(
+ "class SD_01 { void f_SD_01() {}}; int main(){ SD_01 * a = new SD_01(); a->f_SD_01(); } ");
NameCollector col = new NameCollector(true);
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 9);
- ICPPClassType SD_01 = (ICPPClassType) col.getName(0).resolveBinding();
- ICPPMethod f_SD_01 = (ICPPMethod) col.getName(1).resolveBinding();
- ICPPConstructor ctor = SD_01.getConstructors()[0];
- assertInstances(col, SD_01, 3);
- assertInstances(col, ctor, 1);
- assertInstances(col, f_SD_01, 2);
+ assertEquals(col.size(), 9);
+ ICPPClassType SD_01 = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPMethod f_SD_01 = (ICPPMethod) col.getName(1).resolveBinding();
+ ICPPConstructor ctor = SD_01.getConstructors()[0];
+ assertInstances(col, SD_01, 3);
+ assertInstances(col, ctor, 1);
+ assertInstances(col, f_SD_01, 2);
}
public void testBug42979() throws Exception {
@@ -1130,44 +1118,45 @@ public class CompleteParser2Tests extends BaseTestCase {
IASTTranslationUnit tu = parse(code.toString());
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 12);
- ICompositeType OperatorOverload = (ICompositeType) col.getName(0).resolveBinding();
- ICPPMethod op1 = (ICPPMethod) col.getName(1).resolveBinding();
- ICPPMethod op2 = (ICPPMethod) col.getName(4).resolveBinding();
+ assertEquals(col.size(), 12);
+ ICompositeType OperatorOverload = (ICompositeType) col.getName(0).resolveBinding();
+ ICPPMethod op1 = (ICPPMethod) col.getName(1).resolveBinding();
+ ICPPMethod op2 = (ICPPMethod) col.getName(4).resolveBinding();
- assertInstances(col, OperatorOverload, 5);
- assertInstances(col, op1, 1);
- assertInstances(col, op2, 3);
+ assertInstances(col, OperatorOverload, 5);
+ assertInstances(col, op1, 1);
+ assertInstances(col, op2, 3);
}
+
/**
* class A { static int x; } int A::x = 5;
*/
public void testBug43373() throws Exception {
- IASTTranslationUnit tu = parse("class A { static int x; }; int A::x = 5;");
+ IASTTranslationUnit tu = parse("class A { static int x; }; int A::x = 5;");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 5);
- ICompositeType A = (ICompositeType) col.getName(0).resolveBinding();
- ICPPField x = (ICPPField) col.getName(1).resolveBinding();
+ assertEquals(col.size(), 5);
+ ICompositeType A = (ICompositeType) col.getName(0).resolveBinding();
+ ICPPField x = (ICPPField) col.getName(1).resolveBinding();
- assertInstances(col, A, 2);
- assertInstances(col, x, 3);
+ assertInstances(col, A, 2);
+ assertInstances(col, x, 3);
}
public void testBug39504() throws Exception {
- IASTTranslationUnit tu = parse("const int w = 2; int x[ 5 ]; int y = sizeof (x[w]);");
+ IASTTranslationUnit tu = parse("const int w = 2; int x[ 5 ]; int y = sizeof (x[w]);");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 5);
- IVariable w = (IVariable) col.getName(0).resolveBinding();
- IVariable x = (IVariable) col.getName(1).resolveBinding();
+ assertEquals(col.size(), 5);
+ IVariable w = (IVariable) col.getName(0).resolveBinding();
+ IVariable x = (IVariable) col.getName(1).resolveBinding();
- assertInstances(col, w, 2);
- assertInstances(col, x, 2);
+ assertInstances(col, w, 2);
+ assertInstances(col, x, 2);
}
public void testBug43375() throws Exception {
@@ -1183,12 +1172,12 @@ public class CompleteParser2Tests extends BaseTestCase {
buff.append(" }; ");
buff.append("class SD_01 { \n");
buff.append(" public: \n");
- buff.append(" SD_02 *next; \n"); // REFERENCE SD_02
+ buff.append(" SD_02 *next; \n"); // REFERENCE SD_02
buff.append(" void f_SD_01(); \n");
buff.append("}; \n");
buff.append("int main(){ \n");
- buff.append(" SD_01* a = new SD_01(); \n"); // REFERENCE SD_01 * 2
- buff.append(" a->f_SD_01(); \n"); // REFERENCE a && REFERENCE f_SD_01
+ buff.append(" SD_01* a = new SD_01(); \n"); // REFERENCE SD_01 * 2
+ buff.append(" a->f_SD_01(); \n"); // REFERENCE a && REFERENCE f_SD_01
buff.append("} \n");
buff.append("void SD_01::f_SD_01() \n"); // REFERENCE SD_01
buff.append("{ \n");
@@ -1197,41 +1186,42 @@ public class CompleteParser2Tests extends BaseTestCase {
IASTTranslationUnit tu = parse(buff.toString());
NameCollector col = new NameCollector(true);
- tu.accept(col);
-
- assertEquals(col.size(), 18);
- ICompositeType SD_02 = (ICompositeType) col.getName(0).resolveBinding();
- ICPPMethod f_SD_02 = (ICPPMethod) col.getName(1).resolveBinding();
- ICPPClassType SD_01 = (ICPPClassType) col.getName(2).resolveBinding();
- ICPPField next = (ICPPField) col.getName(4).resolveBinding();
- ICPPMethod f_SD_01 = (ICPPMethod) col.getName(5).resolveBinding();
- ICPPConstructor ctor = SD_01.getConstructors()[0];
+ tu.accept(col);
- assertInstances(col, SD_02, 2);
- assertInstances(col, f_SD_02, 2);
- assertInstances(col, SD_01, 4);
- assertInstances(col, ctor, 1);
- assertInstances(col, next, 2);
- assertInstances(col, f_SD_01, 4);
+ assertEquals(col.size(), 18);
+ ICompositeType SD_02 = (ICompositeType) col.getName(0).resolveBinding();
+ ICPPMethod f_SD_02 = (ICPPMethod) col.getName(1).resolveBinding();
+ ICPPClassType SD_01 = (ICPPClassType) col.getName(2).resolveBinding();
+ ICPPField next = (ICPPField) col.getName(4).resolveBinding();
+ ICPPMethod f_SD_01 = (ICPPMethod) col.getName(5).resolveBinding();
+ ICPPConstructor ctor = SD_01.getConstructors()[0];
+
+ assertInstances(col, SD_02, 2);
+ assertInstances(col, f_SD_02, 2);
+ assertInstances(col, SD_01, 4);
+ assertInstances(col, ctor, 1);
+ assertInstances(col, next, 2);
+ assertInstances(col, f_SD_01, 4);
}
- public void testBug43679_A () throws Exception {
- IASTTranslationUnit tu = parse("struct Sample { int size() const; }; extern const Sample * getSample(); int trouble() { return getSample()->size(); } ");
+ public void testBug43679_A() throws Exception {
+ IASTTranslationUnit tu = parse(
+ "struct Sample { int size() const; }; extern const Sample * getSample(); int trouble() { return getSample()->size(); } ");
NameCollector col = new NameCollector();
- tu.accept(col);
+ tu.accept(col);
- assertEquals(col.size(), 7);
- ICompositeType sample = (ICompositeType) col.getName(0).resolveBinding();
- ICPPMethod size = (ICPPMethod) col.getName(1).resolveBinding();
- IFunction getSample = (IFunction) col.getName(3).resolveBinding();
+ assertEquals(col.size(), 7);
+ ICompositeType sample = (ICompositeType) col.getName(0).resolveBinding();
+ ICPPMethod size = (ICPPMethod) col.getName(1).resolveBinding();
+ IFunction getSample = (IFunction) col.getName(3).resolveBinding();
- assertInstances(col, sample, 2);
- assertInstances(col, size, 2);
- assertInstances(col, getSample, 2);
+ assertInstances(col, sample, 2);
+ assertInstances(col, size, 2);
+ assertInstances(col, getSample, 2);
}
- public void testBug43679_B () throws Exception {
- IASTTranslationUnit tu = parse("struct Sample{int size() const; }; struct Sample; ");
+ public void testBug43679_B() throws Exception {
+ IASTTranslationUnit tu = parse("struct Sample{int size() const; }; struct Sample; ");
NameCollector col = new NameCollector();
tu.accept(col);
@@ -1282,7 +1272,8 @@ public class CompleteParser2Tests extends BaseTestCase {
StringBuilder buffer = new StringBuilder();
buffer.append("struct Inner { int a,b,c; };");
buffer.append("struct A { int x; int y[]; struct Inner innerArray[]; int z[]; };");
- buffer.append("struct A myA = { .x = 4, .y[3] = 4, .y[4] = 3, .innerArray[0].a = 3, .innerArray[1].b = 5, .innerArray[2].c=6, .z = { 1,4,5} };");
+ buffer.append(
+ "struct A myA = { .x = 4, .y[3] = 4, .y[4] = 3, .innerArray[0].a = 3, .innerArray[1].b = 5, .innerArray[2].c=6, .z = { 1,4,5} };");
parse(buffer.toString(), true, ParserLanguage.C);
}
@@ -1291,7 +1282,7 @@ public class CompleteParser2Tests extends BaseTestCase {
}
public void testBug39551B() throws Exception {
- //this used to be 99.99 * __I__, but I don't know where the __I__ came from, its not in C99, nor in GCC
+ //this used to be 99.99 * __I__, but I don't know where the __I__ came from, its not in C99, nor in GCC
parse("_Imaginary double id = 99.99 * 1i;", true, ParserLanguage.C);
}
@@ -1300,21 +1291,13 @@ public class CompleteParser2Tests extends BaseTestCase {
}
public void testCBoolAsParameter() throws Exception {
- parse("void f(_Bool b) {} " +
- "_Bool g(_Bool b) {} " +
- "void main(){" +
- " _Bool b; " +
- " f(b);" +
- " f(g((_Bool) 1) );" +
- "}",
- true, ParserLanguage.C);
+ parse("void f(_Bool b) {} " + "_Bool g(_Bool b) {} " + "void main(){" + " _Bool b; " + " f(b);"
+ + " f(g((_Bool) 1) );" + "}", true, ParserLanguage.C);
}
public void testBug44510() throws Exception {
- IASTTranslationUnit tu = parse("int initialize(); " +
- "int initialize(char){} " +
- "int initialize(){ return 1; } " +
- "void main(){ int i = initialize(); }");
+ IASTTranslationUnit tu = parse("int initialize(); " + "int initialize(char){} "
+ + "int initialize(){ return 1; } " + "void main(){ int i = initialize(); }");
NameCollector col = new NameCollector();
tu.accept(col);
@@ -1343,7 +1326,7 @@ public class CompleteParser2Tests extends BaseTestCase {
IVariable obj1 = (IVariable) col.getName(2).resolveBinding();
IEnumeration myEnum = (IEnumeration) col.getName(3).resolveBinding();
IEnumerator item = (IEnumerator) col.getName(4).resolveBinding();
- IVariable obj2 = (IVariable)col.getName(6).resolveBinding();
+ IVariable obj2 = (IVariable) col.getName(6).resolveBinding();
assertInstances(col, myClass, 2);
assertInstances(col, myEnum, 2);
@@ -1465,7 +1448,7 @@ public class CompleteParser2Tests extends BaseTestCase {
assertInstances(col, foo, 2);
}
- public void testErrorHandling_1() throws Exception {
+ public void testErrorHandling_1() throws Exception {
IASTTranslationUnit tu = parse("A anA; int x = c; class A {}; A * anotherA = &anA; int b;", false);
NameCollector col = new NameCollector();
@@ -1484,13 +1467,13 @@ public class CompleteParser2Tests extends BaseTestCase {
assertNotNull(p);
assertNotNull(p2);
- IProblemType pt= (IProblemType) anA.getType();
+ IProblemType pt = (IProblemType) anA.getType();
assertEquals(ISemanticProblem.TYPE_UNRESOLVED_NAME, pt.getID());
}
public void testBug44340() throws Exception {
// Inline function with reference to variables declared after them
- IASTTranslationUnit tu = parse ("class A{ int getX() {return x[1];} int x[10];};");
+ IASTTranslationUnit tu = parse("class A{ int getX() {return x[1];} int x[10];};");
NameCollector col = new NameCollector();
tu.accept(col);
@@ -1520,9 +1503,9 @@ public class CompleteParser2Tests extends BaseTestCase {
assertEquals(col.size(), 4);
IFunction f1 = (IFunction) col.getName(0).resolveBinding();
- IParameter p1 = (IParameter)col.getName(1).resolveBinding();
+ IParameter p1 = (IParameter) col.getName(1).resolveBinding();
IFunction f2 = (IFunction) col.getName(2).resolveBinding();
- IParameter p2 = (IParameter)col.getName(3).resolveBinding();
+ IParameter p2 = (IParameter) col.getName(3).resolveBinding();
assertSame(f1, f2);
assertSame(p1, p2);
}
@@ -1538,9 +1521,9 @@ public class CompleteParser2Tests extends BaseTestCase {
assertEquals(col.size(), 4);
IFunction f1 = (IFunction) col.getName(0).resolveBinding();
- IParameter p1 = (IParameter)col.getName(1).resolveBinding();
+ IParameter p1 = (IParameter) col.getName(1).resolveBinding();
IFunction f2 = (IFunction) col.getName(2).resolveBinding();
- IParameter p2 = (IParameter)col.getName(3).resolveBinding();
+ IParameter p2 = (IParameter) col.getName(3).resolveBinding();
assertNotSame(f1, f2);
assertNotSame(p1, p2);
@@ -1558,12 +1541,12 @@ public class CompleteParser2Tests extends BaseTestCase {
IEnumeration _A = (IEnumeration) col.getName(0).resolveBinding();
ITypedef A = (ITypedef) col.getName(1).resolveBinding();
- ITypedef pA = (ITypedef)col.getName(2).resolveBinding();
+ ITypedef pA = (ITypedef) col.getName(2).resolveBinding();
assertNotNull(_A);
assertSame(A.getType(), _A);
assertTrue(pA.getType() instanceof IPointerType);
- assertSame(((IPointerType)pA.getType()).getType(), _A);
+ assertSame(((IPointerType) pA.getType()).getType(), _A);
}
public void testBug55163() throws Exception {
@@ -1579,14 +1562,15 @@ public class CompleteParser2Tests extends BaseTestCase {
tu.accept(col);
assertEquals(col.size(), 11);
- IVariable i = (IVariable)col.getName(1).resolveBinding();
- IVariable n = (IVariable)col.getName(2).resolveBinding();
- IVariable di = (IVariable)col.getName(3).resolveBinding();
+ IVariable i = (IVariable) col.getName(1).resolveBinding();
+ IVariable n = (IVariable) col.getName(2).resolveBinding();
+ IVariable di = (IVariable) col.getName(3).resolveBinding();
assertInstances(col, i, 6);
assertInstances(col, n, 2);
assertInstances(col, di, 2);
}
+
public void testBug55673() throws Exception {
Writer writer = new StringWriter();
writer.write("struct Example { int i; int (* pfi) (int); }; ");
@@ -1597,11 +1581,11 @@ public class CompleteParser2Tests extends BaseTestCase {
tu.accept(col);
assertEquals(col.size(), 4);
- ICPPField pfi = (ICPPField)col.getName(2).resolveBinding();
+ ICPPField pfi = (ICPPField) col.getName(2).resolveBinding();
assertNotNull(pfi);
assertTrue(pfi.getType() instanceof IPointerType);
- assertTrue(((IPointerType)pfi.getType()).getType() instanceof IFunctionType);
+ assertTrue(((IPointerType) pfi.getType()).getType() instanceof IFunctionType);
}
public void testBug54531() throws Exception {
@@ -1676,7 +1660,7 @@ public class CompleteParser2Tests extends BaseTestCase {
}
public void testBug57800() throws Exception {
- Writer writer= new StringWriter();
+ Writer writer = new StringWriter();
writer.write("class G2 { int j; };");
writer.write("typedef G2 AltG2;");
writer.write("class AltG3 : AltG2 { int x;};");
@@ -1739,144 +1723,143 @@ public class CompleteParser2Tests extends BaseTestCase {
parse(writer.toString());
}
- public void testBug59302() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class A { class N{}; }; ");
- writer.write("class B { friend class A::N; }; ");
- parse(writer.toString());
- }
-
- public void testULong() throws Exception {
- Writer writer = new StringWriter();
- writer.write("#ifndef ASMINCLUDE\n");
- writer.write("typedef unsigned short ushort;\n");
- writer.write("typedef volatile unsigned long semaphore;\n");
- writer.write("typedef unsigned long ulong;\n");
- writer.write("#ifndef _NO_LONGLONG\n");
- writer.write("typedef long long longlong;\n");
- writer.write("typedef unsigned long long ulonglong;\n");
- writer.write("#endif /* _NO_LONGLONG */\n");
- writer.write("#endif /* ASMINCLUDE */\n");
- writer.write("typedef struct section_type_ {\n");
- writer.write("ulong source;\n");
- writer.write("ulong dest;\n");
- writer.write("ulong bytes;\n");
- writer.write("} section_type;\n");
- parse(writer.toString());
- }
-
- public void testBug47926() throws Exception {
- parse("void f() {} class A {}; void main() { A * a = new A(); a->f(); }", false);
- }
-
- public void testBug50984_ASTMethod_getOwnerClassSpecifier_ClassCastException() throws Exception {
- Writer writer = new StringWriter();
- writer.write("template < typename _OutIter > ");
- writer.write("class num_put { ");
- writer.write(" typedef _OutIter iter_type; ");
- writer.write(" template< typename _ValueT > ");
- writer.write(" iter_type _M_convert_float(iter_type); ");
- writer.write("}; ");
- writer.write("template < typename _OutIter > ");
- writer.write("template < typename _ValueT > ");
- writer.write("_OutIter num_put<_OutIter>::_M_convert_float(_OutIter) { } ");
- parse(writer.toString());
- }
-
- public void testGloballyQualifiedUsingDeclaration() throws Exception {
+ public void testBug59302() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class A { class N{}; }; ");
+ writer.write("class B { friend class A::N; }; ");
+ parse(writer.toString());
+ }
+
+ public void testULong() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("#ifndef ASMINCLUDE\n");
+ writer.write("typedef unsigned short ushort;\n");
+ writer.write("typedef volatile unsigned long semaphore;\n");
+ writer.write("typedef unsigned long ulong;\n");
+ writer.write("#ifndef _NO_LONGLONG\n");
+ writer.write("typedef long long longlong;\n");
+ writer.write("typedef unsigned long long ulonglong;\n");
+ writer.write("#endif /* _NO_LONGLONG */\n");
+ writer.write("#endif /* ASMINCLUDE */\n");
+ writer.write("typedef struct section_type_ {\n");
+ writer.write("ulong source;\n");
+ writer.write("ulong dest;\n");
+ writer.write("ulong bytes;\n");
+ writer.write("} section_type;\n");
+ parse(writer.toString());
+ }
+
+ public void testBug47926() throws Exception {
+ parse("void f() {} class A {}; void main() { A * a = new A(); a->f(); }", false);
+ }
+
+ public void testBug50984_ASTMethod_getOwnerClassSpecifier_ClassCastException() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("template < typename _OutIter > ");
+ writer.write("class num_put { ");
+ writer.write(" typedef _OutIter iter_type; ");
+ writer.write(" template< typename _ValueT > ");
+ writer.write(" iter_type _M_convert_float(iter_type); ");
+ writer.write("}; ");
+ writer.write("template < typename _OutIter > ");
+ writer.write("template < typename _ValueT > ");
+ writer.write("_OutIter num_put<_OutIter>::_M_convert_float(_OutIter) { } ");
+ parse(writer.toString());
+ }
+
+ public void testGloballyQualifiedUsingDeclaration() throws Exception {
parse("int iii; namespace N { using ::iii; }");
}
- public void test57513_new() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class A{ A(); A(int); }; \n");
- writer.write(" void f() { \n");
- writer.write(" A * a1 = new A; \n");
- writer.write(" A * a2 = new(1)A(); \n");
- writer.write(" A * a3 = new A(1); \n");
- writer.write("} \n");
+ public void test57513_new() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class A{ A(); A(int); }; \n");
+ writer.write(" void f() { \n");
+ writer.write(" A * a1 = new A; \n");
+ writer.write(" A * a2 = new(1)A(); \n");
+ writer.write(" A * a3 = new A(1); \n");
+ writer.write("} \n");
- parse(writer.toString());
+ parse(writer.toString());
}
- public void test57513_NoConstructor() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class A{ }; \n");
- writer.write(" void f() { \n");
- writer.write(" A * a1 = new A; \n");
- writer.write("} \n");
+ public void test57513_NoConstructor() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class A{ }; \n");
+ writer.write(" void f() { \n");
+ writer.write(" A * a1 = new A; \n");
+ writer.write("} \n");
- parse(writer.toString());
+ parse(writer.toString());
}
- public void test57513_ctorinit() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class A{ A(); A(A *); }; \n");
- writer.write("class B : public A { B(); }; \n");
- writer.write("B::B():A(new A){} \n");
+ public void test57513_ctorinit() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class A{ A(); A(A *); }; \n");
+ writer.write("class B : public A { B(); }; \n");
+ writer.write("B::B():A(new A){} \n");
- parse(writer.toString());
- }
+ parse(writer.toString());
+ }
- public void test575513_qualified() throws Exception {
- Writer writer = new StringWriter();
- writer.write("namespace Foo{ ");
- writer.write(" class Bar{ public : Bar(); }; ");
- writer.write("} ");
- writer.write("void main(){ ");
- writer.write(" Foo::Bar * bar = new Foo::Bar(); ");
- writer.write("} ");
+ public void test575513_qualified() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("namespace Foo{ ");
+ writer.write(" class Bar{ public : Bar(); }; ");
+ writer.write("} ");
+ writer.write("void main(){ ");
+ writer.write(" Foo::Bar * bar = new Foo::Bar(); ");
+ writer.write("} ");
- parse(writer.toString());
+ parse(writer.toString());
}
- public void testBug60944() throws Exception {
- Writer writer = new StringWriter();
- writer.write("typedef int OurInt;\n");
- writer.write("class A { int x; };\n");
- writer.write("typedef A AnotherA;\n");
- writer.write("typedef AnotherA SecondA;\n");
- writer.write("typedef OurInt AnotherInt;\n");
- parse(writer.toString());
+ public void testBug60944() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("typedef int OurInt;\n");
+ writer.write("class A { int x; };\n");
+ writer.write("typedef A AnotherA;\n");
+ writer.write("typedef AnotherA SecondA;\n");
+ writer.write("typedef OurInt AnotherInt;\n");
+ parse(writer.toString());
}
- public void testDestructorReference() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class ABC {\n");
- writer.write(" public:\n");
- writer.write(" ~ABC(){ }\n");
- writer.write("};\n");
- writer.write("int main() { ABC * abc = new ABC();\n");
- writer.write("abc->~ABC();\n");
- writer.write("}\n");
+ public void testDestructorReference() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class ABC {\n");
+ writer.write(" public:\n");
+ writer.write(" ~ABC(){ }\n");
+ writer.write("};\n");
+ writer.write("int main() { ABC * abc = new ABC();\n");
+ writer.write("abc->~ABC();\n");
+ writer.write("}\n");
parse(writer.toString());
- }
-
- public void testBug39676_tough() throws Exception {
- parse("int widths[] = {[0 ... 9] = 1,[10 ... 99] = 2,[100] = 3 };", true, ParserLanguage.C, true);
- }
-
- public void testBug60939() throws Exception {
- for (int i = 0; i < 2; ++i)
- {
- Writer writer = new StringWriter();
- writer.write("namespace ABC { class DEF { }; }\n");
- if (i == 0)
- writer.write("using namespace ABC;\n");
- else
- writer.write("using ABC::DEF;\n");
- writer.write("class GHI : public DEF { };");
- parse(writer.toString());
- }
- }
-
- public void testBug64010() throws Exception {
- Writer writer = new StringWriter();
- writer.write(" #define ONE else if (0) { } \n");
- writer.write(" #define TEN ONE ONE ONE ONE ONE ONE ONE ONE ONE ONE \n ");
- writer.write(" #define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN \n ");
- writer.write(" #define THOU HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN \n");
+ }
+
+ public void testBug39676_tough() throws Exception {
+ parse("int widths[] = {[0 ... 9] = 1,[10 ... 99] = 2,[100] = 3 };", true, ParserLanguage.C, true);
+ }
+
+ public void testBug60939() throws Exception {
+ for (int i = 0; i < 2; ++i) {
+ Writer writer = new StringWriter();
+ writer.write("namespace ABC { class DEF { }; }\n");
+ if (i == 0)
+ writer.write("using namespace ABC;\n");
+ else
+ writer.write("using ABC::DEF;\n");
+ writer.write("class GHI : public DEF { };");
+ parse(writer.toString());
+ }
+ }
+
+ public void testBug64010() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write(" #define ONE else if (0) { } \n");
+ writer.write(" #define TEN ONE ONE ONE ONE ONE ONE ONE ONE ONE ONE \n ");
+ writer.write(" #define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN \n ");
+ writer.write(" #define THOU HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN \n");
writer.write("void foo() ");
writer.write("{ ");
writer.write(" if (0) { } ");
@@ -1887,7 +1870,7 @@ public class CompleteParser2Tests extends BaseTestCase {
parse(writer.toString());
}
- public void testBug64271() throws Exception {
+ public void testBug64271() throws Exception {
Writer writer = new StringWriter();
writer.write("typedef int DWORD;\n");
writer.write("typedef char BYTE;\n");
@@ -1903,32 +1886,33 @@ public class CompleteParser2Tests extends BaseTestCase {
parse(writer.toString());
}
- public void testBug47752() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class BBC\n");
- writer.write("{\n");
- writer.write("int x;\n");
- writer.write("};\n");
- writer.write("void func(BBC bar)\n");
- writer.write("try\n");
- writer.write("{\n");
- writer.write("}\n");
- writer.write("catch (BBC error)\n");
- writer.write("{\n");
- writer.write(" //... error handling code ...\n");
- writer.write("}\n");
- parse(writer.toString());
+ public void testBug47752() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class BBC\n");
+ writer.write("{\n");
+ writer.write("int x;\n");
+ writer.write("};\n");
+ writer.write("void func(BBC bar)\n");
+ writer.write("try\n");
+ writer.write("{\n");
+ writer.write("}\n");
+ writer.write("catch (BBC error)\n");
+ writer.write("{\n");
+ writer.write(" //... error handling code ...\n");
+ writer.write("}\n");
+ parse(writer.toString());
}
- public void testBug61972() throws Exception {
- parse("#define DEF1(A1) A1\n#define DEF2 DEF1(DEF2)\nDEF2;", false);
+
+ public void testBug61972() throws Exception {
+ parse("#define DEF1(A1) A1\n#define DEF2 DEF1(DEF2)\nDEF2;", false);
}
- public void testBug65569() throws Exception {
- parse("class Sample;\nstruct Sample { /* ... */ };");
+ public void testBug65569() throws Exception {
+ parse("class Sample;\nstruct Sample { /* ... */ };");
}
- public void testBug64268() throws Exception {
- Writer writer = new StringWriter();
+ public void testBug64268() throws Exception {
+ Writer writer = new StringWriter();
writer.write("#define BODY \\\n");
writer.write("for (;;) { \\\n");
writer.write("/* this multi-line comment messes \\\n");
@@ -1939,117 +1923,117 @@ public class CompleteParser2Tests extends BaseTestCase {
parse(writer.toString());
}
- public void testBug67622() throws Exception {
- parse("const char * x = __FILE__;");
- }
-
- public void testBug67680() throws Exception {
- Writer writer = new StringWriter();
- writer.write("template < class T> class Base {}; \n");
- writer.write("class Derived : public Base, Base<int>, foo {}; \n");
-
- parse(writer.toString(), false);
- }
-
- public void testTypeIDSignature() throws Exception {
- parse("int * v = (int*)0;");//$NON-NLS-1$
- }
-
- public void testUnaryAmperCast() throws Exception {
- Writer writer = new StringWriter();
- writer.write("void f(char *); \r\n ");
- writer.write("void f(char ); \n ");
- writer.write("void main() { \n ");
- writer.write(" char * t = new char[ 5 ]; \n ");
- writer.write(" f(&t[1]); \n ");
- writer.write("} \n ");
-
- parse(writer.toString());
- }
-
- public void testBug68235() throws Exception {
- Writer writer = new StringWriter();
- writer.write(" struct xTag { int x; }; ");
- writer.write(" typedef xTag xType; ");
- writer.write(" typedef struct yTag { int x; } yType; ");
- writer.write(" class C1 { xType x; yType y; }; ");
-
- parse(writer.toString());
- }
-
- public void testBug60407() throws Exception {
- Writer writer = new StringWriter();
- writer.write("struct ZZZ { int x, y, z; };\r\n");
- writer.write("typedef struct ZZZ _FILE;\n");
- writer.write("typedef _FILE FILE;\n");
- writer.write("static void static_function(FILE * lcd){}\n");
- writer.write("int main(int argc, char **argv) {\n");
- writer.write("FILE * file = 0;\n");
- writer.write("static_function(file);\n");
- writer.write("return 0;\n");
- writer.write("}\n");
- parse(writer.toString());
- }
-
- public void testBug68623() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class A { \n");
- writer.write(" A(); \n");
- writer.write(" class sub{}; \n");
- writer.write(" sub * x; \n");
- writer.write("}; \n");
- writer.write("A::A() : x((sub *) 0) {} \n");
-
- parse(writer.toString());
-
- writer = new StringWriter();
- writer.write("class A { \n");
- writer.write(" A() : x (0) {} \n");
- writer.write(" int x; \n");
- writer.write("}; \n");
-
- parse(writer.toString());
- }
-
- public void testBug69798() throws Exception {
- Writer writer = new StringWriter();
- writer.write("enum Flags { FLAG1, FLAG2 }; \n");
- writer.write("int f() { int a, b; b = (a ? FLAG1 : 0) | FLAG2; } \n");
-
- parse(writer.toString());
- }
-
- public void testBug69662() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class A { operator float * (); }; \n");
- writer.write("A::operator float * () { } \n");
-
- parse(writer.toString());
- }
-
- public void testBug68528() throws Exception {
- Writer writer = new StringWriter();
- writer.write("namespace N526026\n");
- writer.write("{\n");
- writer.write("template <typename T>\n");
- writer.write("class T526026\n");
- writer.write("{\n");
- writer.write("typedef int diff;\n");
- writer.write("};\n");
- writer.write("\n");
- writer.write("template<typename T>\n");
- writer.write("inline T526026< T >\n");
- writer.write("operator+(typename T526026<T>::diff d, const T526026<T> & x)\n");
- writer.write("{ return T526026< T >(); }\n");
- writer.write("}\n");
- parse(writer.toString(), false);
- }
-
- public void testBug71094() throws Exception {
- Writer writer = new StringWriter();
- writer.write("using namespace DOESNOTEXIST;\n");
- writer.write("class A { int x; };\n");
- parse(writer.toString(), false);
+ public void testBug67622() throws Exception {
+ parse("const char * x = __FILE__;");
+ }
+
+ public void testBug67680() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("template < class T> class Base {}; \n");
+ writer.write("class Derived : public Base, Base<int>, foo {}; \n");
+
+ parse(writer.toString(), false);
+ }
+
+ public void testTypeIDSignature() throws Exception {
+ parse("int * v = (int*)0;");//$NON-NLS-1$
+ }
+
+ public void testUnaryAmperCast() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("void f(char *); \r\n ");
+ writer.write("void f(char ); \n ");
+ writer.write("void main() { \n ");
+ writer.write(" char * t = new char[ 5 ]; \n ");
+ writer.write(" f(&t[1]); \n ");
+ writer.write("} \n ");
+
+ parse(writer.toString());
+ }
+
+ public void testBug68235() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write(" struct xTag { int x; }; ");
+ writer.write(" typedef xTag xType; ");
+ writer.write(" typedef struct yTag { int x; } yType; ");
+ writer.write(" class C1 { xType x; yType y; }; ");
+
+ parse(writer.toString());
+ }
+
+ public void testBug60407() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("struct ZZZ { int x, y, z; };\r\n");
+ writer.write("typedef struct ZZZ _FILE;\n");
+ writer.write("typedef _FILE FILE;\n");
+ writer.write("static void static_function(FILE * lcd){}\n");
+ writer.write("int main(int argc, char **argv) {\n");
+ writer.write("FILE * file = 0;\n");
+ writer.write("static_function(file);\n");
+ writer.write("return 0;\n");
+ writer.write("}\n");
+ parse(writer.toString());
+ }
+
+ public void testBug68623() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class A { \n");
+ writer.write(" A(); \n");
+ writer.write(" class sub{}; \n");
+ writer.write(" sub * x; \n");
+ writer.write("}; \n");
+ writer.write("A::A() : x((sub *) 0) {} \n");
+
+ parse(writer.toString());
+
+ writer = new StringWriter();
+ writer.write("class A { \n");
+ writer.write(" A() : x (0) {} \n");
+ writer.write(" int x; \n");
+ writer.write("}; \n");
+
+ parse(writer.toString());
+ }
+
+ public void testBug69798() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("enum Flags { FLAG1, FLAG2 }; \n");
+ writer.write("int f() { int a, b; b = (a ? FLAG1 : 0) | FLAG2; } \n");
+
+ parse(writer.toString());
+ }
+
+ public void testBug69662() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class A { operator float * (); }; \n");
+ writer.write("A::operator float * () { } \n");
+
+ parse(writer.toString());
+ }
+
+ public void testBug68528() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("namespace N526026\n");
+ writer.write("{\n");
+ writer.write("template <typename T>\n");
+ writer.write("class T526026\n");
+ writer.write("{\n");
+ writer.write("typedef int diff;\n");
+ writer.write("};\n");
+ writer.write("\n");
+ writer.write("template<typename T>\n");
+ writer.write("inline T526026< T >\n");
+ writer.write("operator+(typename T526026<T>::diff d, const T526026<T> & x)\n");
+ writer.write("{ return T526026< T >(); }\n");
+ writer.write("}\n");
+ parse(writer.toString(), false);
+ }
+
+ public void testBug71094() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("using namespace DOESNOTEXIST;\n");
+ writer.write("class A { int x; };\n");
+ parse(writer.toString(), false);
}
public void testPredefinedSymbol_bug70928() throws Exception {
@@ -2084,9 +2068,9 @@ public class CompleteParser2Tests extends BaseTestCase {
writer.write("int func3 (void) __attribute__((id,id (3)));\n");
writer.write("int func4 (void) __attribute__((id,id (1+2)));\n");
writer.write("void (****f1)(void) __attribute__((noreturn));\n");
- writer.write("void (__attribute__((noreturn)) ****f2) (void);\n");
- writer.write("char *__attribute__((aligned(8))) *f3;\n");
- writer.write("char * __attribute__((aligned(8))) * f3;\n");
+ writer.write("void (__attribute__((noreturn)) ****f2) (void);\n");
+ writer.write("char *__attribute__((aligned(8))) *f3;\n");
+ writer.write("char * __attribute__((aligned(8))) * f3;\n");
writer.write("void fatal1 () __attribute__ ((noreturn));\n");
writer.write("int square1 (int) __attribute__ ((pure));\n");
writer.write("extern int\n");
@@ -2158,166 +2142,165 @@ public class CompleteParser2Tests extends BaseTestCase {
parse(writer.toString(), true, ParserLanguage.CPP, true);
}
- public void testBug73652() throws Exception {
- StringWriter writer = new StringWriter();
- writer.write("#define DoSuperMethodA IDoSuperMethodA\n");
- writer.write("#define IDoSuperMethodA(a,b,c) IIntuition->IDoSuperMethodA(a,b,c)\n");
+ public void testBug73652() throws Exception {
+ StringWriter writer = new StringWriter();
+ writer.write("#define DoSuperMethodA IDoSuperMethodA\n");
+ writer.write("#define IDoSuperMethodA(a,b,c) IIntuition->IDoSuperMethodA(a,b,c)\n");
writer.write("void hang(void)\n");
writer.write("{\n");
writer.write("DoSuperMethodA(0,0,0);\n");
writer.write("}\n");
- parse(writer.toString() , false);
- }
-
- public void testBug73428() throws Exception {
- parse("namespace { }");//$NON-NLS-1$
- parse("namespace { };");//$NON-NLS-1$
- parse("namespace { int abc; };");//$NON-NLS-1$
- parse("namespace { int abc; }");//$NON-NLS-1$
- }
-
- public void testBug73615() throws Exception {
- for (int i = 0; i < 2; ++i) {
- StringWriter writer = new StringWriter();
- if (i == 0)
- writer.write("class B;\n");
- writer.write("class A { A(B *); };\n");
- if (i == 0)
- parse(writer.toString());
- else
- parse(writer.toString(), false);
- }
- }
-
- public void testBug74180() throws Exception {
- parse("enum DHCPFOBoolean { false, true } additionalHB, more_payload; \n", true,
- ParserLanguage.C);
- }
-
- public void testBug72691() throws Exception {
- StringWriter writer = new StringWriter();
- writer.write("typedef int * PINT; \n");
- writer.write("typedef int * PINT; \n");
- writer.write("PINT pint; \n");
- parse(writer.toString());
- }
-
- public void testBug72691_2() throws Exception {
- StringWriter writer = new StringWriter();
- writer.write("typedef int * PINT; \n");
- writer.write("namespace N { \n");
- writer.write(" typedef int * PINT; \n");
- writer.write("} \n");
- writer.write("using namespace N; \n");
- writer.write("PINT pint; \n");
- parse(writer.toString());
- }
-
- public void testBug74328() throws Exception {
- Writer writer = new StringWriter();
- writer.write("int\n");
- writer.write("main(int argc, char **argv) {\n");
- writer.write(" char *sign;\n");
- writer.write("sign = \"\"; // IProblem generated here, syntax error\n");
- writer.write("return argc;\n");
- writer.write("}\n");
- parse(writer.toString());
- }
-
- public void testBug71733() throws Exception {
- Writer writer = new StringWriter();
- writer.write("void foo(int);\n");
- writer.write("#define BLAH() \\\n");
- writer.write(" foo (/* slash / is misinterpreted as end of comment */ \\\n");
- writer.write(" 4);\n");
- writer.write("int f() { BLAH() }\n");
- parse(writer.toString());
- }
-
- public void testBug69526() throws Exception {
- Writer writer = new StringWriter();
- writer.write("unsigned inkernel;\n");
- writer.write("#define lock_kernel() (inkernel |= 0x01)");
- writer.write("int main(int argc, char **argv) {");
- writer.write("lock_kernel();");
- writer.write("}");
- parse(writer.toString());
- }
-
- public void testBug69454() throws Exception {
- Writer writer = new StringWriter();
- writer.write("#define CATCH_ALL_EXCEPTIONS() \\\n");
- writer.write(" catch(Exception &ex) { handleException(ex); } \\\n");
- writer.write(" catch(...) { handleException(); } \n");
- writer.write("class Exception; \n");
- writer.write("void handleException(Exception & ex) {} \n");
- writer.write("void handleException() {} \n");
- writer.write("void f() { \n");
- writer.write(" try { int i; } \n");
- writer.write(" CATCH_ALL_EXCEPTIONS(); \n");
- writer.write("} \n");
-
- parse(writer.toString());
- }
-
- public void testBug72692A() throws Exception {
- Writer writer = new StringWriter();
- writer.write("extern double pow(double, double);\n");
- writer.write("extern double pow2(double, double){}\n");
- writer.write("namespace DS {\n");
- writer.write("using ::pow;\n");
- writer.write("using ::pow2;\n");
- writer.write("}\n");
- writer.write("using DS::pow;\n");
- writer.write("using DS::pow2;\n");
- parse(writer.toString());
- }
-
- public void testBug72692B() throws Exception {
- Writer writer = new StringWriter();
- writer.write("extern double pow(double, double);\n");
- writer.write("namespace DS {\n");
- writer.write("using ::pow;\n");
- writer.write("inline float pow(float __x, float __y)\n");
- writer.write("{ return ::pow(static_cast<double>(__x), static_cast<double>(__y)); }\n");
- writer.write("}\n");
- writer.write("using namespace DS;\n");
- writer.write("float foo() { double d1 = 3.0, d2 = 4.0; return pow(d1, d2); }");
- parse(writer.toString());
- }
-
- public void testBug72692C() throws Exception {
- Writer writer = new StringWriter();
- writer.write("extern double pow(double, double){}\n");
- writer.write("namespace DS {\n");
- writer.write("using ::pow;\n");
- writer.write("}\n");
- writer.write("using DS::pow;\n");
- parse(writer.toString());
- }
-
- public void testBug74575A() throws Exception {
- Writer writer = new StringWriter();
- writer.write("double pow(double, double);\n");
- writer.write("float pow(float __x, float __y)\n");
- writer.write("{ return 0; }\n");
- parse(writer.toString());
- }
-
- public void testBug75338() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class Thrown { };\n");
- writer.write("void foo() throw(Thrown);");
- parse(writer.toString());
- }
-
- public void testBug74847() throws Exception {
- String code = "class A : public FOO {};";
- parse(code, false);
- }
-
- public void testBug76696() throws Exception {
- Writer writer = new StringWriter();
+ parse(writer.toString(), false);
+ }
+
+ public void testBug73428() throws Exception {
+ parse("namespace { }");//$NON-NLS-1$
+ parse("namespace { };");//$NON-NLS-1$
+ parse("namespace { int abc; };");//$NON-NLS-1$
+ parse("namespace { int abc; }");//$NON-NLS-1$
+ }
+
+ public void testBug73615() throws Exception {
+ for (int i = 0; i < 2; ++i) {
+ StringWriter writer = new StringWriter();
+ if (i == 0)
+ writer.write("class B;\n");
+ writer.write("class A { A(B *); };\n");
+ if (i == 0)
+ parse(writer.toString());
+ else
+ parse(writer.toString(), false);
+ }
+ }
+
+ public void testBug74180() throws Exception {
+ parse("enum DHCPFOBoolean { false, true } additionalHB, more_payload; \n", true, ParserLanguage.C);
+ }
+
+ public void testBug72691() throws Exception {
+ StringWriter writer = new StringWriter();
+ writer.write("typedef int * PINT; \n");
+ writer.write("typedef int * PINT; \n");
+ writer.write("PINT pint; \n");
+ parse(writer.toString());
+ }
+
+ public void testBug72691_2() throws Exception {
+ StringWriter writer = new StringWriter();
+ writer.write("typedef int * PINT; \n");
+ writer.write("namespace N { \n");
+ writer.write(" typedef int * PINT; \n");
+ writer.write("} \n");
+ writer.write("using namespace N; \n");
+ writer.write("PINT pint; \n");
+ parse(writer.toString());
+ }
+
+ public void testBug74328() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("int\n");
+ writer.write("main(int argc, char **argv) {\n");
+ writer.write(" char *sign;\n");
+ writer.write("sign = \"\"; // IProblem generated here, syntax error\n");
+ writer.write("return argc;\n");
+ writer.write("}\n");
+ parse(writer.toString());
+ }
+
+ public void testBug71733() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("void foo(int);\n");
+ writer.write("#define BLAH() \\\n");
+ writer.write(" foo (/* slash / is misinterpreted as end of comment */ \\\n");
+ writer.write(" 4);\n");
+ writer.write("int f() { BLAH() }\n");
+ parse(writer.toString());
+ }
+
+ public void testBug69526() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("unsigned inkernel;\n");
+ writer.write("#define lock_kernel() (inkernel |= 0x01)");
+ writer.write("int main(int argc, char **argv) {");
+ writer.write("lock_kernel();");
+ writer.write("}");
+ parse(writer.toString());
+ }
+
+ public void testBug69454() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("#define CATCH_ALL_EXCEPTIONS() \\\n");
+ writer.write(" catch(Exception &ex) { handleException(ex); } \\\n");
+ writer.write(" catch(...) { handleException(); } \n");
+ writer.write("class Exception; \n");
+ writer.write("void handleException(Exception & ex) {} \n");
+ writer.write("void handleException() {} \n");
+ writer.write("void f() { \n");
+ writer.write(" try { int i; } \n");
+ writer.write(" CATCH_ALL_EXCEPTIONS(); \n");
+ writer.write("} \n");
+
+ parse(writer.toString());
+ }
+
+ public void testBug72692A() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("extern double pow(double, double);\n");
+ writer.write("extern double pow2(double, double){}\n");
+ writer.write("namespace DS {\n");
+ writer.write("using ::pow;\n");
+ writer.write("using ::pow2;\n");
+ writer.write("}\n");
+ writer.write("using DS::pow;\n");
+ writer.write("using DS::pow2;\n");
+ parse(writer.toString());
+ }
+
+ public void testBug72692B() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("extern double pow(double, double);\n");
+ writer.write("namespace DS {\n");
+ writer.write("using ::pow;\n");
+ writer.write("inline float pow(float __x, float __y)\n");
+ writer.write("{ return ::pow(static_cast<double>(__x), static_cast<double>(__y)); }\n");
+ writer.write("}\n");
+ writer.write("using namespace DS;\n");
+ writer.write("float foo() { double d1 = 3.0, d2 = 4.0; return pow(d1, d2); }");
+ parse(writer.toString());
+ }
+
+ public void testBug72692C() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("extern double pow(double, double){}\n");
+ writer.write("namespace DS {\n");
+ writer.write("using ::pow;\n");
+ writer.write("}\n");
+ writer.write("using DS::pow;\n");
+ parse(writer.toString());
+ }
+
+ public void testBug74575A() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("double pow(double, double);\n");
+ writer.write("float pow(float __x, float __y)\n");
+ writer.write("{ return 0; }\n");
+ parse(writer.toString());
+ }
+
+ public void testBug75338() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class Thrown { };\n");
+ writer.write("void foo() throw(Thrown);");
+ parse(writer.toString());
+ }
+
+ public void testBug74847() throws Exception {
+ String code = "class A : public FOO {};";
+ parse(code, false);
+ }
+
+ public void testBug76696() throws Exception {
+ Writer writer = new StringWriter();
writer.write(" void f(){ \n");
writer.write(" if (A a) { \n");
writer.write(" } else { \n");
@@ -2325,200 +2308,200 @@ public class CompleteParser2Tests extends BaseTestCase {
writer.write(" } \n");
parse(writer.toString(), false);
- }
-
- public void testBug74069() throws Exception {
- Writer writer = new StringWriter();
- writer.write("int f() { \n");
- writer.write(" int a, b, c; \n");
- writer.write(" if (a < b) \n");
- writer.write(" if (b < c) \n");
- writer.write(" return b; \n");
- writer.write(" else if (a < c) \n");
- writer.write(" return c; \n");
- writer.write(" else \n");
- writer.write(" return a; \n");
- writer.write(" else if (a < c) \n");
- writer.write(" return a; \n");
- writer.write(" else if (b < c) \n");
- writer.write(" return c; \n");
- writer.write(" else \n");
- writer.write(" return b; \n");
- writer.write("} \n");
-
- parse(writer.toString());
- }
-
- public void testBug77805() throws Exception {
- Writer writer = new StringWriter();
- writer.write("#if X // Do something only if X is true\n");
- writer.write("/* some statements */\n");
- writer.write("#endif\n");
- parse(writer.toString());
- }
-
- public void testBug77821() throws Exception {
- Writer writer = new StringWriter();
- writer.write("typedef struct { /* ... */ }TYPE;\n");
- writer.write("void ptrArith(const TYPE* pType) {\n");
- writer.write("TYPE *temp = 0;\n");
- writer.write("temp = (TYPE*)(pType + 1); /* Parser error is here */\n}\n");
- parse(writer.toString());
- }
-
- public void testBug77009() throws Exception {
+ }
+
+ public void testBug74069() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("int f() { \n");
+ writer.write(" int a, b, c; \n");
+ writer.write(" if (a < b) \n");
+ writer.write(" if (b < c) \n");
+ writer.write(" return b; \n");
+ writer.write(" else if (a < c) \n");
+ writer.write(" return c; \n");
+ writer.write(" else \n");
+ writer.write(" return a; \n");
+ writer.write(" else if (a < c) \n");
+ writer.write(" return a; \n");
+ writer.write(" else if (b < c) \n");
+ writer.write(" return c; \n");
+ writer.write(" else \n");
+ writer.write(" return b; \n");
+ writer.write("} \n");
+
+ parse(writer.toString());
+ }
+
+ public void testBug77805() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("#if X // Do something only if X is true\n");
+ writer.write("/* some statements */\n");
+ writer.write("#endif\n");
+ parse(writer.toString());
+ }
+
+ public void testBug77821() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("typedef struct { /* ... */ }TYPE;\n");
+ writer.write("void ptrArith(const TYPE* pType) {\n");
+ writer.write("TYPE *temp = 0;\n");
+ writer.write("temp = (TYPE*)(pType + 1); /* Parser error is here */\n}\n");
+ parse(writer.toString());
+ }
+
+ public void testBug77009() throws Exception {
parse("int foo(volatile int &);\n");
}
- public void testBug77281() throws Exception {
- Writer writer = new StringWriter();
- writer.write("void fun2(float a, float b) {}\n");
+ public void testBug77281() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("void fun2(float a, float b) {}\n");
writer.write("int main() { fun2(0.24f, 0.25f); }\n");
- parse(writer.toString());
- }
-
- public void testBug77921() throws Exception {
- Writer writer = new StringWriter();
- writer.write("void f()\n{\n");
- writer.write("static float v0[] = { -1.0f, -1.0f, 1.0f };\n}\n");
- parse(writer.toString());
- }
-
- public void testBug71317A() throws Exception {
- Writer writer = new StringWriter();
- writer.write("void f();\n");
- writer.write("namespace NS {\n");
- writer.write("using ::f;\n");
- writer.write("using ::f;\n}");
- parse(writer.toString());
- }
-
- public void testBug71317B() throws Exception {
- Writer writer = new StringWriter();
- writer.write("void f();\n");
- writer.write("namespace NS {\n");
- writer.write("void f();\n");
- writer.write("using ::f;\n}");
- parse(writer.toString());
- }
-
- public void testBug77097() throws Exception {
- Writer writer = new StringWriter();
- writer.write("#define SOME_MACRO() { \\\r\n");
- writer.write("printf(\"Hello World\"); \\\r\n");
- writer.write("printf(\"Good morning\"); \\\r\n");
- parse(writer.toString());
- }
-
- public void testBug77276() throws Exception {
- Writer writer = new StringWriter();
- writer.write("#if (!defined(OS_LIBMODE_R) && !defined(OS_LIBMODE_RP) && \\\r\n");
- writer.write("!defined(OS_LIBMODE_T))\r\n");
- writer.write("#define OS_LIBMODE_DP\r\n");
- writer.write("#endif\r\n");
- parse(writer.toString());
- }
-
- public void testBug78165() throws Exception {
- Writer writer = new StringWriter();
- writer.write("struct Node {\n");
- writer.write("struct Node* Next; // OK: Refers to Node at global scope\n");
- writer.write("struct Data* Data; // OK: Declares type Data at global scope and member Data\n");
- writer.write("};\n");
- writer.write("struct Data {\n");
- writer.write("struct Node* Node; // OK: Refers to Node at global scope\n");
- writer.write("friend struct Glob; // OK: Refers to (as yet) undeclared Glob at global scope.\n");
- writer.write("};\n");
- writer.write("struct Base {\n");
- writer.write("struct Data; // OK: Declares nested Data\n");
- writer.write("struct ::Data* thatData; // OK: Refers to ::Data\n");
- writer.write("struct Base::Data* thisData; // OK: Refers to nested Data\n");
- writer.write("friend class ::Data; // OK: global Data is a friend\n");
- writer.write("friend class Data; // OK: nested Data is a friend\n");
- writer.write("struct Data { /* ... */ }; // Defines nested Data\n");
- writer.write("struct Data; // OK: Redeclares nested Data\n");
- writer.write("};\n");
- writer.write("struct Data; // OK: Redeclares Data at global scope\n");
- writer.write("struct Base::Data* pBase; // OK: refers to nested Data\n");
-
- parse(writer.toString());
- }
-
- public void testBug103560() throws Exception {
- Writer writer = new StringWriter();
- writer.write("#define A(a, b) a ## b \n");
- writer.write("#define FOOBAR 1 \n");
- writer.write("int i = A(FOO, BAR); \n");
- parse(writer.toString(), true, ParserLanguage.CPP);
- }
-
- public void test158192_declspec_on_class() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class __declspec(foobar) Foo1 {};\n");
- writer.write("union __declspec(foobar) Foo2 {};\n");
- writer.write("struct __declspec(foobar) Foo3 {};\n");
- IASTTranslationUnit tu = parse(writer.toString(), true, ParserLanguage.CPP, true);
-
- NameCollector col = new NameCollector();
- tu.accept(col);
-
- assertEquals(3, col.size());
- ICompositeType fooClass = (ICompositeType) col.getName(0).resolveBinding();
- ICompositeType fooUnion = (ICompositeType) col.getName(1).resolveBinding();
- ICompositeType fooStruct = (ICompositeType) col.getName(2).resolveBinding();
-
- assertEquals(ICPPClassType.k_class, fooClass.getKey());
- assertEquals(ICompositeType.k_union, fooUnion.getKey());
- assertEquals(ICompositeType.k_struct, fooStruct.getKey());
-
- assertInstances(col, fooClass, 1);
- assertInstances(col, fooUnion, 1);
- assertInstances(col, fooStruct, 1);
- }
-
- public void test158192_declspec_on_variable() throws Exception {
- Writer writer = new StringWriter();
- writer.write("__declspec(foobar) class Foo {} bar;\n");
- IASTTranslationUnit tu = parse(writer.toString(), true, ParserLanguage.CPP, true);
-
- NameCollector col = new NameCollector();
- tu.accept(col);
-
- assertEquals(2, col.size());
- ICompositeType fooClass = (ICompositeType) col.getName(0).resolveBinding();
- ICPPVariable bar = (ICPPVariable) col.getName(1).resolveBinding();
-
- assertInstances(col, fooClass, 1);
- assertInstances(col, bar, 1);
- }
-
- public void test158192_declspec_in_declarator() throws Exception {
- Writer writer = new StringWriter();
-
- writer.write("int * __declspec(foo) bar = 0;\n");
- IASTTranslationUnit tu = parse(writer.toString(), true, ParserLanguage.CPP, true);
-
- IASTProblem[] problems = CPPVisitor.getProblems(tu);
- assertFalse("__declspec rejected inside declarator", problems.length > 0);
-
- NameCollector col = new NameCollector();
- tu.accept(col);
-
- assertEquals(1, col.size());
- ICPPVariable bar = (ICPPVariable) col.getName(0).resolveBinding();
-
- assertInstances(col, bar, 1);
- }
-
- public void test173874_nestedClasses() throws Exception {
- String code = "class aClass { class bClass; int x; };";
- IASTTranslationUnit tu = parse(code, true, ParserLanguage.CPP, true);
-
- NameCollector col = new NameCollector();
- tu.accept(col);
-
- ICPPClassType cls = (ICPPClassType)col.getName(0).resolveBinding();
- ICPPClassType[] nested = cls.getNestedClasses();
- assertEquals(1, nested.length);
- }
+ parse(writer.toString());
+ }
+
+ public void testBug77921() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("void f()\n{\n");
+ writer.write("static float v0[] = { -1.0f, -1.0f, 1.0f };\n}\n");
+ parse(writer.toString());
+ }
+
+ public void testBug71317A() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("void f();\n");
+ writer.write("namespace NS {\n");
+ writer.write("using ::f;\n");
+ writer.write("using ::f;\n}");
+ parse(writer.toString());
+ }
+
+ public void testBug71317B() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("void f();\n");
+ writer.write("namespace NS {\n");
+ writer.write("void f();\n");
+ writer.write("using ::f;\n}");
+ parse(writer.toString());
+ }
+
+ public void testBug77097() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("#define SOME_MACRO() { \\\r\n");
+ writer.write("printf(\"Hello World\"); \\\r\n");
+ writer.write("printf(\"Good morning\"); \\\r\n");
+ parse(writer.toString());
+ }
+
+ public void testBug77276() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("#if (!defined(OS_LIBMODE_R) && !defined(OS_LIBMODE_RP) && \\\r\n");
+ writer.write("!defined(OS_LIBMODE_T))\r\n");
+ writer.write("#define OS_LIBMODE_DP\r\n");
+ writer.write("#endif\r\n");
+ parse(writer.toString());
+ }
+
+ public void testBug78165() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("struct Node {\n");
+ writer.write("struct Node* Next; // OK: Refers to Node at global scope\n");
+ writer.write("struct Data* Data; // OK: Declares type Data at global scope and member Data\n");
+ writer.write("};\n");
+ writer.write("struct Data {\n");
+ writer.write("struct Node* Node; // OK: Refers to Node at global scope\n");
+ writer.write("friend struct Glob; // OK: Refers to (as yet) undeclared Glob at global scope.\n");
+ writer.write("};\n");
+ writer.write("struct Base {\n");
+ writer.write("struct Data; // OK: Declares nested Data\n");
+ writer.write("struct ::Data* thatData; // OK: Refers to ::Data\n");
+ writer.write("struct Base::Data* thisData; // OK: Refers to nested Data\n");
+ writer.write("friend class ::Data; // OK: global Data is a friend\n");
+ writer.write("friend class Data; // OK: nested Data is a friend\n");
+ writer.write("struct Data { /* ... */ }; // Defines nested Data\n");
+ writer.write("struct Data; // OK: Redeclares nested Data\n");
+ writer.write("};\n");
+ writer.write("struct Data; // OK: Redeclares Data at global scope\n");
+ writer.write("struct Base::Data* pBase; // OK: refers to nested Data\n");
+
+ parse(writer.toString());
+ }
+
+ public void testBug103560() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("#define A(a, b) a ## b \n");
+ writer.write("#define FOOBAR 1 \n");
+ writer.write("int i = A(FOO, BAR); \n");
+ parse(writer.toString(), true, ParserLanguage.CPP);
+ }
+
+ public void test158192_declspec_on_class() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class __declspec(foobar) Foo1 {};\n");
+ writer.write("union __declspec(foobar) Foo2 {};\n");
+ writer.write("struct __declspec(foobar) Foo3 {};\n");
+ IASTTranslationUnit tu = parse(writer.toString(), true, ParserLanguage.CPP, true);
+
+ NameCollector col = new NameCollector();
+ tu.accept(col);
+
+ assertEquals(3, col.size());
+ ICompositeType fooClass = (ICompositeType) col.getName(0).resolveBinding();
+ ICompositeType fooUnion = (ICompositeType) col.getName(1).resolveBinding();
+ ICompositeType fooStruct = (ICompositeType) col.getName(2).resolveBinding();
+
+ assertEquals(ICPPClassType.k_class, fooClass.getKey());
+ assertEquals(ICompositeType.k_union, fooUnion.getKey());
+ assertEquals(ICompositeType.k_struct, fooStruct.getKey());
+
+ assertInstances(col, fooClass, 1);
+ assertInstances(col, fooUnion, 1);
+ assertInstances(col, fooStruct, 1);
+ }
+
+ public void test158192_declspec_on_variable() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("__declspec(foobar) class Foo {} bar;\n");
+ IASTTranslationUnit tu = parse(writer.toString(), true, ParserLanguage.CPP, true);
+
+ NameCollector col = new NameCollector();
+ tu.accept(col);
+
+ assertEquals(2, col.size());
+ ICompositeType fooClass = (ICompositeType) col.getName(0).resolveBinding();
+ ICPPVariable bar = (ICPPVariable) col.getName(1).resolveBinding();
+
+ assertInstances(col, fooClass, 1);
+ assertInstances(col, bar, 1);
+ }
+
+ public void test158192_declspec_in_declarator() throws Exception {
+ Writer writer = new StringWriter();
+
+ writer.write("int * __declspec(foo) bar = 0;\n");
+ IASTTranslationUnit tu = parse(writer.toString(), true, ParserLanguage.CPP, true);
+
+ IASTProblem[] problems = CPPVisitor.getProblems(tu);
+ assertFalse("__declspec rejected inside declarator", problems.length > 0);
+
+ NameCollector col = new NameCollector();
+ tu.accept(col);
+
+ assertEquals(1, col.size());
+ ICPPVariable bar = (ICPPVariable) col.getName(0).resolveBinding();
+
+ assertInstances(col, bar, 1);
+ }
+
+ public void test173874_nestedClasses() throws Exception {
+ String code = "class aClass { class bClass; int x; };";
+ IASTTranslationUnit tu = parse(code, true, ParserLanguage.CPP, true);
+
+ NameCollector col = new NameCollector();
+ tu.accept(col);
+
+ ICPPClassType cls = (ICPPClassType) col.getName(0).resolveBinding();
+ ICPPClassType[] nested = cls.getNestedClasses();
+ assertEquals(1, nested.length);
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMFileBasePluginTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMFileBasePluginTest.java
index 3ec01f9e9b3..15ca397d23e 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMFileBasePluginTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMFileBasePluginTest.java
@@ -40,15 +40,15 @@ import org.eclipse.core.runtime.NullProgressMonitor;
* @author dsteffle
*/
public class DOMFileBasePluginTest extends TestCase {
- static NullProgressMonitor monitor;
- static IWorkspace workspace;
- static IProject project;
- static FileManager fileManager;
- static int numProjects = 0;
- static Class className;
+ static NullProgressMonitor monitor;
+ static IWorkspace workspace;
+ static IProject project;
+ static FileManager fileManager;
+ static int numProjects = 0;
+ static Class className;
static ICProject cPrj;
- public DOMFileBasePluginTest() {
+ public DOMFileBasePluginTest() {
}
public DOMFileBasePluginTest(String name) {
@@ -56,112 +56,111 @@ public class DOMFileBasePluginTest extends TestCase {
}
private void initialize(Class aClassName) {
- if( CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null){
+ if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null) {
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
monitor = new NullProgressMonitor();
-
+
workspace = ResourcesPlugin.getWorkspace();
-
- try {
- cPrj = CProjectHelper.createCCProject("ParserTestProject", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
- project = cPrj.getProject();
-
- // ugly
- if (className == null || !className.equals(aClassName)) {
- className = aClassName;
- numProjects++;
- }
- } catch ( CoreException e ) {
- /*boo*/
- }
+
+ try {
+ cPrj = CProjectHelper.createCCProject("ParserTestProject", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
+ project = cPrj.getProject();
+
+ // ugly
+ if (className == null || !className.equals(aClassName)) {
+ className = aClassName;
+ numProjects++;
+ }
+ } catch (CoreException e) {
+ /*boo*/
+ }
if (project == null)
throw new NullPointerException("Unable to create project"); //$NON-NLS-1$
-
-
+
//Create file manager
fileManager = new FileManager();
- }
- }
-
- public DOMFileBasePluginTest(String name, Class className)
- {
- super(name);
- initialize(className);
- }
-
- public void cleanupProject() throws Exception {
- numProjects--;
-
- try{
- if (numProjects == 0) {
- project.delete( true, false, monitor );
- project = null;
- }
- } catch( Throwable e ){
- /*boo*/
- }
- }
-
- @Override
+ }
+ }
+
+ public DOMFileBasePluginTest(String name, Class className) {
+ super(name);
+ initialize(className);
+ }
+
+ public void cleanupProject() throws Exception {
+ numProjects--;
+
+ try {
+ if (numProjects == 0) {
+ project.delete(true, false, monitor);
+ project = null;
+ }
+ } catch (Throwable e) {
+ /*boo*/
+ }
+ }
+
+ @Override
protected void tearDown() throws Exception {
- if( project == null || !project.exists() )
- return;
-
- IResource [] members = project.members();
- for( int i = 0; i < members.length; i++ ){
- if( members[i].getName().equals( ".project" ) || members[i].getName().equals( ".cproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$
- continue;
- if (members[i].getName().equals(".settings"))
- continue;
- try{
- members[i].delete( false, monitor );
- } catch( Throwable e ){
- /*boo*/
- }
- }
+ if (project == null || !project.exists())
+ return;
+
+ IResource[] members = project.members();
+ for (int i = 0; i < members.length; i++) {
+ if (members[i].getName().equals(".project") || members[i].getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
+ continue;
+ if (members[i].getName().equals(".settings"))
+ continue;
+ try {
+ members[i].delete(false, monitor);
+ } catch (Throwable e) {
+ /*boo*/
+ }
+ }
}
- // below can be used to work with large files (too large for memory)
-// protected IFile importFile(String fileName) throws Exception {
-// IFile file = cPrj.getProject().getFile(fileName);
-// if (!file.exists()) {
-// try{
-// FileInputStream fileIn = new FileInputStream(
-// CTestPlugin.getDefault().getFileInPlugin(new Path("resources/parser/" + fileName)));
-// file.create(fileIn,false, monitor);
-// } catch (CoreException e) {
-// e.printStackTrace();
-// } catch (FileNotFoundException e) {
-// e.printStackTrace();
-// }
-// }
-//
-// return file;
-// }
-
- protected IFolder importFolder(String folderName) throws Exception {
- IFolder folder = project.getProject().getFolder(folderName);
-
+ // below can be used to work with large files (too large for memory)
+ // protected IFile importFile(String fileName) throws Exception {
+ // IFile file = cPrj.getProject().getFile(fileName);
+ // if (!file.exists()) {
+ // try{
+ // FileInputStream fileIn = new FileInputStream(
+ // CTestPlugin.getDefault().getFileInPlugin(new Path("resources/parser/" + fileName)));
+ // file.create(fileIn,false, monitor);
+ // } catch (CoreException e) {
+ // e.printStackTrace();
+ // } catch (FileNotFoundException e) {
+ // e.printStackTrace();
+ // }
+ // }
+ //
+ // return file;
+ // }
+
+ protected IFolder importFolder(String folderName) throws Exception {
+ IFolder folder = project.getProject().getFolder(folderName);
+
//Create file input stream
- if( !folder.exists() )
- folder.create( false, false, monitor );
-
+ if (!folder.exists())
+ folder.create(false, false, monitor);
+
return folder;
- }
- public IFile importFile(String fileName, String contents ) throws Exception{
+ }
+
+ public IFile importFile(String fileName, String contents) throws Exception {
//Obtain file handle
IFile file = project.getProject().getFile(fileName);
-
- InputStream stream = new ByteArrayInputStream( contents.getBytes() );
+
+ InputStream stream = new ByteArrayInputStream(contents.getBytes());
//Create file input stream
- if( file.exists() )
- file.setContents( stream, false, false, monitor );
+ if (file.exists())
+ file.setContents(stream, false, false, monitor);
else
- file.create( stream, false, monitor );
-
+ file.create(stream, false, monitor);
+
fileManager.addFile(file);
-
+
return file;
}
-
+
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCParserExtensionTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCParserExtensionTestSuite.java
index dd588742150..e07a843f9fd 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCParserExtensionTestSuite.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCParserExtensionTestSuite.java
@@ -24,12 +24,12 @@ import junit.framework.TestSuite;
public class DOMGCCParserExtensionTestSuite extends TestCase {
public static Test suite() {
- TestSuite suite= new TestSuite(DOMGCCParserExtensionTestSuite.class.getName());
-// suite.addTestSuite( GCCScannerExtensionsTest.class );
-// suite.addTestSuite( GCCQuickParseExtensionsTest.class );
-// suite.addTestSuite( GCCCompleteParseExtensionsTest.class );
- suite.addTestSuite( DOMGCCSelectionParseExtensionsTest.class);
+ TestSuite suite = new TestSuite(DOMGCCParserExtensionTestSuite.class.getName());
+ // suite.addTestSuite( GCCScannerExtensionsTest.class );
+ // suite.addTestSuite( GCCQuickParseExtensionsTest.class );
+ // suite.addTestSuite( GCCCompleteParseExtensionsTest.class );
+ suite.addTestSuite(DOMGCCSelectionParseExtensionsTest.class);
return suite;
}
-
+
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCSelectionParseExtensionsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCSelectionParseExtensionsTest.java
index a31a0140b5a..d7072b53209 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCSelectionParseExtensionsTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCSelectionParseExtensionsTest.java
@@ -35,14 +35,13 @@ public class DOMGCCSelectionParseExtensionsTest extends DOMSelectionParseTestBas
super(name, DOMGCCSelectionParseExtensionsTest.class);
}
- public void testBug43021() throws Exception
- {
+ public void testBug43021() throws Exception {
Writer writer = new StringWriter();
- writer.write( "extern int johnc(__const char *__restrict __format, ...);\n" ); //$NON-NLS-1$
- writer.write( "void m() {johnc(\"HI\");}" ); //$NON-NLS-1$
+ writer.write("extern int johnc(__const char *__restrict __format, ...);\n"); //$NON-NLS-1$
+ writer.write("void m() {johnc(\"HI\");}"); //$NON-NLS-1$
String code = writer.toString();
- int startIndex = code.indexOf( "{johnc") + 1; //$NON-NLS-1$
- IASTNode node = parse( code, startIndex, startIndex + 5 );
- assertNotNull( node );
+ int startIndex = code.indexOf("{johnc") + 1; //$NON-NLS-1$
+ IASTNode node = parse(code, startIndex, startIndex + 5);
+ assertNotNull(node);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationMacroTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationMacroTests.java
index a105e0ef215..8a2de1cfbd7 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationMacroTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationMacroTests.java
@@ -41,446 +41,448 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
public class DOMLocationMacroTests extends AST2TestBase {
final ParserLanguage[] languages = new ParserLanguage[] { ParserLanguage.C, ParserLanguage.CPP };
-
- public DOMLocationMacroTests() {
+
+ public DOMLocationMacroTests() {
}
public DOMLocationMacroTests(String name) {
super(name);
}
- public void testObjectStyleMacroExpansionSimpleDeclarator() throws Exception
- {
- StringBuilder buffer = new StringBuilder( "#define ABC D\n" ); //$NON-NLS-1$
- buffer.append( "int ABC;"); //$NON-NLS-1$
- String code = buffer.toString();
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTPreprocessorObjectStyleMacroDefinition ABC = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[0];
- IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTDeclarator d = var.getDeclarators()[0];
- assertEquals( d.getName().toString(), "D"); //$NON-NLS-1$
- IASTNodeLocation [] declaratorLocations = d.getNodeLocations();
- assertEquals( declaratorLocations.length, 1 );
- IASTMacroExpansionLocation expansion = (IASTMacroExpansionLocation) declaratorLocations[0];
- IASTPreprocessorObjectStyleMacroDefinition fromExpansion = (IASTPreprocessorObjectStyleMacroDefinition) expansion.getExpansion().getMacroDefinition();
- assertEqualsMacros( fromExpansion, ABC );
- assertEquals( expansion.getNodeOffset(), 0 );
- assertEquals( expansion.getNodeLength(), 1 );
- IASTNodeLocation [] macroLocation = expansion.getExpansion().getNodeLocations();
- assertEquals( macroLocation.length, 1 );
- assertTrue( macroLocation[0] instanceof IASTFileLocation );
- assertEquals( macroLocation[0].getNodeOffset(), code.indexOf( "int ABC;") + "int ".length() ); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals( macroLocation[0].getNodeLength(), "ABC".length() ); //$NON-NLS-1$
- }
- }
-
- public void testObjectMacroExpansionModestDeclarator() throws Exception
- {
- StringBuilder buffer = new StringBuilder( "#define ABC * D\n" ); //$NON-NLS-1$
- buffer.append( "int ABC;"); //$NON-NLS-1$
- String code = buffer.toString();
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTPreprocessorObjectStyleMacroDefinition ABC = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[0];
- IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTDeclarator d = var.getDeclarators()[0];
- assertEquals( d.getName().toString(), "D"); //$NON-NLS-1$
- assertEquals( d.getPointerOperators().length, 1 );
- IASTNodeLocation [] declaratorLocations = d.getNodeLocations();
- assertEquals( declaratorLocations.length, 1 );
- IASTMacroExpansionLocation expansion = (IASTMacroExpansionLocation) declaratorLocations[0];
- IASTPreprocessorObjectStyleMacroDefinition fromExpansion = (IASTPreprocessorObjectStyleMacroDefinition) expansion.getExpansion().getMacroDefinition();
- assertEqualsMacros( fromExpansion, ABC );
- assertEquals( expansion.getNodeOffset(), 0 );
- assertEquals( 2, expansion.getNodeLength() );
- IASTNodeLocation [] macroLocation = expansion.getExpansion().getNodeLocations();
- assertEquals( macroLocation.length, 1 );
- assertTrue( macroLocation[0] instanceof IASTFileLocation );
- assertEquals( macroLocation[0].getNodeOffset(), code.indexOf( "int ABC;") + "int ".length() ); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals( macroLocation[0].getNodeLength(), "ABC".length() ); //$NON-NLS-1$
-
- IASTName n = d.getName();
- IASTNodeLocation [] nameLocations = n.getNodeLocations();
- assertEquals( nameLocations.length, 1 );
- final IASTMacroExpansionLocation nodeLocation = (IASTMacroExpansionLocation) nameLocations[0];
- assertEquals( nodeLocation.getNodeOffset(), 1 );
- assertEquals( nodeLocation.getNodeLength(), 1 );
-
- assertEquals( nodeLocation.getExpansion().getNodeLocations()[0].getNodeOffset(), macroLocation[0].getNodeOffset() );
- assertEquals( nodeLocation.getExpansion().getNodeLocations()[0].getNodeLength(), macroLocation[0].getNodeLength() );
-
- IASTPointer po = (IASTPointer) d.getPointerOperators()[0];
- assertFalse( po.isConst() );
- assertFalse( po.isVolatile() );
- IASTMacroExpansionLocation pointerLocation = (IASTMacroExpansionLocation) po.getNodeLocations()[0];
- assertEquals( pointerLocation.getNodeOffset(), 0 );
- assertEquals( pointerLocation.getNodeLength(), 1 );
- assertEquals( pointerLocation.getExpansion().getNodeLocations()[0].getNodeOffset(), macroLocation[0].getNodeOffset() );
- assertEquals( pointerLocation.getExpansion().getNodeLocations()[0].getNodeLength(), macroLocation[0].getNodeLength() );
- assertEqualsMacros( pointerLocation.getExpansion().getMacroDefinition(), nodeLocation.getExpansion().getMacroDefinition() );
- }
- }
-
- public void testObjectMacroExpansionPartialDeclSpec() throws Exception
- {
- StringBuilder buffer = new StringBuilder( "#define XYZ const\n"); //$NON-NLS-1$
- buffer.append( "XYZ int var;"); //$NON-NLS-1$
- String code = buffer.toString();
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTPreprocessorObjectStyleMacroDefinition defXYZ = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[0];
- IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTSimpleDeclSpecifier declSpec = (IASTSimpleDeclSpecifier) var.getDeclSpecifier();
- IASTNodeLocation [] declSpecLocations = declSpec.getNodeLocations();
- assertEquals( declSpecLocations.length, 2 );
- IASTMacroExpansionLocation expansion = (IASTMacroExpansionLocation) declSpecLocations[0];
- assertEqualsMacros( defXYZ, expansion.getExpansion().getMacroDefinition() );
- assertEquals( expansion.getNodeOffset(), 0 );
- assertEquals( expansion.getNodeLength(), 1 );
- IASTNodeLocation [] expansionLocations = expansion.getExpansion().getNodeLocations();
- assertEquals( expansionLocations.length, 1 );
- assertTrue( expansionLocations[0] instanceof IASTFileLocation );
- assertEquals( expansionLocations[0].getNodeOffset(), code.indexOf( "XYZ int")); //$NON-NLS-1$
- assertEquals( expansionLocations[0].getNodeLength(), "XYZ".length()); //$NON-NLS-1$
- IASTFileLocation second = (IASTFileLocation) declSpecLocations[1];
- assertEquals( second.getNodeOffset(), code.indexOf( " int") ); //$NON-NLS-1$
- assertEquals( second.getNodeLength(), " int".length() ); //$NON-NLS-1$
- }
- }
-
- public void testObjectMacroExpansionNested() throws Exception
- {
- StringBuilder buffer = new StringBuilder( "#define XYZ const\n"); //$NON-NLS-1$
- buffer.append( "#define PO *\n"); //$NON-NLS-1$
- buffer.append( "#define C_PO PO XYZ\n"); //$NON-NLS-1$
- buffer.append( "int C_PO var;"); //$NON-NLS-1$
- String code = buffer.toString();
-
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- final IASTPreprocessorMacroDefinition[] macroDefinitions = tu.getMacroDefinitions();
- IASTPreprocessorMacroDefinition XYZ = macroDefinitions[0];
- IASTPreprocessorMacroDefinition PO = macroDefinitions[1];
- IASTPreprocessorMacroDefinition C_PO = macroDefinitions[2];
- IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- assertTrue( var.getDeclarators()[0].getPointerOperators().length > 0 );
- IASTNodeLocation [] locations = var.getNodeLocations();
- assertEquals( 3, locations.length);
- IASTFileLocation start_loc = (IASTFileLocation) locations[0];
- assertEquals( start_loc.getNodeOffset(), code.indexOf( "int") ); //$NON-NLS-1$
- assertEquals( start_loc.getNodeLength(), "int ".length()); //$NON-NLS-1$
- IASTMacroExpansionLocation mac_loc = (IASTMacroExpansionLocation) locations[1];
- final IASTPreprocessorMacroDefinition C_PO2 = mac_loc.getExpansion().getMacroDefinition();
- assertEqualsMacros( C_PO, C_PO2 );
- assertEquals( 0, mac_loc.getNodeOffset());
- assertEquals( 2, mac_loc.getNodeLength() );
- IASTFileLocation end_loc = (IASTFileLocation) locations[2];
- assertEquals( code.indexOf( " var"), end_loc.getNodeOffset() ); //$NON-NLS-1$
- assertEquals( " var;".length(), end_loc.getNodeLength() ); //$NON-NLS-1$
- }
- }
-
- public void testObjectMacroExpansionComplex() throws Exception
- {
- StringBuilder buffer = new StringBuilder( "#define XYZ const\n"); //$NON-NLS-1$
- buffer.append( "#define PO *\n"); //$NON-NLS-1$
- buffer.append( "#define C_PO PO XYZ\n"); //$NON-NLS-1$
- buffer.append( "#define IT int\n"); //$NON-NLS-1$
- buffer.append( "#define V var\n"); //$NON-NLS-1$
- buffer.append( "XYZ IT C_PO C_PO V;"); //$NON-NLS-1$
- String code = buffer.toString();
-
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTPreprocessorObjectStyleMacroDefinition XYZ = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[0];
-// IASTPreprocessorObjectStyleMacroDefinition PO = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[1];
- IASTPreprocessorObjectStyleMacroDefinition C_PO = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[2];
- IASTPreprocessorObjectStyleMacroDefinition IT = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[3];
- IASTPreprocessorObjectStyleMacroDefinition V = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[4];
-
- IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- final IASTNodeLocation[] nodeLocations = var.getNodeLocations();
-
- assertEquals( 10, nodeLocations.length );
- IASTMacroExpansionLocation first_loc = (IASTMacroExpansionLocation) nodeLocations[0];
- assertEqualsMacros( first_loc.getExpansion().getMacroDefinition(), XYZ );
- IASTFileLocation second_loc = (IASTFileLocation) nodeLocations[1];
- assertEquals( 1, second_loc.getNodeLength() );
- IASTMacroExpansionLocation third_loc = (IASTMacroExpansionLocation) nodeLocations[2];
- assertEqualsMacros( third_loc.getExpansion().getMacroDefinition(), IT );
- IASTFileLocation fourth_loc = (IASTFileLocation) nodeLocations[3];
- assertEquals( 1, fourth_loc.getNodeLength() );
- IASTMacroExpansionLocation fifth_loc = (IASTMacroExpansionLocation) nodeLocations[4];
- assertEqualsMacros( fifth_loc.getExpansion().getMacroDefinition(), C_PO );
- IASTFileLocation sixth_loc = (IASTFileLocation) nodeLocations[5];
- assertEquals( 1, sixth_loc.getNodeLength() );
- IASTMacroExpansionLocation seventh_loc = (IASTMacroExpansionLocation) nodeLocations[6];
- assertEqualsMacros( seventh_loc.getExpansion().getMacroDefinition(), C_PO );
- IASTFileLocation eighth_loc = (IASTFileLocation) nodeLocations[7];
- assertEquals( 1, eighth_loc.getNodeLength() );
- IASTMacroExpansionLocation ninth_loc = (IASTMacroExpansionLocation) nodeLocations[8];
- assertEqualsMacros( ninth_loc.getExpansion().getMacroDefinition(), V );
- IASTFileLocation tenth_loc = (IASTFileLocation) nodeLocations[9];
- assertEquals( 1, tenth_loc.getNodeLength() );
-
- final IASTFileLocation flatLocation = var.getFileLocation();
- assertNotNull( flatLocation);
- assertEquals( code.indexOf("XYZ IT C_PO C_PO V;"), flatLocation.getNodeOffset() ); //$NON-NLS-1$
- assertEquals( "XYZ IT C_PO C_PO V;".length(), flatLocation.getNodeLength() ); //$NON-NLS-1$
-
-
- }
- }
-
- public void testStdioBug() throws ParserException
- {
- StringBuilder buffer = new StringBuilder( "#define _PTR void *\n"); //$NON-NLS-1$
- buffer.append( "#define __cdecl __attribute__ ((__cdecl__))\n" ); //$NON-NLS-1$
- buffer.append( "#define _EXFUN(name, proto) __cdecl name proto\n"); //$NON-NLS-1$
- buffer.append( "_PTR _EXFUN(memchr,(const _PTR, int, size_t));\n"); //$NON-NLS-1$
- String code = buffer.toString();
-
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language, true, true);
- final IASTPreprocessorMacroDefinition[] macroDefinitions = tu.getMacroDefinitions();
- IASTPreprocessorObjectStyleMacroDefinition _PTR = (IASTPreprocessorObjectStyleMacroDefinition) macroDefinitions[0];
- IASTPreprocessorFunctionStyleMacroDefinition _EXFUN = (IASTPreprocessorFunctionStyleMacroDefinition) macroDefinitions[2];
- IASTSimpleDeclaration memchr = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTNodeLocation [] locations = memchr.getNodeLocations();
- assertEquals( locations.length, 4 );
- IASTMacroExpansionLocation loc_1 = (IASTMacroExpansionLocation) locations[0];
- assertEqualsMacros( _PTR, loc_1.getExpansion().getMacroDefinition() );
- IASTFileLocation loc_2 = (IASTFileLocation) locations[1];
- assertEquals( loc_2.getNodeOffset(), code.indexOf( " _EXFUN(")); //$NON-NLS-1$
- assertEquals( loc_2.getNodeLength(), " ".length() ); //$NON-NLS-1$
- IASTMacroExpansionLocation loc_3 = (IASTMacroExpansionLocation) locations[2];
- assertEqualsMacros( _EXFUN, loc_3.getExpansion().getMacroDefinition() );
- IASTFileLocation loc_4 = (IASTFileLocation) locations[3];
- assertEquals( loc_4.getNodeOffset(), code.indexOf( ";")); //$NON-NLS-1$
- assertEquals( loc_4.getNodeLength(), 1 );
- IASTFileLocation flat = memchr.getFileLocation();
- assertEquals( flat.getNodeOffset() , code.indexOf( "_PTR _EXFUN(memchr,(const _PTR, int, size_t));")); //$NON-NLS-1$
- assertEquals( flat.getNodeLength(), "_PTR _EXFUN(memchr,(const _PTR, int, size_t));".length() ); //$NON-NLS-1$
-
- IASTDeclarator d = memchr.getDeclarators()[0];
- IASTFileLocation f = d.getFileLocation();
- assertEquals( code.indexOf( "_PTR _EXFUN(memchr,(const _PTR, int, size_t))"), f.getNodeOffset() ); //$NON-NLS-1$
- assertEquals( "_PTR _EXFUN(memchr,(const _PTR, int, size_t))".length(), f.getNodeLength() ); //$NON-NLS-1$
- }
- }
-
- private void assertEqualsMacros(IASTPreprocessorMacroDefinition fromExpansion, IASTPreprocessorMacroDefinition source) {
- assertEquals( fromExpansion.getExpansion(), source.getExpansion() );
- assertEquals( fromExpansion.getName().toString(), source.getName().toString() );
- }
-
- public void testMacroBindings() throws Exception
- {
- StringBuilder buffer = new StringBuilder( "#define ABC def\n"); //$NON-NLS-1$
- buffer.append( "int ABC;\n"); //$NON-NLS-1$
- buffer.append( "#undef ABC\n"); //$NON-NLS-1$
- buffer.append( "#define ABC ghi\n"); //$NON-NLS-1$
- buffer.append( "int ABC;\n"); //$NON-NLS-1$
- String code = buffer.toString();
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTPreprocessorMacroDefinition [] macros = tu.getMacroDefinitions();
- assertEquals( macros.length, 2 );
- IASTPreprocessorObjectStyleMacroDefinition ABC1 = (IASTPreprocessorObjectStyleMacroDefinition) macros[0];
- IASTPreprocessorObjectStyleMacroDefinition ABC2 = (IASTPreprocessorObjectStyleMacroDefinition) macros[1];
- IMacroBinding binding1 = (IMacroBinding) ABC1.getName().resolveBinding();
- assertNotNull( binding1 );
- IMacroBinding binding2 = (IMacroBinding) ABC2.getName().resolveBinding();
- assertNotNull( binding2 );
- assertNotSame( binding1, binding2 );
- IASTName [] firstReferences = tu.getReferences( binding1 );
- IASTName [] firstDeclarations = tu.getDeclarationsInAST( binding1 );
- assertEquals( firstReferences.length, 2 );
- assertEquals( firstReferences[0].getPropertyInParent(), IASTPreprocessorMacroExpansion.EXPANSION_NAME );
- assertEquals( firstReferences[0].getParent().getParent(), tu );
- assertEquals( firstReferences[1].getPropertyInParent(), IASTPreprocessorStatement.MACRO_NAME );
- assertTrue( firstReferences[1].getParent() instanceof IASTPreprocessorUndefStatement );
- assertEquals( firstDeclarations.length, 1 );
- assertSame( ABC1.getName(), firstDeclarations[0] );
- IASTName [] secondReferences = tu.getReferences(binding2);
- IASTName [] secondDeclarations = tu.getDeclarationsInAST( binding2 );
- assertEquals( 1, secondReferences.length );
- assertEquals( secondReferences[0].getPropertyInParent(), IASTPreprocessorMacroExpansion.EXPANSION_NAME );
- assertEquals( secondReferences[0].getParent().getParent(), tu );
- assertSame( ABC2.getName(), secondDeclarations[0]);
- }
- }
-
-
- public void testBug90978() throws Exception {
- StringBuilder buffer = new StringBuilder( "#define MACRO mm\n"); //$NON-NLS-1$
- buffer.append( "int MACRO;\n"); //$NON-NLS-1$
- String code = buffer.toString();
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTPreprocessorObjectStyleMacroDefinition MACRO = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[0];
- IASTName macro_name = MACRO.getName();
- IMacroBinding binding = (IMacroBinding) macro_name.resolveBinding();
- IASTName [] references = tu.getReferences( binding );
- assertEquals( references.length, 1 );
- IASTName reference = references[0];
- IASTNodeLocation [] nodeLocations = reference.getNodeLocations();
- assertEquals( nodeLocations.length, 1 );
- assertTrue( nodeLocations[0] instanceof IASTFileLocation );
- IASTFileLocation loc = (IASTFileLocation) nodeLocations[0];
- assertEquals( code.indexOf( "int MACRO") + "int ".length(), loc.getNodeOffset() ); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals( "MACRO".length(), loc.getNodeLength() ); //$NON-NLS-1$
- }
- }
-
- public void testBug94933() throws Exception {
- StringBuilder buffer = new StringBuilder( "#define API extern\n" ); //$NON-NLS-1$
- buffer.append( "#define MYAPI API\n"); //$NON-NLS-1$
- buffer.append( "MYAPI void func() {}" ); //$NON-NLS-1$
- String code = buffer.toString();
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
- assertNotNull( f.getFileLocation() );
- }
- }
-
- public void testFunctionMacroExpansionWithNameSubstitution_Bug173637() throws Exception
- {
- StringBuilder buffer = new StringBuilder( "#define PLUS5(x) (x+5)\n"); //$NON-NLS-1$
- buffer.append( "#define FUNCTION PLUS5 \n"); //$NON-NLS-1$
- buffer.append( "int var= FUNCTION(1);"); //$NON-NLS-1$
- String code = buffer.toString();
-
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTEqualsInitializer initializer= (IASTEqualsInitializer)var.getDeclarators()[0].getInitializer();
- IASTInitializerClause expr= initializer.getInitializerClause();
- assertNotNull(expr.getFileLocation());
- IASTNodeLocation [] locations = expr.getNodeLocations();
- assertEquals(1, locations.length);
- IASTMacroExpansionLocation macroExpansion = (IASTMacroExpansionLocation) locations[0];
- IASTNodeLocation[] expLocations= macroExpansion.getExpansion().getNodeLocations();
- assertEquals(1, expLocations.length);
- assertEquals(code.indexOf("FUNCTION(1)"), expLocations[0].getNodeOffset());
- assertEquals("FUNCTION(1)".length(), expLocations[0].getNodeLength());
- }
- }
-
-
- private void assertMacroLocation(IASTDeclaration decl, int index, int length) {
- IASTSimpleDeclaration var = (IASTSimpleDeclaration) decl;
- IASTEqualsInitializer initializer= (IASTEqualsInitializer)var.getDeclarators()[0].getInitializer();
- IASTInitializerClause expr= initializer.getInitializerClause();
- assertNotNull(expr.getFileLocation());
- IASTNodeLocation [] locations = expr.getNodeLocations();
- assertEquals(1, locations.length);
- IASTMacroExpansionLocation macroExpansion = (IASTMacroExpansionLocation) locations[0];
- IASTNodeLocation[] expLocations= macroExpansion.getExpansion().getNodeLocations();
- assertEquals(1, expLocations.length);
- IASTFileLocation fileLocation = expLocations[0].asFileLocation();
- assertEquals(index, fileLocation.getNodeOffset());
- assertEquals(length, fileLocation.getNodeLength());
- }
-
- private void assertExpressionLocation(IASTDeclaration decl, int index, int length) {
- IASTSimpleDeclaration var = (IASTSimpleDeclaration) decl;
- IASTEqualsInitializer initializer= (IASTEqualsInitializer)var.getDeclarators()[0].getInitializer();
- IASTInitializerClause expr= initializer.getInitializerClause();
- IASTFileLocation fileLocation = expr.getFileLocation();
- assertNotNull(fileLocation);
- assertEquals(index, fileLocation.getNodeOffset());
- assertEquals(length, fileLocation.getNodeLength());
- }
-
-
- public void testBug186257() throws Exception {
- StringBuilder sb = new StringBuilder();
- sb.append("typedef char STR; \n"); //$NON-NLS-1$
- sb.append("#define Nullstr Null(STR*) \n"); //$NON-NLS-1$
- sb.append("#define Null(x) ((x)NULL) \n"); //$NON-NLS-1$
- sb.append("int x = Nullstr; \n"); //$NON-NLS-1$
- sb.append("int y = whatever; \n"); //$NON-NLS-1$
- String code = sb.toString();
-
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTDeclaration[] decls = tu.getDeclarations();
- assertMacroLocation(decls[1], code.indexOf("Nullstr;"), "Nullstr".length()); //$NON-NLS-1$ //$NON-NLS-2$
- assertExpressionLocation(decls[2], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
-
- public void testArgumentExpansion() throws Exception {
- StringBuilder sb = new StringBuilder();
- sb.append("#define ADD(a,b, c) (a) + (b) + (c) \n"); //$NON-NLS-1$
- sb.append("#define ONEYONENOE 111111 \n"); //$NON-NLS-1$
- sb.append("#define TWO 2 \n"); //$NON-NLS-1$
- sb.append("#define THREE 3 \n"); //$NON-NLS-1$
- sb.append("int x = ADD(ONEYONENOE,TWO, THREE); \n"); //$NON-NLS-1$
- sb.append("int y = whatever; \n"); //$NON-NLS-1$
- String code = sb.toString();
-
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTDeclaration[] decls = tu.getDeclarations();
- assertMacroLocation(decls[0], code.indexOf("ADD(ONEYONENOE,TWO, THREE)"), "ADD(ONEYONENOE,TWO, THREE)".length()); //$NON-NLS-1$ //$NON-NLS-2$
- assertExpressionLocation(decls[1], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
-
- public void testArgumentCapture() throws Exception {
- StringBuilder sb = new StringBuilder();
- sb.append("#define add(x,y) x + y \n"); //$NON-NLS-1$
- sb.append("#define add2 add(x, \n"); //$NON-NLS-1$
- sb.append("int x = add2 z); \n"); //$NON-NLS-1$
- sb.append("int y = whatever; \n"); //$NON-NLS-1$
- String code = sb.toString();
-
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTDeclaration[] decls = tu.getDeclarations();
- assertMacroLocation(decls[0], code.indexOf("add2 z);"), "add2 z)".length()); //$NON-NLS-1$ //$NON-NLS-2$
- assertExpressionLocation(decls[1], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
-
- public void testFunctionMacroNotCalled() throws Exception {
- StringBuilder sb = new StringBuilder();
- sb.append("#define FUNCTION(x) x \n"); //$NON-NLS-1$
- sb.append("#define YO FUNCTION \n"); //$NON-NLS-1$
- sb.append("int x = YO; \n"); //$NON-NLS-1$
- sb.append("int y = whatever; \n"); //$NON-NLS-1$
- String code = sb.toString();
-
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTDeclaration[] decls = tu.getDeclarations();
- assertMacroLocation(decls[0], code.indexOf("YO;"), "YO".length()); //$NON-NLS-1$ //$NON-NLS-2$
- assertExpressionLocation(decls[1], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public void testBuildFunctionMacroName() throws Exception {
- StringBuilder sb = new StringBuilder();
- sb.append("#define FUN1(x) x \n"); //$NON-NLS-1$
- sb.append("#define FUN1(x) x \n"); //$NON-NLS-1$
- sb.append("#define MAKEFUN(num) FUN ## num \n"); //$NON-NLS-1$
- sb.append("int x = MAKEFUN(1)(z); \n"); //$NON-NLS-1$
- sb.append("int y = whatever; \n"); //$NON-NLS-1$
- String code = sb.toString();
-
- for (ParserLanguage language : languages) {
- IASTTranslationUnit tu = parse(code, language);
- IASTDeclaration[] decls = tu.getDeclarations();
- assertMacroLocation(decls[0], code.indexOf("MAKEFUN(1)(z);"), "MAKEFUN(1)(z)".length()); //$NON-NLS-1$ //$NON-NLS-2$
- assertExpressionLocation(decls[1], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
+ public void testObjectStyleMacroExpansionSimpleDeclarator() throws Exception {
+ StringBuilder buffer = new StringBuilder("#define ABC D\n"); //$NON-NLS-1$
+ buffer.append("int ABC;"); //$NON-NLS-1$
+ String code = buffer.toString();
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTPreprocessorObjectStyleMacroDefinition ABC = (IASTPreprocessorObjectStyleMacroDefinition) tu
+ .getMacroDefinitions()[0];
+ IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTDeclarator d = var.getDeclarators()[0];
+ assertEquals(d.getName().toString(), "D"); //$NON-NLS-1$
+ IASTNodeLocation[] declaratorLocations = d.getNodeLocations();
+ assertEquals(declaratorLocations.length, 1);
+ IASTMacroExpansionLocation expansion = (IASTMacroExpansionLocation) declaratorLocations[0];
+ IASTPreprocessorObjectStyleMacroDefinition fromExpansion = (IASTPreprocessorObjectStyleMacroDefinition) expansion
+ .getExpansion().getMacroDefinition();
+ assertEqualsMacros(fromExpansion, ABC);
+ assertEquals(expansion.getNodeOffset(), 0);
+ assertEquals(expansion.getNodeLength(), 1);
+ IASTNodeLocation[] macroLocation = expansion.getExpansion().getNodeLocations();
+ assertEquals(macroLocation.length, 1);
+ assertTrue(macroLocation[0] instanceof IASTFileLocation);
+ assertEquals(macroLocation[0].getNodeOffset(), code.indexOf("int ABC;") + "int ".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(macroLocation[0].getNodeLength(), "ABC".length()); //$NON-NLS-1$
+ }
+ }
+
+ public void testObjectMacroExpansionModestDeclarator() throws Exception {
+ StringBuilder buffer = new StringBuilder("#define ABC * D\n"); //$NON-NLS-1$
+ buffer.append("int ABC;"); //$NON-NLS-1$
+ String code = buffer.toString();
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTPreprocessorObjectStyleMacroDefinition ABC = (IASTPreprocessorObjectStyleMacroDefinition) tu
+ .getMacroDefinitions()[0];
+ IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTDeclarator d = var.getDeclarators()[0];
+ assertEquals(d.getName().toString(), "D"); //$NON-NLS-1$
+ assertEquals(d.getPointerOperators().length, 1);
+ IASTNodeLocation[] declaratorLocations = d.getNodeLocations();
+ assertEquals(declaratorLocations.length, 1);
+ IASTMacroExpansionLocation expansion = (IASTMacroExpansionLocation) declaratorLocations[0];
+ IASTPreprocessorObjectStyleMacroDefinition fromExpansion = (IASTPreprocessorObjectStyleMacroDefinition) expansion
+ .getExpansion().getMacroDefinition();
+ assertEqualsMacros(fromExpansion, ABC);
+ assertEquals(expansion.getNodeOffset(), 0);
+ assertEquals(2, expansion.getNodeLength());
+ IASTNodeLocation[] macroLocation = expansion.getExpansion().getNodeLocations();
+ assertEquals(macroLocation.length, 1);
+ assertTrue(macroLocation[0] instanceof IASTFileLocation);
+ assertEquals(macroLocation[0].getNodeOffset(), code.indexOf("int ABC;") + "int ".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(macroLocation[0].getNodeLength(), "ABC".length()); //$NON-NLS-1$
+
+ IASTName n = d.getName();
+ IASTNodeLocation[] nameLocations = n.getNodeLocations();
+ assertEquals(nameLocations.length, 1);
+ final IASTMacroExpansionLocation nodeLocation = (IASTMacroExpansionLocation) nameLocations[0];
+ assertEquals(nodeLocation.getNodeOffset(), 1);
+ assertEquals(nodeLocation.getNodeLength(), 1);
+
+ assertEquals(nodeLocation.getExpansion().getNodeLocations()[0].getNodeOffset(),
+ macroLocation[0].getNodeOffset());
+ assertEquals(nodeLocation.getExpansion().getNodeLocations()[0].getNodeLength(),
+ macroLocation[0].getNodeLength());
+
+ IASTPointer po = (IASTPointer) d.getPointerOperators()[0];
+ assertFalse(po.isConst());
+ assertFalse(po.isVolatile());
+ IASTMacroExpansionLocation pointerLocation = (IASTMacroExpansionLocation) po.getNodeLocations()[0];
+ assertEquals(pointerLocation.getNodeOffset(), 0);
+ assertEquals(pointerLocation.getNodeLength(), 1);
+ assertEquals(pointerLocation.getExpansion().getNodeLocations()[0].getNodeOffset(),
+ macroLocation[0].getNodeOffset());
+ assertEquals(pointerLocation.getExpansion().getNodeLocations()[0].getNodeLength(),
+ macroLocation[0].getNodeLength());
+ assertEqualsMacros(pointerLocation.getExpansion().getMacroDefinition(),
+ nodeLocation.getExpansion().getMacroDefinition());
+ }
+ }
+
+ public void testObjectMacroExpansionPartialDeclSpec() throws Exception {
+ StringBuilder buffer = new StringBuilder("#define XYZ const\n"); //$NON-NLS-1$
+ buffer.append("XYZ int var;"); //$NON-NLS-1$
+ String code = buffer.toString();
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTPreprocessorObjectStyleMacroDefinition defXYZ = (IASTPreprocessorObjectStyleMacroDefinition) tu
+ .getMacroDefinitions()[0];
+ IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTSimpleDeclSpecifier declSpec = (IASTSimpleDeclSpecifier) var.getDeclSpecifier();
+ IASTNodeLocation[] declSpecLocations = declSpec.getNodeLocations();
+ assertEquals(declSpecLocations.length, 2);
+ IASTMacroExpansionLocation expansion = (IASTMacroExpansionLocation) declSpecLocations[0];
+ assertEqualsMacros(defXYZ, expansion.getExpansion().getMacroDefinition());
+ assertEquals(expansion.getNodeOffset(), 0);
+ assertEquals(expansion.getNodeLength(), 1);
+ IASTNodeLocation[] expansionLocations = expansion.getExpansion().getNodeLocations();
+ assertEquals(expansionLocations.length, 1);
+ assertTrue(expansionLocations[0] instanceof IASTFileLocation);
+ assertEquals(expansionLocations[0].getNodeOffset(), code.indexOf("XYZ int")); //$NON-NLS-1$
+ assertEquals(expansionLocations[0].getNodeLength(), "XYZ".length()); //$NON-NLS-1$
+ IASTFileLocation second = (IASTFileLocation) declSpecLocations[1];
+ assertEquals(second.getNodeOffset(), code.indexOf(" int")); //$NON-NLS-1$
+ assertEquals(second.getNodeLength(), " int".length()); //$NON-NLS-1$
+ }
+ }
+
+ public void testObjectMacroExpansionNested() throws Exception {
+ StringBuilder buffer = new StringBuilder("#define XYZ const\n"); //$NON-NLS-1$
+ buffer.append("#define PO *\n"); //$NON-NLS-1$
+ buffer.append("#define C_PO PO XYZ\n"); //$NON-NLS-1$
+ buffer.append("int C_PO var;"); //$NON-NLS-1$
+ String code = buffer.toString();
+
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ final IASTPreprocessorMacroDefinition[] macroDefinitions = tu.getMacroDefinitions();
+ IASTPreprocessorMacroDefinition XYZ = macroDefinitions[0];
+ IASTPreprocessorMacroDefinition PO = macroDefinitions[1];
+ IASTPreprocessorMacroDefinition C_PO = macroDefinitions[2];
+ IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ assertTrue(var.getDeclarators()[0].getPointerOperators().length > 0);
+ IASTNodeLocation[] locations = var.getNodeLocations();
+ assertEquals(3, locations.length);
+ IASTFileLocation start_loc = (IASTFileLocation) locations[0];
+ assertEquals(start_loc.getNodeOffset(), code.indexOf("int")); //$NON-NLS-1$
+ assertEquals(start_loc.getNodeLength(), "int ".length()); //$NON-NLS-1$
+ IASTMacroExpansionLocation mac_loc = (IASTMacroExpansionLocation) locations[1];
+ final IASTPreprocessorMacroDefinition C_PO2 = mac_loc.getExpansion().getMacroDefinition();
+ assertEqualsMacros(C_PO, C_PO2);
+ assertEquals(0, mac_loc.getNodeOffset());
+ assertEquals(2, mac_loc.getNodeLength());
+ IASTFileLocation end_loc = (IASTFileLocation) locations[2];
+ assertEquals(code.indexOf(" var"), end_loc.getNodeOffset()); //$NON-NLS-1$
+ assertEquals(" var;".length(), end_loc.getNodeLength()); //$NON-NLS-1$
+ }
+ }
+
+ public void testObjectMacroExpansionComplex() throws Exception {
+ StringBuilder buffer = new StringBuilder("#define XYZ const\n"); //$NON-NLS-1$
+ buffer.append("#define PO *\n"); //$NON-NLS-1$
+ buffer.append("#define C_PO PO XYZ\n"); //$NON-NLS-1$
+ buffer.append("#define IT int\n"); //$NON-NLS-1$
+ buffer.append("#define V var\n"); //$NON-NLS-1$
+ buffer.append("XYZ IT C_PO C_PO V;"); //$NON-NLS-1$
+ String code = buffer.toString();
+
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTPreprocessorObjectStyleMacroDefinition XYZ = (IASTPreprocessorObjectStyleMacroDefinition) tu
+ .getMacroDefinitions()[0];
+ // IASTPreprocessorObjectStyleMacroDefinition PO = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[1];
+ IASTPreprocessorObjectStyleMacroDefinition C_PO = (IASTPreprocessorObjectStyleMacroDefinition) tu
+ .getMacroDefinitions()[2];
+ IASTPreprocessorObjectStyleMacroDefinition IT = (IASTPreprocessorObjectStyleMacroDefinition) tu
+ .getMacroDefinitions()[3];
+ IASTPreprocessorObjectStyleMacroDefinition V = (IASTPreprocessorObjectStyleMacroDefinition) tu
+ .getMacroDefinitions()[4];
+
+ IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ final IASTNodeLocation[] nodeLocations = var.getNodeLocations();
+
+ assertEquals(10, nodeLocations.length);
+ IASTMacroExpansionLocation first_loc = (IASTMacroExpansionLocation) nodeLocations[0];
+ assertEqualsMacros(first_loc.getExpansion().getMacroDefinition(), XYZ);
+ IASTFileLocation second_loc = (IASTFileLocation) nodeLocations[1];
+ assertEquals(1, second_loc.getNodeLength());
+ IASTMacroExpansionLocation third_loc = (IASTMacroExpansionLocation) nodeLocations[2];
+ assertEqualsMacros(third_loc.getExpansion().getMacroDefinition(), IT);
+ IASTFileLocation fourth_loc = (IASTFileLocation) nodeLocations[3];
+ assertEquals(1, fourth_loc.getNodeLength());
+ IASTMacroExpansionLocation fifth_loc = (IASTMacroExpansionLocation) nodeLocations[4];
+ assertEqualsMacros(fifth_loc.getExpansion().getMacroDefinition(), C_PO);
+ IASTFileLocation sixth_loc = (IASTFileLocation) nodeLocations[5];
+ assertEquals(1, sixth_loc.getNodeLength());
+ IASTMacroExpansionLocation seventh_loc = (IASTMacroExpansionLocation) nodeLocations[6];
+ assertEqualsMacros(seventh_loc.getExpansion().getMacroDefinition(), C_PO);
+ IASTFileLocation eighth_loc = (IASTFileLocation) nodeLocations[7];
+ assertEquals(1, eighth_loc.getNodeLength());
+ IASTMacroExpansionLocation ninth_loc = (IASTMacroExpansionLocation) nodeLocations[8];
+ assertEqualsMacros(ninth_loc.getExpansion().getMacroDefinition(), V);
+ IASTFileLocation tenth_loc = (IASTFileLocation) nodeLocations[9];
+ assertEquals(1, tenth_loc.getNodeLength());
+
+ final IASTFileLocation flatLocation = var.getFileLocation();
+ assertNotNull(flatLocation);
+ assertEquals(code.indexOf("XYZ IT C_PO C_PO V;"), flatLocation.getNodeOffset()); //$NON-NLS-1$
+ assertEquals("XYZ IT C_PO C_PO V;".length(), flatLocation.getNodeLength()); //$NON-NLS-1$
+
+ }
+ }
+
+ public void testStdioBug() throws ParserException {
+ StringBuilder buffer = new StringBuilder("#define _PTR void *\n"); //$NON-NLS-1$
+ buffer.append("#define __cdecl __attribute__ ((__cdecl__))\n"); //$NON-NLS-1$
+ buffer.append("#define _EXFUN(name, proto) __cdecl name proto\n"); //$NON-NLS-1$
+ buffer.append("_PTR _EXFUN(memchr,(const _PTR, int, size_t));\n"); //$NON-NLS-1$
+ String code = buffer.toString();
+
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language, true, true);
+ final IASTPreprocessorMacroDefinition[] macroDefinitions = tu.getMacroDefinitions();
+ IASTPreprocessorObjectStyleMacroDefinition _PTR = (IASTPreprocessorObjectStyleMacroDefinition) macroDefinitions[0];
+ IASTPreprocessorFunctionStyleMacroDefinition _EXFUN = (IASTPreprocessorFunctionStyleMacroDefinition) macroDefinitions[2];
+ IASTSimpleDeclaration memchr = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTNodeLocation[] locations = memchr.getNodeLocations();
+ assertEquals(locations.length, 4);
+ IASTMacroExpansionLocation loc_1 = (IASTMacroExpansionLocation) locations[0];
+ assertEqualsMacros(_PTR, loc_1.getExpansion().getMacroDefinition());
+ IASTFileLocation loc_2 = (IASTFileLocation) locations[1];
+ assertEquals(loc_2.getNodeOffset(), code.indexOf(" _EXFUN(")); //$NON-NLS-1$
+ assertEquals(loc_2.getNodeLength(), " ".length()); //$NON-NLS-1$
+ IASTMacroExpansionLocation loc_3 = (IASTMacroExpansionLocation) locations[2];
+ assertEqualsMacros(_EXFUN, loc_3.getExpansion().getMacroDefinition());
+ IASTFileLocation loc_4 = (IASTFileLocation) locations[3];
+ assertEquals(loc_4.getNodeOffset(), code.indexOf(";")); //$NON-NLS-1$
+ assertEquals(loc_4.getNodeLength(), 1);
+ IASTFileLocation flat = memchr.getFileLocation();
+ assertEquals(flat.getNodeOffset(), code.indexOf("_PTR _EXFUN(memchr,(const _PTR, int, size_t));")); //$NON-NLS-1$
+ assertEquals(flat.getNodeLength(), "_PTR _EXFUN(memchr,(const _PTR, int, size_t));".length()); //$NON-NLS-1$
+
+ IASTDeclarator d = memchr.getDeclarators()[0];
+ IASTFileLocation f = d.getFileLocation();
+ assertEquals(code.indexOf("_PTR _EXFUN(memchr,(const _PTR, int, size_t))"), f.getNodeOffset()); //$NON-NLS-1$
+ assertEquals("_PTR _EXFUN(memchr,(const _PTR, int, size_t))".length(), f.getNodeLength()); //$NON-NLS-1$
+ }
+ }
+
+ private void assertEqualsMacros(IASTPreprocessorMacroDefinition fromExpansion,
+ IASTPreprocessorMacroDefinition source) {
+ assertEquals(fromExpansion.getExpansion(), source.getExpansion());
+ assertEquals(fromExpansion.getName().toString(), source.getName().toString());
+ }
+
+ public void testMacroBindings() throws Exception {
+ StringBuilder buffer = new StringBuilder("#define ABC def\n"); //$NON-NLS-1$
+ buffer.append("int ABC;\n"); //$NON-NLS-1$
+ buffer.append("#undef ABC\n"); //$NON-NLS-1$
+ buffer.append("#define ABC ghi\n"); //$NON-NLS-1$
+ buffer.append("int ABC;\n"); //$NON-NLS-1$
+ String code = buffer.toString();
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTPreprocessorMacroDefinition[] macros = tu.getMacroDefinitions();
+ assertEquals(macros.length, 2);
+ IASTPreprocessorObjectStyleMacroDefinition ABC1 = (IASTPreprocessorObjectStyleMacroDefinition) macros[0];
+ IASTPreprocessorObjectStyleMacroDefinition ABC2 = (IASTPreprocessorObjectStyleMacroDefinition) macros[1];
+ IMacroBinding binding1 = (IMacroBinding) ABC1.getName().resolveBinding();
+ assertNotNull(binding1);
+ IMacroBinding binding2 = (IMacroBinding) ABC2.getName().resolveBinding();
+ assertNotNull(binding2);
+ assertNotSame(binding1, binding2);
+ IASTName[] firstReferences = tu.getReferences(binding1);
+ IASTName[] firstDeclarations = tu.getDeclarationsInAST(binding1);
+ assertEquals(firstReferences.length, 2);
+ assertEquals(firstReferences[0].getPropertyInParent(), IASTPreprocessorMacroExpansion.EXPANSION_NAME);
+ assertEquals(firstReferences[0].getParent().getParent(), tu);
+ assertEquals(firstReferences[1].getPropertyInParent(), IASTPreprocessorStatement.MACRO_NAME);
+ assertTrue(firstReferences[1].getParent() instanceof IASTPreprocessorUndefStatement);
+ assertEquals(firstDeclarations.length, 1);
+ assertSame(ABC1.getName(), firstDeclarations[0]);
+ IASTName[] secondReferences = tu.getReferences(binding2);
+ IASTName[] secondDeclarations = tu.getDeclarationsInAST(binding2);
+ assertEquals(1, secondReferences.length);
+ assertEquals(secondReferences[0].getPropertyInParent(), IASTPreprocessorMacroExpansion.EXPANSION_NAME);
+ assertEquals(secondReferences[0].getParent().getParent(), tu);
+ assertSame(ABC2.getName(), secondDeclarations[0]);
+ }
+ }
+
+ public void testBug90978() throws Exception {
+ StringBuilder buffer = new StringBuilder("#define MACRO mm\n"); //$NON-NLS-1$
+ buffer.append("int MACRO;\n"); //$NON-NLS-1$
+ String code = buffer.toString();
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTPreprocessorObjectStyleMacroDefinition MACRO = (IASTPreprocessorObjectStyleMacroDefinition) tu
+ .getMacroDefinitions()[0];
+ IASTName macro_name = MACRO.getName();
+ IMacroBinding binding = (IMacroBinding) macro_name.resolveBinding();
+ IASTName[] references = tu.getReferences(binding);
+ assertEquals(references.length, 1);
+ IASTName reference = references[0];
+ IASTNodeLocation[] nodeLocations = reference.getNodeLocations();
+ assertEquals(nodeLocations.length, 1);
+ assertTrue(nodeLocations[0] instanceof IASTFileLocation);
+ IASTFileLocation loc = (IASTFileLocation) nodeLocations[0];
+ assertEquals(code.indexOf("int MACRO") + "int ".length(), loc.getNodeOffset()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("MACRO".length(), loc.getNodeLength()); //$NON-NLS-1$
+ }
+ }
+
+ public void testBug94933() throws Exception {
+ StringBuilder buffer = new StringBuilder("#define API extern\n"); //$NON-NLS-1$
+ buffer.append("#define MYAPI API\n"); //$NON-NLS-1$
+ buffer.append("MYAPI void func() {}"); //$NON-NLS-1$
+ String code = buffer.toString();
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ assertNotNull(f.getFileLocation());
+ }
+ }
+
+ public void testFunctionMacroExpansionWithNameSubstitution_Bug173637() throws Exception {
+ StringBuilder buffer = new StringBuilder("#define PLUS5(x) (x+5)\n"); //$NON-NLS-1$
+ buffer.append("#define FUNCTION PLUS5 \n"); //$NON-NLS-1$
+ buffer.append("int var= FUNCTION(1);"); //$NON-NLS-1$
+ String code = buffer.toString();
+
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTEqualsInitializer initializer = (IASTEqualsInitializer) var.getDeclarators()[0].getInitializer();
+ IASTInitializerClause expr = initializer.getInitializerClause();
+ assertNotNull(expr.getFileLocation());
+ IASTNodeLocation[] locations = expr.getNodeLocations();
+ assertEquals(1, locations.length);
+ IASTMacroExpansionLocation macroExpansion = (IASTMacroExpansionLocation) locations[0];
+ IASTNodeLocation[] expLocations = macroExpansion.getExpansion().getNodeLocations();
+ assertEquals(1, expLocations.length);
+ assertEquals(code.indexOf("FUNCTION(1)"), expLocations[0].getNodeOffset());
+ assertEquals("FUNCTION(1)".length(), expLocations[0].getNodeLength());
+ }
+ }
+
+ private void assertMacroLocation(IASTDeclaration decl, int index, int length) {
+ IASTSimpleDeclaration var = (IASTSimpleDeclaration) decl;
+ IASTEqualsInitializer initializer = (IASTEqualsInitializer) var.getDeclarators()[0].getInitializer();
+ IASTInitializerClause expr = initializer.getInitializerClause();
+ assertNotNull(expr.getFileLocation());
+ IASTNodeLocation[] locations = expr.getNodeLocations();
+ assertEquals(1, locations.length);
+ IASTMacroExpansionLocation macroExpansion = (IASTMacroExpansionLocation) locations[0];
+ IASTNodeLocation[] expLocations = macroExpansion.getExpansion().getNodeLocations();
+ assertEquals(1, expLocations.length);
+ IASTFileLocation fileLocation = expLocations[0].asFileLocation();
+ assertEquals(index, fileLocation.getNodeOffset());
+ assertEquals(length, fileLocation.getNodeLength());
+ }
+
+ private void assertExpressionLocation(IASTDeclaration decl, int index, int length) {
+ IASTSimpleDeclaration var = (IASTSimpleDeclaration) decl;
+ IASTEqualsInitializer initializer = (IASTEqualsInitializer) var.getDeclarators()[0].getInitializer();
+ IASTInitializerClause expr = initializer.getInitializerClause();
+ IASTFileLocation fileLocation = expr.getFileLocation();
+ assertNotNull(fileLocation);
+ assertEquals(index, fileLocation.getNodeOffset());
+ assertEquals(length, fileLocation.getNodeLength());
+ }
+
+ public void testBug186257() throws Exception {
+ StringBuilder sb = new StringBuilder();
+ sb.append("typedef char STR; \n"); //$NON-NLS-1$
+ sb.append("#define Nullstr Null(STR*) \n"); //$NON-NLS-1$
+ sb.append("#define Null(x) ((x)NULL) \n"); //$NON-NLS-1$
+ sb.append("int x = Nullstr; \n"); //$NON-NLS-1$
+ sb.append("int y = whatever; \n"); //$NON-NLS-1$
+ String code = sb.toString();
+
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ assertMacroLocation(decls[1], code.indexOf("Nullstr;"), "Nullstr".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertExpressionLocation(decls[2], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public void testArgumentExpansion() throws Exception {
+ StringBuilder sb = new StringBuilder();
+ sb.append("#define ADD(a,b, c) (a) + (b) + (c) \n"); //$NON-NLS-1$
+ sb.append("#define ONEYONENOE 111111 \n"); //$NON-NLS-1$
+ sb.append("#define TWO 2 \n"); //$NON-NLS-1$
+ sb.append("#define THREE 3 \n"); //$NON-NLS-1$
+ sb.append("int x = ADD(ONEYONENOE,TWO, THREE); \n"); //$NON-NLS-1$
+ sb.append("int y = whatever; \n"); //$NON-NLS-1$
+ String code = sb.toString();
+
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ assertMacroLocation(decls[0], code.indexOf("ADD(ONEYONENOE,TWO, THREE)"), //$NON-NLS-1$
+ "ADD(ONEYONENOE,TWO, THREE)".length()); //$NON-NLS-1$
+ assertExpressionLocation(decls[1], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public void testArgumentCapture() throws Exception {
+ StringBuilder sb = new StringBuilder();
+ sb.append("#define add(x,y) x + y \n"); //$NON-NLS-1$
+ sb.append("#define add2 add(x, \n"); //$NON-NLS-1$
+ sb.append("int x = add2 z); \n"); //$NON-NLS-1$
+ sb.append("int y = whatever; \n"); //$NON-NLS-1$
+ String code = sb.toString();
+
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ assertMacroLocation(decls[0], code.indexOf("add2 z);"), "add2 z)".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertExpressionLocation(decls[1], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public void testFunctionMacroNotCalled() throws Exception {
+ StringBuilder sb = new StringBuilder();
+ sb.append("#define FUNCTION(x) x \n"); //$NON-NLS-1$
+ sb.append("#define YO FUNCTION \n"); //$NON-NLS-1$
+ sb.append("int x = YO; \n"); //$NON-NLS-1$
+ sb.append("int y = whatever; \n"); //$NON-NLS-1$
+ String code = sb.toString();
+
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ assertMacroLocation(decls[0], code.indexOf("YO;"), "YO".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertExpressionLocation(decls[1], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public void testBuildFunctionMacroName() throws Exception {
+ StringBuilder sb = new StringBuilder();
+ sb.append("#define FUN1(x) x \n"); //$NON-NLS-1$
+ sb.append("#define FUN1(x) x \n"); //$NON-NLS-1$
+ sb.append("#define MAKEFUN(num) FUN ## num \n"); //$NON-NLS-1$
+ sb.append("int x = MAKEFUN(1)(z); \n"); //$NON-NLS-1$
+ sb.append("int y = whatever; \n"); //$NON-NLS-1$
+ String code = sb.toString();
+
+ for (ParserLanguage language : languages) {
+ IASTTranslationUnit tu = parse(code, language);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ assertMacroLocation(decls[0], code.indexOf("MAKEFUN(1)(z);"), "MAKEFUN(1)(z)".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertExpressionLocation(decls[1], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java
index b8dbd56ffd5..997fd70aaef 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java
@@ -82,343 +82,346 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
*/
public class DOMLocationTests extends AST2TestBase {
- public DOMLocationTests() {
+ public DOMLocationTests() {
}
public DOMLocationTests(String name) {
setName(name);
}
- public static TestSuite suite() {
- return suite(DOMLocationTests.class);
- }
+ public static TestSuite suite() {
+ return suite(DOMLocationTests.class);
+ }
public void testBaseCase() throws ParserException {
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse("int x;", p); //$NON-NLS-1$
- IASTDeclaration declaration = tu.getDeclarations()[0];
- IASTNodeLocation[] nodeLocations = declaration.getNodeLocations();
- assertNotNull(nodeLocations);
- assertEquals(nodeLocations.length, 1);
- assertTrue(nodeLocations[0] instanceof IASTFileLocation);
- IASTFileLocation fileLocation = ((IASTFileLocation) nodeLocations[0]);
- assertEquals(fileLocation.getFileName(), TEST_CODE);
- assertEquals(fileLocation.getNodeOffset(), 0);
- assertEquals(fileLocation.getNodeLength(), 6);
- IASTNodeLocation[] tuLocations = tu.getNodeLocations();
- assertEquals(tuLocations.length, nodeLocations.length);
- assertEquals(fileLocation.getFileName(), ((IASTFileLocation) tuLocations[0]).getFileName());
- assertEquals(fileLocation.getNodeOffset(), tuLocations[0].getNodeOffset());
- assertEquals(fileLocation.getNodeLength(), tuLocations[0].getNodeLength());
- }
- }
-
- public void testSimpleDeclaration() throws ParserException {
- String code = "int xLen5, * yLength8, zLength16( int );"; //$NON-NLS-1$
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p);
- IASTDeclaration[] declarations = tu.getDeclarations();
- assertEquals(declarations.length, 1);
- IASTSimpleDeclaration declaration = (IASTSimpleDeclaration) declarations[0];
- IASTNodeLocation[] nodeLocations = declaration.getNodeLocations();
- assertNotNull(nodeLocations);
- assertEquals(nodeLocations.length, 1);
- assertTrue(nodeLocations[0] instanceof IASTFileLocation);
- IASTFileLocation fileLocation = ((IASTFileLocation) nodeLocations[0]);
- assertEquals(fileLocation.getFileName(), TEST_CODE);
- assertEquals(fileLocation.getNodeOffset(), 0);
- assertEquals(fileLocation.getNodeLength(), code.indexOf(";") + 1); //$NON-NLS-1$
- IASTDeclarator[] declarators = declaration.getDeclarators();
- assertEquals(declarators.length, 3);
- for (int i = 0; i < 3; ++i) {
- IASTDeclarator declarator = declarators[i];
- switch (i) {
- case 0:
- assertSoleLocation(declarator, code.indexOf("xLen5"), "xLen5".length()); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case 1:
- assertSoleLocation(declarator, code.indexOf("* yLength8"), "* yLength8".length()); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case 2:
- assertSoleLocation(declarator, code.indexOf("zLength16( int )"), "zLength16( int )".length()); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- }
- }
-
- }
- }
-
- public void testSimpleObjectStyleMacroDefinition() throws Exception {
- String code = "/* hi */\n#define FOOT 0x01\n\n"; //$NON-NLS-1$
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p);
- IASTDeclaration[] declarations = tu.getDeclarations();
- assertEquals(declarations.length, 0);
- IASTPreprocessorMacroDefinition[] macros = tu.getMacroDefinitions();
- assertNotNull(macros);
- assertEquals(macros.length, 1);
- assertSoleLocation(macros[0], code.indexOf("#"), code.indexOf("0x01") + 4 - code.indexOf("#")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertTrue(macros[0] instanceof IASTPreprocessorObjectStyleMacroDefinition);
- assertEquals(macros[0].getName().toString(), "FOOT"); //$NON-NLS-1$
- assertEquals(macros[0].getExpansion(), "0x01"); //$NON-NLS-1$
- }
- }
-
- public void testSimpleFunctionStyleMacroDefinition() throws Exception {
- String code = "#define FOOBAH( WOOBAH ) JOHN##WOOBAH\n\n"; //$NON-NLS-1$
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p);
- IASTDeclaration[] declarations = tu.getDeclarations();
- assertEquals(declarations.length, 0);
- IASTPreprocessorMacroDefinition[] macros = tu.getMacroDefinitions();
- assertNotNull(macros);
- assertEquals(macros.length, 1);
- assertTrue(macros[0] instanceof IASTPreprocessorFunctionStyleMacroDefinition);
- assertSoleLocation(macros[0], code.indexOf("#define"), code.indexOf("##WOOBAH") + 8 - code.indexOf("#define")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$s
- assertEquals(macros[0].getName().toString(), "FOOBAH"); //$NON-NLS-1$
- assertEquals(macros[0].getExpansion(), "JOHN##WOOBAH"); //$NON-NLS-1$
- IASTFunctionStyleMacroParameter[] parms = ((IASTPreprocessorFunctionStyleMacroDefinition) macros[0]).getParameters();
- assertNotNull(parms);
- assertEquals(parms.length, 1);
- assertEquals(parms[0].getParameter(), "WOOBAH"); //$NON-NLS-1$
- }
-
- }
-
- private void assertSoleLocation(IASTNode n, int offset, int length) {
- assertEquals(length, ((ASTNode)n).getLength());
- IASTNodeLocation[] locations = n.getNodeLocations();
- assertEquals(1, locations.length);
- IASTNodeLocation nodeLocation = locations[0];
- assertEquals(offset, nodeLocation.getNodeOffset());
- assertEquals(length, nodeLocation.getNodeLength());
- }
-
- private void assertFileLocation(IASTNode n, int offset, int length) {
- IASTNodeLocation location = n.getFileLocation();
- assertEquals(offset, location.getNodeOffset());
- assertEquals(length, location.getNodeLength());
- }
-
- public void testBug83664() throws Exception {
- String code = "int foo(x) int x; {\n return x;\n }\n"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.C, true);
- IASTDeclaration[] declarations = tu.getDeclarations();
- assertEquals(declarations.length, 1);
- IASTFunctionDefinition definition = (IASTFunctionDefinition) declarations[0];
- IASTFunctionDeclarator declarator = definition.getDeclarator();
- assertSoleLocation(declarator, code.indexOf("foo"), code.indexOf("int x;") + 6 - code.indexOf("foo")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
- assertEquals(body.getStatements().length, 1);
- IASTReturnStatement returnStatement = (IASTReturnStatement) body.getStatements()[0];
- IASTIdExpression expression = (IASTIdExpression) returnStatement.getReturnValue();
- assertSoleLocation(expression, code.indexOf("return ") + "return ".length(), 1); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBug84343() throws Exception {
- String code = "class A {}; int f() {\nA * b = 0;\nreturn b;}"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[1];
- IASTDeclarationStatement ds = (IASTDeclarationStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0];
- IASTSimpleDeclaration b = (IASTSimpleDeclaration) ds.getDeclaration();
- ICPPASTNamedTypeSpecifier namedTypeSpec = (ICPPASTNamedTypeSpecifier) b.getDeclSpecifier();
- assertSoleLocation(namedTypeSpec, code.indexOf("\nA") + 1, 1); //$NON-NLS-1$
- }
-
- public void testBug84366() throws Exception {
- String code = "enum hue { red, blue, green };"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- IASTSimpleDeclaration d = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTEnumerationSpecifier enumeration = (IASTEnumerationSpecifier) d.getDeclSpecifier();
- IASTEnumerationSpecifier.IASTEnumerator enumerator = enumeration.getEnumerators()[0];
- assertSoleLocation(enumerator, code.indexOf("red"), "red".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBug84375() throws Exception {
- String code = "class D { public: int x; };\nclass C : public virtual D {};"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- IASTSimpleDeclaration d2 = (IASTSimpleDeclaration) tu.getDeclarations()[1];
- ICPPASTCompositeTypeSpecifier classSpec = (ICPPASTCompositeTypeSpecifier) d2.getDeclSpecifier();
- ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier [] bases = classSpec.getBaseSpecifiers();
- assertSoleLocation(bases[0], code.indexOf("public virtual D"), "public virtual D".length()); //$NON-NLS-1$ //$NON-NLS-2$
-
- }
-
- public void testBug84357() throws Exception {
- String code = "class X { int a;\n};\nint X:: * pmi = &X::a;"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- IASTSimpleDeclaration pmi = (IASTSimpleDeclaration) tu.getDeclarations()[1];
- IASTDeclarator d = pmi.getDeclarators()[0];
- IASTPointerOperator p = d.getPointerOperators()[0];
- assertSoleLocation(p, code.indexOf("X:: *"), "X:: *".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBug84367() throws Exception {
- String code = "void foo( int );"; //$NON-NLS-1$
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p);
- IASTSimpleDeclaration definition = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTStandardFunctionDeclarator declarator = (IASTStandardFunctionDeclarator) definition.getDeclarators()[0];
- IASTParameterDeclaration parameter = declarator.getParameters()[0];
- assertSoleLocation(parameter, code.indexOf("int"), 3); //$NON-NLS-1$
- }
- }
-
- public void testElaboratedTypeSpecifier() throws ParserException {
- String code = "/* blah */ struct A anA; /* blah */"; //$NON-NLS-1$
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p);
- IASTSimpleDeclaration declaration = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IASTElaboratedTypeSpecifier elabType = (IASTElaboratedTypeSpecifier) declaration.getDeclSpecifier();
- assertSoleLocation(elabType, code.indexOf("struct"), "struct A".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public void testBug83852() throws Exception {
- String code = "/* blah */ typedef short jc; int x = 4; jc myJc = (jc)x; "; //$NON-NLS-1$
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p);
- IASTDeclaration[] declarations = tu.getDeclarations();
- assertEquals(3, declarations.length);
- for (int i = 0; i < 3; ++i) {
- IASTSimpleDeclaration decl = (IASTSimpleDeclaration) declarations[i];
- int start = 0, length = 0;
- switch (i) {
- case 0:
- start = code.indexOf("typedef"); //$NON-NLS-1$
- length = "typedef short jc;".length(); //$NON-NLS-1$
- break;
- case 1:
- start = code.indexOf("int x = 4;"); //$NON-NLS-1$
- length = "int x = 4;".length(); //$NON-NLS-1$
- break;
- case 2:
- start = code.indexOf("jc myJc = (jc)x;"); //$NON-NLS-1$
- length = "jc myJc = (jc)x;".length(); //$NON-NLS-1$
- break;
- }
- assertSoleLocation(decl, start, length);
- }
- IASTEqualsInitializer initializer = (IASTEqualsInitializer) ((IASTSimpleDeclaration) declarations[2])
- .getDeclarators()[0].getInitializer();
- IASTCastExpression castExpression = (IASTCastExpression) initializer.getInitializerClause();
- IASTTypeId typeId = castExpression.getTypeId();
- assertSoleLocation(typeId, code.indexOf("(jc)") + 1, "jc".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public void testBug83853() throws ParserException {
- String code = "int f() {return (1?0:1); }"; //$NON-NLS-1$
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p);
- IASTFunctionDefinition definition = (IASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement statement = (IASTCompoundStatement) definition.getBody();
- IASTReturnStatement returnStatement = (IASTReturnStatement) statement.getStatements()[0];
- IASTUnaryExpression unaryExpression = (IASTUnaryExpression) returnStatement.getReturnValue();
- assertEquals(unaryExpression.getOperator(), IASTUnaryExpression.op_bracketedPrimary);
- IASTConditionalExpression conditional = (IASTConditionalExpression) unaryExpression.getOperand();
- assertSoleLocation(conditional, code.indexOf("1?0:1"), "1?0:1".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public void testBug84374() throws Exception {
- String code = "class P1 { public: int x; };\nclass P2 { public: int x; };\nclass B : public P1, public P2 {};\nvoid main() {\nB * b = new B();\n}"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- IASTFunctionDefinition main = (IASTFunctionDefinition) tu.getDeclarations()[3];
- IASTCompoundStatement statement = (IASTCompoundStatement) main.getBody();
- IASTDeclarationStatement decl = (IASTDeclarationStatement) statement.getStatements()[0];
- IASTSimpleDeclaration b = (IASTSimpleDeclaration) decl.getDeclaration();
- IASTEqualsInitializer initializerExpression = (IASTEqualsInitializer) b.getDeclarators()[0].getInitializer();
- assertSoleLocation(initializerExpression.getInitializerClause(),code.indexOf("new B()"), "new B()".length()); //$NON-NLS-1$ //$NON-NLS-2$
- ICPPASTNewExpression newExpression = (ICPPASTNewExpression) initializerExpression.getInitializerClause();
- assertSoleLocation(newExpression, code.indexOf("new B()"), "new B()".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBug83737() throws Exception {
- String code = "void f() { if( a == 0 ) g( a ); else if( a < 0 ) g( a >> 1 ); else if( a > 0 ) g( *(&a + 2) ); }"; //$NON-NLS-1$
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p);
- IASTFunctionDefinition definition = (IASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement statement = (IASTCompoundStatement) definition.getBody();
- IASTIfStatement first_if = (IASTIfStatement) statement.getStatements()[0];
- IASTIfStatement second_if = (IASTIfStatement) first_if.getElseClause();
- IASTIfStatement third_if = (IASTIfStatement) second_if.getElseClause();
- assertNull(third_if.getElseClause());
- int first_if_start = code.indexOf("if( a == 0 )"); //$NON-NLS-1$
- int total_if_length = "if( a == 0 ) g( a ); else if( a < 0 ) g( a >> 1 ); else if( a > 0 ) g( *(&a + 2) );".length(); //$NON-NLS-1$
- int total_if_end = first_if_start + total_if_length;
- int second_if_start = code.indexOf("if( a < 0 )"); //$NON-NLS-1$
- int third_if_start = code.indexOf("if( a > 0 )"); //$NON-NLS-1$
- assertSoleLocation(first_if, first_if_start, total_if_length);
- assertSoleLocation(second_if, second_if_start, total_if_end - second_if_start);
- assertSoleLocation(third_if, third_if_start, total_if_end - third_if_start);
- }
- }
-
- public void testBug84467() throws Exception {
- String code = "class D { };\n D d1;\n const D d2;\n void foo() {\n typeid(d1) == typeid(d2);\n }"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- IASTBinaryExpression bexp = (IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
- .getDeclarations()[3]).getBody()).getStatements()[0]).getExpression();
- IASTUnaryExpression exp = (IASTUnaryExpression) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
- .getDeclarations()[3]).getBody()).getStatements()[0])
- .getExpression()).getOperand1();
-
- assertSoleLocation(bexp, code.indexOf("typeid(d1) == typeid(d2)"), "typeid(d1) == typeid(d2)".length()); //$NON-NLS-1$ //$NON-NLS-2$
- assertSoleLocation(exp, code.indexOf("typeid(d1)"), "typeid(d1)".length()); //$NON-NLS-1$ //$NON-NLS-2$
- exp = (IASTUnaryExpression) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
- .getDeclarations()[3]).getBody()).getStatements()[0]).getExpression()).getOperand2();
- assertSoleLocation(exp, code.indexOf("typeid(d2)"), "typeid(d2)".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBug84576() throws Exception {
- String code = "namespace A {\n extern \"C\" int g();\n }"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTLinkageSpecification spec = (ICPPASTLinkageSpecification) ((ICPPASTNamespaceDefinition) tu.getDeclarations()[0]).getDeclarations()[0];
- assertSoleLocation(spec, code.indexOf("extern \"C\""), "extern \"C\" int g();".length()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testSimplePreprocessorStatements() throws Exception
- {
- StringBuilder buffer = new StringBuilder();
- buffer.append( "#ifndef _APPLE_H_\n"); //$NON-NLS-1$
- buffer.append( "#define _APPLE_H_\n"); //$NON-NLS-1$
- buffer.append( "#undef _APPLE_H_\n"); //$NON-NLS-1$
- buffer.append( "#endif\n"); //$NON-NLS-1$
- String code = buffer.toString();
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p);
- assertEquals( tu.getDeclarations().length, 0 );
- IASTPreprocessorStatement [] statements = tu.getAllPreprocessorStatements();
- assertEquals( statements.length, 4 );
- IASTPreprocessorIfndefStatement ifndef = (IASTPreprocessorIfndefStatement) statements[0];
- assertTrue( ifndef.taken() );
- assertSoleLocation( ifndef, code.indexOf( "#ifndef _APPLE_H_"), "#ifndef _APPLE_H_".length() ); //$NON-NLS-1$ //$NON-NLS-2$
- IASTPreprocessorObjectStyleMacroDefinition definition = (IASTPreprocessorObjectStyleMacroDefinition) statements[1];
- assertSoleLocation( definition, code.indexOf( "#define _APPLE_H_"), "#define _APPLE_H_".length() ); //$NON-NLS-1$ //$NON-NLS-2$
- IASTPreprocessorUndefStatement undef = (IASTPreprocessorUndefStatement) statements[2];
- assertSoleLocation( undef, code.indexOf("#undef _APPLE_H_"), "#undef _APPLE_H_".length() ); //$NON-NLS-1$ //$NON-NLS-2$
- IASTPreprocessorEndifStatement endif = (IASTPreprocessorEndifStatement) statements[3];
- assertSoleLocation( endif, code.indexOf( "#endif"), "#endif".length() ); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public void testBug162180() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append( "#include <notfound.h>\n"); //$NON-NLS-1$
- buffer.append( "int x;\n"); //$NON-NLS-1$
- String code = buffer.toString();
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p, false, false);
- IASTDeclaration[] decls= tu.getDeclarations();
- assertEquals( decls.length, 1 );
- IASTPreprocessorStatement [] statements = tu.getAllPreprocessorStatements();
- assertEquals( statements.length, 1 );
- IASTProblem[] problems = tu.getPreprocessorProblems();
- assertEquals( problems.length, 1 );
- assertSoleLocation( decls[0], code, "int x;");
- }
- }
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse("int x;", p); //$NON-NLS-1$
+ IASTDeclaration declaration = tu.getDeclarations()[0];
+ IASTNodeLocation[] nodeLocations = declaration.getNodeLocations();
+ assertNotNull(nodeLocations);
+ assertEquals(nodeLocations.length, 1);
+ assertTrue(nodeLocations[0] instanceof IASTFileLocation);
+ IASTFileLocation fileLocation = ((IASTFileLocation) nodeLocations[0]);
+ assertEquals(fileLocation.getFileName(), TEST_CODE);
+ assertEquals(fileLocation.getNodeOffset(), 0);
+ assertEquals(fileLocation.getNodeLength(), 6);
+ IASTNodeLocation[] tuLocations = tu.getNodeLocations();
+ assertEquals(tuLocations.length, nodeLocations.length);
+ assertEquals(fileLocation.getFileName(), ((IASTFileLocation) tuLocations[0]).getFileName());
+ assertEquals(fileLocation.getNodeOffset(), tuLocations[0].getNodeOffset());
+ assertEquals(fileLocation.getNodeLength(), tuLocations[0].getNodeLength());
+ }
+ }
+
+ public void testSimpleDeclaration() throws ParserException {
+ String code = "int xLen5, * yLength8, zLength16( int );"; //$NON-NLS-1$
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p);
+ IASTDeclaration[] declarations = tu.getDeclarations();
+ assertEquals(declarations.length, 1);
+ IASTSimpleDeclaration declaration = (IASTSimpleDeclaration) declarations[0];
+ IASTNodeLocation[] nodeLocations = declaration.getNodeLocations();
+ assertNotNull(nodeLocations);
+ assertEquals(nodeLocations.length, 1);
+ assertTrue(nodeLocations[0] instanceof IASTFileLocation);
+ IASTFileLocation fileLocation = ((IASTFileLocation) nodeLocations[0]);
+ assertEquals(fileLocation.getFileName(), TEST_CODE);
+ assertEquals(fileLocation.getNodeOffset(), 0);
+ assertEquals(fileLocation.getNodeLength(), code.indexOf(";") + 1); //$NON-NLS-1$
+ IASTDeclarator[] declarators = declaration.getDeclarators();
+ assertEquals(declarators.length, 3);
+ for (int i = 0; i < 3; ++i) {
+ IASTDeclarator declarator = declarators[i];
+ switch (i) {
+ case 0:
+ assertSoleLocation(declarator, code.indexOf("xLen5"), "xLen5".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ case 1:
+ assertSoleLocation(declarator, code.indexOf("* yLength8"), "* yLength8".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ case 2:
+ assertSoleLocation(declarator, code.indexOf("zLength16( int )"), "zLength16( int )".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ }
+ }
+
+ }
+ }
+
+ public void testSimpleObjectStyleMacroDefinition() throws Exception {
+ String code = "/* hi */\n#define FOOT 0x01\n\n"; //$NON-NLS-1$
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p);
+ IASTDeclaration[] declarations = tu.getDeclarations();
+ assertEquals(declarations.length, 0);
+ IASTPreprocessorMacroDefinition[] macros = tu.getMacroDefinitions();
+ assertNotNull(macros);
+ assertEquals(macros.length, 1);
+ assertSoleLocation(macros[0], code.indexOf("#"), code.indexOf("0x01") + 4 - code.indexOf("#")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertTrue(macros[0] instanceof IASTPreprocessorObjectStyleMacroDefinition);
+ assertEquals(macros[0].getName().toString(), "FOOT"); //$NON-NLS-1$
+ assertEquals(macros[0].getExpansion(), "0x01"); //$NON-NLS-1$
+ }
+ }
+
+ public void testSimpleFunctionStyleMacroDefinition() throws Exception {
+ String code = "#define FOOBAH( WOOBAH ) JOHN##WOOBAH\n\n"; //$NON-NLS-1$
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p);
+ IASTDeclaration[] declarations = tu.getDeclarations();
+ assertEquals(declarations.length, 0);
+ IASTPreprocessorMacroDefinition[] macros = tu.getMacroDefinitions();
+ assertNotNull(macros);
+ assertEquals(macros.length, 1);
+ assertTrue(macros[0] instanceof IASTPreprocessorFunctionStyleMacroDefinition);
+ assertSoleLocation(macros[0], code.indexOf("#define"), //$NON-NLS-1$
+ code.indexOf("##WOOBAH") + 8 - code.indexOf("#define")); //$NON-NLS-1$ //$NON-NLS-2$s
+ assertEquals(macros[0].getName().toString(), "FOOBAH"); //$NON-NLS-1$
+ assertEquals(macros[0].getExpansion(), "JOHN##WOOBAH"); //$NON-NLS-1$
+ IASTFunctionStyleMacroParameter[] parms = ((IASTPreprocessorFunctionStyleMacroDefinition) macros[0])
+ .getParameters();
+ assertNotNull(parms);
+ assertEquals(parms.length, 1);
+ assertEquals(parms[0].getParameter(), "WOOBAH"); //$NON-NLS-1$
+ }
+
+ }
+
+ private void assertSoleLocation(IASTNode n, int offset, int length) {
+ assertEquals(length, ((ASTNode) n).getLength());
+ IASTNodeLocation[] locations = n.getNodeLocations();
+ assertEquals(1, locations.length);
+ IASTNodeLocation nodeLocation = locations[0];
+ assertEquals(offset, nodeLocation.getNodeOffset());
+ assertEquals(length, nodeLocation.getNodeLength());
+ }
+
+ private void assertFileLocation(IASTNode n, int offset, int length) {
+ IASTNodeLocation location = n.getFileLocation();
+ assertEquals(offset, location.getNodeOffset());
+ assertEquals(length, location.getNodeLength());
+ }
+
+ public void testBug83664() throws Exception {
+ String code = "int foo(x) int x; {\n return x;\n }\n"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.C, true);
+ IASTDeclaration[] declarations = tu.getDeclarations();
+ assertEquals(declarations.length, 1);
+ IASTFunctionDefinition definition = (IASTFunctionDefinition) declarations[0];
+ IASTFunctionDeclarator declarator = definition.getDeclarator();
+ assertSoleLocation(declarator, code.indexOf("foo"), code.indexOf("int x;") + 6 - code.indexOf("foo")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
+ assertEquals(body.getStatements().length, 1);
+ IASTReturnStatement returnStatement = (IASTReturnStatement) body.getStatements()[0];
+ IASTIdExpression expression = (IASTIdExpression) returnStatement.getReturnValue();
+ assertSoleLocation(expression, code.indexOf("return ") + "return ".length(), 1); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBug84343() throws Exception {
+ String code = "class A {}; int f() {\nA * b = 0;\nreturn b;}"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[1];
+ IASTDeclarationStatement ds = (IASTDeclarationStatement) ((IASTCompoundStatement) f.getBody())
+ .getStatements()[0];
+ IASTSimpleDeclaration b = (IASTSimpleDeclaration) ds.getDeclaration();
+ ICPPASTNamedTypeSpecifier namedTypeSpec = (ICPPASTNamedTypeSpecifier) b.getDeclSpecifier();
+ assertSoleLocation(namedTypeSpec, code.indexOf("\nA") + 1, 1); //$NON-NLS-1$
+ }
+
+ public void testBug84366() throws Exception {
+ String code = "enum hue { red, blue, green };"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ IASTSimpleDeclaration d = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTEnumerationSpecifier enumeration = (IASTEnumerationSpecifier) d.getDeclSpecifier();
+ IASTEnumerationSpecifier.IASTEnumerator enumerator = enumeration.getEnumerators()[0];
+ assertSoleLocation(enumerator, code.indexOf("red"), "red".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBug84375() throws Exception {
+ String code = "class D { public: int x; };\nclass C : public virtual D {};"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ IASTSimpleDeclaration d2 = (IASTSimpleDeclaration) tu.getDeclarations()[1];
+ ICPPASTCompositeTypeSpecifier classSpec = (ICPPASTCompositeTypeSpecifier) d2.getDeclSpecifier();
+ ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier[] bases = classSpec.getBaseSpecifiers();
+ assertSoleLocation(bases[0], code.indexOf("public virtual D"), "public virtual D".length()); //$NON-NLS-1$ //$NON-NLS-2$
+
+ }
+
+ public void testBug84357() throws Exception {
+ String code = "class X { int a;\n};\nint X:: * pmi = &X::a;"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ IASTSimpleDeclaration pmi = (IASTSimpleDeclaration) tu.getDeclarations()[1];
+ IASTDeclarator d = pmi.getDeclarators()[0];
+ IASTPointerOperator p = d.getPointerOperators()[0];
+ assertSoleLocation(p, code.indexOf("X:: *"), "X:: *".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBug84367() throws Exception {
+ String code = "void foo( int );"; //$NON-NLS-1$
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p);
+ IASTSimpleDeclaration definition = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTStandardFunctionDeclarator declarator = (IASTStandardFunctionDeclarator) definition.getDeclarators()[0];
+ IASTParameterDeclaration parameter = declarator.getParameters()[0];
+ assertSoleLocation(parameter, code.indexOf("int"), 3); //$NON-NLS-1$
+ }
+ }
+
+ public void testElaboratedTypeSpecifier() throws ParserException {
+ String code = "/* blah */ struct A anA; /* blah */"; //$NON-NLS-1$
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p);
+ IASTSimpleDeclaration declaration = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IASTElaboratedTypeSpecifier elabType = (IASTElaboratedTypeSpecifier) declaration.getDeclSpecifier();
+ assertSoleLocation(elabType, code.indexOf("struct"), "struct A".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public void testBug83852() throws Exception {
+ String code = "/* blah */ typedef short jc; int x = 4; jc myJc = (jc)x; "; //$NON-NLS-1$
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p);
+ IASTDeclaration[] declarations = tu.getDeclarations();
+ assertEquals(3, declarations.length);
+ for (int i = 0; i < 3; ++i) {
+ IASTSimpleDeclaration decl = (IASTSimpleDeclaration) declarations[i];
+ int start = 0, length = 0;
+ switch (i) {
+ case 0:
+ start = code.indexOf("typedef"); //$NON-NLS-1$
+ length = "typedef short jc;".length(); //$NON-NLS-1$
+ break;
+ case 1:
+ start = code.indexOf("int x = 4;"); //$NON-NLS-1$
+ length = "int x = 4;".length(); //$NON-NLS-1$
+ break;
+ case 2:
+ start = code.indexOf("jc myJc = (jc)x;"); //$NON-NLS-1$
+ length = "jc myJc = (jc)x;".length(); //$NON-NLS-1$
+ break;
+ }
+ assertSoleLocation(decl, start, length);
+ }
+ IASTEqualsInitializer initializer = (IASTEqualsInitializer) ((IASTSimpleDeclaration) declarations[2])
+ .getDeclarators()[0].getInitializer();
+ IASTCastExpression castExpression = (IASTCastExpression) initializer.getInitializerClause();
+ IASTTypeId typeId = castExpression.getTypeId();
+ assertSoleLocation(typeId, code.indexOf("(jc)") + 1, "jc".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public void testBug83853() throws ParserException {
+ String code = "int f() {return (1?0:1); }"; //$NON-NLS-1$
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p);
+ IASTFunctionDefinition definition = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement statement = (IASTCompoundStatement) definition.getBody();
+ IASTReturnStatement returnStatement = (IASTReturnStatement) statement.getStatements()[0];
+ IASTUnaryExpression unaryExpression = (IASTUnaryExpression) returnStatement.getReturnValue();
+ assertEquals(unaryExpression.getOperator(), IASTUnaryExpression.op_bracketedPrimary);
+ IASTConditionalExpression conditional = (IASTConditionalExpression) unaryExpression.getOperand();
+ assertSoleLocation(conditional, code.indexOf("1?0:1"), "1?0:1".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public void testBug84374() throws Exception {
+ String code = "class P1 { public: int x; };\nclass P2 { public: int x; };\nclass B : public P1, public P2 {};\nvoid main() {\nB * b = new B();\n}"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ IASTFunctionDefinition main = (IASTFunctionDefinition) tu.getDeclarations()[3];
+ IASTCompoundStatement statement = (IASTCompoundStatement) main.getBody();
+ IASTDeclarationStatement decl = (IASTDeclarationStatement) statement.getStatements()[0];
+ IASTSimpleDeclaration b = (IASTSimpleDeclaration) decl.getDeclaration();
+ IASTEqualsInitializer initializerExpression = (IASTEqualsInitializer) b.getDeclarators()[0].getInitializer();
+ assertSoleLocation(initializerExpression.getInitializerClause(), code.indexOf("new B()"), "new B()".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ ICPPASTNewExpression newExpression = (ICPPASTNewExpression) initializerExpression.getInitializerClause();
+ assertSoleLocation(newExpression, code.indexOf("new B()"), "new B()".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBug83737() throws Exception {
+ String code = "void f() { if( a == 0 ) g( a ); else if( a < 0 ) g( a >> 1 ); else if( a > 0 ) g( *(&a + 2) ); }"; //$NON-NLS-1$
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p);
+ IASTFunctionDefinition definition = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement statement = (IASTCompoundStatement) definition.getBody();
+ IASTIfStatement first_if = (IASTIfStatement) statement.getStatements()[0];
+ IASTIfStatement second_if = (IASTIfStatement) first_if.getElseClause();
+ IASTIfStatement third_if = (IASTIfStatement) second_if.getElseClause();
+ assertNull(third_if.getElseClause());
+ int first_if_start = code.indexOf("if( a == 0 )"); //$NON-NLS-1$
+ int total_if_length = "if( a == 0 ) g( a ); else if( a < 0 ) g( a >> 1 ); else if( a > 0 ) g( *(&a + 2) );" //$NON-NLS-1$
+ .length();
+ int total_if_end = first_if_start + total_if_length;
+ int second_if_start = code.indexOf("if( a < 0 )"); //$NON-NLS-1$
+ int third_if_start = code.indexOf("if( a > 0 )"); //$NON-NLS-1$
+ assertSoleLocation(first_if, first_if_start, total_if_length);
+ assertSoleLocation(second_if, second_if_start, total_if_end - second_if_start);
+ assertSoleLocation(third_if, third_if_start, total_if_end - third_if_start);
+ }
+ }
+
+ public void testBug84467() throws Exception {
+ String code = "class D { };\n D d1;\n const D d2;\n void foo() {\n typeid(d1) == typeid(d2);\n }"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ IASTBinaryExpression bexp = (IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
+ .getDeclarations()[3]).getBody()).getStatements()[0]).getExpression();
+ IASTUnaryExpression exp = (IASTUnaryExpression) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
+ .getDeclarations()[3]).getBody()).getStatements()[0]).getExpression()).getOperand1();
+
+ assertSoleLocation(bexp, code.indexOf("typeid(d1) == typeid(d2)"), "typeid(d1) == typeid(d2)".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertSoleLocation(exp, code.indexOf("typeid(d1)"), "typeid(d1)".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ exp = (IASTUnaryExpression) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
+ .getDeclarations()[3]).getBody()).getStatements()[0]).getExpression()).getOperand2();
+ assertSoleLocation(exp, code.indexOf("typeid(d2)"), "typeid(d2)".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBug84576() throws Exception {
+ String code = "namespace A {\n extern \"C\" int g();\n }"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTLinkageSpecification spec = (ICPPASTLinkageSpecification) ((ICPPASTNamespaceDefinition) tu
+ .getDeclarations()[0]).getDeclarations()[0];
+ assertSoleLocation(spec, code.indexOf("extern \"C\""), "extern \"C\" int g();".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testSimplePreprocessorStatements() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#ifndef _APPLE_H_\n"); //$NON-NLS-1$
+ buffer.append("#define _APPLE_H_\n"); //$NON-NLS-1$
+ buffer.append("#undef _APPLE_H_\n"); //$NON-NLS-1$
+ buffer.append("#endif\n"); //$NON-NLS-1$
+ String code = buffer.toString();
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p);
+ assertEquals(tu.getDeclarations().length, 0);
+ IASTPreprocessorStatement[] statements = tu.getAllPreprocessorStatements();
+ assertEquals(statements.length, 4);
+ IASTPreprocessorIfndefStatement ifndef = (IASTPreprocessorIfndefStatement) statements[0];
+ assertTrue(ifndef.taken());
+ assertSoleLocation(ifndef, code.indexOf("#ifndef _APPLE_H_"), "#ifndef _APPLE_H_".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ IASTPreprocessorObjectStyleMacroDefinition definition = (IASTPreprocessorObjectStyleMacroDefinition) statements[1];
+ assertSoleLocation(definition, code.indexOf("#define _APPLE_H_"), "#define _APPLE_H_".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ IASTPreprocessorUndefStatement undef = (IASTPreprocessorUndefStatement) statements[2];
+ assertSoleLocation(undef, code.indexOf("#undef _APPLE_H_"), "#undef _APPLE_H_".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ IASTPreprocessorEndifStatement endif = (IASTPreprocessorEndifStatement) statements[3];
+ assertSoleLocation(endif, code.indexOf("#endif"), "#endif".length()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public void testBug162180() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#include <notfound.h>\n"); //$NON-NLS-1$
+ buffer.append("int x;\n"); //$NON-NLS-1$
+ String code = buffer.toString();
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p, false, false);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ assertEquals(decls.length, 1);
+ IASTPreprocessorStatement[] statements = tu.getAllPreprocessorStatements();
+ assertEquals(statements.length, 1);
+ IASTProblem[] problems = tu.getPreprocessorProblems();
+ assertEquals(problems.length, 1);
+ assertSoleLocation(decls[0], code, "int x;");
+ }
+ }
private void assertSoleLocation(IASTNode node, String code, String snip) {
assertSoleLocation(node, code.indexOf(snip), snip.length());
@@ -428,380 +431,382 @@ public class DOMLocationTests extends AST2TestBase {
assertFileLocation(node, code.indexOf(snip), snip.length());
}
- public void testBug162180_0() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append( "#include <notfound.h>\n"); //$NON-NLS-1$
- buffer.append( "#include <notfound1.h> \r\n"); //$NON-NLS-1$
- buffer.append( "#include <notfound2.h> // more stuff \n"); //$NON-NLS-1$
- buffer.append( "int x;\n"); //$NON-NLS-1$
- String code = buffer.toString();
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p, false, false);
- IASTDeclaration[] decls= tu.getDeclarations();
- IASTPreprocessorStatement [] statements = tu.getAllPreprocessorStatements();
- IASTProblem[] problems = tu.getPreprocessorProblems();
- assertEquals( 1, decls.length);
- assertEquals( 3, statements.length);
- assertEquals( 3, problems.length);
- String snip= "<notfound.h>";
- assertSoleLocation(statements[0], code, "#include <notfound.h>");
- assertSoleLocation(statements[1], code, "#include <notfound1.h>");
- assertSoleLocation(statements[2], code, "#include <notfound2.h>");
- assertSoleLocation(decls[0], code, "int x;");
- }
- }
-
- public void test162180_1() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append( "#define xxx(!) int a\n"); // [0-20]
- buffer.append( "int x;\n"); // [21-27]
- buffer.append( "int x\\i;\n"); // [28-36]
- buffer.append( "int x2;\n"); // [37-44]
- String code = buffer.toString();
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p, false, false);
- IASTDeclaration[] decls= tu.getDeclarations();
- IASTPreprocessorStatement [] statements = tu.getAllPreprocessorStatements();
- IASTProblem[] problems = tu.getPreprocessorProblems();
- assertEquals( 3, decls.length);
- assertEquals( 0, statements.length);
- assertEquals( 2, problems.length);
- assertSoleLocation(problems[0], code, "xxx(!");
- assertSoleLocation( decls[0], code, "int x;");
- assertSoleLocation( problems[1], code, "\\");
- assertFileLocation( decls[1], code, "int x\\i;");
- assertSoleLocation( decls[2], code, "int x2;");
- }
- }
-
- public void test162180_2() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append( "#define ! x\n");
- buffer.append( "int x;\n");
- String code = buffer.toString();
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p, false, false);
- IASTDeclaration[] decls= tu.getDeclarations();
- IASTPreprocessorStatement [] statements = tu.getAllPreprocessorStatements();
- IASTProblem[] problems = tu.getPreprocessorProblems();
- assertEquals( 1, decls.length);
- assertEquals( 0, statements.length);
- assertEquals( 1, problems.length);
- assertSoleLocation(problems[0], code, "!");
- assertSoleLocation( decls[0], code, "int x;");
- }
- }
-
- public void test162180_3() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append( "#define nix(x) x\n");
- buffer.append( "nix(y,z);");
- buffer.append( "int x;\n");
- String code = buffer.toString();
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p, false, false);
- IASTDeclaration[] decls= tu.getDeclarations();
- IASTPreprocessorStatement [] statements = tu.getAllPreprocessorStatements();
- IASTProblem[] problems = tu.getPreprocessorProblems();
- assertEquals( 2, decls.length);
- assertEquals( 1, statements.length);
- assertEquals( 1, problems.length);
- assertSoleLocation(problems[0], code, "nix(y,");
- assertSoleLocation( decls[1], code, "int x;");
- }
- }
-
- public void test162180_4() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append( "#include \"\"\n");
- buffer.append( "#else\n");
- buffer.append( "int x;\n");
- String code = buffer.toString();
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p, false, false);
- IASTDeclaration[] decls= tu.getDeclarations();
- IASTProblem[] problems = tu.getPreprocessorProblems();
- assertEquals( 1, decls.length);
- assertEquals( 2, problems.length);
- assertSoleLocation(problems[0], code, "#include \"\"");
- assertSoleLocation(problems[1], code, "#else");
- assertSoleLocation( decls[0], code, "int x;");
- }
- }
-
- public void testBug85820() throws Exception {
+ public void testBug162180_0() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#include <notfound.h>\n"); //$NON-NLS-1$
+ buffer.append("#include <notfound1.h> \r\n"); //$NON-NLS-1$
+ buffer.append("#include <notfound2.h> // more stuff \n"); //$NON-NLS-1$
+ buffer.append("int x;\n"); //$NON-NLS-1$
+ String code = buffer.toString();
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p, false, false);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ IASTPreprocessorStatement[] statements = tu.getAllPreprocessorStatements();
+ IASTProblem[] problems = tu.getPreprocessorProblems();
+ assertEquals(1, decls.length);
+ assertEquals(3, statements.length);
+ assertEquals(3, problems.length);
+ String snip = "<notfound.h>";
+ assertSoleLocation(statements[0], code, "#include <notfound.h>");
+ assertSoleLocation(statements[1], code, "#include <notfound1.h>");
+ assertSoleLocation(statements[2], code, "#include <notfound2.h>");
+ assertSoleLocation(decls[0], code, "int x;");
+ }
+ }
+
+ public void test162180_1() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#define xxx(!) int a\n"); // [0-20]
+ buffer.append("int x;\n"); // [21-27]
+ buffer.append("int x\\i;\n"); // [28-36]
+ buffer.append("int x2;\n"); // [37-44]
+ String code = buffer.toString();
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p, false, false);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ IASTPreprocessorStatement[] statements = tu.getAllPreprocessorStatements();
+ IASTProblem[] problems = tu.getPreprocessorProblems();
+ assertEquals(3, decls.length);
+ assertEquals(0, statements.length);
+ assertEquals(2, problems.length);
+ assertSoleLocation(problems[0], code, "xxx(!");
+ assertSoleLocation(decls[0], code, "int x;");
+ assertSoleLocation(problems[1], code, "\\");
+ assertFileLocation(decls[1], code, "int x\\i;");
+ assertSoleLocation(decls[2], code, "int x2;");
+ }
+ }
+
+ public void test162180_2() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#define ! x\n");
+ buffer.append("int x;\n");
+ String code = buffer.toString();
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p, false, false);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ IASTPreprocessorStatement[] statements = tu.getAllPreprocessorStatements();
+ IASTProblem[] problems = tu.getPreprocessorProblems();
+ assertEquals(1, decls.length);
+ assertEquals(0, statements.length);
+ assertEquals(1, problems.length);
+ assertSoleLocation(problems[0], code, "!");
+ assertSoleLocation(decls[0], code, "int x;");
+ }
+ }
+
+ public void test162180_3() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#define nix(x) x\n");
+ buffer.append("nix(y,z);");
+ buffer.append("int x;\n");
+ String code = buffer.toString();
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p, false, false);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ IASTPreprocessorStatement[] statements = tu.getAllPreprocessorStatements();
+ IASTProblem[] problems = tu.getPreprocessorProblems();
+ assertEquals(2, decls.length);
+ assertEquals(1, statements.length);
+ assertEquals(1, problems.length);
+ assertSoleLocation(problems[0], code, "nix(y,");
+ assertSoleLocation(decls[1], code, "int x;");
+ }
+ }
+
+ public void test162180_4() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#include \"\"\n");
+ buffer.append("#else\n");
+ buffer.append("int x;\n");
+ String code = buffer.toString();
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p, false, false);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ IASTProblem[] problems = tu.getPreprocessorProblems();
+ assertEquals(1, decls.length);
+ assertEquals(2, problems.length);
+ assertSoleLocation(problems[0], code, "#include \"\"");
+ assertSoleLocation(problems[1], code, "#else");
+ assertSoleLocation(decls[0], code, "int x;");
+ }
+ }
+
+ public void testBug85820() throws Exception {
String code = "int *p = (int []){2, 4};"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse( code, ParserLanguage.C );
+ IASTTranslationUnit tu = parse(code, ParserLanguage.C);
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTDeclarator d = sd.getDeclarators()[0];
- assertSoleLocation( d, code.indexOf("*p = (int []){2, 4}"), "*p = (int []){2, 4}".length() ); //$NON-NLS-1$//$NON-NLS-2$
+ assertSoleLocation(d, code.indexOf("*p = (int []){2, 4}"), "*p = (int []){2, 4}".length()); //$NON-NLS-1$//$NON-NLS-2$
}
-
- public void testBug86323() throws Exception {
+
+ public void testBug86323() throws Exception {
String code = "void f() { int i=0; for (; i<10; i++) { } }"; //$NON-NLS-1$
- for (ParserLanguage p : ParserLanguage.values()) {
- IASTTranslationUnit tu = parse(code, p);
- IASTForStatement for_stmt = (IASTForStatement) ((IASTCompoundStatement)((IASTFunctionDefinition)tu.getDeclarations()[0]).getBody()).getStatements()[1];
- assertTrue( for_stmt.getInitializerStatement() instanceof IASTNullStatement );
- }
- }
-
- public void testBug86698_1() throws Exception {
+ for (ParserLanguage p : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(code, p);
+ IASTForStatement for_stmt = (IASTForStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
+ .getDeclarations()[0]).getBody()).getStatements()[1];
+ assertTrue(for_stmt.getInitializerStatement() instanceof IASTNullStatement);
+ }
+ }
+
+ public void testBug86698_1() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append( "struct C;\n"); //$NON-NLS-1$
- buffer.append( "void no_opt(C*);\n"); //$NON-NLS-1$
- buffer.append( "struct C {\n"); //$NON-NLS-1$
- buffer.append( "int c;\n"); //$NON-NLS-1$
- buffer.append( "C() : c(0) { no_opt(this); }\n"); //$NON-NLS-1$
- buffer.append( "};\n"); //$NON-NLS-1$
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
- final ICPPASTCompositeTypeSpecifier ct= getCompositeType(tu, 2);
+ buffer.append("struct C;\n"); //$NON-NLS-1$
+ buffer.append("void no_opt(C*);\n"); //$NON-NLS-1$
+ buffer.append("struct C {\n"); //$NON-NLS-1$
+ buffer.append("int c;\n"); //$NON-NLS-1$
+ buffer.append("C() : c(0) { no_opt(this); }\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
+ final ICPPASTCompositeTypeSpecifier ct = getCompositeType(tu, 2);
final ICPPASTFunctionDefinition fdef = getDeclaration(ct, 1);
ICPPASTFunctionDeclarator funC = (ICPPASTFunctionDeclarator) fdef.getDeclarator();
- assertSoleLocation( funC, buffer.toString().indexOf("C()"), "C()".length() ); //$NON-NLS-1$//$NON-NLS-2$
- ICPPASTConstructorChainInitializer memInit= fdef.getMemberInitializers()[0];
- assertSoleLocation( memInit, buffer.toString().indexOf("c(0)"), "c(0)".length() ); //$NON-NLS-1$//$NON-NLS-2$
+ assertSoleLocation(funC, buffer.toString().indexOf("C()"), "C()".length()); //$NON-NLS-1$//$NON-NLS-2$
+ ICPPASTConstructorChainInitializer memInit = fdef.getMemberInitializers()[0];
+ assertSoleLocation(memInit, buffer.toString().indexOf("c(0)"), "c(0)".length()); //$NON-NLS-1$//$NON-NLS-2$
}
- public void testBug86698_2() throws Exception {
+ public void testBug86698_2() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append( "int f(int);\n"); //$NON-NLS-1$
- buffer.append( "class C {\n"); //$NON-NLS-1$
- buffer.append( "int i;\n"); //$NON-NLS-1$
- buffer.append( "double d;\n"); //$NON-NLS-1$
- buffer.append( "public:\n"); //$NON-NLS-1$
- buffer.append( "C(int, double);\n"); //$NON-NLS-1$
- buffer.append( "};\n"); //$NON-NLS-1$
- buffer.append( "C::C(int ii, double id)\n"); //$NON-NLS-1$
- buffer.append( "try\n"); //$NON-NLS-1$
- buffer.append( ": i(f(ii)), d(id)\n"); //$NON-NLS-1$
- buffer.append( "{\n }\n"); //$NON-NLS-1$
- buffer.append( "catch (...)\n"); //$NON-NLS-1$
- buffer.append( "{\n }\n"); //$NON-NLS-1$
-
- final String code = buffer.toString();
+ buffer.append("int f(int);\n"); //$NON-NLS-1$
+ buffer.append("class C {\n"); //$NON-NLS-1$
+ buffer.append("int i;\n"); //$NON-NLS-1$
+ buffer.append("double d;\n"); //$NON-NLS-1$
+ buffer.append("public:\n"); //$NON-NLS-1$
+ buffer.append("C(int, double);\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+ buffer.append("C::C(int ii, double id)\n"); //$NON-NLS-1$
+ buffer.append("try\n"); //$NON-NLS-1$
+ buffer.append(": i(f(ii)), d(id)\n"); //$NON-NLS-1$
+ buffer.append("{\n }\n"); //$NON-NLS-1$
+ buffer.append("catch (...)\n"); //$NON-NLS-1$
+ buffer.append("{\n }\n"); //$NON-NLS-1$
+
+ final String code = buffer.toString();
IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- final IASTFunctionDefinition fdef = (IASTFunctionDefinition)tu.getDeclarations()[2];
+ final IASTFunctionDefinition fdef = (IASTFunctionDefinition) tu.getDeclarations()[2];
assertInstance(fdef, ICPPASTFunctionWithTryBlock.class);
- assertSoleLocation(fdef.getDeclarator(), code.indexOf("C::C(int ii, double id)"), "C::C(int ii, double id)".length() ); //$NON-NLS-1$//$NON-NLS-2$
- ICPPASTFunctionWithTryBlock tryblock= ((ICPPASTFunctionWithTryBlock) fdef);
+ assertSoleLocation(fdef.getDeclarator(), code.indexOf("C::C(int ii, double id)"), //$NON-NLS-1$
+ "C::C(int ii, double id)".length()); //$NON-NLS-1$
+ ICPPASTFunctionWithTryBlock tryblock = ((ICPPASTFunctionWithTryBlock) fdef);
assertSoleLocation(tryblock.getCatchHandlers()[0], code.indexOf("catch"), "catch (...)\n{\n }".length());
}
- public void testBug157009_1() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("#ifndef A\r\n#error X\r\n#else\r\n#error Y\r\n#endif");
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, false, false);
-
- IASTProblem[] problems= tu.getPreprocessorProblems();
- assertEquals(1, problems.length);
- assertSoleLocation(problems[0], buffer.indexOf("X"), "X".length() );
- }
-
- public void testBug157009_2() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("#ifndef A\n#error X\n#else\n#error Y\n#endif");
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, false, false);
-
- IASTProblem[] problems= tu.getPreprocessorProblems();
- assertEquals(1, problems.length);
- assertSoleLocation(problems[0], buffer.indexOf("X"), "X".length() );
- }
-
- public void testBug171520() throws Exception {
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171520
- StringBuilder buffer = new StringBuilder();
- buffer.append("int i = sizeof(int);");
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, false, false);
- IASTDeclaration[] decls= tu.getDeclarations();
- assertEquals(1, decls.length);
- assertSoleLocation(decls[0], 0, buffer.length());
- assertTrue(decls[0] instanceof IASTSimpleDeclaration);
- IASTSimpleDeclaration simpleDecl= (IASTSimpleDeclaration)decls[0];
- IASTDeclarator[] declarators= simpleDecl.getDeclarators();
- assertEquals(1, declarators.length);
- IASTInitializer initializer= declarators[0].getInitializer();
- assertTrue(initializer instanceof IASTEqualsInitializer);
- IASTInitializerClause expr= ((IASTEqualsInitializer)initializer).getInitializerClause();
- assertTrue(expr instanceof IASTTypeIdExpression);
- assertSoleLocation(expr, buffer.indexOf("sizeof"), "sizeof(int)".length());
- }
-
- public void testBug120607() throws Exception {
- // C/C++ Indexer rejects valid pre-processor directive
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=120607
- StringBuilder buffer = new StringBuilder();
- buffer.append("#import \"include_once.h\"\n");
- buffer.append("#warning \"deprecated include\"\n");
- buffer.append("#line 5\n");
- buffer.append("# 5 \"foo.h\"\n");
- buffer.append("#ident \"version 1.0\"\n");
- buffer.append("#assert thisIsTrue(value)\n");
- buffer.append("#unassert thisIsTrue(value)\n");
- buffer.append("#invalid");
- String code= buffer.toString();
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP, true, false);
-
- IASTProblem[] problems= tu.getPreprocessorProblems();
- assertEquals(3, problems.length);
- assertEquals(IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND, problems[0].getID());
- assertEquals(IProblem.PREPROCESSOR_POUND_WARNING, problems[1].getID());
- assertEquals(IProblem.PREPROCESSOR_INVALID_DIRECTIVE, problems[2].getID());
- assertSoleLocation(problems[0], code, "#import \"include_once.h\"");
- assertSoleLocation(problems[1], code, "\"deprecated include\"");
- assertSoleLocation(problems[2], code, "#invalid");
- }
-
- public void testBug527396_1() throws Exception {
- String code = "void foo() noexcept {}"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
- ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarator();
- String rawDeclarator = "foo() noexcept"; //$NON-NLS-1$
- assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testBug527396_2() throws Exception {
- String code = "void foo() noexcept(false) {}"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
- ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarator();
- String rawDeclarator = "foo() noexcept(false)"; //$NON-NLS-1$
- assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testBug527396_3() throws Exception {
- String code = "void foo() {}"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
- ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarator();
- String rawDeclarator = "foo()"; //$NON-NLS-1$
- assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testBug527396_4() throws Exception {
- String code = "void foo() noexcept;"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- IASTSimpleDeclaration definition = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarators()[0];
- String rawDeclarator = "foo() noexcept"; //$NON-NLS-1$
- assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testBug527396_5() throws Exception {
- String code = "void foo() noexcept(false);"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- IASTSimpleDeclaration definition = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarators()[0];
- String rawDeclarator = "foo() noexcept(false)"; //$NON-NLS-1$
- assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testBug527396_6() throws Exception {
- String code = "void foo();"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- IASTSimpleDeclaration definition = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarators()[0];
- String rawDeclarator = "foo()"; //$NON-NLS-1$
- assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testSwitchInitStatement_1() throws Exception {
- String code = "void foo() { switch (int i = 1; i) {} }"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
- IASTSwitchStatement statement = (IASTSwitchStatement) body.getStatements()[0];
- String rawDeclarator = "switch (int i = 1; i) {}"; //$NON-NLS-1$
- assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testSwitchInitStatement_2() throws Exception {
- String code = "void foo() { char c = 'a'; switch (; c) {} }"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
- IASTSwitchStatement statement = (IASTSwitchStatement) body.getStatements()[1];
- String rawDeclarator = "switch (; c) {}"; //$NON-NLS-1$
- assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testIfInitStatement_1() throws Exception {
- String code = "void foo() { if (int i = 1; i == 1) {} }"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
- IASTIfStatement statement = (IASTIfStatement) body.getStatements()[0];
- String rawDeclarator = "if (int i = 1; i == 1) {}"; //$NON-NLS-1$
- assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testIfInitStatement_2() throws Exception {
- String code = "void foo() { if (; bool b = true) {} }"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
- IASTIfStatement statement = (IASTIfStatement) body.getStatements()[0];
- String rawDeclarator = "if (; bool b = true) {}"; //$NON-NLS-1$
- assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testConstexprIf_1() throws Exception {
- String code = "void foo() { if constexpr (true) {} }"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
- IASTIfStatement statement = (IASTIfStatement) body.getStatements()[0];
- String rawDeclarator = "if constexpr (true) {}"; //$NON-NLS-1$
- assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testConstexprIf_2() throws Exception {
- String code = "void foo() { if constexpr (constexpr int i = 1; i == 1) {} }"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
- IASTIfStatement statement = (IASTIfStatement) body.getStatements()[0];
- String rawDeclarator = "if constexpr (constexpr int i = 1; i == 1) {}"; //$NON-NLS-1$
- assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- public void testConstexprIf_3() throws Exception {
- String code = "void foo() { if constexpr (; constexpr bool b = true) {} }"; //$NON-NLS-1$
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
- ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
- IASTIfStatement statement = (IASTIfStatement) body.getStatements()[0];
- String rawDeclarator = "if constexpr (; constexpr bool b = true) {}"; //$NON-NLS-1$
- assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
- }
-
- // int main(void){
- // #define one 1
- // int integer = one;
- // return integer;
- // }
- public void testRawSignature_Bug117029() throws Exception {
- String content= getContents(1)[0].toString();
- IASTTranslationUnit tu= parse(content, ParserLanguage.CPP);
- IASTFunctionDefinition decl= (IASTFunctionDefinition) tu.getDeclarations()[0];
- IASTCompoundStatement compound= (IASTCompoundStatement) decl.getBody();
- assertEquals("int integer = one;", compound.getStatements()[0].getRawSignature());
- assertEquals("return integer;", compound.getStatements()[1].getRawSignature());
- }
-
+ public void testBug157009_1() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#ifndef A\r\n#error X\r\n#else\r\n#error Y\r\n#endif");
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, false, false);
+
+ IASTProblem[] problems = tu.getPreprocessorProblems();
+ assertEquals(1, problems.length);
+ assertSoleLocation(problems[0], buffer.indexOf("X"), "X".length());
+ }
+
+ public void testBug157009_2() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#ifndef A\n#error X\n#else\n#error Y\n#endif");
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, false, false);
+
+ IASTProblem[] problems = tu.getPreprocessorProblems();
+ assertEquals(1, problems.length);
+ assertSoleLocation(problems[0], buffer.indexOf("X"), "X".length());
+ }
+
+ public void testBug171520() throws Exception {
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171520
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int i = sizeof(int);");
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ IASTDeclaration[] decls = tu.getDeclarations();
+ assertEquals(1, decls.length);
+ assertSoleLocation(decls[0], 0, buffer.length());
+ assertTrue(decls[0] instanceof IASTSimpleDeclaration);
+ IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) decls[0];
+ IASTDeclarator[] declarators = simpleDecl.getDeclarators();
+ assertEquals(1, declarators.length);
+ IASTInitializer initializer = declarators[0].getInitializer();
+ assertTrue(initializer instanceof IASTEqualsInitializer);
+ IASTInitializerClause expr = ((IASTEqualsInitializer) initializer).getInitializerClause();
+ assertTrue(expr instanceof IASTTypeIdExpression);
+ assertSoleLocation(expr, buffer.indexOf("sizeof"), "sizeof(int)".length());
+ }
+
+ public void testBug120607() throws Exception {
+ // C/C++ Indexer rejects valid pre-processor directive
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=120607
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#import \"include_once.h\"\n");
+ buffer.append("#warning \"deprecated include\"\n");
+ buffer.append("#line 5\n");
+ buffer.append("# 5 \"foo.h\"\n");
+ buffer.append("#ident \"version 1.0\"\n");
+ buffer.append("#assert thisIsTrue(value)\n");
+ buffer.append("#unassert thisIsTrue(value)\n");
+ buffer.append("#invalid");
+ String code = buffer.toString();
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP, true, false);
+
+ IASTProblem[] problems = tu.getPreprocessorProblems();
+ assertEquals(3, problems.length);
+ assertEquals(IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND, problems[0].getID());
+ assertEquals(IProblem.PREPROCESSOR_POUND_WARNING, problems[1].getID());
+ assertEquals(IProblem.PREPROCESSOR_INVALID_DIRECTIVE, problems[2].getID());
+ assertSoleLocation(problems[0], code, "#import \"include_once.h\"");
+ assertSoleLocation(problems[1], code, "\"deprecated include\"");
+ assertSoleLocation(problems[2], code, "#invalid");
+ }
+
+ public void testBug527396_1() throws Exception {
+ String code = "void foo() noexcept {}"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
+ ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarator();
+ String rawDeclarator = "foo() noexcept"; //$NON-NLS-1$
+ assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testBug527396_2() throws Exception {
+ String code = "void foo() noexcept(false) {}"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
+ ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarator();
+ String rawDeclarator = "foo() noexcept(false)"; //$NON-NLS-1$
+ assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testBug527396_3() throws Exception {
+ String code = "void foo() {}"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
+ ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarator();
+ String rawDeclarator = "foo()"; //$NON-NLS-1$
+ assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testBug527396_4() throws Exception {
+ String code = "void foo() noexcept;"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ IASTSimpleDeclaration definition = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarators()[0];
+ String rawDeclarator = "foo() noexcept"; //$NON-NLS-1$
+ assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testBug527396_5() throws Exception {
+ String code = "void foo() noexcept(false);"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ IASTSimpleDeclaration definition = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarators()[0];
+ String rawDeclarator = "foo() noexcept(false)"; //$NON-NLS-1$
+ assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testBug527396_6() throws Exception {
+ String code = "void foo();"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ IASTSimpleDeclaration definition = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ ICPPASTDeclarator declarator = (ICPPASTDeclarator) definition.getDeclarators()[0];
+ String rawDeclarator = "foo()"; //$NON-NLS-1$
+ assertSoleLocation(declarator, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testSwitchInitStatement_1() throws Exception {
+ String code = "void foo() { switch (int i = 1; i) {} }"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
+ IASTSwitchStatement statement = (IASTSwitchStatement) body.getStatements()[0];
+ String rawDeclarator = "switch (int i = 1; i) {}"; //$NON-NLS-1$
+ assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testSwitchInitStatement_2() throws Exception {
+ String code = "void foo() { char c = 'a'; switch (; c) {} }"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
+ IASTSwitchStatement statement = (IASTSwitchStatement) body.getStatements()[1];
+ String rawDeclarator = "switch (; c) {}"; //$NON-NLS-1$
+ assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testIfInitStatement_1() throws Exception {
+ String code = "void foo() { if (int i = 1; i == 1) {} }"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
+ IASTIfStatement statement = (IASTIfStatement) body.getStatements()[0];
+ String rawDeclarator = "if (int i = 1; i == 1) {}"; //$NON-NLS-1$
+ assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testIfInitStatement_2() throws Exception {
+ String code = "void foo() { if (; bool b = true) {} }"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
+ IASTIfStatement statement = (IASTIfStatement) body.getStatements()[0];
+ String rawDeclarator = "if (; bool b = true) {}"; //$NON-NLS-1$
+ assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testConstexprIf_1() throws Exception {
+ String code = "void foo() { if constexpr (true) {} }"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
+ IASTIfStatement statement = (IASTIfStatement) body.getStatements()[0];
+ String rawDeclarator = "if constexpr (true) {}"; //$NON-NLS-1$
+ assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testConstexprIf_2() throws Exception {
+ String code = "void foo() { if constexpr (constexpr int i = 1; i == 1) {} }"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
+ IASTIfStatement statement = (IASTIfStatement) body.getStatements()[0];
+ String rawDeclarator = "if constexpr (constexpr int i = 1; i == 1) {}"; //$NON-NLS-1$
+ assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ public void testConstexprIf_3() throws Exception {
+ String code = "void foo() { if constexpr (; constexpr bool b = true) {} }"; //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ ICPPASTFunctionDefinition definition = (ICPPASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement body = (IASTCompoundStatement) definition.getBody();
+ IASTIfStatement statement = (IASTIfStatement) body.getStatements()[0];
+ String rawDeclarator = "if constexpr (; constexpr bool b = true) {}"; //$NON-NLS-1$
+ assertSoleLocation(statement, code.indexOf(rawDeclarator), rawDeclarator.length());
+ }
+
+ // int main(void){
+ // #define one 1
+ // int integer = one;
+ // return integer;
+ // }
+ public void testRawSignature_Bug117029() throws Exception {
+ String content = getContents(1)[0].toString();
+ IASTTranslationUnit tu = parse(content, ParserLanguage.CPP);
+ IASTFunctionDefinition decl = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ IASTCompoundStatement compound = (IASTCompoundStatement) decl.getBody();
+ assertEquals("int integer = one;", compound.getStatements()[0].getRawSignature());
+ assertEquals("return integer;", compound.getStatements()[1].getRawSignature());
+ }
+
public void testTemplateIdNameLocation_Bug211444() throws Exception {
- IASTTranslationUnit tu = parse( "Foo::template test<T> bar;", ParserLanguage.CPP );
+ IASTTranslationUnit tu = parse("Foo::template test<T> bar;", ParserLanguage.CPP);
NameCollector col = new NameCollector();
- tu.accept( col );
-
+ tu.accept(col);
+
ICPPASTQualifiedName qn = (ICPPASTQualifiedName) col.getName(0);
IASTName lastName = qn.getLastName();
assertTrue(lastName instanceof ICPPASTTemplateId);
- ICPPASTTemplateId templateId= (ICPPASTTemplateId) lastName;
- IASTName templateIdName= templateId.getTemplateName();
-
+ ICPPASTTemplateId templateId = (ICPPASTTemplateId) lastName;
+ IASTName templateIdName = templateId.getTemplateName();
+
assertEquals("test", templateIdName.getRawSignature()); //$NON-NLS-1$
}
@@ -820,11 +825,12 @@ public class DOMLocationTests extends AST2TestBase {
public void testFunctionDeclaratorLocationContainsVirtualSpecifiers_Bug518628() throws Exception {
String testCode = getAboveComment();
BindingAssertionHelper assertionHelper = getAssertionHelper(ParserLanguage.CPP);
- String[] funcDeclaratorSignatures = new String[]{"func1() final", "func2() override", "func3() final override", "func4() override final"};
+ String[] funcDeclaratorSignatures = new String[] { "func1() final", "func2() override",
+ "func3() final override", "func4() override final" };
Arrays.stream(funcDeclaratorSignatures).forEach(signature -> {
IASTNode func1Declarator = assertionHelper.assertNode(signature, ICPPASTFunctionDeclarator.class);
assertFileLocation(func1Declarator, testCode, signature);
-
+
});
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java
index d66145b3f87..b7174a8adbb 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java
@@ -33,7 +33,7 @@ import junit.framework.TestSuite;
*/
public class DOMParserTestSuite extends TestCase {
public static Test suite() {
- TestSuite suite= new TestSuite(DOMParserTestSuite.class.getName());
+ TestSuite suite = new TestSuite(DOMParserTestSuite.class.getName());
suite.addTest(AST2Tests.suite());
suite.addTestSuite(GCCTests.class);
suite.addTest(AST2CPPTests.suite());
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java
index f20700f017d..0242505d264 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Emanuel Graf - initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Emanuel Graf - initial API and implementation
* Markus Schorn (Wind River Systems)
******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2;
@@ -36,164 +36,163 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
*
*/
public class DOMPreprocessorInformationTest extends AST2TestBase {
-
+
public void testPragma() throws Exception {
String msg = "GCC poison printf sprintf fprintf";
- StringBuilder buffer = new StringBuilder( "#pragma " + msg + "\n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ StringBuilder buffer = new StringBuilder("#pragma " + msg + "\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(1, st.length);
assertTrue(st[0] instanceof IASTPreprocessorPragmaStatement);
IASTPreprocessorPragmaStatement pragma = (IASTPreprocessorPragmaStatement) st[0];
assertEquals(msg, new String(pragma.getMessage()));
}
-
+
public void testElIf() throws Exception {
String cond = "2 == 2";
- StringBuilder buffer = new StringBuilder( "#if 1 == 2\n#elif " + cond + "\n#else\n#endif\n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ StringBuilder buffer = new StringBuilder("#if 1 == 2\n#elif " + cond + "\n#else\n#endif\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(4, st.length);
assertTrue(st[1] instanceof IASTPreprocessorElifStatement);
IASTPreprocessorElifStatement pragma = (IASTPreprocessorElifStatement) st[1];
assertEquals(cond, new String(pragma.getCondition()));
}
-
+
public void testIf() throws Exception {
String cond = "2 == 2";
- StringBuilder buffer = new StringBuilder( "#if " + cond + "\n#endif\n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ StringBuilder buffer = new StringBuilder("#if " + cond + "\n#endif\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(2, st.length);
assertTrue(st[0] instanceof IASTPreprocessorIfStatement);
IASTPreprocessorIfStatement pragma = (IASTPreprocessorIfStatement) st[0];
assertEquals(cond, new String(pragma.getCondition()));
}
-
- public void testIfDef() throws Exception{
+
+ public void testIfDef() throws Exception {
String cond = "SYMBOL";
- StringBuilder buffer = new StringBuilder( "#ifdef " + cond + "\n#endif\n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ StringBuilder buffer = new StringBuilder("#ifdef " + cond + "\n#endif\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(2, st.length);
assertTrue(st[0] instanceof IASTPreprocessorIfdefStatement);
IASTPreprocessorIfdefStatement pragma = (IASTPreprocessorIfdefStatement) st[0];
assertEquals(cond, new String(pragma.getCondition()));
}
-
- public void testIfnDef() throws Exception{
+
+ public void testIfnDef() throws Exception {
String cond = "SYMBOL";
- StringBuilder buffer = new StringBuilder( "#ifndef " + cond + "\n#endif\n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ StringBuilder buffer = new StringBuilder("#ifndef " + cond + "\n#endif\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(2, st.length);
assertTrue(st[0] instanceof IASTPreprocessorIfndefStatement);
IASTPreprocessorIfndefStatement pragma = (IASTPreprocessorIfndefStatement) st[0];
assertEquals(cond, new String(pragma.getCondition()));
}
-
- public void testError() throws Exception{
+
+ public void testError() throws Exception {
String msg = "Message";
- StringBuilder buffer = new StringBuilder( "#error " + msg + "\n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP, false, false );
+ StringBuilder buffer = new StringBuilder("#error " + msg + "\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, false, false);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(1, st.length);
assertTrue(st[0] instanceof IASTPreprocessorErrorStatement);
IASTPreprocessorErrorStatement pragma = (IASTPreprocessorErrorStatement) st[0];
assertEquals(msg, new String(pragma.getMessage()));
}
-
+
public void testPragmaWithSpaces() throws Exception {
String msg = "GCC poison printf sprintf fprintf";
- StringBuilder buffer = new StringBuilder( "# pragma " + msg + " \n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ StringBuilder buffer = new StringBuilder("# pragma " + msg + " \n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(1, st.length);
assertTrue(st[0] instanceof IASTPreprocessorPragmaStatement);
IASTPreprocessorPragmaStatement pragma = (IASTPreprocessorPragmaStatement) st[0];
assertEquals(msg, new String(pragma.getMessage()));
}
-
+
public void testElIfWithSpaces() throws Exception {
String cond = "2 == 2";
- StringBuilder buffer = new StringBuilder( "#if 1 == 2\n# elif " + cond + " \n#else\n#endif\n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ StringBuilder buffer = new StringBuilder("#if 1 == 2\n# elif " + cond + " \n#else\n#endif\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(4, st.length);
assertTrue(st[1] instanceof IASTPreprocessorElifStatement);
IASTPreprocessorElifStatement pragma = (IASTPreprocessorElifStatement) st[1];
assertEquals(cond, new String(pragma.getCondition()));
}
-
+
public void testIfWithSpaces() throws Exception {
String cond = "2 == 2";
- StringBuilder buffer = new StringBuilder( "# if " + cond + " \n#endif\n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ StringBuilder buffer = new StringBuilder("# if " + cond + " \n#endif\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(2, st.length);
assertTrue(st[0] instanceof IASTPreprocessorIfStatement);
IASTPreprocessorIfStatement pragma = (IASTPreprocessorIfStatement) st[0];
assertEquals(cond, new String(pragma.getCondition()));
}
-
- public void testIfDefWithSpaces() throws Exception{
+
+ public void testIfDefWithSpaces() throws Exception {
String cond = "SYMBOL";
- StringBuilder buffer = new StringBuilder( "# ifdef " + cond + " \n#endif\n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ StringBuilder buffer = new StringBuilder("# ifdef " + cond + " \n#endif\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(2, st.length);
assertTrue(st[0] instanceof IASTPreprocessorIfdefStatement);
IASTPreprocessorIfdefStatement pragma = (IASTPreprocessorIfdefStatement) st[0];
assertEquals(cond, new String(pragma.getCondition()));
}
-
- public void testIfnDefWithSpaces() throws Exception{
+
+ public void testIfnDefWithSpaces() throws Exception {
String cond = "SYMBOL";
- StringBuilder buffer = new StringBuilder( "# ifndef " + cond + "\t\n#endif\n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ StringBuilder buffer = new StringBuilder("# ifndef " + cond + "\t\n#endif\n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(2, st.length);
assertTrue(st[0] instanceof IASTPreprocessorIfndefStatement);
IASTPreprocessorIfndefStatement pragma = (IASTPreprocessorIfndefStatement) st[0];
assertEquals(cond, new String(pragma.getCondition()));
}
-
- public void testErrorWithSpaces() throws Exception{
+
+ public void testErrorWithSpaces() throws Exception {
String msg = "Message";
- StringBuilder buffer = new StringBuilder( "# error \t" + msg + " \n" ); //$NON-NLS-1$
- IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP, false, false );
+ StringBuilder buffer = new StringBuilder("# error \t" + msg + " \n"); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, false, false);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(1, st.length);
assertTrue(st[0] instanceof IASTPreprocessorErrorStatement);
IASTPreprocessorErrorStatement pragma = (IASTPreprocessorErrorStatement) st[0];
assertEquals(msg, new String(pragma.getMessage()));
}
-
+
public void testMacroExpansion() throws Exception {
StringBuilder sb = new StringBuilder();
sb.append("#define add(a, b) (a) + (b) \n");
sb.append("int x = add(foo, bar); \n");
String code = sb.toString();
-
- IASTTranslationUnit tu = parse( code, ParserLanguage.CPP, false, false );
+
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP, false, false);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(1, st.length);
assertTrue(st[0] instanceof IASTPreprocessorFunctionStyleMacroDefinition);
-
+
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTEqualsInitializer einit = (IASTEqualsInitializer) decl.getDeclarators()[0].getInitializer();
- IASTInitializerClause init= einit.getInitializerClause();
-
-
+ IASTInitializerClause init = einit.getInitializerClause();
+
IASTNodeLocation[] nodeLocations = init.getNodeLocations();
assertEquals(1, nodeLocations.length);
}
-
+
// #ifdef xxx
// #elif
// #endif
public void testElifWithoutCondition_bug185324() throws Exception {
- CharSequence code= getContents(1)[0];
+ CharSequence code = getContents(1)[0];
IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, false);
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(3, st.length);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSearchUtil.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSearchUtil.java
index f3ccbef95b8..142355b1775 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSearchUtil.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSearchUtil.java
@@ -44,93 +44,92 @@ import org.eclipse.core.runtime.content.IContentType;
*/
public class DOMSearchUtil {
public static final int DECLARATIONS = 1;
- public static final int DEFINITIONS = 2;
- public static final int DECLARATIONS_DEFINITIONS = 3;
- public static final int REFERENCES = 4;
- public static final int ALL_OCCURRENCES = 5;
-
- /**
- * Retrieves the ParserLanguage from an file.
- */
- public static ParserLanguage getLanguageFromFile(IFile file) {
- IProject project = file.getProject();
- IContentType contentType = CCorePlugin.getContentType(project, file.getFullPath().lastSegment());
- if (contentType != null) {
- String lid = contentType.getId();
- if (CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(lid) ||
- CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(lid)) {
- return ParserLanguage.CPP;
- }
- }
- return ParserLanguage.C;
- }
-
- /**
- * The NameCollector used to get IASTNames from an IASTNode.
- *
- * @author dsteffle
- */
- static public class NameCollector extends ASTVisitor {
- {
- shouldVisitNames = true;
- }
- public List nameList = new ArrayList();
-
- @Override
+ public static final int DEFINITIONS = 2;
+ public static final int DECLARATIONS_DEFINITIONS = 3;
+ public static final int REFERENCES = 4;
+ public static final int ALL_OCCURRENCES = 5;
+
+ /**
+ * Retrieves the ParserLanguage from an file.
+ */
+ public static ParserLanguage getLanguageFromFile(IFile file) {
+ IProject project = file.getProject();
+ IContentType contentType = CCorePlugin.getContentType(project, file.getFullPath().lastSegment());
+ if (contentType != null) {
+ String lid = contentType.getId();
+ if (CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(lid) || CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(lid)) {
+ return ParserLanguage.CPP;
+ }
+ }
+ return ParserLanguage.C;
+ }
+
+ /**
+ * The NameCollector used to get IASTNames from an IASTNode.
+ *
+ * @author dsteffle
+ */
+ static public class NameCollector extends ASTVisitor {
+ {
+ shouldVisitNames = true;
+ }
+ public List nameList = new ArrayList();
+
+ @Override
public int visit(IASTName name) {
- nameList.add(name);
- return PROCESS_CONTINUE;
- }
+ nameList.add(name);
+ return PROCESS_CONTINUE;
+ }
- public IASTName getName(int idx) {
- if (idx < 0 || idx >= nameList.size())
- return null;
- return (IASTName) nameList.get(idx);
- }
+ public IASTName getName(int idx) {
+ if (idx < 0 || idx >= nameList.size())
+ return null;
+ return (IASTName) nameList.get(idx);
+ }
- public int size() {
- return nameList.size();
- }
- }
+ public int size() {
+ return nameList.size();
+ }
+ }
/**
* Returns the ParserLanguage corresponding to the IPath and IProject.
* Returns ParserLanguage.CPP if the file type is a header.
*/
- public static ParserLanguage getLanguage(IPath path, IProject project) {
- //FIXME: ALAIN, for headers should we assume CPP ??
- // The problem is that it really depends on how the header was included.
- String id = null;
- IContentType contentType = CCorePlugin.getContentType(project, path.lastSegment());
- if (contentType != null) {
- id = contentType.getId();
- }
- if (id != null) {
- if (CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(id)) {
- return ParserLanguage.CPP;
- } else if (CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(id)) {
- return ParserLanguage.CPP;
- } else if (CCorePlugin.CONTENT_TYPE_CHEADER.equals(id)) {
- return ParserLanguage.C;
- } else if (CCorePlugin.CONTENT_TYPE_CSOURCE.equals(id)) {
- return ParserLanguage.C;
- } else if (CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(id)) {
- // ???
- // What do we do here ?
- }
- }
+ public static ParserLanguage getLanguage(IPath path, IProject project) {
+ //FIXME: ALAIN, for headers should we assume CPP ??
+ // The problem is that it really depends on how the header was included.
+ String id = null;
+ IContentType contentType = CCorePlugin.getContentType(project, path.lastSegment());
+ if (contentType != null) {
+ id = contentType.getId();
+ }
+ if (id != null) {
+ if (CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(id)) {
+ return ParserLanguage.CPP;
+ } else if (CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(id)) {
+ return ParserLanguage.CPP;
+ } else if (CCorePlugin.CONTENT_TYPE_CHEADER.equals(id)) {
+ return ParserLanguage.C;
+ } else if (CCorePlugin.CONTENT_TYPE_CSOURCE.equals(id)) {
+ return ParserLanguage.C;
+ } else if (CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(id)) {
+ // ???
+ // What do we do here ?
+ }
+ }
return ParserLanguage.CPP;
- }
-
- /**
- * This is used to get the names from the TU that the IASTName searchName belongs to.
- *
- * @param searchName the IASTName whose references/declarations are to be retrieved
- * @param limitTo used to specify whether to get declarations, references, or both, one of:
- * (CSearchPattern.DECLARATION | CSearchPattern.REFERENCES | CSearchPattern.ALL_OCCURRENCES)
- * @return IASTName[] declarations, references, or both depending on limitTo that correspond to the IASTName searchName searched for
- */
- public static IName[] getNamesFromDOM(IASTName searchName, int limitTo) {
+ }
+
+ /**
+ * This is used to get the names from the TU that the IASTName searchName belongs to.
+ *
+ * @param searchName the IASTName whose references/declarations are to be retrieved
+ * @param limitTo used to specify whether to get declarations, references, or both, one of:
+ * (CSearchPattern.DECLARATION | CSearchPattern.REFERENCES | CSearchPattern.ALL_OCCURRENCES)
+ * @return IASTName[] declarations, references, or both depending on limitTo that correspond to the IASTName searchName searched for
+ */
+ public static IName[] getNamesFromDOM(IASTName searchName, int limitTo) {
IName[] names = null;
IASTTranslationUnit tu = searchName.getTranslationUnit();
@@ -141,28 +140,29 @@ public class DOMSearchUtil {
IBinding binding = searchName.resolveBinding();
if (binding instanceof IIndexBinding) {
Assert.fail("Not implemented");
-// try {
-// ArrayList pdomNames = new ArrayList();
-// IPDOMResolver pdom= ((PDOMBinding) binding).getPDOM();
-// // First decls
-// names= pdom.getDeclarations(binding);
-// pdomNames.addAll(Arrays.asList(names));
-// // Next defs
-// names= pdom.getDefinitions(binding);
-// pdomNames.addAll(Arrays.asList(names));
-// names = (IName[])pdomNames.toArray(new IName[pdomNames.size()]);
-// } catch (CoreException e) {
-// CCorePlugin.log(e);
-// }
+ // try {
+ // ArrayList pdomNames = new ArrayList();
+ // IPDOMResolver pdom= ((PDOMBinding) binding).getPDOM();
+ // // First decls
+ // names= pdom.getDeclarations(binding);
+ // pdomNames.addAll(Arrays.asList(names));
+ // // Next defs
+ // names= pdom.getDefinitions(binding);
+ // pdomNames.addAll(Arrays.asList(names));
+ // names = (IName[])pdomNames.toArray(new IName[pdomNames.size()]);
+ // } catch (CoreException e) {
+ // CCorePlugin.log(e);
+ // }
} else {
names = getNames(tu, binding, limitTo);
if (names == null || names.length == 0) { // try alternate strategies
try {
// fix for 86829, 95224
- if ((binding instanceof ICPPConstructor || (binding instanceof ICPPMethod && ((ICPPMethod)binding).isDestructor()))
+ if ((binding instanceof ICPPConstructor
+ || (binding instanceof ICPPMethod && ((ICPPMethod) binding).isDestructor()))
&& binding.getScope() instanceof ICPPClassScope) {
- binding = ((ICPPClassScope) binding.getScope()).getClassType();
+ binding = ((ICPPClassScope) binding.getScope()).getClassType();
names = getNames(tu, binding, limitTo);
}
} catch (DOMException e) {
@@ -171,24 +171,23 @@ public class DOMSearchUtil {
}
return names;
- }
+ }
private static IASTName[] getNames(IASTTranslationUnit tu, IBinding binding, int limitTo) {
- IASTName[] names = null;
- if (limitTo == DECLARATIONS ||
- limitTo == DECLARATIONS_DEFINITIONS) {
- names = tu.getDeclarationsInAST(binding);
- } else if (limitTo == REFERENCES) {
- names = tu.getReferences(binding);
- } else if (limitTo == DEFINITIONS) {
- names = tu.getDefinitionsInAST(binding);
- } else if (limitTo == ALL_OCCURRENCES) {
- names = tu.getDeclarationsInAST(binding);
- names = ArrayUtil.addAll(IASTName.class, names, tu.getReferences(binding));
- } else { // assume ALL
- names = tu.getDeclarationsInAST(binding);
- names = ArrayUtil.addAll(IASTName.class, names, tu.getReferences(binding));
- }
+ IASTName[] names = null;
+ if (limitTo == DECLARATIONS || limitTo == DECLARATIONS_DEFINITIONS) {
+ names = tu.getDeclarationsInAST(binding);
+ } else if (limitTo == REFERENCES) {
+ names = tu.getReferences(binding);
+ } else if (limitTo == DEFINITIONS) {
+ names = tu.getDefinitionsInAST(binding);
+ } else if (limitTo == ALL_OCCURRENCES) {
+ names = tu.getDeclarationsInAST(binding);
+ names = ArrayUtil.addAll(IASTName.class, names, tu.getReferences(binding));
+ } else { // assume ALL
+ names = tu.getDeclarationsInAST(binding);
+ names = ArrayUtil.addAll(IASTName.class, names, tu.getReferences(binding));
+ }
return names;
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTest.java
index 53552724954..5a0cf21157e 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTest.java
@@ -151,24 +151,22 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testBug57898() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Gonzo { public: void playHorn(); };\n");
- writer.write( "void Gonzo::playHorn() { return; }\n");
- writer.write( "int main(int argc, char **argv) { Gonzo gonzo; gonzo.playHorn(); }\n");
+ writer.write("class Gonzo { public: void playHorn(); };\n");
+ writer.write("void Gonzo::playHorn() { return; }\n");
+ writer.write("int main(int argc, char **argv) { Gonzo gonzo; gonzo.playHorn(); }\n");
String code = writer.toString();
- for( int i = 0; i < 3; ++i )
- {
+ for (int i = 0; i < 3; ++i) {
int start = -1, stop = -1;
- switch( i )
- {
- case 0:
- start = code.indexOf("void playHorn") + 5;
- break;
- case 1:
- start = code.indexOf("::playHorn") + 2;
- break;
- case 2:
- start = code.indexOf(".playHorn") + 1;
- break;
+ switch (i) {
+ case 0:
+ start = code.indexOf("void playHorn") + 5;
+ break;
+ case 1:
+ start = code.indexOf("::playHorn") + 2;
+ break;
+ case 2:
+ start = code.indexOf(".playHorn") + 1;
+ break;
}
stop = start + 8;
IASTNode node = parse(code, start, stop);
@@ -186,7 +184,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testConstructorDestructorDeclaration() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Gonzo { Gonzo(); ~Gonzo(); };");
+ writer.write("class Gonzo { Gonzo(); ~Gonzo(); };");
String code = writer.toString();
int offset = code.indexOf(" Gonzo()") + 1;
IASTNode node = parse(code, offset, offset + 5);
@@ -204,8 +202,8 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testBug60264() throws Exception {
Writer writer = new StringWriter();
- writer.write( "namespace Muppets { int i; }\n");
- writer.write( "int main(int argc, char **argv) { Muppets::i = 1; }\n");
+ writer.write("namespace Muppets { int i; }\n");
+ writer.write("int main(int argc, char **argv) { Muppets::i = 1; }\n");
String code = writer.toString();
int index = code.indexOf("Muppets::");
IASTNode node = parse(code, index, index + 7);
@@ -233,14 +231,14 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testBug61613() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Foo { // ** (A) **\n");
- writer.write( " public:\n");
- writer.write( "Foo() {};\n");
- writer.write( "};\n");
- writer.write( "int \n");
- writer.write( "main(int argc, char **argv) {\n");
- writer.write( "Foo foo; // ** (B) **\n");
- writer.write( "}\n");
+ writer.write("class Foo { // ** (A) **\n");
+ writer.write(" public:\n");
+ writer.write("Foo() {};\n");
+ writer.write("};\n");
+ writer.write("int \n");
+ writer.write("main(int argc, char **argv) {\n");
+ writer.write("Foo foo; // ** (B) **\n");
+ writer.write("}\n");
String code = writer.toString();
int index = code.indexOf("class Foo") + 6;
IASTNode node = parse(code, index, index + 3);
@@ -256,35 +254,33 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testBug60038() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Gonzo {\n");
- writer.write( "public:\n");
- writer.write( "Gonzo( const Gonzo & other ){}\n");
- writer.write( "Gonzo() {}\n");
- writer.write( "~Gonzo(){}\n");
- writer.write( "};\n");
- writer.write( "int main(int argc, char **argv) {\n");
- writer.write( " Gonzo * g = new Gonzo();\n");
- writer.write( " Gonzo * g2 = new Gonzo( *g );\n");
- writer.write( " g->~Gonzo();\n");
- writer.write( " return (int) g2;\n");
- writer.write( "}\n");
+ writer.write("class Gonzo {\n");
+ writer.write("public:\n");
+ writer.write("Gonzo( const Gonzo & other ){}\n");
+ writer.write("Gonzo() {}\n");
+ writer.write("~Gonzo(){}\n");
+ writer.write("};\n");
+ writer.write("int main(int argc, char **argv) {\n");
+ writer.write(" Gonzo * g = new Gonzo();\n");
+ writer.write(" Gonzo * g2 = new Gonzo( *g );\n");
+ writer.write(" g->~Gonzo();\n");
+ writer.write(" return (int) g2;\n");
+ writer.write("}\n");
String code = writer.toString();
- for( int i = 0; i < 3; ++i )
- {
+ for (int i = 0; i < 3; ++i) {
int startOffset = 0, endOffset = 0;
- switch( i )
- {
- case 0:
- startOffset = code.indexOf("new Gonzo()") + 4;
- endOffset = startOffset + 5;
- break;
- case 1:
- startOffset = code.indexOf("new Gonzo( ") + 4;
- endOffset = startOffset + 5;
- break;
- default:
- startOffset = code.indexOf("->~") + 2;
- endOffset = startOffset + 6;
+ switch (i) {
+ case 0:
+ startOffset = code.indexOf("new Gonzo()") + 4;
+ endOffset = startOffset + 5;
+ break;
+ case 1:
+ startOffset = code.indexOf("new Gonzo( ") + 4;
+ endOffset = startOffset + 5;
+ break;
+ default:
+ startOffset = code.indexOf("->~") + 2;
+ endOffset = startOffset + 6;
}
IASTNode node = parse(code, startOffset, endOffset);
assertTrue(node instanceof IASTName);
@@ -295,35 +291,34 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
}
assertTrue(binding instanceof ICPPMethod);
IName[] decls = null;
- switch( i )
- {
- case 0:
- assertTrue(binding instanceof ICPPConstructor);
- decls = getDeclarationOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "Gonzo");
- assertEquals(((ASTNode) decls[0]).getOffset(), 53);
- assertEquals(((ASTNode) decls[0]).getLength(), 5);
- break;
- case 1:
- assertTrue(binding instanceof ICPPConstructor);
- decls = getDeclarationOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "Gonzo");
- assertEquals(((ASTNode) decls[0]).getOffset(), 22);
- assertEquals(((ASTNode) decls[0]).getLength(), 5);
- break;
- default:
- assertFalse( binding instanceof ICPPConstructor);
- String name = ((IASTName) node).toString();
- assertEquals(name.indexOf("~"), 0);
- assertEquals(name.indexOf("Gonzo"), 1);
- decls = getDeclarationOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "~Gonzo");
- assertEquals(((ASTNode) decls[0]).getOffset(), 64);
- assertEquals(((ASTNode) decls[0]).getLength(), 6);
- break;
+ switch (i) {
+ case 0:
+ assertTrue(binding instanceof ICPPConstructor);
+ decls = getDeclarationOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "Gonzo");
+ assertEquals(((ASTNode) decls[0]).getOffset(), 53);
+ assertEquals(((ASTNode) decls[0]).getLength(), 5);
+ break;
+ case 1:
+ assertTrue(binding instanceof ICPPConstructor);
+ decls = getDeclarationOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "Gonzo");
+ assertEquals(((ASTNode) decls[0]).getOffset(), 22);
+ assertEquals(((ASTNode) decls[0]).getLength(), 5);
+ break;
+ default:
+ assertFalse(binding instanceof ICPPConstructor);
+ String name = ((IASTName) node).toString();
+ assertEquals(name.indexOf("~"), 0);
+ assertEquals(name.indexOf("Gonzo"), 1);
+ decls = getDeclarationOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "~Gonzo");
+ assertEquals(((ASTNode) decls[0]).getOffset(), 64);
+ assertEquals(((ASTNode) decls[0]).getLength(), 6);
+ break;
}
}
@@ -331,16 +326,16 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testMethodReference() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Sample { public:\n");
- writer.write( " int getAnswer() const;\n");
- writer.write( "};\n");
- writer.write( "int main(int argc, char **argv) {\n");
- writer.write( " Sample * s = new Sample();\n");
- writer.write( " return s->getAnswer();\n");
- writer.write( "}\n");
+ writer.write("class Sample { public:\n");
+ writer.write(" int getAnswer() const;\n");
+ writer.write("};\n");
+ writer.write("int main(int argc, char **argv) {\n");
+ writer.write(" Sample * s = new Sample();\n");
+ writer.write(" return s->getAnswer();\n");
+ writer.write("}\n");
String code = writer.toString();
int startIndex = code.indexOf("->getAnswer") + 2;
- IASTNode node = parse(code, startIndex, startIndex+9);
+ IASTNode node = parse(code, startIndex, startIndex + 9);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPMethod);
assertEquals(((IASTName) node).toString(), "getAnswer");
@@ -367,10 +362,10 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testBug63966() throws Exception {
Writer writer = new StringWriter();
- writer.write( "void foo(int a) {}\n");
- writer.write( "void foo(long a) {}\n");
- writer.write( "int main(int argc, char **argv) {\n");
- writer.write( "foo(1); \n }");
+ writer.write("void foo(int a) {}\n");
+ writer.write("void foo(long a) {}\n");
+ writer.write("int main(int argc, char **argv) {\n");
+ writer.write("foo(1); \n }");
String code = writer.toString();
int startIndex = code.indexOf("foo(1)");
parse(code, startIndex, startIndex + 3);
@@ -378,16 +373,14 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testBug66744() throws Exception {
Writer writer = new StringWriter();
- writer.write( "enum EColours { RED, GREEN, BLUE }; \n");
- writer.write( "void foo() { EColours color = GREEN; } \n");
+ writer.write("enum EColours { RED, GREEN, BLUE }; \n");
+ writer.write("void foo() { EColours color = GREEN; } \n");
String code = writer.toString();
int startIndex = code.indexOf("EColours color");
parse(code, startIndex, startIndex + 8);
}
-
-
public void testBug68527() throws Exception {
Writer writer = new StringWriter();
writer.write("struct X;\n");
@@ -399,15 +392,15 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testBug60407() throws Exception {
Writer writer = new StringWriter();
- writer.write( "struct ZZZ { int x, y, z; };\n");
- writer.write( "typedef struct ZZZ _FILE;\n");
- writer.write( "typedef _FILE FILE;\n");
- writer.write( "static void static_function(FILE * lcd){}\n");
- writer.write( "int main(int argc, char **argv) {\n");
- writer.write( "FILE * file = 0;\n");
- writer.write( "static_function( file );\n");
- writer.write( "return 0;\n" );
- writer.write( "}\n");
+ writer.write("struct ZZZ { int x, y, z; };\n");
+ writer.write("typedef struct ZZZ _FILE;\n");
+ writer.write("typedef _FILE FILE;\n");
+ writer.write("static void static_function(FILE * lcd){}\n");
+ writer.write("int main(int argc, char **argv) {\n");
+ writer.write("FILE * file = 0;\n");
+ writer.write("static_function( file );\n");
+ writer.write("return 0;\n");
+ writer.write("}\n");
String code = writer.toString();
int startIndex = code.indexOf("static_function( file )");
parse(code, startIndex, startIndex + "static_function".length());
@@ -415,14 +408,14 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testBug61800() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class B {};\n");
- writer.write( "class ABCDEF {\n");
- writer.write( " static B stInt; };\n");
- writer.write( "B ABCDEF::stInt = 5;\n");
+ writer.write("class B {};\n");
+ writer.write("class ABCDEF {\n");
+ writer.write(" static B stInt; };\n");
+ writer.write("B ABCDEF::stInt = 5;\n");
String code = writer.toString();
int startIndex = code.indexOf("::stInt") + 2;
- IASTNode node = parse(code, startIndex, startIndex+ 5);
+ IASTNode node = parse(code, startIndex, startIndex + 5);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
assertEquals(((IASTName) node).toString(), "stInt");
@@ -434,16 +427,16 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
}
public void testBug68739() throws Exception {
- Writer writer = new StringWriter();
- writer.write( "int fprintf( int *, const char *, ... ); \n");
- writer.write( "void boo( int * lcd ) { \n");
- writer.write( " /**/fprintf( lcd, \"%c%s 0x%x\", ' ', \"bbb\", 2 ); \n");
- writer.write( "} \n");
+ Writer writer = new StringWriter();
+ writer.write("int fprintf( int *, const char *, ... ); \n");
+ writer.write("void boo( int * lcd ) { \n");
+ writer.write(" /**/fprintf( lcd, \"%c%s 0x%x\", ' ', \"bbb\", 2 ); \n");
+ writer.write("} \n");
- String code = writer.toString();
+ String code = writer.toString();
int startIndex = code.indexOf("/**/fprintf") + 4;
- IASTNode node = parse(code, startIndex, startIndex+ 7);
+ IASTNode node = parse(code, startIndex, startIndex + 7);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof IFunction);
@@ -452,17 +445,17 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void testBug72818() throws Exception {
Writer writer = new StringWriter();
- writer.write( "union Squaw { int x; double u; };\n");
- writer.write( "int main(int argc, char **argv) {\n");
- writer.write( "return sizeof( Squaw );\n");
- writer.write( "}\n");
+ writer.write("union Squaw { int x; double u; };\n");
+ writer.write("int main(int argc, char **argv) {\n");
+ writer.write("return sizeof( Squaw );\n");
+ writer.write("}\n");
String code = writer.toString();
- int startIndex = code.indexOf("sizeof( ") + "sizeof( ".length(); //$NON-NLS-2$
+ int startIndex = code.indexOf("sizeof( ") + "sizeof( ".length(); //$NON-NLS-2$
IASTNode node = parse(code, startIndex, startIndex + 5);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPClassType);
assertEquals(((IASTName) node).toString(), "Squaw");
- assertEquals(((ICPPClassType)((IASTName) node).resolveBinding()).getKey(), ICompositeType.k_union);
+ assertEquals(((ICPPClassType) ((IASTName) node).resolveBinding()).getKey(), ICompositeType.k_union);
IName[] decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "Squaw");
@@ -472,16 +465,16 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public void test72220() throws Exception {
Writer writer = new StringWriter();
- writer.write( "const int FOUND_ME = 1;\n");
- writer.write( "class Test{\n");
- writer.write( "public:\n");
- writer.write( "const int findCode() const;\n");
- writer.write( "};\n");
- writer.write( "const int Test::findCode() const {\n");
- writer.write( "return FOUND_ME;\n");
- writer.write( "}\n");
+ writer.write("const int FOUND_ME = 1;\n");
+ writer.write("class Test{\n");
+ writer.write("public:\n");
+ writer.write("const int findCode() const;\n");
+ writer.write("};\n");
+ writer.write("const int Test::findCode() const {\n");
+ writer.write("return FOUND_ME;\n");
+ writer.write("}\n");
String code = writer.toString();
- int startIndex = code.indexOf("return ") + "return ".length(); //$NON-NLS-2$
+ int startIndex = code.indexOf("return ") + "return ".length(); //$NON-NLS-2$
IASTNode node = parse(code, startIndex, startIndex + 8);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof IVariable);
@@ -493,17 +486,17 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(((ASTNode) decls[0]).getLength(), 8);
}
- public void testBug72721() throws Exception{
- Writer writer = new StringWriter();
- writer.write(" class ABC { public: ABC(int); }; \n");
- writer.write("void f() { \n");
- writer.write(" int j = 1; \n");
- writer.write(" new ABC( j + 1 ); \n");
- writer.write("} \n");
+ public void testBug72721() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write(" class ABC { public: ABC(int); }; \n");
+ writer.write("void f() { \n");
+ writer.write(" int j = 1; \n");
+ writer.write(" new ABC( j + 1 ); \n");
+ writer.write("} \n");
- String code = writer.toString();
- int startIndex = code.indexOf("ABC(");
- IASTNode node = parse(code, startIndex, startIndex + 3);
+ String code = writer.toString();
+ int startIndex = code.indexOf("ABC(");
+ IASTNode node = parse(code, startIndex, startIndex + 3);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPConstructor);
assertEquals(((IASTName) node).toString(), "ABC");
@@ -514,17 +507,17 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(((ASTNode) decls[0]).getLength(), 3);
}
- public void testBug72372() throws Exception{
- Writer writer = new StringWriter();
- writer.write("namespace B { \n");
- writer.write(" class SD_02 { void f_SD(); }; \n");
- writer.write("} \n");
- writer.write("using namespace B; \n");
- writer.write("void SD_02::f_SD(){} \n");
+ public void testBug72372() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("namespace B { \n");
+ writer.write(" class SD_02 { void f_SD(); }; \n");
+ writer.write("} \n");
+ writer.write("using namespace B; \n");
+ writer.write("void SD_02::f_SD(){} \n");
- String code = writer.toString();
- int startIndex = code.indexOf(":f_SD");
- IASTNode node = parse(code, startIndex + 1, startIndex + 5);
+ String code = writer.toString();
+ int startIndex = code.indexOf(":f_SD");
+ IASTNode node = parse(code, startIndex + 1, startIndex + 5);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPMethod);
assertEquals(((IASTName) node).toString(), "f_SD");
@@ -534,21 +527,22 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(((ASTNode) decls[0]).getOffset(), 71);
assertEquals(((ASTNode) decls[0]).getLength(), 4);
}
- public void testBug72372_2() throws Exception{
- Writer writer = new StringWriter();
- writer.write("namespace A { \n");
- writer.write(" namespace B { \n");
- writer.write(" void f_SD(); \n");
- writer.write(" } \n");
- writer.write("} \n");
- writer.write("namespace C { \n");
- writer.write(" using namespace A; \n");
- writer.write("} \n");
- writer.write("void C::B::f_SD(){} \n");
-
- String code = writer.toString();
- int startIndex = code.indexOf(":f_SD");
- IASTNode node = parse(code, startIndex + 1, startIndex + 5);
+
+ public void testBug72372_2() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("namespace A { \n");
+ writer.write(" namespace B { \n");
+ writer.write(" void f_SD(); \n");
+ writer.write(" } \n");
+ writer.write("} \n");
+ writer.write("namespace C { \n");
+ writer.write(" using namespace A; \n");
+ writer.write("} \n");
+ writer.write("void C::B::f_SD(){} \n");
+
+ String code = writer.toString();
+ int startIndex = code.indexOf(":f_SD");
+ IASTNode node = parse(code, startIndex + 1, startIndex + 5);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof IFunction);
assertEquals(((IASTName) node).toString(), "f_SD");
@@ -559,14 +553,14 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(((ASTNode) decls[0]).getLength(), 4);
}
- public void testBug72713() throws Exception{
- Writer writer = new StringWriter();
- writer.write( "class Deck{ void initialize(); }; \n");
- writer.write( "void Deck::initialize(){} \n");
+ public void testBug72713() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class Deck{ void initialize(); }; \n");
+ writer.write("void Deck::initialize(){} \n");
- String code = writer.toString();
- int startIndex = code.indexOf(":initialize");
- IASTNode node = parse(code, startIndex + 1, startIndex + 11);
+ String code = writer.toString();
+ int startIndex = code.indexOf(":initialize");
+ IASTNode node = parse(code, startIndex + 1, startIndex + 11);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPMethod);
assertEquals(((IASTName) node).toString(), "initialize");
@@ -577,15 +571,15 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(((ASTNode) decls[0]).getLength(), 10);
}
- public void testBug72712() throws Exception{
- Writer writer = new StringWriter();
- writer.write( "class B{ public: B(); }; void f(){ B* b; b = new B(); }");
+ public void testBug72712() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class B{ public: B(); }; void f(){ B* b; b = new B(); }");
- String code = writer.toString();
- int startIndex = code.indexOf("new B" ) + 4;
+ String code = writer.toString();
+ int startIndex = code.indexOf("new B") + 4;
- IASTNode node = parse(code, startIndex, startIndex + 1);
- node = TestUtil.findImplicitName(node);
+ IASTNode node = parse(code, startIndex, startIndex + 1);
+ node = TestUtil.findImplicitName(node);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPConstructor);
assertEquals(((IASTName) node).toString(), "B");
@@ -596,16 +590,16 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(1, ((ASTNode) decls[0]).getLength());
}
- public void testBug72712_2() throws Exception{
- Writer writer = new StringWriter();
- writer.write( "class A {}; \n");
- writer.write( "class B{ public: B( A* ); }; \n");
- writer.write( "void f(){ B* b; b = new B( (A*)0 ); } \n");
+ public void testBug72712_2() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class A {}; \n");
+ writer.write("class B{ public: B( A* ); }; \n");
+ writer.write("void f(){ B* b; b = new B( (A*)0 ); } \n");
- String code = writer.toString();
- int startIndex = code.indexOf("(A*)" ) + 1;
+ String code = writer.toString();
+ int startIndex = code.indexOf("(A*)") + 1;
- IASTNode node = parse(code, startIndex, startIndex + 1);
+ IASTNode node = parse(code, startIndex, startIndex + 1);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPClassType);
assertEquals(((IASTName) node).toString(), "A");
@@ -616,18 +610,18 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(((ASTNode) decls[0]).getLength(), 1);
}
- public void testBug72814() throws Exception{
- CPPASTNameBase.sAllowNameComputation= true;
+ public void testBug72814() throws Exception {
+ CPPASTNameBase.sAllowNameComputation = true;
- Writer writer = new StringWriter();
- writer.write( "namespace N{ \n");
- writer.write( " template < class T > class AAA { T _t; };\n");
- writer.write( "} \n");
- writer.write( "N::AAA<int> a; \n");
+ Writer writer = new StringWriter();
+ writer.write("namespace N{ \n");
+ writer.write(" template < class T > class AAA { T _t; };\n");
+ writer.write("} \n");
+ writer.write("N::AAA<int> a; \n");
- String code = writer.toString();
- int startIndex = code.indexOf("AAA<int>");
- IASTNode node = parse(code, startIndex, startIndex + 3);
+ String code = writer.toString();
+ int startIndex = code.indexOf("AAA<int>");
+ IASTNode node = parse(code, startIndex, startIndex + 3);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPClassType);
@@ -638,28 +632,28 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(((ASTNode) decls[0]).getOffset(), 75);
assertEquals(((ASTNode) decls[0]).getLength(), 3);
- node = parse(code, startIndex, startIndex + 8);
+ node = parse(code, startIndex, startIndex + 8);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPClassType);
assertEquals(((IASTName) node).toString(), "AAA<int>");
decls = getDeclarationOffTU((IASTName) node);
// TODO raised bug 92632 for below
-// assertEquals(decls.length, 1);
-// assertEquals(decls[0].toString(), "AAA");
-// assertEquals(((ASTNode) decls[0]).getOffset(), 15);
-// assertEquals(((ASTNode) decls[0]).getLength(), 3);
+ // assertEquals(decls.length, 1);
+ // assertEquals(decls[0].toString(), "AAA");
+ // assertEquals(((ASTNode) decls[0]).getOffset(), 15);
+ // assertEquals(((ASTNode) decls[0]).getLength(), 3);
}
public void testBug72710() throws Exception {
Writer writer = new StringWriter();
- writer.write( "class Card{\n");
- writer.write( " Card( int rank );\n");
- writer.write( " int rank;\n");
- writer.write( "};\n");
- writer.write( "Card::Card( int rank ) {\n");
- writer.write( "this->rank = rank;\n");
- writer.write( "}\n");
+ writer.write("class Card{\n");
+ writer.write(" Card( int rank );\n");
+ writer.write(" int rank;\n");
+ writer.write("};\n");
+ writer.write("Card::Card( int rank ) {\n");
+ writer.write("this->rank = rank;\n");
+ writer.write("}\n");
String code = writer.toString();
int index = code.indexOf("this->rank") + 6;
IASTNode node = parse(code, index, index + 4);
@@ -673,9 +667,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(((ASTNode) decls[0]).getLength(), 4);
}
-
- public void testBug75731() throws Exception
- {
+ public void testBug75731() throws Exception {
Writer writer = new StringWriter();
writer.write("int rank() {\n");
writer.write("return 5;\n}\n");
@@ -698,7 +690,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof IFunction);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
IName[] decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "rank");
@@ -710,7 +702,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPClassType);
assertEquals(((IASTName) node).toString(), "Card");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "Card");
@@ -722,7 +714,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPConstructor);
assertEquals(((IASTName) node).toString(), "Card");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 2);
assertEquals(decls[0].toString(), "Card");
@@ -734,7 +726,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof IParameter);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 2);
assertEquals(decls[0].toString(), "rank");
@@ -746,7 +738,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "rank");
@@ -758,7 +750,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPMethod);
assertEquals(((IASTName) node).toString(), "getRank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "getRank");
@@ -770,7 +762,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPClassType);
assertEquals(((IASTName) node).toString(), "Card");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "Card");
@@ -782,7 +774,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPConstructor);
assertEquals(((IASTName) node).toString(), "Card");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 2);
assertEquals(decls[0].toString(), "Card");
@@ -794,7 +786,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof IParameter);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 2);
assertEquals(decls[0].toString(), "rank");
@@ -806,7 +798,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "rank");
@@ -818,7 +810,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof IFunction);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "rank");
@@ -830,7 +822,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "rank");
@@ -842,7 +834,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "rank");
@@ -854,7 +846,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "rank");
@@ -866,7 +858,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof IParameter);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 2);
assertEquals(decls[0].toString(), "rank");
@@ -878,7 +870,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "rank");
@@ -890,7 +882,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "rank");
@@ -902,7 +894,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
assertEquals(((IASTName) node).toString(), "rank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "rank");
@@ -914,7 +906,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPMethod);
assertEquals(((IASTName) node).toString(), "getRank");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "getRank");
@@ -935,7 +927,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPNamespace);
assertEquals(((IASTName) node).toString(), "N");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
IName[] decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "N");
@@ -954,7 +946,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof IParameter);
assertEquals(((IASTName) node).toString(), "itself");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
IName[] decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "itself");
@@ -974,7 +966,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICompositeType);
assertEquals(((IASTName) node).toString(), "Data");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
IName[] decls = getDeclarationOffTU((IASTName) node);
assertEquals(decls.length, 1);
assertEquals(decls[0].toString(), "Data");
@@ -995,7 +987,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICompositeType);
assertEquals(((IASTName) node).toString(), "Data");
- assertEquals(((ASTNode)node).getOffset(), index);
+ assertEquals(((ASTNode) node).getOffset(), index);
}
public void testBug64326() throws Exception {
@@ -1073,10 +1065,10 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
ICElement[] scope = new ICElement[1];
scope[0] = new CProject(null, project);
-// // TODO need to register to an index and wait for it to finish before this test will work
-//
-// Set matches = SearchEngine.getMatchesFromSearchEngine(SearchEngine.createCSearchScope(scope), (IASTName) node, CSearchPattern.DECLARATIONS);
-// assertEquals(matches.size(), 1);
+ // // TODO need to register to an index and wait for it to finish before this test will work
+ //
+ // Set matches = SearchEngine.getMatchesFromSearchEngine(SearchEngine.createCSearchScope(scope), (IASTName) node, CSearchPattern.DECLARATIONS);
+ // assertEquals(matches.size(), 1);
}
public void testBug78114() throws Exception {
@@ -1148,7 +1140,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
writer.write("return (0); \n");
writer.write(" }\n");
- String code = writer.toString();
+ String code = writer.toString();
int index = code.indexOf("operator=(zero)");
IASTNode node = parse(code, index, index + 9, true);
@@ -1435,159 +1427,159 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(((ASTNode) decls[0]).getLength(), 1);
}
- public void testBug86504() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class C { };\n");
- writer.write("void f(int(C)) { } // void f(int (*fp)(C c)) { }\n");
- writer.write("// not: void f(int C);\n");
- writer.write("int g(C);\n");
- writer.write("void foo() {\n");
- writer.write("f(g); // openDeclarations on g causes StackOverflowError\n");
- writer.write("}\n");
-
- String code = writer.toString();
-
- int index = code.indexOf("g); ");
- IASTNode node = parse(code, index, index + 1, true);
- assertTrue(node instanceof IASTName);
- assertTrue(((IASTName) node).resolveBinding() instanceof ICPPFunction);
- assertEquals(((IASTName) node).toString(), "g");
-
- IName[] decls = getDeclarationOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "g");
- assertEquals(((ASTNode) decls[0]).getOffset(), 89);
- assertEquals(((ASTNode) decls[0]).getLength(), 1);
- }
-
- public void testBug79811() throws Exception {
- Writer writer = new StringWriter();
- writer.write("enum E{E0};\n");
- writer.write("void f() {\n");
- writer.write("enum E{E1};\n");
- writer.write("E e; //this one is incorrectly found\n");
- writer.write("}\n");
- writer.write("E f; //ok\n");
-
- String code = writer.toString();
-
- int index = code.indexOf("E{E0}");
- IASTNode node = parse(code, index, index + 1, true);
- assertTrue(node instanceof IASTName);
- assertTrue(((IASTName) node).resolveBinding() instanceof IEnumeration);
- assertEquals(((IASTName) node).toString(), "E");
-
- IName[] decls = getReferencesOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "E");
- assertEquals(((ASTNode) decls[0]).getOffset(), 76);
- assertEquals(((ASTNode) decls[0]).getLength(), 1);
- }
-
- public void testBugLabelWithMacro() throws Exception {
- Writer writer = new StringWriter();
- writer.write("#define UINT32 unsigned int\n");
- writer.write("#define HANDLE unsigned int**\n");
- writer.write("void foo()\n");
- writer.write("{\n");
- writer.write("UINT32 u;\n");
- writer.write("HANDLE h;\n");
- writer.write("}\n");
- writer.write("int foo2() {\n");
- writer.write("test:\n");
- writer.write("goto test;\n");
- writer.write("return foo();\n");
- writer.write("}\n");
-
- String code = writer.toString();
-
- int index = code.indexOf("HANDLE h");
- IASTNode node = parse(code, index, index + 6, true);
- assertTrue(node instanceof IASTName);
- assertTrue(((IASTName) node).resolveBinding() instanceof IMacroBinding);
- assertEquals(((IASTName) node).toString(), "HANDLE");
-
- IName[] decls = getDeclarationOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "HANDLE");
- assertEquals(((ASTNode) decls[0]).getOffset(), 36);
- assertEquals(((ASTNode) decls[0]).getLength(), 6);
-
- index = code.indexOf("test;");
- node = parse(code, index, index + 4, true);
- assertTrue(node instanceof IASTName);
- assertTrue(((IASTName) node).resolveBinding() instanceof ILabel);
- assertEquals(((IASTName) node).toString(), "test");
-
- decls = getDeclarationOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "test");
- assertLocation(code, "test:", 4, decls[0]);
- }
-
- public void testBugMethodDef() throws Exception {
- Writer writer = new StringWriter();
- writer.write("class tetrahedron {\n");
- writer.write("private:\n");
- writer.write("int color;\n");
- writer.write("public:\n");
- writer.write("/* Methods */\n");
- writer.write("void setColor(int c) \n");
- writer.write("{color = c < 0 ? 0 : c;};\n");
- writer.write("void set();\n");
- writer.write("};\n");
- writer.write("void tetrahedron::set() {\n");
- writer.write("int color;\n");
- writer.write("setColor(color);\n");
- writer.write("}\n");
-
- String code = writer.toString();
-
- int index = code.indexOf("setColor(color)");
- IASTNode node = parse(code, index, index + 8, true);
- assertTrue(node instanceof IASTName);
- assertTrue(((IASTName) node).resolveBinding() instanceof ICPPMethod);
- assertEquals(((IASTName) node).toString(), "setColor");
-
- IName[] decls = getDeclarationOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "setColor");
- assertEquals(((ASTNode) decls[0]).getOffset(), 67);
- assertEquals(((ASTNode) decls[0]).getLength(), 8);
-
- IName[] refs = getReferencesOffTU((IASTName) node);
- assertEquals(refs.length, 1);
- assertEquals(refs[0].toString(), "setColor");
- assertEquals(((ASTNode)refs[0]).getOffset(), 162);
- assertEquals(((ASTNode)refs[0]).getLength(), 8);
- }
-
- public void testBug86698A() throws Exception {
- Writer writer = new StringWriter();
- writer.write("struct C;\n");
- writer.write("void no_opt(C*);\n");
- writer.write("struct C {\n");
- writer.write("int c;\n");
- writer.write("C() : c(0) { no_opt(this); }\n");
- writer.write("};\n");
-
- String code = writer.toString();
-
- int index = code.indexOf("c(0)");
- IASTNode node = parse(code, index, index + 1, true);
- assertTrue(node instanceof IASTName);
- assertTrue(((IASTName) node).resolveBinding() instanceof IVariable);
- assertEquals(((IASTName) node).toString(), "c");
-
- IName[] decls = getDeclarationOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "c");
- assertEquals(((ASTNode) decls[0]).getOffset(), 42);
- assertEquals(((ASTNode) decls[0]).getLength(), 1);
- }
-
- public void testBug86698B() throws Exception {
- Writer writer = new StringWriter();
+ public void testBug86504() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class C { };\n");
+ writer.write("void f(int(C)) { } // void f(int (*fp)(C c)) { }\n");
+ writer.write("// not: void f(int C);\n");
+ writer.write("int g(C);\n");
+ writer.write("void foo() {\n");
+ writer.write("f(g); // openDeclarations on g causes StackOverflowError\n");
+ writer.write("}\n");
+
+ String code = writer.toString();
+
+ int index = code.indexOf("g); ");
+ IASTNode node = parse(code, index, index + 1, true);
+ assertTrue(node instanceof IASTName);
+ assertTrue(((IASTName) node).resolveBinding() instanceof ICPPFunction);
+ assertEquals(((IASTName) node).toString(), "g");
+
+ IName[] decls = getDeclarationOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "g");
+ assertEquals(((ASTNode) decls[0]).getOffset(), 89);
+ assertEquals(((ASTNode) decls[0]).getLength(), 1);
+ }
+
+ public void testBug79811() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("enum E{E0};\n");
+ writer.write("void f() {\n");
+ writer.write("enum E{E1};\n");
+ writer.write("E e; //this one is incorrectly found\n");
+ writer.write("}\n");
+ writer.write("E f; //ok\n");
+
+ String code = writer.toString();
+
+ int index = code.indexOf("E{E0}");
+ IASTNode node = parse(code, index, index + 1, true);
+ assertTrue(node instanceof IASTName);
+ assertTrue(((IASTName) node).resolveBinding() instanceof IEnumeration);
+ assertEquals(((IASTName) node).toString(), "E");
+
+ IName[] decls = getReferencesOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "E");
+ assertEquals(((ASTNode) decls[0]).getOffset(), 76);
+ assertEquals(((ASTNode) decls[0]).getLength(), 1);
+ }
+
+ public void testBugLabelWithMacro() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("#define UINT32 unsigned int\n");
+ writer.write("#define HANDLE unsigned int**\n");
+ writer.write("void foo()\n");
+ writer.write("{\n");
+ writer.write("UINT32 u;\n");
+ writer.write("HANDLE h;\n");
+ writer.write("}\n");
+ writer.write("int foo2() {\n");
+ writer.write("test:\n");
+ writer.write("goto test;\n");
+ writer.write("return foo();\n");
+ writer.write("}\n");
+
+ String code = writer.toString();
+
+ int index = code.indexOf("HANDLE h");
+ IASTNode node = parse(code, index, index + 6, true);
+ assertTrue(node instanceof IASTName);
+ assertTrue(((IASTName) node).resolveBinding() instanceof IMacroBinding);
+ assertEquals(((IASTName) node).toString(), "HANDLE");
+
+ IName[] decls = getDeclarationOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "HANDLE");
+ assertEquals(((ASTNode) decls[0]).getOffset(), 36);
+ assertEquals(((ASTNode) decls[0]).getLength(), 6);
+
+ index = code.indexOf("test;");
+ node = parse(code, index, index + 4, true);
+ assertTrue(node instanceof IASTName);
+ assertTrue(((IASTName) node).resolveBinding() instanceof ILabel);
+ assertEquals(((IASTName) node).toString(), "test");
+
+ decls = getDeclarationOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "test");
+ assertLocation(code, "test:", 4, decls[0]);
+ }
+
+ public void testBugMethodDef() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("class tetrahedron {\n");
+ writer.write("private:\n");
+ writer.write("int color;\n");
+ writer.write("public:\n");
+ writer.write("/* Methods */\n");
+ writer.write("void setColor(int c) \n");
+ writer.write("{color = c < 0 ? 0 : c;};\n");
+ writer.write("void set();\n");
+ writer.write("};\n");
+ writer.write("void tetrahedron::set() {\n");
+ writer.write("int color;\n");
+ writer.write("setColor(color);\n");
+ writer.write("}\n");
+
+ String code = writer.toString();
+
+ int index = code.indexOf("setColor(color)");
+ IASTNode node = parse(code, index, index + 8, true);
+ assertTrue(node instanceof IASTName);
+ assertTrue(((IASTName) node).resolveBinding() instanceof ICPPMethod);
+ assertEquals(((IASTName) node).toString(), "setColor");
+
+ IName[] decls = getDeclarationOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "setColor");
+ assertEquals(((ASTNode) decls[0]).getOffset(), 67);
+ assertEquals(((ASTNode) decls[0]).getLength(), 8);
+
+ IName[] refs = getReferencesOffTU((IASTName) node);
+ assertEquals(refs.length, 1);
+ assertEquals(refs[0].toString(), "setColor");
+ assertEquals(((ASTNode) refs[0]).getOffset(), 162);
+ assertEquals(((ASTNode) refs[0]).getLength(), 8);
+ }
+
+ public void testBug86698A() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("struct C;\n");
+ writer.write("void no_opt(C*);\n");
+ writer.write("struct C {\n");
+ writer.write("int c;\n");
+ writer.write("C() : c(0) { no_opt(this); }\n");
+ writer.write("};\n");
+
+ String code = writer.toString();
+
+ int index = code.indexOf("c(0)");
+ IASTNode node = parse(code, index, index + 1, true);
+ assertTrue(node instanceof IASTName);
+ assertTrue(((IASTName) node).resolveBinding() instanceof IVariable);
+ assertEquals(((IASTName) node).toString(), "c");
+
+ IName[] decls = getDeclarationOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "c");
+ assertEquals(((ASTNode) decls[0]).getOffset(), 42);
+ assertEquals(((ASTNode) decls[0]).getLength(), 1);
+ }
+
+ public void testBug86698B() throws Exception {
+ Writer writer = new StringWriter();
writer.write("int f(int);\n");
writer.write("class C {\n");
writer.write("int i;\n");
@@ -1609,18 +1601,18 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
String code = writer.toString();
- int index = code.indexOf("i(f(ii)), d(id)");
- IASTNode node = parse(code, index, index + 1, true);
- assertTrue(node instanceof IASTName);
- assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
- assertEquals(((IASTName) node).toString(), "i");
+ int index = code.indexOf("i(f(ii)), d(id)");
+ IASTNode node = parse(code, index, index + 1, true);
+ assertTrue(node instanceof IASTName);
+ assertTrue(((IASTName) node).resolveBinding() instanceof ICPPField);
+ assertEquals(((IASTName) node).toString(), "i");
- IName[] decls = getDeclarationOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "i");
- assertEquals(code.indexOf("int i") + 4, ((ASTNode) decls[0]).getOffset());
- assertEquals(((ASTNode) decls[0]).getLength(), 1);
- }
+ IName[] decls = getDeclarationOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "i");
+ assertEquals(code.indexOf("int i") + 4, ((ASTNode) decls[0]).getOffset());
+ assertEquals(((ASTNode) decls[0]).getLength(), 1);
+ }
public void testBug64181() throws Exception {
StringBuilder buffer = new StringBuilder();
@@ -1637,7 +1629,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
String code = buffer.toString();
int index = code.indexOf("Foo::bar;");
- IASTNode node = parse(code, index, index + 3, true);
+ IASTNode node = parse(code, index, index + 3, true);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof ICPPNamespace);
@@ -1659,7 +1651,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
String code = buffer.toString();
int index = code.indexOf("MyChicken c;");
- IASTNode node = parse(code, index, index + 9, true);
+ IASTNode node = parse(code, index, index + 9, true);
assertNotNull(node);
assertTrue(node instanceof IASTName);
assertTrue(((IASTName) node).resolveBinding() instanceof IMacroBinding);
@@ -1671,44 +1663,44 @@ public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
assertEquals(((ASTNode) decls[0]).getLength(), 9);
}
- public void testBug86993() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("#define _BEGIN_STD_C extern \"C\" {\n");
- buffer.append("#define _END_STD_C }\n");
- buffer.append("_BEGIN_STD_C\n");
- buffer.append("char c; // selection on this fails because offset for \n");
- buffer.append("_END_STD_C\n");
- buffer.append("char foo() {\n");
- buffer.append("return c; // ref \n");
- buffer.append("}\n");
-
- String code = buffer.toString();
- int index = code.indexOf("return c;");
- IASTNode node = parse(code, index + 7, index + 8, true);
- assertNotNull(node);
- assertTrue(node instanceof IASTName);
- assertTrue(((IASTName) node).resolveBinding() instanceof ICPPVariable);
- assertEquals(((IASTName) node).toString(), "c");
- IName[] decls = getDeclarationOffTU((IASTName) node);
- assertEquals(decls.length, 1);
- assertEquals(decls[0].toString(), "c");
- assertLocation(code, "c;", 1, decls[0]);
-
- index = code.indexOf("char c");
- node = parse(code, index + 5, index + 6, true);
- assertNotNull(node);
- assertTrue(node instanceof IASTName);
- assertTrue(((IASTName) node).resolveBinding() instanceof ICPPVariable);
- IName[] refs = getReferencesOffTU((IASTName) node);
- assertEquals(refs.length, 1);
- assertEquals(refs[0].toString(), "c");
- assertLocation(code, "c; // ref", 1, refs[0]);
- }
-
- private void assertLocation(String code, String occur, int length, IName name) {
- int offset= code.indexOf(occur);
- final IASTFileLocation loc= name.getFileLocation();
- assertEquals(offset, loc.getNodeOffset());
- assertEquals(length, loc.getNodeLength());
+ public void testBug86993() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("#define _BEGIN_STD_C extern \"C\" {\n");
+ buffer.append("#define _END_STD_C }\n");
+ buffer.append("_BEGIN_STD_C\n");
+ buffer.append("char c; // selection on this fails because offset for \n");
+ buffer.append("_END_STD_C\n");
+ buffer.append("char foo() {\n");
+ buffer.append("return c; // ref \n");
+ buffer.append("}\n");
+
+ String code = buffer.toString();
+ int index = code.indexOf("return c;");
+ IASTNode node = parse(code, index + 7, index + 8, true);
+ assertNotNull(node);
+ assertTrue(node instanceof IASTName);
+ assertTrue(((IASTName) node).resolveBinding() instanceof ICPPVariable);
+ assertEquals(((IASTName) node).toString(), "c");
+ IName[] decls = getDeclarationOffTU((IASTName) node);
+ assertEquals(decls.length, 1);
+ assertEquals(decls[0].toString(), "c");
+ assertLocation(code, "c;", 1, decls[0]);
+
+ index = code.indexOf("char c");
+ node = parse(code, index + 5, index + 6, true);
+ assertNotNull(node);
+ assertTrue(node instanceof IASTName);
+ assertTrue(((IASTName) node).resolveBinding() instanceof ICPPVariable);
+ IName[] refs = getReferencesOffTU((IASTName) node);
+ assertEquals(refs.length, 1);
+ assertEquals(refs[0].toString(), "c");
+ assertLocation(code, "c; // ref", 1, refs[0]);
+ }
+
+ private void assertLocation(String code, String occur, int length, IName name) {
+ int offset = code.indexOf(occur);
+ final IASTFileLocation loc = name.getFileLocation();
+ assertEquals(offset, loc.getNodeOffset());
+ assertEquals(length, loc.getNodeLength());
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTestBase.java
index 9a4d9355a15..f4706f4842e 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTestBase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTestBase.java
@@ -40,30 +40,31 @@ public class DOMSelectionParseTestBase extends DOMFileBasePluginTest {
}
protected IASTNode parse(String code, int offset1, int offset2) throws Exception {
- return parse( code, offset1, offset2, true );
+ return parse(code, offset1, offset2, true);
}
protected IASTNode parse(String code, int offset1, int offset2, boolean expectedToPass) throws Exception {
IFile file = importFile("temp.cpp", code); //$NON-NLS-1$
return parse(file, offset1, offset2, expectedToPass);
}
-
+
protected IASTNode parse(IFile file, int offset1, int offset2, boolean expectedToPass) throws Exception {
- ITranslationUnit tu = (ITranslationUnit)CCorePlugin.getDefault().getCoreModel().create(file);
+ ITranslationUnit tu = (ITranslationUnit) CCorePlugin.getDefault().getCoreModel().create(file);
IASTTranslationUnit ast = tu.getAST();
- IASTName name= ast.getNodeSelector(null).findName(offset1, offset2 - offset1);
+ IASTName name = ast.getNodeSelector(null).findName(offset1, offset2 - offset1);
+
+ if (!expectedToPass)
+ return null;
- if (!expectedToPass) return null;
-
assertNotNull(name);
return name;
}
-
+
protected IName[] getDeclarationOffTU(IASTName name) {
- return DOMSearchUtil.getNamesFromDOM(name, DOMSearchUtil.DECLARATIONS);
+ return DOMSearchUtil.getNamesFromDOM(name, DOMSearchUtil.DECLARATIONS);
+ }
+
+ protected IName[] getReferencesOffTU(IASTName name) {
+ return DOMSearchUtil.getNamesFromDOM(name, DOMSearchUtil.REFERENCES);
}
-
- protected IName[] getReferencesOffTU(IASTName name) {
- return DOMSearchUtil.getNamesFromDOM(name, DOMSearchUtil.REFERENCES);
- }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/FaultToleranceTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/FaultToleranceTests.java
index 8dced8669da..fb3039a0d25 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/FaultToleranceTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/FaultToleranceTests.java
@@ -34,254 +34,252 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
* Testcases related to recovery from invalid syntax.
*/
public class FaultToleranceTests extends AST2TestBase {
-
+
public static TestSuite suite() {
return suite(FaultToleranceTests.class);
}
-
+
public FaultToleranceTests() {
super();
}
-
+
public FaultToleranceTests(String name) {
super(name);
}
-
+
// typedef int tint;
// struct X {
// int a;
// }
// tint b;
- public void testCompositeTypeWithoutSemi() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTCompositeTypeSpecifier def= getCompositeType(tu, 1);
- IASTProblemDeclaration pdecl= getDeclaration(tu, 2);
- IASTSimpleDeclaration sdecl= getDeclaration(tu, 3);
- }
- }
+ public void testCompositeTypeWithoutSemi() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTCompositeTypeSpecifier def = getCompositeType(tu, 1);
+ IASTProblemDeclaration pdecl = getDeclaration(tu, 2);
+ IASTSimpleDeclaration sdecl = getDeclaration(tu, 3);
+ }
+ }
// typedef int tint;
// struct X {
// int a;
// } c
// tint b;
- public void testCompositeTypeWithDtorWithoutSemi() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTSimpleDeclaration sdecl= getDeclaration(tu, 1);
- assertInstance(sdecl.getDeclSpecifier(), IASTCompositeTypeSpecifier.class);
- assertEquals(1, sdecl.getDeclarators().length);
- IASTProblemDeclaration pdecl= getDeclaration(tu, 2);
- sdecl= getDeclaration(tu, 3);
- }
- }
-
+ public void testCompositeTypeWithDtorWithoutSemi() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTSimpleDeclaration sdecl = getDeclaration(tu, 1);
+ assertInstance(sdecl.getDeclSpecifier(), IASTCompositeTypeSpecifier.class);
+ assertEquals(1, sdecl.getDeclarators().length);
+ IASTProblemDeclaration pdecl = getDeclaration(tu, 2);
+ sdecl = getDeclaration(tu, 3);
+ }
+ }
+
// typedef int tint;
- // int a
+ // int a
// tint b;
- public void testVariableWithoutSemi() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTSimpleDeclaration sdecl= getDeclaration(tu, 1);
- assertEquals("int a", sdecl.getRawSignature());
- IASTProblemDeclaration pdecl= getDeclaration(tu, 2);
- sdecl= getDeclaration(tu, 3);
- }
- }
+ public void testVariableWithoutSemi() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTSimpleDeclaration sdecl = getDeclaration(tu, 1);
+ assertEquals("int a", sdecl.getRawSignature());
+ IASTProblemDeclaration pdecl = getDeclaration(tu, 2);
+ sdecl = getDeclaration(tu, 3);
+ }
+ }
// typedef int tint;
- // int a()
+ // int a()
// tint b;
- public void testPrototypeWithoutSemi() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTSimpleDeclaration sdecl= getDeclaration(tu, 1);
- assertEquals("int a()", sdecl.getRawSignature());
- IASTProblemDeclaration pdecl= getDeclaration(tu, 2);
- sdecl= getDeclaration(tu, 3);
- }
- }
+ public void testPrototypeWithoutSemi() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTSimpleDeclaration sdecl = getDeclaration(tu, 1);
+ assertEquals("int a()", sdecl.getRawSignature());
+ IASTProblemDeclaration pdecl = getDeclaration(tu, 2);
+ sdecl = getDeclaration(tu, 3);
+ }
+ }
// void f() {
- // int a= 1
+ // int a= 1
// f()
- // }
- public void testExpressionWithoutSemi_314593() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- IASTStatement stmt= getStatement(fdef, 0);
- assertEquals("int a= 1", stmt.getRawSignature());
- IASTProblemStatement pstmt= getStatement(fdef, 1);
- stmt= getStatement(fdef, 2);
- assertEquals("f()", stmt.getRawSignature());
- pstmt= getStatement(fdef, 3);
- }
- }
+ // }
+ public void testExpressionWithoutSemi_314593() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ IASTStatement stmt = getStatement(fdef, 0);
+ assertEquals("int a= 1", stmt.getRawSignature());
+ IASTProblemStatement pstmt = getStatement(fdef, 1);
+ stmt = getStatement(fdef, 2);
+ assertEquals("f()", stmt.getRawSignature());
+ pstmt = getStatement(fdef, 3);
+ }
+ }
- // struct X {
- // int a;
- public void testIncompleteCompositeType() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTCompositeTypeSpecifier comp= getCompositeType(tu, 0);
- IASTProblemDeclaration pdecl= getDeclaration(tu, 1);
-
- IASTSimpleDeclaration sdecl= getDeclaration(comp, 0);
- }
- }
-
- // void func() {
- // int a;
- public void testIncompleteFunctionDefinition() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- IASTProblemDeclaration pdecl= getDeclaration(tu, 1);
-
- IASTDeclarationStatement sdecl= getStatement(fdef, 0);
- }
- }
-
+ // struct X {
+ // int a;
+ public void testIncompleteCompositeType() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTCompositeTypeSpecifier comp = getCompositeType(tu, 0);
+ IASTProblemDeclaration pdecl = getDeclaration(tu, 1);
- // namespace ns {
- // int a;
- public void testIncompleteNamespace() throws Exception {
- final String comment= getAboveComment();
- IASTTranslationUnit tu= parse(comment, ParserLanguage.CPP, false, false);
- ICPPASTNamespaceDefinition ns= getDeclaration(tu, 0);
- IASTProblemDeclaration pdecl= getDeclaration(tu, 1);
+ IASTSimpleDeclaration sdecl = getDeclaration(comp, 0);
+ }
+ }
- IASTSimpleDeclaration sdecl= getDeclaration(ns, 0);
- }
+ // void func() {
+ // int a;
+ public void testIncompleteFunctionDefinition() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ IASTProblemDeclaration pdecl = getDeclaration(tu, 1);
- // extern "C" {
- // int a;
- public void testIncompleteLinkageSpec() throws Exception {
- final String comment= getAboveComment();
- IASTTranslationUnit tu= parse(comment, ParserLanguage.CPP, false, false);
- ICPPASTLinkageSpecification ls= getDeclaration(tu, 0);
- IASTProblemDeclaration pdecl= getDeclaration(tu, 1);
+ IASTDeclarationStatement sdecl = getStatement(fdef, 0);
+ }
+ }
- IASTSimpleDeclaration sdecl= getDeclaration(ls, 0);
- }
+ // namespace ns {
+ // int a;
+ public void testIncompleteNamespace() throws Exception {
+ final String comment = getAboveComment();
+ IASTTranslationUnit tu = parse(comment, ParserLanguage.CPP, false, false);
+ ICPPASTNamespaceDefinition ns = getDeclaration(tu, 0);
+ IASTProblemDeclaration pdecl = getDeclaration(tu, 1);
- // void test() {
- // int a= offsetof(struct mystruct, singlechar);
- // }
- public void testRangeOfProblemNode_Bug238151() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- IASTProblemStatement pdecl= getStatement(fdef, 0);
- assertEquals("int a= offsetof(struct mystruct, singlechar);", pdecl.getRawSignature());
- }
- }
-
- // int f(){
- // if( 12 A )
- // return -1;
- // int v;
- // }
- public void testProblemInIfExpression_Bug100321() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- IASTIfStatement ifstmt= getStatement(fdef, 0);
- assertInstance(ifstmt.getConditionExpression(), IASTProblemExpression.class);
- assertEquals("12 A", ifstmt.getConditionExpression().getRawSignature());
- assertInstance(ifstmt.getThenClause(), IASTReturnStatement.class);
- }
- }
-
- // _MYMACRO_ myType foo();
- // _MYMACRO_ myType foo() {}
- // extern void foo2() _MYMACRO_;
- public void testUndefinedMacrosInFunctionDeclarations_Bug234085() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTProblemDeclaration pd= getDeclaration(tu, 0);
- assertEquals("_MYMACRO_", pd.getRawSignature());
- IASTSimpleDeclaration sdecl= getDeclaration(tu, 1);
- assertEquals("myType foo();", sdecl.getRawSignature());
-
- pd= getDeclaration(tu, 2);
- assertEquals("_MYMACRO_", pd.getRawSignature());
- IASTFunctionDefinition fdef= getDeclaration(tu, 3);
- assertEquals("myType foo() {}", fdef.getRawSignature());
+ IASTSimpleDeclaration sdecl = getDeclaration(ns, 0);
+ }
- sdecl= getDeclaration(tu, 4);
- assertEquals("extern void foo2()", sdecl.getRawSignature());
- pd= getDeclaration(tu, 5); // the missing semicolon
-
- if (lang == ParserLanguage.CPP) {
- pd= getDeclaration(tu, 6);
- assertEquals("_MYMACRO_;", pd.getRawSignature());
- } else {
- sdecl= getDeclaration(tu, 6);
- assertEquals("_MYMACRO_;", sdecl.getRawSignature());
- }
- }
- }
+ // extern "C" {
+ // int a;
+ public void testIncompleteLinkageSpec() throws Exception {
+ final String comment = getAboveComment();
+ IASTTranslationUnit tu = parse(comment, ParserLanguage.CPP, false, false);
+ ICPPASTLinkageSpecification ls = getDeclaration(tu, 0);
+ IASTProblemDeclaration pdecl = getDeclaration(tu, 1);
- // enum _T { I J, K }; // missing comma
- // int i;
- public void testEnumProblem() throws Exception {
- final String comment= getAboveComment();
- for (ParserLanguage lang : ParserLanguage.values()) {
- IASTTranslationUnit tu= parse(comment, lang, false, false);
- IASTSimpleDeclaration e= getDeclaration(tu, 0);
- IASTProblemDeclaration p= getDeclaration(tu, 1);
- assertEquals("J, K };", p.getRawSignature());
- IASTSimpleDeclaration s= getDeclaration(tu, 2);
- assertEquals("int i;", s.getRawSignature());
- }
- }
+ IASTSimpleDeclaration sdecl = getDeclaration(ls, 0);
+ }
+
+ // void test() {
+ // int a= offsetof(struct mystruct, singlechar);
+ // }
+ public void testRangeOfProblemNode_Bug238151() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ IASTProblemStatement pdecl = getStatement(fdef, 0);
+ assertEquals("int a= offsetof(struct mystruct, singlechar);", pdecl.getRawSignature());
+ }
+ }
+
+ // int f(){
+ // if( 12 A )
+ // return -1;
+ // int v;
+ // }
+ public void testProblemInIfExpression_Bug100321() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ IASTIfStatement ifstmt = getStatement(fdef, 0);
+ assertInstance(ifstmt.getConditionExpression(), IASTProblemExpression.class);
+ assertEquals("12 A", ifstmt.getConditionExpression().getRawSignature());
+ assertInstance(ifstmt.getThenClause(), IASTReturnStatement.class);
+ }
+ }
+
+ // _MYMACRO_ myType foo();
+ // _MYMACRO_ myType foo() {}
+ // extern void foo2() _MYMACRO_;
+ public void testUndefinedMacrosInFunctionDeclarations_Bug234085() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTProblemDeclaration pd = getDeclaration(tu, 0);
+ assertEquals("_MYMACRO_", pd.getRawSignature());
+ IASTSimpleDeclaration sdecl = getDeclaration(tu, 1);
+ assertEquals("myType foo();", sdecl.getRawSignature());
+
+ pd = getDeclaration(tu, 2);
+ assertEquals("_MYMACRO_", pd.getRawSignature());
+ IASTFunctionDefinition fdef = getDeclaration(tu, 3);
+ assertEquals("myType foo() {}", fdef.getRawSignature());
+
+ sdecl = getDeclaration(tu, 4);
+ assertEquals("extern void foo2()", sdecl.getRawSignature());
+ pd = getDeclaration(tu, 5); // the missing semicolon
+
+ if (lang == ParserLanguage.CPP) {
+ pd = getDeclaration(tu, 6);
+ assertEquals("_MYMACRO_;", pd.getRawSignature());
+ } else {
+ sdecl = getDeclaration(tu, 6);
+ assertEquals("_MYMACRO_;", sdecl.getRawSignature());
+ }
+ }
+ }
+
+ // enum _T { I J, K }; // missing comma
+ // int i;
+ public void testEnumProblem() throws Exception {
+ final String comment = getAboveComment();
+ for (ParserLanguage lang : ParserLanguage.values()) {
+ IASTTranslationUnit tu = parse(comment, lang, false, false);
+ IASTSimpleDeclaration e = getDeclaration(tu, 0);
+ IASTProblemDeclaration p = getDeclaration(tu, 1);
+ assertEquals("J, K };", p.getRawSignature());
+ IASTSimpleDeclaration s = getDeclaration(tu, 2);
+ assertEquals("int i;", s.getRawSignature());
+ }
+ }
+
+ // class A {
+ // enum _T { I J, K }; // missing comma
+ // int i;
+ // };
+ public void testEnumError_Bug72685() throws Exception {
+ final String comment = getAboveComment();
+ IASTTranslationUnit tu = parse(comment, ParserLanguage.CPP, false, false);
+ IASTCompositeTypeSpecifier ct = getCompositeType(tu, 0);
+ IASTSimpleDeclaration e = getDeclaration(ct, 0);
+ IASTProblemDeclaration p = getDeclaration(ct, 1);
+ assertEquals("J, K };", p.getRawSignature());
+ IASTSimpleDeclaration s = getDeclaration(ct, 2);
+ assertEquals("int i;", s.getRawSignature());
+ }
- // class A {
- // enum _T { I J, K }; // missing comma
- // int i;
- // };
- public void testEnumError_Bug72685() throws Exception {
- final String comment= getAboveComment();
- IASTTranslationUnit tu= parse(comment, ParserLanguage.CPP, false, false);
- IASTCompositeTypeSpecifier ct= getCompositeType(tu, 0);
- IASTSimpleDeclaration e= getDeclaration(ct, 0);
- IASTProblemDeclaration p= getDeclaration(ct, 1);
- assertEquals("J, K };", p.getRawSignature());
- IASTSimpleDeclaration s= getDeclaration(ct, 2);
- assertEquals("int i;", s.getRawSignature());
- }
-
-
// #define XX() .
// int c;
// XX(
// );
// int d;
public void testErrorRecovery_273759() throws Exception {
- IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.C, false, false);
- IASTSimpleDeclaration s= getDeclaration(tu, 0);
- IASTProblemDeclaration p= getDeclaration(tu, 1);
- s= getDeclaration(tu, 2);
-
- tu= parse(getAboveComment(), ParserLanguage.CPP, false, false);
- s= getDeclaration(tu, 0);
- p= getDeclaration(tu, 1);
- s= getDeclaration(tu, 2);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, false, false);
+ IASTSimpleDeclaration s = getDeclaration(tu, 0);
+ IASTProblemDeclaration p = getDeclaration(tu, 1);
+ s = getDeclaration(tu, 2);
+
+ tu = parse(getAboveComment(), ParserLanguage.CPP, false, false);
+ s = getDeclaration(tu, 0);
+ p = getDeclaration(tu, 1);
+ s = getDeclaration(tu, 2);
}
-
+
// TINT* f(TINT* p) {
// TINT* f1(TINT* p) {
// TINT* f2(TINT* p) {
@@ -314,8 +312,8 @@ public class FaultToleranceTests extends AST2TestBase {
// TINT* f29(TINT* p) {
// }
public void testPerformanceIssue_364108() throws Exception {
- final String comment= getAboveComment();
- parse(comment, ParserLanguage.CPP, false, false);
- parse(comment, ParserLanguage.C, false, false);
+ final String comment = getAboveComment();
+ parse(comment, ParserLanguage.CPP, false, false);
+ parse(comment, ParserLanguage.C, false, false);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java
index 4da8b229797..531cb5bd75f 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java
@@ -49,7 +49,7 @@ public class GCCCompleteParseExtensionsTest extends AST2TestBase {
CNameResolver resolver = new CNameResolver();
tu.accept(resolver);
if (resolver.numProblemBindings > 0)
- throw new ParserException(" there are " + resolver.numProblemBindings + " ProblemBindings on the tu"); //$NON-NLS-2$
+ throw new ParserException(" there are " + resolver.numProblemBindings + " ProblemBindings on the tu"); //$NON-NLS-2$
if (resolver.numNullBindings > 0)
throw new ParserException("Expected no null bindings, encountered " + resolver.numNullBindings);
return tu;
@@ -61,43 +61,49 @@ public class GCCCompleteParseExtensionsTest extends AST2TestBase {
CPPNameResolver resolver = new CPPNameResolver();
tu.accept(resolver);
if (resolver.numProblemBindings > 0)
- throw new ParserException(" there are " + resolver.numProblemBindings + " ProblemBindings on the tu"); //$NON-NLS-2$
+ throw new ParserException(" there are " + resolver.numProblemBindings + " ProblemBindings on the tu"); //$NON-NLS-2$
if (resolver.numNullBindings > 0)
throw new ParserException("Expected no null bindings, encountered " + resolver.numNullBindings);
return tu;
}
- public void testBug39695() throws Exception {
- parseGCC("int a = __alignof__ (int);").getDeclarations();
- }
+ public void testBug39695() throws Exception {
+ parseGCC("int a = __alignof__ (int);").getDeclarations();
+ }
- public void testBug39684() throws Exception {
- IASTDeclaration bar = parseGCC("typeof(foo(1)) bar () { return foo(1); }").getDeclarations()[0];
+ public void testBug39684() throws Exception {
+ IASTDeclaration bar = parseGCC("typeof(foo(1)) bar () { return foo(1); }").getDeclarations()[0];
assertTrue(bar instanceof CASTFunctionDefinition);
- CFunction barFunc = (CFunction)((CASTFunctionDefinition)bar).getDeclarator().getName().resolveBinding();
+ CFunction barFunc = (CFunction) ((CASTFunctionDefinition) bar).getDeclarator().getName().resolveBinding();
IFunctionType type = barFunc.getType();
- // TODO Devin typeof declSpec has 0 length, also doesn't seem to have a type for typeof... raise a bug
-// IASTSimpleTypeSpecifier simpleTypeSpec = ((IASTSimpleTypeSpecifier)bar.getReturnType().getTypeSpecifier());
-// assertEquals(simpleTypeSpec.getType(), IASTGCCSimpleTypeSpecifier.Type.TYPEOF);
- }
+ // TODO Devin typeof declSpec has 0 length, also doesn't seem to have a type for typeof... raise a bug
+ // IASTSimpleTypeSpecifier simpleTypeSpec = ((IASTSimpleTypeSpecifier)bar.getReturnType().getTypeSpecifier());
+ // assertEquals(simpleTypeSpec.getType(), IASTGCCSimpleTypeSpecifier.Type.TYPEOF);
+ }
- public void testBug39698A() throws Exception {
- IASTDeclaration[] decls = parseGPP("int a=0; \n int b=1; \n int c = a <? b;").getDeclarations();
- assertEquals(ASTStringUtil.getExpressionString((IASTExpression) ((IASTEqualsInitializer)((IASTSimpleDeclaration)decls[2]).getDeclarators()[0].getInitializer()).getInitializerClause()), "a <? b");
- }
+ public void testBug39698A() throws Exception {
+ IASTDeclaration[] decls = parseGPP("int a=0; \n int b=1; \n int c = a <? b;").getDeclarations();
+ assertEquals(ASTStringUtil.getExpressionString(
+ (IASTExpression) ((IASTEqualsInitializer) ((IASTSimpleDeclaration) decls[2]).getDeclarators()[0]
+ .getInitializer()).getInitializerClause()),
+ "a <? b");
+ }
- public void testBug39698B() throws Exception {
- IASTDeclaration[] decls = parseGPP("int a=0; \n int b=1; \n int c = a >? b;").getDeclarations();
- assertEquals(ASTStringUtil.getExpressionString((IASTExpression) ((IASTEqualsInitializer)((IASTSimpleDeclaration)decls[2]).getDeclarators()[0].getInitializer()).getInitializerClause()), "a >? b");
- }
+ public void testBug39698B() throws Exception {
+ IASTDeclaration[] decls = parseGPP("int a=0; \n int b=1; \n int c = a >? b;").getDeclarations();
+ assertEquals(ASTStringUtil.getExpressionString(
+ (IASTExpression) ((IASTEqualsInitializer) ((IASTSimpleDeclaration) decls[2]).getDeclarators()[0]
+ .getInitializer()).getInitializerClause()),
+ "a >? b");
+ }
public void testPredefinedSymbol_bug69791() throws Exception {
parseGPP("typedef __builtin_va_list __gnuc_va_list; \n").getDeclarations();
parseGCC("typedef __builtin_va_list __gnuc_va_list; \n").getDeclarations();
}
- public void testBug39697() throws Exception {
+ public void testBug39697() throws Exception {
Writer writer = new StringWriter();
writer.write("__asm__( \"CODE\" );\n");
writer.write("__inline__ int foo() { return 4; }\n");
@@ -106,29 +112,33 @@ public class GCCCompleteParseExtensionsTest extends AST2TestBase {
writer.write("__signed__ int signedInt;\n");
IASTDeclaration[] decls = parseGCC(writer.toString()).getDeclarations();
- assertEquals(((IASTASMDeclaration)decls[0]).getAssembly(), "\"CODE\"");
- assertTrue(((IASTFunctionDefinition)decls[1]).getDeclSpecifier().isInline());
- assertTrue(((IASTSimpleDeclaration)decls[2]).getDeclSpecifier().isConst());
- assertTrue(((IASTSimpleDeclaration)decls[3]).getDeclSpecifier().isVolatile());
- assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[4]).getDeclSpecifier()).isSigned());
-
- writer = new StringWriter();
- writer.write("int * __restrict__ resPointer1;\n");
- writer.write("int * __restrict resPointer2;\n");
- decls = parseGCC(writer.toString()).getDeclarations();
- assertTrue(((ICASTPointer)((IASTSimpleDeclaration)decls[0]).getDeclarators()[0].getPointerOperators()[0]).isRestrict());
- assertTrue(((ICASTPointer)((IASTSimpleDeclaration)decls[1]).getDeclarators()[0].getPointerOperators()[0]).isRestrict());
-
- writer = new StringWriter();
- writer.write("int * __restrict__ resPointer1;\n");
- writer.write("int * __restrict resPointer2;\n");
- decls = parseGPP(writer.toString()).getDeclarations();
- assertTrue(((IASTPointer)((IASTSimpleDeclaration)decls[0]).getDeclarators()[0].getPointerOperators()[0]).isRestrict());
- assertTrue(((IASTPointer)((IASTSimpleDeclaration)decls[1]).getDeclarators()[0].getPointerOperators()[0]).isRestrict());
+ assertEquals(((IASTASMDeclaration) decls[0]).getAssembly(), "\"CODE\"");
+ assertTrue(((IASTFunctionDefinition) decls[1]).getDeclSpecifier().isInline());
+ assertTrue(((IASTSimpleDeclaration) decls[2]).getDeclSpecifier().isConst());
+ assertTrue(((IASTSimpleDeclaration) decls[3]).getDeclSpecifier().isVolatile());
+ assertTrue(((ICASTSimpleDeclSpecifier) ((IASTSimpleDeclaration) decls[4]).getDeclSpecifier()).isSigned());
+
+ writer = new StringWriter();
+ writer.write("int * __restrict__ resPointer1;\n");
+ writer.write("int * __restrict resPointer2;\n");
+ decls = parseGCC(writer.toString()).getDeclarations();
+ assertTrue(((ICASTPointer) ((IASTSimpleDeclaration) decls[0]).getDeclarators()[0].getPointerOperators()[0])
+ .isRestrict());
+ assertTrue(((ICASTPointer) ((IASTSimpleDeclaration) decls[1]).getDeclarators()[0].getPointerOperators()[0])
+ .isRestrict());
+
+ writer = new StringWriter();
+ writer.write("int * __restrict__ resPointer1;\n");
+ writer.write("int * __restrict resPointer2;\n");
+ decls = parseGPP(writer.toString()).getDeclarations();
+ assertTrue(((IASTPointer) ((IASTSimpleDeclaration) decls[0]).getDeclarators()[0].getPointerOperators()[0])
+ .isRestrict());
+ assertTrue(((IASTPointer) ((IASTSimpleDeclaration) decls[1]).getDeclarators()[0].getPointerOperators()[0])
+ .isRestrict());
}
public void testBug73954A() throws Exception {
- StringWriter writer = new StringWriter();
+ StringWriter writer = new StringWriter();
writer.write("void f(){ \n");
writer.write(" __builtin_expect( 23, 2); \n");
writer.write(" __builtin_prefetch( (const void *)0, 1, 2); \n");
@@ -164,212 +174,212 @@ public class GCCCompleteParseExtensionsTest extends AST2TestBase {
writer.write(" __builtin_powil (0, 0); \n");
writer.write("} \n");
- parseGCC(writer.toString());
+ parseGCC(writer.toString());
}
- public void testBug39686() throws Exception {
- Writer code = new StringWriter();
- code.write("__complex__ double x; // complex double\n");
- code.write("__complex__ short int a; // complex short int\n");
- code.write("__complex__ float y = 2.5fi; // 2.5 imaginary float literal\n");
- code.write("__complex__ int z = 3i; // imaginary intege r literal\n");
- code.write("double v = __real__ x; // real part of expression\n");
- code.write("double w = __imag__ x; // imaginary part of expression\n");
- parseGCC(code.toString());
- }
+ public void testBug39686() throws Exception {
+ Writer code = new StringWriter();
+ code.write("__complex__ double x; // complex double\n");
+ code.write("__complex__ short int a; // complex short int\n");
+ code.write("__complex__ float y = 2.5fi; // 2.5 imaginary float literal\n");
+ code.write("__complex__ int z = 3i; // imaginary intege r literal\n");
+ code.write("double v = __real__ x; // real part of expression\n");
+ code.write("double w = __imag__ x; // imaginary part of expression\n");
+ parseGCC(code.toString());
+ }
public void testBug39551B() throws Exception {
- //this used to be 99.99 * __I__, but I don't know where the __I__ came from, its not in C99, nor in GCC
+ //this used to be 99.99 * __I__, but I don't know where the __I__ came from, its not in C99, nor in GCC
IASTDeclaration decl = parseGCC("_Imaginary double id = 99.99 * 1i;").getDeclarations()[0];
// TODO Devin does ICPPASTSimpleDeclSpecifier need something for isImaginary ?
// assertEquals(variable.getName(), "id");
-// assertTrue(((IASTSimpleTypeSpecifier)variable.getAbstractDeclaration().getTypeSpecifier()).isImaginary());
+ // assertTrue(((IASTSimpleTypeSpecifier)variable.getAbstractDeclaration().getTypeSpecifier()).isImaginary());
+ }
+
+ public void testBug39681() throws Exception {
+ Writer code = new StringWriter();
+ code.write("double\n");
+ code.write("foo (double a, double b)\n");
+ code.write("{\n");
+ code.write(" double square (double z) { return z * z; }\n");
+ code.write(" return square (a) + square (b);\n");
+ code.write("}\n");
+ parseGCC(code.toString());
}
- public void testBug39681() throws Exception {
- Writer code = new StringWriter();
- code.write("double\n");
- code.write("foo (double a, double b)\n");
- code.write("{\n");
- code.write(" double square (double z) { return z * z; }\n");
- code.write(" return square (a) + square (b);\n");
- code.write("}\n");
- parseGCC(code.toString());
- }
-
- public void testBug39677() throws Exception {
+ public void testBug39677() throws Exception {
parseGPP("class B { public: B(); int a;}; B::B() : a(({ 1; })) {}");
- Writer writer = new StringWriter();
- writer.write("int foo(); class B { public: B(); int a;};");
- writer.write("B::B() : a(( { int y = foo (); int z;\n");
- writer.write("if (y > 0) z = y;\n");
- writer.write("else z = - y;\n");
- writer.write("z; })) {}\n");
+ Writer writer = new StringWriter();
+ writer.write("int foo(); class B { public: B(); int a;};");
+ writer.write("B::B() : a(( { int y = foo (); int z;\n");
+ writer.write("if (y > 0) z = y;\n");
+ writer.write("else z = - y;\n");
+ writer.write("z; })) {}\n");
parseGPP(writer.toString());
- writer = new StringWriter();
- writer.write("int x = ({ int foo(); int y = foo (); int z;\n");
- writer.write("if (y > 0) z = y;\n");
- writer.write("else z = - y;\n");
- writer.write("z; });\n");
+ writer = new StringWriter();
+ writer.write("int x = ({ int foo(); int y = foo (); int z;\n");
+ writer.write("if (y > 0) z = y;\n");
+ writer.write("else z = - y;\n");
+ writer.write("z; });\n");
parseGPP(writer.toString());
- writer = new StringWriter();
- writer.write("int foo(); \n");
- writer.write("typeof({ int y = foo (); \n");
- writer.write(" int z; \n");
- writer.write(" if (y > 0) z = y; \n");
- writer.write(" else z = - y; \n");
- writer.write(" z; \n");
- writer.write(" }) zoot; \n");
-
- parseGPP(writer.toString()); // TODO Devin raised bug 93980
- }
-
- public void testBug75401() throws Exception {
- Writer writer = new StringWriter();
- writer.write("#define va_list __builtin_va_list \n");
- writer.write("#define va_arg(v,l) __builtin_va_arg(v,l) \n");
- writer.write("#define va_start(v,l) __builtin_va_start(v,l) \n");
- writer.write("#define va_end(v) __builtin_va_end(v) \n");
- writer.write("void variadic(int first, ...) { \n");
- writer.write(" va_list v; \n");
- writer.write(" va_start(v, first); \n");
- writer.write(" long l = va_arg(v, long); \n");
- writer.write(" va_end(v); \n");
- writer.write("} \n");
-
- parseGCC(writer.toString());
- parseGPP(writer.toString());
- }
-
- public void testBug73954B() throws Exception {
- Writer writer = new StringWriter();
- writer.write("#define foo(x) \\\n");
- writer.write(" __builtin_choose_expr( 1, foo_d(x), (void)0 ) \n");
- writer.write("int foo_d( int x ); \n");
- writer.write("int main() { \n");
- writer.write(" if( __builtin_constant_p(1) && \n");
- writer.write(" __builtin_types_compatible_p( 1, 'c') ) \n");
- writer.write(" foo(1); \n");
- writer.write("} \n");
-
- parseGCC(writer.toString());
- }
+ writer = new StringWriter();
+ writer.write("int foo(); \n");
+ writer.write("typeof({ int y = foo (); \n");
+ writer.write(" int z; \n");
+ writer.write(" if (y > 0) z = y; \n");
+ writer.write(" else z = - y; \n");
+ writer.write(" z; \n");
+ writer.write(" }) zoot; \n");
+
+ parseGPP(writer.toString()); // TODO Devin raised bug 93980
+ }
+
+ public void testBug75401() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("#define va_list __builtin_va_list \n");
+ writer.write("#define va_arg(v,l) __builtin_va_arg(v,l) \n");
+ writer.write("#define va_start(v,l) __builtin_va_start(v,l) \n");
+ writer.write("#define va_end(v) __builtin_va_end(v) \n");
+ writer.write("void variadic(int first, ...) { \n");
+ writer.write(" va_list v; \n");
+ writer.write(" va_start(v, first); \n");
+ writer.write(" long l = va_arg(v, long); \n");
+ writer.write(" va_end(v); \n");
+ writer.write("} \n");
+
+ parseGCC(writer.toString());
+ parseGPP(writer.toString());
+ }
+
+ public void testBug73954B() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("#define foo(x) \\\n");
+ writer.write(" __builtin_choose_expr( 1, foo_d(x), (void)0 ) \n");
+ writer.write("int foo_d( int x ); \n");
+ writer.write("int main() { \n");
+ writer.write(" if( __builtin_constant_p(1) && \n");
+ writer.write(" __builtin_types_compatible_p( 1, 'c') ) \n");
+ writer.write(" foo(1); \n");
+ writer.write("} \n");
+
+ parseGCC(writer.toString());
+ }
public void testGNUExternalTemplate_bug71603() throws Exception {
parseGPP("template <typename T> \n class A {}; \n extern template class A<int>; \n").getDeclarations();
}
public void testBug74190_g_assert_1() throws Exception {
- Writer writer = new StringWriter();
- writer.write("void log( int ); \n");
- writer.write("void f() { \n");
- writer.write(" int a = 1; \n");
- writer.write(" (void)({ if( a ){ } \n");
- writer.write(" else{ log( a ); } \n");
- writer.write(" }); \n");
- writer.write("} \n");
-
- parseGCC(writer.toString());
- parseGPP(writer.toString());
+ Writer writer = new StringWriter();
+ writer.write("void log( int ); \n");
+ writer.write("void f() { \n");
+ writer.write(" int a = 1; \n");
+ writer.write(" (void)({ if( a ){ } \n");
+ writer.write(" else{ log( a ); } \n");
+ writer.write(" }); \n");
+ writer.write("} \n");
+
+ parseGCC(writer.toString());
+ parseGPP(writer.toString());
}
public void testBug74190_g_return_if_fail() throws Exception {
- Writer writer = new StringWriter();
- writer.write("void f() { \n");
- writer.write(" (void)({ if( ( ({ 0; }) ) ) \n");
- writer.write(" { } \n");
- writer.write(" }); \n");
- writer.write("} \n");
-
- parseGCC(writer.toString());
- parseGPP(writer.toString());
+ Writer writer = new StringWriter();
+ writer.write("void f() { \n");
+ writer.write(" (void)({ if( ( ({ 0; }) ) ) \n");
+ writer.write(" { } \n");
+ writer.write(" }); \n");
+ writer.write("} \n");
+
+ parseGCC(writer.toString());
+ parseGPP(writer.toString());
}
- public void testBug95635() throws Exception{
- StringWriter writer = new StringWriter();
- writer.write("void f(){ \n");
- writer.write(" char a[10]; \n");
- writer.write(" __builtin_va_list b; \n");
- writer.write(" __builtin_abort(); \n");
- writer.write(" __builtin_exit(1); \n");
- writer.write(" __builtin__Exit(1); \n");
- writer.write(" __builtin__exit(1); \n");
- writer.write(" __builtin_conj(1); \n");
- writer.write(" __builtin_conjf(1); \n");
- writer.write(" __builtin_conjl(1); \n");
- writer.write(" __builtin_creal(1); \n");
- writer.write(" __builtin_crealf(1); \n");
- writer.write(" __builtin_creall(1); \n");
- writer.write(" __builtin_cimag(1); \n");
- writer.write(" __builtin_cimagf(1); \n");
- writer.write(" __builtin_cimagl(1); \n");
- writer.write(" __builtin_imaxabs(1); \n");
- writer.write(" __builtin_llabs(1); \n");
- writer.write(" __builtin_vscanf(\"\",b);\n");
- writer.write(" __builtin_vsnprintf(a, 1, \"\", b); \n");
- writer.write(" __builtin_vsscanf(\"\", \"\", b);\n");
- writer.write(" __builtin_cosf(1); \n");
- writer.write(" __builtin_cosl(1); \n");
- writer.write(" __builtin_expf(1); \n");
- writer.write(" __builtin_expl(1); \n");
- writer.write(" __builtin_fabsf(1); \n");
- writer.write(" __builtin_fabsl(1); \n");
- writer.write(" __builtin_logf(1); \n");
- writer.write(" __builtin_logl(1); \n");
- writer.write(" __builtin_sinf(1); \n");
- writer.write(" __builtin_sinl(1); \n");
- writer.write(" __builtin_sqrtf(1); \n");
- writer.write(" __builtin_sqrtl(1); \n");
- writer.write(" __builtin_abs(1); \n");
- writer.write(" __builtin_cos(1); \n");
- writer.write(" __builtin_exp(1); \n");
- writer.write(" __builtin_fabs(1); \n");
- writer.write(" __builtin_fprintf((void*)0, \"\");\n");
- writer.write(" __builtin_fputs(\"\", (void*)0);\n");
- writer.write(" __builtin_labs(1); \n");
- writer.write(" __builtin_log(1); \n");
- writer.write(" __builtin_memcmp((void*)0, (void*)0, 1);\n");
- writer.write(" __builtin_memcpy((void*)0,(void*)0, 1);\n");
- writer.write(" __builtin_memset((void*)0, 1, 1);\n");
- writer.write(" __builtin_printf(\"\"); \n");
- writer.write(" __builtin_putchar(1); \n");
- writer.write(" __builtin_puts(\"\"); \n");
- writer.write(" __builtin_scanf(\"\"); \n");
- writer.write(" __builtin_sin(1); \n");
- writer.write(" __builtin_snprintf(a, 1, \"\");\n");
- writer.write(" __builtin_sprintf(a, \"\");\n");
- writer.write(" __builtin_sqrt(1); \n");
- writer.write(" __builtin_sscanf(\"\", \"\"); \n");
- writer.write(" __builtin_strcat(a, \"\"); \n");
- writer.write(" __builtin_strchr(\"\", 1); \n");
- writer.write(" __builtin_strcmp(\"\", \"\"); \n");
- writer.write(" __builtin_strcpy(a, \"\"); \n");
- writer.write(" __builtin_strcspn(\"\", \"\");\n");
- writer.write(" __builtin_strlen(\"\"); \n");
- writer.write(" __builtin_strncat(a, \"\", 1);\n");
- writer.write(" __builtin_strncmp(\"\", \"\", 1);\n");
- writer.write(" __builtin_strncpy(a, \"\", 1);\n");
- writer.write(" __builtin_strpbrk(\"\", \"\");\n");
- writer.write(" __builtin_strrchr(\"\", 1); \n");
- writer.write(" __builtin_strspn(\"\", \"\"); \n");
- writer.write(" __builtin_strstr(\"\", \"\"); \n");
- writer.write(" __builtin_strstr(\"\", \"\"); \n");
- writer.write(" __builtin_vprintf(a, b);\n");
- writer.write(" __builtin_vsprintf(a, \"\", b); \n");
- writer.write(" __builtin_isgreater(1.0,1.0); \n");
- writer.write(" __builtin_isgreaterequal(1.0,1.0);\n");
- writer.write(" __builtin_isless(1.0,1.0); \n");
- writer.write(" __builtin_islessequal(1.0,1.0); \n");
- writer.write(" __builtin_islessgreater(1.0,1.0); \n");
- writer.write(" __builtin_isunordered(1.0,1.0); \n");
- writer.write("} \n");
-
- final String code = writer.toString();
+ public void testBug95635() throws Exception {
+ StringWriter writer = new StringWriter();
+ writer.write("void f(){ \n");
+ writer.write(" char a[10]; \n");
+ writer.write(" __builtin_va_list b; \n");
+ writer.write(" __builtin_abort(); \n");
+ writer.write(" __builtin_exit(1); \n");
+ writer.write(" __builtin__Exit(1); \n");
+ writer.write(" __builtin__exit(1); \n");
+ writer.write(" __builtin_conj(1); \n");
+ writer.write(" __builtin_conjf(1); \n");
+ writer.write(" __builtin_conjl(1); \n");
+ writer.write(" __builtin_creal(1); \n");
+ writer.write(" __builtin_crealf(1); \n");
+ writer.write(" __builtin_creall(1); \n");
+ writer.write(" __builtin_cimag(1); \n");
+ writer.write(" __builtin_cimagf(1); \n");
+ writer.write(" __builtin_cimagl(1); \n");
+ writer.write(" __builtin_imaxabs(1); \n");
+ writer.write(" __builtin_llabs(1); \n");
+ writer.write(" __builtin_vscanf(\"\",b);\n");
+ writer.write(" __builtin_vsnprintf(a, 1, \"\", b); \n");
+ writer.write(" __builtin_vsscanf(\"\", \"\", b);\n");
+ writer.write(" __builtin_cosf(1); \n");
+ writer.write(" __builtin_cosl(1); \n");
+ writer.write(" __builtin_expf(1); \n");
+ writer.write(" __builtin_expl(1); \n");
+ writer.write(" __builtin_fabsf(1); \n");
+ writer.write(" __builtin_fabsl(1); \n");
+ writer.write(" __builtin_logf(1); \n");
+ writer.write(" __builtin_logl(1); \n");
+ writer.write(" __builtin_sinf(1); \n");
+ writer.write(" __builtin_sinl(1); \n");
+ writer.write(" __builtin_sqrtf(1); \n");
+ writer.write(" __builtin_sqrtl(1); \n");
+ writer.write(" __builtin_abs(1); \n");
+ writer.write(" __builtin_cos(1); \n");
+ writer.write(" __builtin_exp(1); \n");
+ writer.write(" __builtin_fabs(1); \n");
+ writer.write(" __builtin_fprintf((void*)0, \"\");\n");
+ writer.write(" __builtin_fputs(\"\", (void*)0);\n");
+ writer.write(" __builtin_labs(1); \n");
+ writer.write(" __builtin_log(1); \n");
+ writer.write(" __builtin_memcmp((void*)0, (void*)0, 1);\n");
+ writer.write(" __builtin_memcpy((void*)0,(void*)0, 1);\n");
+ writer.write(" __builtin_memset((void*)0, 1, 1);\n");
+ writer.write(" __builtin_printf(\"\"); \n");
+ writer.write(" __builtin_putchar(1); \n");
+ writer.write(" __builtin_puts(\"\"); \n");
+ writer.write(" __builtin_scanf(\"\"); \n");
+ writer.write(" __builtin_sin(1); \n");
+ writer.write(" __builtin_snprintf(a, 1, \"\");\n");
+ writer.write(" __builtin_sprintf(a, \"\");\n");
+ writer.write(" __builtin_sqrt(1); \n");
+ writer.write(" __builtin_sscanf(\"\", \"\"); \n");
+ writer.write(" __builtin_strcat(a, \"\"); \n");
+ writer.write(" __builtin_strchr(\"\", 1); \n");
+ writer.write(" __builtin_strcmp(\"\", \"\"); \n");
+ writer.write(" __builtin_strcpy(a, \"\"); \n");
+ writer.write(" __builtin_strcspn(\"\", \"\");\n");
+ writer.write(" __builtin_strlen(\"\"); \n");
+ writer.write(" __builtin_strncat(a, \"\", 1);\n");
+ writer.write(" __builtin_strncmp(\"\", \"\", 1);\n");
+ writer.write(" __builtin_strncpy(a, \"\", 1);\n");
+ writer.write(" __builtin_strpbrk(\"\", \"\");\n");
+ writer.write(" __builtin_strrchr(\"\", 1); \n");
+ writer.write(" __builtin_strspn(\"\", \"\"); \n");
+ writer.write(" __builtin_strstr(\"\", \"\"); \n");
+ writer.write(" __builtin_strstr(\"\", \"\"); \n");
+ writer.write(" __builtin_vprintf(a, b);\n");
+ writer.write(" __builtin_vsprintf(a, \"\", b); \n");
+ writer.write(" __builtin_isgreater(1.0,1.0); \n");
+ writer.write(" __builtin_isgreaterequal(1.0,1.0);\n");
+ writer.write(" __builtin_isless(1.0,1.0); \n");
+ writer.write(" __builtin_islessequal(1.0,1.0); \n");
+ writer.write(" __builtin_islessgreater(1.0,1.0); \n");
+ writer.write(" __builtin_isunordered(1.0,1.0); \n");
+ writer.write("} \n");
+
+ final String code = writer.toString();
parseGCC(code);
- parseGPP(code);
- }
+ parseGPP(code);
+ }
// typedef int size_t; // will be defined in <stddef.h>
// struct S {int m;};
@@ -380,7 +390,7 @@ public class GCCCompleteParseExtensionsTest extends AST2TestBase {
// gcc with __GNUC__ >= 4 defines:
// #define offsetof(type, field) __builtin_offsetof(type, field)
- String code= getAboveComment();
+ String code = getAboveComment();
parseGCC(code);
parseGPP(code);
}
@@ -424,35 +434,35 @@ public class GCCCompleteParseExtensionsTest extends AST2TestBase {
// __int128 a;
// unsigned __int128 b;
public void test__int128() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseGCC(code);
parseGPP(code);
}
// __float128 f;
public void test__float128() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseGCC(code);
parseGPP(code);
}
-
+
// _Decimal32 x;
public void test_Decimal32() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseGCC(code);
parseGPP(code);
}
// _Decimal64 x;
public void test_Decimal64() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseGCC(code);
parseGPP(code);
}
// _Decimal128 x;
public void test_Decimal128() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseGCC(code);
parseGPP(code);
}
@@ -460,7 +470,7 @@ public class GCCCompleteParseExtensionsTest extends AST2TestBase {
// struct waldo {
// } __attribute__((__aligned__((1))));
public void test__attribute__aligned_bug400204() throws Exception {
- String code= getAboveComment();
+ String code = getAboveComment();
parseGCC(code);
parseGPP(code);
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCTests.java
index 6f57514f2e6..08a5881f029 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCTests.java
@@ -34,7 +34,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
*/
public class GCCTests extends AST2TestBase {
- public GCCTests() {
+ public GCCTests() {
}
public GCCTests(String name) {
@@ -42,148 +42,148 @@ public class GCCTests extends AST2TestBase {
}
public void testGCC20000113() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("struct x { \n");
- buffer.append(" unsigned x1:1; \n");
- buffer.append(" unsigned x2:2; \n");
- buffer.append(" unsigned x3:3; \n");
- buffer.append("}; \n");
- buffer.append("foobar(int x, int y, int z) { \n");
- buffer.append(" struct x a = {x, y, z}; \n");
- buffer.append(" struct x b = {x, y, z}; \n");
- buffer.append(" struct x *c = &b; \n");
- buffer.append(" c->x3 += (a.x2 - a.x1) * c->x2; \n");
- buffer.append(" if (a.x1 != 1 || c->x3 != 5) \n");
- buffer.append(" return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
-
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 33);
- ICompositeType x = (ICompositeType) collector.getName(0).resolveBinding();
- IField x1 = (IField) collector.getName(1).resolveBinding();
- IField x2 = (IField) collector.getName(2).resolveBinding();
- IField x3 = (IField) collector.getName(3).resolveBinding();
- IVariable vx = (IVariable) collector.getName(5).resolveBinding();
- IVariable vy = (IVariable) collector.getName(6).resolveBinding();
- IVariable vz = (IVariable) collector.getName(7).resolveBinding();
- IVariable a = (IVariable) collector.getName(9).resolveBinding();
- IVariable b = (IVariable) collector.getName(14).resolveBinding();
- IVariable c = (IVariable) collector.getName(19).resolveBinding();
-
- assertInstances(collector, x, 4);
- assertInstances(collector, x1, 3);
- assertInstances(collector, x2, 3);
- assertInstances(collector, x3, 3);
- assertInstances(collector, vx, 3);
- assertInstances(collector, vy, 3);
- assertInstances(collector, vz, 3);
- assertInstances(collector, a, 4);
- assertInstances(collector, b, 2);
- assertInstances(collector, c, 4);
- }
-
- public void testGCC20000205() throws Exception{
- StringBuilder buffer = new StringBuilder();
- buffer.append("static int f(int a) { \n");
- buffer.append(" if (a == 0) \n");
- buffer.append(" return 0; \n");
- buffer.append(" do \n");
- buffer.append(" if (a & 128) \n");
- buffer.append(" return 1; \n");
- buffer.append(" while (f(0)); \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
-
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 5);
- IFunction f = (IFunction) collector.getName(0).resolveBinding();
- IVariable a = (IVariable) collector.getName(1).resolveBinding();
-
- assertInstances(collector, f, 2);
- assertInstances(collector, a, 3);
- }
-
- public void testGCC20000217() throws Exception{
- StringBuilder buffer = new StringBuilder();
- buffer.append("unsigned short int showbug(unsigned short int * a, \n");
- buffer.append(" unsigned short int * b) { \n");
- buffer.append(" *a += *b - 8; \n");
- buffer.append(" return (*a >= 8); \n");
- buffer.append("} \n");
- buffer.append("int main() { \n");
- buffer.append(" unsigned short int x = 0; \n");
- buffer.append(" unsigned short int y = 10; \n");
- buffer.append(" if (showbug(&x, &y) != 0) \n");
- buffer.append(" return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 12);
-
- IFunction showBug = (IFunction) collector.getName(0).resolveBinding();
- IVariable a = (IVariable) collector.getName(1).resolveBinding();
- IVariable b = (IVariable) collector.getName(2).resolveBinding();
- IVariable x = (IVariable) collector.getName(7).resolveBinding();
- IVariable y = (IVariable) collector.getName(8).resolveBinding();
-
- assertInstances(collector, showBug, 2);
- assertInstances(collector, a, 3);
- assertInstances(collector, b, 2);
- assertInstances(collector, x, 2);
- assertInstances(collector, y, 2);
- }
-
- public void testGCC20000224() throws Exception{
- StringBuilder buffer = new StringBuilder();
- buffer.append("int loop_1 = 100; \n");
- buffer.append("int loop_2 = 7; \n");
- buffer.append("int flag = 0; \n");
- buffer.append("int test(void) { \n");
- buffer.append(" int i; \n");
- buffer.append(" int counter = 0; \n");
- buffer.append(" while (loop_1 > counter) { \n");
- buffer.append(" if (flag & 1) { \n");
- buffer.append(" for (i = 0; i < loop_2; i++) { \n");
- buffer.append(" counter++; \n");
- buffer.append(" } \n");
- buffer.append(" } \n");
- buffer.append(" flag++; \n");
- buffer.append(" } \n");
- buffer.append(" return 1; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 16);
- IVariable loop1 = (IVariable) collector.getName(0).resolveBinding();
- IVariable loop2 = (IVariable) collector.getName(1).resolveBinding();
- IVariable flag = (IVariable) collector.getName(2).resolveBinding();
- IVariable i = (IVariable) collector.getName(5).resolveBinding();
- IVariable counter = (IVariable) collector.getName(6).resolveBinding();
-
- assertInstances(collector, loop1, 2);
- assertInstances(collector, loop2, 2);
- assertInstances(collector, flag, 3);
- assertInstances(collector, i, 4);
- assertInstances(collector, counter, 3);
- }
-
- public void testGCC20000225() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("struct x { \n");
+ buffer.append(" unsigned x1:1; \n");
+ buffer.append(" unsigned x2:2; \n");
+ buffer.append(" unsigned x3:3; \n");
+ buffer.append("}; \n");
+ buffer.append("foobar(int x, int y, int z) { \n");
+ buffer.append(" struct x a = {x, y, z}; \n");
+ buffer.append(" struct x b = {x, y, z}; \n");
+ buffer.append(" struct x *c = &b; \n");
+ buffer.append(" c->x3 += (a.x2 - a.x1) * c->x2; \n");
+ buffer.append(" if (a.x1 != 1 || c->x3 != 5) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 33);
+ ICompositeType x = (ICompositeType) collector.getName(0).resolveBinding();
+ IField x1 = (IField) collector.getName(1).resolveBinding();
+ IField x2 = (IField) collector.getName(2).resolveBinding();
+ IField x3 = (IField) collector.getName(3).resolveBinding();
+ IVariable vx = (IVariable) collector.getName(5).resolveBinding();
+ IVariable vy = (IVariable) collector.getName(6).resolveBinding();
+ IVariable vz = (IVariable) collector.getName(7).resolveBinding();
+ IVariable a = (IVariable) collector.getName(9).resolveBinding();
+ IVariable b = (IVariable) collector.getName(14).resolveBinding();
+ IVariable c = (IVariable) collector.getName(19).resolveBinding();
+
+ assertInstances(collector, x, 4);
+ assertInstances(collector, x1, 3);
+ assertInstances(collector, x2, 3);
+ assertInstances(collector, x3, 3);
+ assertInstances(collector, vx, 3);
+ assertInstances(collector, vy, 3);
+ assertInstances(collector, vz, 3);
+ assertInstances(collector, a, 4);
+ assertInstances(collector, b, 2);
+ assertInstances(collector, c, 4);
+ }
+
+ public void testGCC20000205() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("static int f(int a) { \n");
+ buffer.append(" if (a == 0) \n");
+ buffer.append(" return 0; \n");
+ buffer.append(" do \n");
+ buffer.append(" if (a & 128) \n");
+ buffer.append(" return 1; \n");
+ buffer.append(" while (f(0)); \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 5);
+ IFunction f = (IFunction) collector.getName(0).resolveBinding();
+ IVariable a = (IVariable) collector.getName(1).resolveBinding();
+
+ assertInstances(collector, f, 2);
+ assertInstances(collector, a, 3);
+ }
+
+ public void testGCC20000217() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("unsigned short int showbug(unsigned short int * a, \n");
+ buffer.append(" unsigned short int * b) { \n");
+ buffer.append(" *a += *b - 8; \n");
+ buffer.append(" return (*a >= 8); \n");
+ buffer.append("} \n");
+ buffer.append("int main() { \n");
+ buffer.append(" unsigned short int x = 0; \n");
+ buffer.append(" unsigned short int y = 10; \n");
+ buffer.append(" if (showbug(&x, &y) != 0) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 12);
+
+ IFunction showBug = (IFunction) collector.getName(0).resolveBinding();
+ IVariable a = (IVariable) collector.getName(1).resolveBinding();
+ IVariable b = (IVariable) collector.getName(2).resolveBinding();
+ IVariable x = (IVariable) collector.getName(7).resolveBinding();
+ IVariable y = (IVariable) collector.getName(8).resolveBinding();
+
+ assertInstances(collector, showBug, 2);
+ assertInstances(collector, a, 3);
+ assertInstances(collector, b, 2);
+ assertInstances(collector, x, 2);
+ assertInstances(collector, y, 2);
+ }
+
+ public void testGCC20000224() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int loop_1 = 100; \n");
+ buffer.append("int loop_2 = 7; \n");
+ buffer.append("int flag = 0; \n");
+ buffer.append("int test(void) { \n");
+ buffer.append(" int i; \n");
+ buffer.append(" int counter = 0; \n");
+ buffer.append(" while (loop_1 > counter) { \n");
+ buffer.append(" if (flag & 1) { \n");
+ buffer.append(" for (i = 0; i < loop_2; i++) { \n");
+ buffer.append(" counter++; \n");
+ buffer.append(" } \n");
+ buffer.append(" } \n");
+ buffer.append(" flag++; \n");
+ buffer.append(" } \n");
+ buffer.append(" return 1; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 16);
+ IVariable loop1 = (IVariable) collector.getName(0).resolveBinding();
+ IVariable loop2 = (IVariable) collector.getName(1).resolveBinding();
+ IVariable flag = (IVariable) collector.getName(2).resolveBinding();
+ IVariable i = (IVariable) collector.getName(5).resolveBinding();
+ IVariable counter = (IVariable) collector.getName(6).resolveBinding();
+
+ assertInstances(collector, loop1, 2);
+ assertInstances(collector, loop2, 2);
+ assertInstances(collector, flag, 3);
+ assertInstances(collector, i, 4);
+ assertInstances(collector, counter, 3);
+ }
+
+ public void testGCC20000225() throws Exception {
StringBuilder buffer = new StringBuilder();
buffer.append("int main() { \n");
buffer.append(" int nResult, b = 0, i = -1; \n");
@@ -200,642 +200,641 @@ public class GCCTests extends AST2TestBase {
buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 11);
- IVariable nResult = (IVariable) collector.getName(1).resolveBinding();
- IVariable b = (IVariable) collector.getName(2).resolveBinding();
- IVariable i = (IVariable) collector.getName(3).resolveBinding();
-
- assertInstances(collector, nResult, 3);
- assertInstances(collector, b, 3);
- assertInstances(collector, i, 4);
- }
-
- public void testGCC20000227() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("static const unsigned char f[] = \"\\0\\377\"; \n");
- buffer.append("static const unsigned char g[] = \"\\0y\"; \n");
- buffer.append("int main() { \n");
- buffer.append(" if (sizeof f != 3 || sizeof g != 3) \n");
- buffer.append(" return -1; \n");
- buffer.append(" if (f[0] != g[0]) \n");
- buffer.append(" return -1; \n");
- buffer.append(" if (f[1] != g[1] || f[2] != g[2]) \n");
- buffer.append(" return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 11);
+ IVariable nResult = (IVariable) collector.getName(1).resolveBinding();
+ IVariable b = (IVariable) collector.getName(2).resolveBinding();
+ IVariable i = (IVariable) collector.getName(3).resolveBinding();
+
+ assertInstances(collector, nResult, 3);
+ assertInstances(collector, b, 3);
+ assertInstances(collector, i, 4);
+ }
+
+ public void testGCC20000227() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("static const unsigned char f[] = \"\\0\\377\"; \n");
+ buffer.append("static const unsigned char g[] = \"\\0y\"; \n");
+ buffer.append("int main() { \n");
+ buffer.append(" if (sizeof f != 3 || sizeof g != 3) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" if (f[0] != g[0]) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" if (f[1] != g[1] || f[2] != g[2]) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 11);
+ IVariable f = (IVariable) collector.getName(0).resolveBinding();
+ IVariable g = (IVariable) collector.getName(1).resolveBinding();
+
+ assertInstances(collector, f, 5);
+ assertInstances(collector, g, 5);
+ }
+
+ public void testGCC20000313() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("unsigned int buggy(unsigned int *param) { \n");
+ buffer.append(" unsigned int accu, zero = 0, borrow; \n");
+ buffer.append(" accu = - *param; \n");
+ buffer.append(" borrow = - (accu > zero); \n");
+ buffer.append(" return borrow; \n");
+ buffer.append("} \n");
+ buffer.append("int main(void) { \n");
+ buffer.append(" unsigned int param = 1; \n");
+ buffer.append(" unsigned int borrow = buggy (&param); \n");
+ buffer.append(" if (param != 0) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" if (borrow +1 != 0) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 19);
+ IFunction buggy = (IFunction) collector.getName(0).resolveBinding();
+ IParameter param = (IParameter) collector.getName(1).resolveBinding();
+ IVariable accu = (IVariable) collector.getName(2).resolveBinding();
+ IVariable zero = (IVariable) collector.getName(3).resolveBinding();
+ IVariable borrow = (IVariable) collector.getName(4).resolveBinding();
+ IVariable param2 = (IVariable) collector.getName(13).resolveBinding();
+ IVariable borrow2 = (IVariable) collector.getName(14).resolveBinding();
+
+ assertInstances(collector, buggy, 2);
+ assertInstances(collector, param, 2);
+ assertInstances(collector, accu, 3);
+ assertInstances(collector, zero, 2);
+ assertInstances(collector, borrow, 3);
+ assertInstances(collector, param2, 3);
+ assertInstances(collector, borrow2, 2);
+ }
+
+ public void testGCC20000314_1() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int main() { \n");
+ buffer.append(" long winds = 0; \n");
+ buffer.append(" while (winds != 0) { \n");
+ buffer.append(" if (*(char*)winds) \n");
+ buffer.append(" break; \n");
+ buffer.append(" } \n");
+ buffer.append(" if (winds == 0 || winds != 0 || *(char*) winds) \n");
+ buffer.append(" return 0; \n");
+ buffer.append(" return -1; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 7);
+ IVariable winds = (IVariable) collector.getName(1).resolveBinding();
+
+ assertInstances(collector, winds, 6);
+ }
+
+ public void testGCC20000314_2() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("typedef unsigned long long uint64; \n");
+ buffer.append("const uint64 bigconst = 1ULL << 34; \n");
+ buffer.append("int a = 1; \n");
+ buffer.append("static uint64 getmask(void) { \n");
+ buffer.append(" if (a) return bigconst; \n");
+ buffer.append(" else return 0; \n");
+ buffer.append("} \n");
+ buffer.append("main() { \n");
+ buffer.append(" uint64 f = getmask(); \n");
+ buffer.append(" if (sizeof (long long) == 8 && f != bigconst) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 15);
+ ITypedef uint64 = (ITypedef) collector.getName(0).resolveBinding();
+ IVariable bigconst = (IVariable) collector.getName(2).resolveBinding();
+ IVariable a = (IVariable) collector.getName(3).resolveBinding();
+ IFunction getmask = (IFunction) collector.getName(5).resolveBinding();
+ IVariable f = (IVariable) collector.getName(11).resolveBinding();
+
+ assertInstances(collector, uint64, 4);
+ assertInstances(collector, bigconst, 3);
+ assertInstances(collector, a, 2);
+ assertInstances(collector, getmask, 2);
+ assertInstances(collector, f, 2);
+ }
+
+ public void testGCC20000403() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("extern unsigned long aa[], bb[]; \n");
+ buffer.append("int seqgt(unsigned long a, unsigned short win, unsigned long b); \n");
+ buffer.append("int seqgt2 (unsigned long a, unsigned short win, unsigned long b); \n");
+ buffer.append("main() { \n");
+ buffer.append(" if (!seqgt(*aa, 0x1000, *bb) || !seqgt2(*aa, 0x1000, *bb)) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+ buffer.append("int seqgt(unsigned long a, unsigned short win, unsigned long b) { \n");
+ buffer.append(" return (long) ((a + win) - b) > 0; \n");
+ buffer.append("} \n");
+ buffer.append("int seqgt2(unsigned long a, unsigned short win, unsigned long b) { \n");
+ buffer.append(" long l = ((a + win) - b); \n");
+ buffer.append(" return 1 > 0; \n");
+ buffer.append("} \n");
+ buffer.append("unsigned long aa[] = { (1UL << (sizeof(long) *8 - 1)) = 0xfff }; \n");
+ buffer.append("unsigned long bb[] = { (1UL << (sizeof(long) *8 - 1)) = 0xfff }; \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 34);
+ IVariable aa = (IVariable) collector.getName(0).resolveBinding();
+ IVariable bb = (IVariable) collector.getName(1).resolveBinding();
+ IFunction seqgt = (IFunction) collector.getName(2).resolveBinding();
+ IParameter a1 = (IParameter) collector.getName(3).resolveBinding();
+ IParameter win1 = (IParameter) collector.getName(4).resolveBinding();
+ IParameter b1 = (IParameter) collector.getName(5).resolveBinding();
+ IFunction seqgt2 = (IFunction) collector.getName(6).resolveBinding();
+ IParameter a2 = (IParameter) collector.getName(7).resolveBinding();
+ IParameter win2 = (IParameter) collector.getName(8).resolveBinding();
+ IParameter b2 = (IParameter) collector.getName(9).resolveBinding();
+
+ assertInstances(collector, aa, 4);
+ assertInstances(collector, bb, 4);
+ assertInstances(collector, seqgt, 3);
+ assertInstances(collector, a1, 3);
+ assertInstances(collector, win1, 3);
+ assertInstances(collector, b1, 3);
+ assertInstances(collector, seqgt2, 3);
+ assertInstances(collector, a2, 3);
+ assertInstances(collector, win2, 3);
+ assertInstances(collector, b2, 3);
+ }
+
+ public void testGCC20000412_1() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("short int i = -1; \n");
+ buffer.append("const char * const wordlist[207]; \n");
+ buffer.append("const char * const * foo(void) { \n");
+ buffer.append(" register const char * const *wordptr = &wordlist[207u + i]; \n");
+ buffer.append(" return wordptr; \n");
+ buffer.append("} \n");
+ buffer.append("int main() { \n");
+ buffer.append(" if (foo() != &wordlist[206]) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 11);
+ IVariable i = (IVariable) collector.getName(0).resolveBinding();
+ IVariable wordlist = (IVariable) collector.getName(1).resolveBinding();
+ IFunction foo = (IFunction) collector.getName(2).resolveBinding();
+ IVariable wordptr = (IVariable) collector.getName(4).resolveBinding();
+
+ assertInstances(collector, i, 2);
+ assertInstances(collector, wordlist, 3);
+ assertInstances(collector, foo, 2);
+ assertInstances(collector, wordptr, 2);
+ }
+
+ public void testGCC20000412_2() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int f(int a, int *y) { \n");
+ buffer.append(" int x = a; \n");
+ buffer.append(" if (a == 0) return *y; \n");
+ buffer.append(" return f(a-1, &x); \n");
+ buffer.append("} \n");
+ buffer.append("int main(int argc, char** argv) { \n");
+ buffer.append(" if (f(100, (int *) 0) != 1) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 14);
+ IFunction f = (IFunction) collector.getName(0).resolveBinding();
+ IParameter a = (IParameter) collector.getName(1).resolveBinding();
+ IParameter y = (IParameter) collector.getName(2).resolveBinding();
+ IVariable x = (IVariable) collector.getName(3).resolveBinding();
+
+ assertInstances(collector, f, 3);
+ assertInstances(collector, a, 4);
+ assertInstances(collector, y, 2);
+ assertInstances(collector, x, 2);
+ }
+
+ public void testGCC20000412_3() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("typedef struct { \n");
+ buffer.append(" char y; \n");
+ buffer.append(" char x[32]; \n");
+ buffer.append("} X; \n");
+ buffer.append("int z(void) { \n");
+ buffer.append(" X xxx; \n");
+ buffer.append(" xxx.x[0] = xxx.x[31] = '0'; \n");
+ buffer.append(" xxx.y = 0xf; \n");
+ buffer.append(" return f(xxx, xxx); \n");
+ buffer.append("} \n");
+ buffer.append("int main (void) { \n");
+ buffer.append(" int val; \n");
+ buffer.append(" val = z(); \n");
+ buffer.append(" if (val != 0x60) return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+ buffer.append("int f(X x, X y) { \n");
+ buffer.append(" if (x.y != y.y) \n");
+ buffer.append(" return 'F'; \n");
+ buffer.append(" return x.x[0] + y.x[0]; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 36);
+ IField y = (IField) collector.getName(1).resolveBinding();
+ IField x = (IField) collector.getName(2).resolveBinding();
+ ITypedef X = (ITypedef) collector.getName(3).resolveBinding();
+ IFunction z = (IFunction) collector.getName(4).resolveBinding();
+ IVariable xxx = (IVariable) collector.getName(7).resolveBinding();
+ IVariable val = (IVariable) collector.getName(19).resolveBinding();
+ IParameter px = (IParameter) collector.getName(25).resolveBinding();
+ IParameter py = (IParameter) collector.getName(27).resolveBinding();
+
+ assertInstances(collector, y, 4);
+ assertInstances(collector, x, 5);
+ assertInstances(collector, X, 4);
+ assertInstances(collector, z, 2);
+ assertInstances(collector, xxx, 6);
+ assertInstances(collector, val, 3);
+ assertInstances(collector, px, 3);
+ assertInstances(collector, py, 3);
+ }
+
+ public void testGCC20000412_4() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("void f(int i, int j, int radius, int width, int N) { \n");
+ buffer.append(" const int diff = i - radius; \n");
+ buffer.append(" const int lowk = (diff > 0 ? diff : 0); \n");
+ buffer.append(" int k; \n");
+ buffer.append(" for (k = lowk; k <= 2; k++) { \n");
+ buffer.append(" int idx = ((k-i+radius) * width - j + radius); \n");
+ buffer.append(" if (idx < 0) return -1; \n");
+ buffer.append(" } \n");
+ buffer.append(" for (k = lowk; k <= 2; k++) ; \n");
+ buffer.append("} \n");
+ buffer.append("int main (int argc, char** argv) { \n");
+ buffer.append(" int exc_rad = 2; \n");
+ buffer.append(" int N = 8; \n");
+ buffer.append(" int i; \n");
+ buffer.append(" for (i = 1; i < 4; i++) \n");
+ buffer.append(" f(i, 1, exc_rad, 2*exc_rad + 1, N); \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 43);
+ IFunction f = (IFunction) collector.getName(0).resolveBinding();
+ IParameter i1 = (IParameter) collector.getName(1).resolveBinding();
+ IParameter j = (IParameter) collector.getName(2).resolveBinding();
+ IParameter radius = (IParameter) collector.getName(3).resolveBinding();
+ IParameter width = (IParameter) collector.getName(4).resolveBinding();
+ IParameter N1 = (IParameter) collector.getName(5).resolveBinding();
+ IVariable diff = (IVariable) collector.getName(6).resolveBinding();
+ IVariable lowk = (IVariable) collector.getName(9).resolveBinding();
+ IVariable k = (IVariable) collector.getName(12).resolveBinding();
+ IVariable idx = (IVariable) collector.getName(17).resolveBinding();
+ IVariable exc_rad = (IVariable) collector.getName(32).resolveBinding();
+ IVariable N2 = (IVariable) collector.getName(33).resolveBinding();
+ IVariable i2 = (IVariable) collector.getName(34).resolveBinding();
+
+ assertInstances(collector, f, 2);
+ assertInstances(collector, i1, 3);
+ assertInstances(collector, j, 2);
+ assertInstances(collector, radius, 4);
+ assertInstances(collector, width, 2);
+ assertInstances(collector, N1, 1);
+ assertInstances(collector, diff, 3);
+ assertInstances(collector, lowk, 3);
+ assertInstances(collector, k, 8);
+ assertInstances(collector, idx, 2);
+ assertInstances(collector, exc_rad, 3);
+ assertInstances(collector, N2, 2);
+ assertInstances(collector, i2, 5);
+ }
+
+ public void testGCC20000412_5() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int main(void) { \n");
+ buffer.append(" struct { \n");
+ buffer.append(" int node; \n");
+ buffer.append(" int type; \n");
+ buffer.append(" } lastglob[1] = { { 0, 1 } }; \n");
+ buffer.append(" if (lastglob[0].node != 0 || lastglob[0].type != 1) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 11);
- IVariable f = (IVariable) collector.getName(0).resolveBinding();
- IVariable g = (IVariable) collector.getName(1).resolveBinding();
-
- assertInstances(collector, f, 5);
- assertInstances(collector, g, 5);
- }
-
- public void testGCC20000313() throws Exception{
- StringBuilder buffer = new StringBuilder();
- buffer.append("unsigned int buggy(unsigned int *param) { \n");
- buffer.append(" unsigned int accu, zero = 0, borrow; \n");
- buffer.append(" accu = - *param; \n");
- buffer.append(" borrow = - (accu > zero); \n");
- buffer.append(" return borrow; \n");
- buffer.append("} \n");
- buffer.append("int main(void) { \n");
- buffer.append(" unsigned int param = 1; \n");
- buffer.append(" unsigned int borrow = buggy (&param); \n");
- buffer.append(" if (param != 0) \n");
- buffer.append(" return -1; \n");
- buffer.append(" if (borrow +1 != 0) \n");
- buffer.append(" return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 19);
- IFunction buggy = (IFunction) collector.getName(0).resolveBinding();
- IParameter param = (IParameter) collector.getName(1).resolveBinding();
- IVariable accu = (IVariable) collector.getName(2).resolveBinding();
- IVariable zero = (IVariable) collector.getName(3).resolveBinding();
- IVariable borrow = (IVariable) collector.getName(4).resolveBinding();
- IVariable param2 = (IVariable) collector.getName(13).resolveBinding();
- IVariable borrow2 = (IVariable) collector.getName(14).resolveBinding();
-
- assertInstances(collector, buggy, 2);
- assertInstances(collector, param, 2);
- assertInstances(collector, accu, 3);
- assertInstances(collector, zero, 2);
- assertInstances(collector, borrow, 3);
- assertInstances(collector, param2, 3);
- assertInstances(collector, borrow2, 2);
- }
-
- public void testGCC20000314_1() throws Exception{
- StringBuilder buffer = new StringBuilder();
- buffer.append("int main() { \n");
- buffer.append(" long winds = 0; \n");
- buffer.append(" while (winds != 0) { \n");
- buffer.append(" if (*(char*)winds) \n");
- buffer.append(" break; \n");
- buffer.append(" } \n");
- buffer.append(" if (winds == 0 || winds != 0 || *(char*) winds) \n");
- buffer.append(" return 0; \n");
- buffer.append(" return -1; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 7);
- IVariable winds = (IVariable) collector.getName(1).resolveBinding();
-
- assertInstances(collector, winds, 6);
- }
-
- public void testGCC20000314_2() throws Exception{
- StringBuilder buffer = new StringBuilder();
- buffer.append("typedef unsigned long long uint64; \n");
- buffer.append("const uint64 bigconst = 1ULL << 34; \n");
- buffer.append("int a = 1; \n");
- buffer.append("static uint64 getmask(void) { \n");
- buffer.append(" if (a) return bigconst; \n");
- buffer.append(" else return 0; \n");
- buffer.append("} \n");
- buffer.append("main() { \n");
- buffer.append(" uint64 f = getmask(); \n");
- buffer.append(" if (sizeof (long long) == 8 && f != bigconst) \n");
- buffer.append(" return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 15);
- ITypedef uint64 = (ITypedef) collector.getName(0).resolveBinding();
- IVariable bigconst = (IVariable) collector.getName(2).resolveBinding();
- IVariable a = (IVariable) collector.getName(3).resolveBinding();
- IFunction getmask = (IFunction) collector.getName(5).resolveBinding();
- IVariable f = (IVariable) collector.getName(11).resolveBinding();
-
- assertInstances(collector, uint64, 4);
- assertInstances(collector, bigconst, 3);
- assertInstances(collector, a, 2);
- assertInstances(collector, getmask, 2);
- assertInstances(collector, f, 2);
- }
-
- public void testGCC20000403() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("extern unsigned long aa[], bb[]; \n");
- buffer.append("int seqgt(unsigned long a, unsigned short win, unsigned long b); \n");
- buffer.append("int seqgt2 (unsigned long a, unsigned short win, unsigned long b); \n");
- buffer.append("main() { \n");
- buffer.append(" if (!seqgt(*aa, 0x1000, *bb) || !seqgt2(*aa, 0x1000, *bb)) \n");
- buffer.append(" return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
- buffer.append("int seqgt(unsigned long a, unsigned short win, unsigned long b) { \n");
- buffer.append(" return (long) ((a + win) - b) > 0; \n");
- buffer.append("} \n");
- buffer.append("int seqgt2(unsigned long a, unsigned short win, unsigned long b) { \n");
- buffer.append(" long l = ((a + win) - b); \n");
- buffer.append(" return 1 > 0; \n");
- buffer.append("} \n");
- buffer.append("unsigned long aa[] = { (1UL << (sizeof(long) *8 - 1)) = 0xfff }; \n");
- buffer.append("unsigned long bb[] = { (1UL << (sizeof(long) *8 - 1)) = 0xfff }; \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 34);
- IVariable aa = (IVariable) collector.getName(0).resolveBinding();
- IVariable bb = (IVariable) collector.getName(1).resolveBinding();
- IFunction seqgt = (IFunction) collector.getName(2).resolveBinding();
- IParameter a1 = (IParameter) collector.getName(3).resolveBinding();
- IParameter win1 = (IParameter) collector.getName(4).resolveBinding();
- IParameter b1 = (IParameter) collector.getName(5).resolveBinding();
- IFunction seqgt2 = (IFunction) collector.getName(6).resolveBinding();
- IParameter a2 = (IParameter) collector.getName(7).resolveBinding();
- IParameter win2 = (IParameter) collector.getName(8).resolveBinding();
- IParameter b2 = (IParameter) collector.getName(9).resolveBinding();
-
- assertInstances(collector, aa, 4);
- assertInstances(collector, bb, 4);
- assertInstances(collector, seqgt, 3);
- assertInstances(collector, a1, 3);
- assertInstances(collector, win1, 3);
- assertInstances(collector, b1, 3);
- assertInstances(collector, seqgt2, 3);
- assertInstances(collector, a2, 3);
- assertInstances(collector, win2, 3);
- assertInstances(collector, b2, 3);
- }
-
- public void testGCC20000412_1 () throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("short int i = -1; \n");
- buffer.append("const char * const wordlist[207]; \n");
- buffer.append("const char * const * foo(void) { \n");
- buffer.append(" register const char * const *wordptr = &wordlist[207u + i]; \n");
- buffer.append(" return wordptr; \n");
- buffer.append("} \n");
- buffer.append("int main() { \n");
- buffer.append(" if (foo() != &wordlist[206]) \n");
- buffer.append(" return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 11);
- IVariable i = (IVariable) collector.getName(0).resolveBinding();
- IVariable wordlist = (IVariable) collector.getName(1).resolveBinding();
- IFunction foo = (IFunction) collector.getName(2).resolveBinding();
- IVariable wordptr = (IVariable) collector.getName(4).resolveBinding();
-
- assertInstances(collector, i, 2);
- assertInstances(collector, wordlist, 3);
- assertInstances(collector, foo, 2);
- assertInstances(collector, wordptr, 2);
- }
-
- public void testGCC20000412_2() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("int f(int a, int *y) { \n");
- buffer.append(" int x = a; \n");
- buffer.append(" if (a == 0) return *y; \n");
- buffer.append(" return f(a-1, &x); \n");
- buffer.append("} \n");
- buffer.append("int main(int argc, char** argv) { \n");
- buffer.append(" if (f(100, (int *) 0) != 1) \n");
- buffer.append(" return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 14);
- IFunction f = (IFunction) collector.getName(0).resolveBinding();
- IParameter a = (IParameter) collector.getName(1).resolveBinding();
- IParameter y = (IParameter) collector.getName(2).resolveBinding();
- IVariable x = (IVariable) collector.getName(3).resolveBinding();
-
- assertInstances(collector, f, 3);
- assertInstances(collector, a, 4);
- assertInstances(collector, y, 2);
- assertInstances(collector, x, 2);
- }
-
- public void testGCC20000412_3() throws Exception{
- StringBuilder buffer = new StringBuilder();
- buffer.append("typedef struct { \n");
- buffer.append(" char y; \n");
- buffer.append(" char x[32]; \n");
- buffer.append("} X; \n");
- buffer.append("int z(void) { \n");
- buffer.append(" X xxx; \n");
- buffer.append(" xxx.x[0] = xxx.x[31] = '0'; \n");
- buffer.append(" xxx.y = 0xf; \n");
- buffer.append(" return f(xxx, xxx); \n");
- buffer.append("} \n");
- buffer.append("int main (void) { \n");
- buffer.append(" int val; \n");
- buffer.append(" val = z(); \n");
- buffer.append(" if (val != 0x60) return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
- buffer.append("int f(X x, X y) { \n");
- buffer.append(" if (x.y != y.y) \n");
- buffer.append(" return 'F'; \n");
- buffer.append(" return x.x[0] + y.x[0]; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 36);
- IField y = (IField) collector.getName(1).resolveBinding();
- IField x = (IField) collector.getName(2).resolveBinding();
- ITypedef X = (ITypedef) collector.getName(3).resolveBinding();
- IFunction z = (IFunction) collector.getName(4).resolveBinding();
- IVariable xxx = (IVariable) collector.getName(7).resolveBinding();
- IVariable val = (IVariable) collector.getName(19).resolveBinding();
- IParameter px = (IParameter) collector.getName(25).resolveBinding();
- IParameter py = (IParameter) collector.getName(27).resolveBinding();
-
- assertInstances(collector, y, 4);
- assertInstances(collector, x, 5);
- assertInstances(collector, X, 4);
- assertInstances(collector, z, 2);
- assertInstances(collector, xxx, 6);
- assertInstances(collector, val, 3);
- assertInstances(collector, px, 3);
- assertInstances(collector, py, 3);
- }
-
- public void testGCC20000412_4() throws Exception{
- StringBuilder buffer = new StringBuilder();
- buffer.append("void f(int i, int j, int radius, int width, int N) { \n");
- buffer.append(" const int diff = i - radius; \n");
- buffer.append(" const int lowk = (diff > 0 ? diff : 0); \n");
- buffer.append(" int k; \n");
- buffer.append(" for (k = lowk; k <= 2; k++) { \n");
- buffer.append(" int idx = ((k-i+radius) * width - j + radius); \n");
- buffer.append(" if (idx < 0) return -1; \n");
- buffer.append(" } \n");
- buffer.append(" for (k = lowk; k <= 2; k++) ; \n");
- buffer.append("} \n");
- buffer.append("int main (int argc, char** argv) { \n");
- buffer.append(" int exc_rad = 2; \n");
- buffer.append(" int N = 8; \n");
- buffer.append(" int i; \n");
- buffer.append(" for (i = 1; i < 4; i++) \n");
- buffer.append(" f(i, 1, exc_rad, 2*exc_rad + 1, N); \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 43);
- IFunction f = (IFunction) collector.getName(0).resolveBinding();
- IParameter i1 = (IParameter) collector.getName(1).resolveBinding();
- IParameter j = (IParameter) collector.getName(2).resolveBinding();
- IParameter radius = (IParameter) collector.getName(3).resolveBinding();
- IParameter width = (IParameter) collector.getName(4).resolveBinding();
- IParameter N1 = (IParameter) collector.getName(5).resolveBinding();
- IVariable diff = (IVariable) collector.getName(6).resolveBinding();
- IVariable lowk = (IVariable) collector.getName(9).resolveBinding();
- IVariable k = (IVariable) collector.getName(12).resolveBinding();
- IVariable idx = (IVariable) collector.getName(17).resolveBinding();
- IVariable exc_rad = (IVariable) collector.getName(32).resolveBinding();
- IVariable N2 = (IVariable) collector.getName(33).resolveBinding();
- IVariable i2 = (IVariable) collector.getName(34).resolveBinding();
-
- assertInstances(collector, f, 2);
- assertInstances(collector, i1, 3);
- assertInstances(collector, j, 2);
- assertInstances(collector, radius, 4);
- assertInstances(collector, width, 2);
- assertInstances(collector, N1, 1);
- assertInstances(collector, diff, 3);
- assertInstances(collector, lowk, 3);
- assertInstances(collector, k, 8);
- assertInstances(collector, idx, 2);
- assertInstances(collector, exc_rad, 3);
- assertInstances(collector, N2, 2);
- assertInstances(collector, i2, 5);
- }
-
- public void testGCC20000412_5() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("int main(void) { \n");
- buffer.append(" struct { \n");
- buffer.append(" int node; \n");
- buffer.append(" int type; \n");
- buffer.append(" } lastglob[1] = { { 0, 1 } }; \n");
- buffer.append(" if (lastglob[0].node != 0 || lastglob[0].type != 1) \n");
- buffer.append(" return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 10);
- IField node = (IField) collector.getName(3).resolveBinding();
- IField type = (IField) collector.getName(4).resolveBinding();
- IVariable lastglob = (IVariable) collector.getName(5).resolveBinding();
-
- assertInstances(collector, node, 2);
- assertInstances(collector, type, 2);
- assertInstances(collector, lastglob, 3);
- }
-
- public void testGCC20000419() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("struct foo { int a, b, c; }; \n");
- buffer.append("void brother(int a, int b, int c) { \n");
- buffer.append(" if (a) return; \n");
- buffer.append("} \n");
- buffer.append("void sister(struct foo f, int b, int c) { \n");
- buffer.append(" brother((f.b == b), b, c); \n");
- buffer.append("} \n");
- buffer.append("int main() { \n");
- buffer.append(" struct foo f = { 7, 8, 9 }; \n");
- buffer.append(" sister(f, 1, 2); \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 25);
- ICompositeType foo = (ICompositeType) collector.getName(0).resolveBinding();
- IField fa = (IField) collector.getName(1).resolveBinding();
- IField fb = (IField) collector.getName(2).resolveBinding();
- IField fc = (IField) collector.getName(3).resolveBinding();
- IFunction brother = (IFunction) collector.getName(4).resolveBinding();
- IParameter pa = (IParameter) collector.getName(5).resolveBinding();
- IParameter pb = (IParameter) collector.getName(6).resolveBinding();
- IParameter pc = (IParameter) collector.getName(7).resolveBinding();
- IFunction sister = (IFunction) collector.getName(9).resolveBinding();
- IParameter sf = (IParameter) collector.getName(11).resolveBinding();
- IParameter sb = (IParameter) collector.getName(12).resolveBinding();
- IParameter sc = (IParameter) collector.getName(13).resolveBinding();
- IVariable f = (IVariable) collector.getName(22).resolveBinding();
-
- assertInstances(collector, foo, 3);
- assertInstances(collector, fa, 1);
- assertInstances(collector, fb, 2);
- assertInstances(collector, fc, 1);
- assertInstances(collector, brother, 2);
- assertInstances(collector, pa, 2);
- assertInstances(collector, pb, 1);
- assertInstances(collector, pc, 1);
- assertInstances(collector, sister, 2);
- assertInstances(collector, sf, 2);
- assertInstances(collector, sb, 3);
- assertInstances(collector, sc, 2);
- assertInstances(collector, f, 2);
- }
-
- public void testGCC20000503() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("unsigned long sub(int a) { \n");
- buffer.append(" return ((0 > a - 2) ? 0 : a - 2) * sizeof(long); \n");
- buffer.append("} \n");
- buffer.append("main() { \n");
- buffer.append(" return (sub(0) != 0); \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 6);
- IFunction sub = (IFunction) collector.getName(0).resolveBinding();
- IParameter a = (IParameter) collector.getName(1).resolveBinding();
-
- assertInstances(collector, sub, 2);
- assertInstances(collector, a, 3);
- }
-
- public void testGCC20000511() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("int f(int value, int expect) { \n");
- buffer.append(" return (value == expect); \n");
- buffer.append("} \n");
- buffer.append("main() { \n");
- buffer.append(" int a = 7, b = 6, c = 4, d = 7, e = 2; \n");
- buffer.append(" f(a || b % c, 1); \n");
- buffer.append(" f(a ? b % c : 0, 2); \n");
- buffer.append(" f(a = b % c, 2); \n");
- buffer.append(" f(a *= b % c, 4); \n");
- buffer.append(" f(a /= b % c, 2); \n");
- buffer.append(" f(a %= b % c, 0); \n");
- buffer.append(" f(a += b % c, 2); \n");
- buffer.append(" f(d || c && e, 1); \n");
- buffer.append(" f(d ? c && e : 0, 1); \n");
- buffer.append(" f(d = c && e, 1); \n");
- buffer.append(" f(d *= c && e, 1); \n");
- buffer.append(" f(d %= c && e, 0); \n");
- buffer.append(" f(d += c && e, 1); \n");
- buffer.append(" f(d -= c && e, 0); \n");
- buffer.append(" f(d || c || e, 1); \n");
- buffer.append(" f(d ? c || e : 0, 0); \n");
- buffer.append(" f(d = c || e, 1); \n");
- buffer.append(" f(d *= c || e, 1); \n");
- buffer.append(" f(d %= c || e, 0); \n");
- buffer.append(" f(d += c || e, 1); \n");
- buffer.append(" f(d -= c || e, 0); \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 95);
- IFunction f = (IFunction) collector.getName(0).resolveBinding();
- IParameter v = (IParameter) collector.getName(1).resolveBinding();
- IParameter ex = (IParameter) collector.getName(2).resolveBinding();
- IVariable a = (IVariable) collector.getName(6).resolveBinding();
- IVariable b = (IVariable) collector.getName(7).resolveBinding();
- IVariable c = (IVariable) collector.getName(8).resolveBinding();
- IVariable d = (IVariable) collector.getName(9).resolveBinding();
- IVariable e = (IVariable) collector.getName(10).resolveBinding();
-
-
- assertInstances(collector, f, 22);
- assertInstances(collector, v, 2);
- assertInstances(collector, ex, 2);
- assertInstances(collector, a, 8);
- assertInstances(collector, b, 8);
- assertInstances(collector, c, 22);
- assertInstances(collector, d, 15);
- assertInstances(collector, e, 15);
- }
-
- public void testGCC20000603() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("struct s1 { double d; }; \n");
- buffer.append("struct s2 { double d; }; \n");
- buffer.append("double f(struct s1 * a, struct s2 *b) { \n");
- buffer.append(" a->d = 1.0; \n");
- buffer.append(" return b->d + 1.0; \n");
- buffer.append("} \n");
- buffer.append("int main() { \n");
- buffer.append(" struct s1 a; \n");
- buffer.append(" a.d = 0.0; \n");
- buffer.append(" if (f(&a, (struct s2 *)&a) != 2.0) \n");
- buffer.append(" return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 22);
- ICompositeType s1 = (ICompositeType) collector.getName(0).resolveBinding();
- IField d1 = (IField) collector.getName(1).resolveBinding();
- ICompositeType s2 = (ICompositeType) collector.getName(2).resolveBinding();
- IField d2 = (IField) collector.getName(3).resolveBinding();
- IFunction f = (IFunction) collector.getName(4).resolveBinding();
- IParameter pa = (IParameter) collector.getName(6).resolveBinding();
- IParameter pb = (IParameter) collector.getName(8).resolveBinding();
- IVariable a = (IVariable) collector.getName(15).resolveBinding();
-
- assertInstances(collector, s1, 3);
- assertInstances(collector, s2, 3);
- assertInstances(collector, d1, 3);
- assertInstances(collector, d2, 2);
- assertInstances(collector, f, 2);
- assertInstances(collector, pa, 2);
- assertInstances(collector, pb, 2);
- assertInstances(collector, a, 4);
- }
-
- public void testGCC20000605_2() throws Exception{
- StringBuilder buffer = new StringBuilder();
- buffer.append("struct F { int i; }; \n");
- buffer.append("void f1(struct F *x, struct F * y) { \n");
- buffer.append(" int timeout = 0; \n");
- buffer.append(" for (; ((const struct F*)x)->i < y->i; x->i++) \n");
- buffer.append(" if (++timeout > 5) \n");
- buffer.append(" return; \n");
- buffer.append("} \n");
- buffer.append("main() { \n");
- buffer.append(" struct F x, y; \n");
- buffer.append(" x.i = 0; y.i = 1; \n");
- buffer.append(" f1(&x, &y); \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 27);
- ICompositeType F = (ICompositeType) collector.getName(0).resolveBinding();
- IField i = (IField) collector.getName(1).resolveBinding();
- IFunction f1 = (IFunction) collector.getName(2).resolveBinding();
- IParameter px = (IParameter) collector.getName(4).resolveBinding();
- IParameter py = (IParameter) collector.getName(6).resolveBinding();
- IVariable timeout = (IVariable) collector.getName(7).resolveBinding();
- IVariable x = (IVariable) collector.getName(18).resolveBinding();
- IVariable y = (IVariable) collector.getName(19).resolveBinding();
-
- assertInstances(collector, F, 5);
- assertInstances(collector, i, 6);
- assertInstances(collector, f1, 2);
- assertInstances(collector, px, 3);
- assertInstances(collector, py, 2);
- assertInstances(collector, timeout, 2);
- assertInstances(collector, x, 3);
- assertInstances(collector, y, 3);
- }
-
- public void testGCC20000605_3() throws Exception{
- StringBuilder buffer = new StringBuilder();
- buffer.append("struct F { int x; int y; }; \n");
- buffer.append("int main() { \n");
- buffer.append(" int timeout = 0, x = 0; \n");
- buffer.append(" while (1) { \n");
- buffer.append(" const struct F i = { x++, }; \n");
- buffer.append(" if (i.x > 0) \n");
- buffer.append(" break; \n");
- buffer.append(" if (++timeout > 5) \n");
- buffer.append(" goto die; \n");
- buffer.append(" } \n");
- buffer.append(" die: return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 14);
- ICompositeType F = (ICompositeType) collector.getName(0).resolveBinding();
- IField fx = (IField) collector.getName(1).resolveBinding();
- IField fy = (IField) collector.getName(2).resolveBinding();
- IVariable timeout = (IVariable) collector.getName(4).resolveBinding();
- IVariable x = (IVariable) collector.getName(5).resolveBinding();
- IVariable i = (IVariable) collector.getName(7).resolveBinding();
- ILabel die = (ILabel) collector.getName(13).resolveBinding();
-
- assertInstances(collector, F, 2);
- assertInstances(collector, fx, 2);
- assertInstances(collector, fy, 1);
- assertInstances(collector, timeout, 2);
- assertInstances(collector, x, 2);
- assertInstances(collector, i, 2);
- assertInstances(collector, die, 2);
- }
-
- public void testGCCenum_2() throws Exception {
- StringBuilder buffer = new StringBuilder();
- buffer.append("enum foo { FOO, BAR }; \n");
- buffer.append("int main() { \n");
- buffer.append(" int i; \n");
- buffer.append(" for (i = BAR; i >= FOO; --i) \n");
- buffer.append(" if (i == -1) return -1; \n");
- buffer.append(" return 0; \n");
- buffer.append("} \n");
-
- IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
- NameCollector collector = new NameCollector();
- tu.accept(collector);
-
- assertEquals(collector.size(), 11);
- IEnumeration foo = (IEnumeration) collector.getName(0).resolveBinding();
- IEnumerator FOO = (IEnumerator) collector.getName(1).resolveBinding();
- IEnumerator BAR = (IEnumerator) collector.getName(2).resolveBinding();
- IVariable i = (IVariable) collector.getName(4).resolveBinding();
-
- assertInstances(collector, foo, 1);
- assertInstances(collector, FOO, 2);
- assertInstances(collector, BAR, 2);
- assertInstances(collector, i, 5);
- }
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 10);
+ IField node = (IField) collector.getName(3).resolveBinding();
+ IField type = (IField) collector.getName(4).resolveBinding();
+ IVariable lastglob = (IVariable) collector.getName(5).resolveBinding();
+
+ assertInstances(collector, node, 2);
+ assertInstances(collector, type, 2);
+ assertInstances(collector, lastglob, 3);
+ }
+
+ public void testGCC20000419() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("struct foo { int a, b, c; }; \n");
+ buffer.append("void brother(int a, int b, int c) { \n");
+ buffer.append(" if (a) return; \n");
+ buffer.append("} \n");
+ buffer.append("void sister(struct foo f, int b, int c) { \n");
+ buffer.append(" brother((f.b == b), b, c); \n");
+ buffer.append("} \n");
+ buffer.append("int main() { \n");
+ buffer.append(" struct foo f = { 7, 8, 9 }; \n");
+ buffer.append(" sister(f, 1, 2); \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 25);
+ ICompositeType foo = (ICompositeType) collector.getName(0).resolveBinding();
+ IField fa = (IField) collector.getName(1).resolveBinding();
+ IField fb = (IField) collector.getName(2).resolveBinding();
+ IField fc = (IField) collector.getName(3).resolveBinding();
+ IFunction brother = (IFunction) collector.getName(4).resolveBinding();
+ IParameter pa = (IParameter) collector.getName(5).resolveBinding();
+ IParameter pb = (IParameter) collector.getName(6).resolveBinding();
+ IParameter pc = (IParameter) collector.getName(7).resolveBinding();
+ IFunction sister = (IFunction) collector.getName(9).resolveBinding();
+ IParameter sf = (IParameter) collector.getName(11).resolveBinding();
+ IParameter sb = (IParameter) collector.getName(12).resolveBinding();
+ IParameter sc = (IParameter) collector.getName(13).resolveBinding();
+ IVariable f = (IVariable) collector.getName(22).resolveBinding();
+
+ assertInstances(collector, foo, 3);
+ assertInstances(collector, fa, 1);
+ assertInstances(collector, fb, 2);
+ assertInstances(collector, fc, 1);
+ assertInstances(collector, brother, 2);
+ assertInstances(collector, pa, 2);
+ assertInstances(collector, pb, 1);
+ assertInstances(collector, pc, 1);
+ assertInstances(collector, sister, 2);
+ assertInstances(collector, sf, 2);
+ assertInstances(collector, sb, 3);
+ assertInstances(collector, sc, 2);
+ assertInstances(collector, f, 2);
+ }
+
+ public void testGCC20000503() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("unsigned long sub(int a) { \n");
+ buffer.append(" return ((0 > a - 2) ? 0 : a - 2) * sizeof(long); \n");
+ buffer.append("} \n");
+ buffer.append("main() { \n");
+ buffer.append(" return (sub(0) != 0); \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 6);
+ IFunction sub = (IFunction) collector.getName(0).resolveBinding();
+ IParameter a = (IParameter) collector.getName(1).resolveBinding();
+
+ assertInstances(collector, sub, 2);
+ assertInstances(collector, a, 3);
+ }
+
+ public void testGCC20000511() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("int f(int value, int expect) { \n");
+ buffer.append(" return (value == expect); \n");
+ buffer.append("} \n");
+ buffer.append("main() { \n");
+ buffer.append(" int a = 7, b = 6, c = 4, d = 7, e = 2; \n");
+ buffer.append(" f(a || b % c, 1); \n");
+ buffer.append(" f(a ? b % c : 0, 2); \n");
+ buffer.append(" f(a = b % c, 2); \n");
+ buffer.append(" f(a *= b % c, 4); \n");
+ buffer.append(" f(a /= b % c, 2); \n");
+ buffer.append(" f(a %= b % c, 0); \n");
+ buffer.append(" f(a += b % c, 2); \n");
+ buffer.append(" f(d || c && e, 1); \n");
+ buffer.append(" f(d ? c && e : 0, 1); \n");
+ buffer.append(" f(d = c && e, 1); \n");
+ buffer.append(" f(d *= c && e, 1); \n");
+ buffer.append(" f(d %= c && e, 0); \n");
+ buffer.append(" f(d += c && e, 1); \n");
+ buffer.append(" f(d -= c && e, 0); \n");
+ buffer.append(" f(d || c || e, 1); \n");
+ buffer.append(" f(d ? c || e : 0, 0); \n");
+ buffer.append(" f(d = c || e, 1); \n");
+ buffer.append(" f(d *= c || e, 1); \n");
+ buffer.append(" f(d %= c || e, 0); \n");
+ buffer.append(" f(d += c || e, 1); \n");
+ buffer.append(" f(d -= c || e, 0); \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 95);
+ IFunction f = (IFunction) collector.getName(0).resolveBinding();
+ IParameter v = (IParameter) collector.getName(1).resolveBinding();
+ IParameter ex = (IParameter) collector.getName(2).resolveBinding();
+ IVariable a = (IVariable) collector.getName(6).resolveBinding();
+ IVariable b = (IVariable) collector.getName(7).resolveBinding();
+ IVariable c = (IVariable) collector.getName(8).resolveBinding();
+ IVariable d = (IVariable) collector.getName(9).resolveBinding();
+ IVariable e = (IVariable) collector.getName(10).resolveBinding();
+
+ assertInstances(collector, f, 22);
+ assertInstances(collector, v, 2);
+ assertInstances(collector, ex, 2);
+ assertInstances(collector, a, 8);
+ assertInstances(collector, b, 8);
+ assertInstances(collector, c, 22);
+ assertInstances(collector, d, 15);
+ assertInstances(collector, e, 15);
+ }
+
+ public void testGCC20000603() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("struct s1 { double d; }; \n");
+ buffer.append("struct s2 { double d; }; \n");
+ buffer.append("double f(struct s1 * a, struct s2 *b) { \n");
+ buffer.append(" a->d = 1.0; \n");
+ buffer.append(" return b->d + 1.0; \n");
+ buffer.append("} \n");
+ buffer.append("int main() { \n");
+ buffer.append(" struct s1 a; \n");
+ buffer.append(" a.d = 0.0; \n");
+ buffer.append(" if (f(&a, (struct s2 *)&a) != 2.0) \n");
+ buffer.append(" return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 22);
+ ICompositeType s1 = (ICompositeType) collector.getName(0).resolveBinding();
+ IField d1 = (IField) collector.getName(1).resolveBinding();
+ ICompositeType s2 = (ICompositeType) collector.getName(2).resolveBinding();
+ IField d2 = (IField) collector.getName(3).resolveBinding();
+ IFunction f = (IFunction) collector.getName(4).resolveBinding();
+ IParameter pa = (IParameter) collector.getName(6).resolveBinding();
+ IParameter pb = (IParameter) collector.getName(8).resolveBinding();
+ IVariable a = (IVariable) collector.getName(15).resolveBinding();
+
+ assertInstances(collector, s1, 3);
+ assertInstances(collector, s2, 3);
+ assertInstances(collector, d1, 3);
+ assertInstances(collector, d2, 2);
+ assertInstances(collector, f, 2);
+ assertInstances(collector, pa, 2);
+ assertInstances(collector, pb, 2);
+ assertInstances(collector, a, 4);
+ }
+
+ public void testGCC20000605_2() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("struct F { int i; }; \n");
+ buffer.append("void f1(struct F *x, struct F * y) { \n");
+ buffer.append(" int timeout = 0; \n");
+ buffer.append(" for (; ((const struct F*)x)->i < y->i; x->i++) \n");
+ buffer.append(" if (++timeout > 5) \n");
+ buffer.append(" return; \n");
+ buffer.append("} \n");
+ buffer.append("main() { \n");
+ buffer.append(" struct F x, y; \n");
+ buffer.append(" x.i = 0; y.i = 1; \n");
+ buffer.append(" f1(&x, &y); \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 27);
+ ICompositeType F = (ICompositeType) collector.getName(0).resolveBinding();
+ IField i = (IField) collector.getName(1).resolveBinding();
+ IFunction f1 = (IFunction) collector.getName(2).resolveBinding();
+ IParameter px = (IParameter) collector.getName(4).resolveBinding();
+ IParameter py = (IParameter) collector.getName(6).resolveBinding();
+ IVariable timeout = (IVariable) collector.getName(7).resolveBinding();
+ IVariable x = (IVariable) collector.getName(18).resolveBinding();
+ IVariable y = (IVariable) collector.getName(19).resolveBinding();
+
+ assertInstances(collector, F, 5);
+ assertInstances(collector, i, 6);
+ assertInstances(collector, f1, 2);
+ assertInstances(collector, px, 3);
+ assertInstances(collector, py, 2);
+ assertInstances(collector, timeout, 2);
+ assertInstances(collector, x, 3);
+ assertInstances(collector, y, 3);
+ }
+
+ public void testGCC20000605_3() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("struct F { int x; int y; }; \n");
+ buffer.append("int main() { \n");
+ buffer.append(" int timeout = 0, x = 0; \n");
+ buffer.append(" while (1) { \n");
+ buffer.append(" const struct F i = { x++, }; \n");
+ buffer.append(" if (i.x > 0) \n");
+ buffer.append(" break; \n");
+ buffer.append(" if (++timeout > 5) \n");
+ buffer.append(" goto die; \n");
+ buffer.append(" } \n");
+ buffer.append(" die: return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 14);
+ ICompositeType F = (ICompositeType) collector.getName(0).resolveBinding();
+ IField fx = (IField) collector.getName(1).resolveBinding();
+ IField fy = (IField) collector.getName(2).resolveBinding();
+ IVariable timeout = (IVariable) collector.getName(4).resolveBinding();
+ IVariable x = (IVariable) collector.getName(5).resolveBinding();
+ IVariable i = (IVariable) collector.getName(7).resolveBinding();
+ ILabel die = (ILabel) collector.getName(13).resolveBinding();
+
+ assertInstances(collector, F, 2);
+ assertInstances(collector, fx, 2);
+ assertInstances(collector, fy, 1);
+ assertInstances(collector, timeout, 2);
+ assertInstances(collector, x, 2);
+ assertInstances(collector, i, 2);
+ assertInstances(collector, die, 2);
+ }
+
+ public void testGCCenum_2() throws Exception {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("enum foo { FOO, BAR }; \n");
+ buffer.append("int main() { \n");
+ buffer.append(" int i; \n");
+ buffer.append(" for (i = BAR; i >= FOO; --i) \n");
+ buffer.append(" if (i == -1) return -1; \n");
+ buffer.append(" return 0; \n");
+ buffer.append("} \n");
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
+ NameCollector collector = new NameCollector();
+ tu.accept(collector);
+
+ assertEquals(collector.size(), 11);
+ IEnumeration foo = (IEnumeration) collector.getName(0).resolveBinding();
+ IEnumerator FOO = (IEnumerator) collector.getName(1).resolveBinding();
+ IEnumerator BAR = (IEnumerator) collector.getName(2).resolveBinding();
+ IVariable i = (IVariable) collector.getName(4).resolveBinding();
+
+ assertInstances(collector, foo, 1);
+ assertInstances(collector, FOO, 2);
+ assertInstances(collector, BAR, 2);
+ assertInstances(collector, i, 5);
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ImageLocationTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ImageLocationTests.java
index 31785370c4f..01863280ad2 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ImageLocationTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ImageLocationTests.java
@@ -28,15 +28,15 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
*/
public class ImageLocationTests extends AST2TestBase {
- private static final int CODE = IASTImageLocation.REGULAR_CODE;
- private static final int MACRO = IASTImageLocation.MACRO_DEFINITION;
- private static final int MACRO_ARG = IASTImageLocation.ARGUMENT_TO_MACRO_EXPANSION;
+ private static final int CODE = IASTImageLocation.REGULAR_CODE;
+ private static final int MACRO = IASTImageLocation.MACRO_DEFINITION;
+ private static final int MACRO_ARG = IASTImageLocation.ARGUMENT_TO_MACRO_EXPANSION;
public static Test suite() {
- return suite(ImageLocationTests.class);
- }
+ return suite(ImageLocationTests.class);
+ }
- public ImageLocationTests() {
+ public ImageLocationTests() {
}
public ImageLocationTests(String name) {
@@ -45,13 +45,13 @@ public class ImageLocationTests extends AST2TestBase {
// int a;
public void testFileLocation() throws Exception {
- String code= getContents(1)[0].toString();
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
-
- IASTDeclaration declaration = tu.getDeclarations()[0];
- IASTName name= getName(declaration);
- IASTImageLocation loc= name.getImageLocation();
- assertLocation(CODE, code, "a", 0, loc);
+ String code = getContents(1)[0].toString();
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+
+ IASTDeclaration declaration = tu.getDeclarations()[0];
+ IASTName name = getName(declaration);
+ IASTImageLocation loc = name.getImageLocation();
+ assertLocation(CODE, code, "a", 0, loc);
}
// #define M result1
@@ -59,69 +59,69 @@ public class ImageLocationTests extends AST2TestBase {
// int M;
// int F();
public void testMacroLocation() throws Exception {
- String code= getContents(1)[0].toString();
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
-
- IASTDeclaration declaration = tu.getDeclarations()[0];
- IASTName name= getName(declaration);
- IASTImageLocation loc= name.getImageLocation();
- assertLocation(MACRO, code, "result1", 0, loc);
-
- declaration = tu.getDeclarations()[1];
- name= getName(declaration);
- loc= name.getImageLocation();
- assertLocation(MACRO, code, "result2", 0, loc);
+ String code = getContents(1)[0].toString();
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+
+ IASTDeclaration declaration = tu.getDeclarations()[0];
+ IASTName name = getName(declaration);
+ IASTImageLocation loc = name.getImageLocation();
+ assertLocation(MACRO, code, "result1", 0, loc);
+
+ declaration = tu.getDeclarations()[1];
+ name = getName(declaration);
+ loc = name.getImageLocation();
+ assertLocation(MACRO, code, "result2", 0, loc);
}
// #define M result
// #define F() M
// int F();
public void testIndirectMacroLocation() throws Exception {
- String code= getContents(1)[0].toString();
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
-
- IASTDeclaration declaration = tu.getDeclarations()[0];
- IASTName name= getName(declaration);
- IASTImageLocation loc= name.getImageLocation();
- assertLocation(MACRO, code, "result", 0, loc);
+ String code = getContents(1)[0].toString();
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+
+ IASTDeclaration declaration = tu.getDeclarations()[0];
+ IASTName name = getName(declaration);
+ IASTImageLocation loc = name.getImageLocation();
+ assertLocation(MACRO, code, "result", 0, loc);
}
-
// #define M result1
// #define F(x) x
// int F(result2);
// int F(M);
public void testMacroArgumentLocation() throws Exception {
- String code= getContents(1)[0].toString();
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
-
- IASTDeclaration declaration = tu.getDeclarations()[0];
- IASTName name= getName(declaration);
- IASTImageLocation loc= name.getImageLocation();
- assertLocation(MACRO_ARG, code, "result2", 0, loc);
-
- declaration = tu.getDeclarations()[1];
- name= getName(declaration);
- loc= name.getImageLocation();
- assertLocation(MACRO, code, "result1", 0, loc);
+ String code = getContents(1)[0].toString();
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+
+ IASTDeclaration declaration = tu.getDeclarations()[0];
+ IASTName name = getName(declaration);
+ IASTImageLocation loc = name.getImageLocation();
+ assertLocation(MACRO_ARG, code, "result2", 0, loc);
+
+ declaration = tu.getDeclarations()[1];
+ name = getName(declaration);
+ loc = name.getImageLocation();
+ assertLocation(MACRO, code, "result1", 0, loc);
}
private void assertLocation(int kind, String code, String name, int extra, IASTImageLocation loc) {
assertNotNull(loc);
assertEquals(kind, loc.getLocationKind());
assertEquals(code.indexOf(name), loc.getNodeOffset());
- assertEquals(name.length()-extra, loc.getNodeLength());
+ assertEquals(name.length() - extra, loc.getNodeLength());
}
private IASTName getName(IASTNode node) {
- final IASTName[] result= {null};
+ final IASTName[] result = { null };
node.accept(new ASTVisitor() {
{
- shouldVisitNames= true;
+ shouldVisitNames = true;
}
+
@Override
public int visit(IASTName name) {
- result[0]= name;
+ result[0] = name;
return PROCESS_ABORT;
}
});
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/LanguageExtensionsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/LanguageExtensionsTest.java
index 52dbc5e8689..174a818dab1 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/LanguageExtensionsTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/LanguageExtensionsTest.java
@@ -48,25 +48,25 @@ import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
* Testcases for non-gnu language extensions.
*/
public class LanguageExtensionsTest extends AST2TestBase {
-
- protected static final int SIZEOF_EXTENSION = 0x1;
+
+ protected static final int SIZEOF_EXTENSION = 0x1;
protected static final int FUNCTION_STYLE_ASM = 0x2;
protected static final int SLASH_PERCENT_COMMENT = 0x4;
public static TestSuite suite() {
return suite(LanguageExtensionsTest.class);
}
-
+
public LanguageExtensionsTest() {
super();
}
-
+
public LanguageExtensionsTest(String name) {
super(name);
}
-
+
private IASTTranslationUnit parse(ISourceCodeParser parser) {
- IASTTranslationUnit tu= parser.parse();
+ IASTTranslationUnit tu = parser.parse();
assertFalse(parser.encounteredError());
assertEquals(0, tu.getPreprocessorProblemsCount());
assertEquals(0, CPPVisitor.getProblems(tu).length);
@@ -76,8 +76,8 @@ public class LanguageExtensionsTest extends AST2TestBase {
protected IASTTranslationUnit parse(String code, IScannerExtensionConfiguration sext,
ICPPParserExtensionConfiguration pext) throws Exception {
FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
- IScanner scanner = new CPreprocessor(codeReader, new ScannerInfo(), ParserLanguage.CPP, NULL_LOG,
- sext, IncludeFileContentProvider.getSavedFilesProvider());
+ IScanner scanner = new CPreprocessor(codeReader, new ScannerInfo(), ParserLanguage.CPP, NULL_LOG, sext,
+ IncludeFileContentProvider.getSavedFilesProvider());
GNUCPPSourceParser parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, pext);
return parse(parser);
}
@@ -90,157 +90,143 @@ public class LanguageExtensionsTest extends AST2TestBase {
GNUCSourceParser parser = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, pext);
return parse(parser);
}
-
+
protected IASTTranslationUnit parseCPPWithExtension(String code, final int extensions) throws Exception {
- return parse(code,
- new GPPScannerExtensionConfiguration() {
- @Override
- public boolean supportSlashPercentComments() {
- return (extensions & SLASH_PERCENT_COMMENT) != 0;
- }
- },
- new GPPParserExtensionConfiguration() {
- @Override
- public boolean supportExtendedSizeofOperator() {
- return (extensions & SIZEOF_EXTENSION) != 0;
- }
- @Override
- public boolean supportFunctionStyleAssembler() {
- return (extensions & FUNCTION_STYLE_ASM) != 0;
- }
+ return parse(code, new GPPScannerExtensionConfiguration() {
+ @Override
+ public boolean supportSlashPercentComments() {
+ return (extensions & SLASH_PERCENT_COMMENT) != 0;
+ }
+ }, new GPPParserExtensionConfiguration() {
+ @Override
+ public boolean supportExtendedSizeofOperator() {
+ return (extensions & SIZEOF_EXTENSION) != 0;
}
- );
+
+ @Override
+ public boolean supportFunctionStyleAssembler() {
+ return (extensions & FUNCTION_STYLE_ASM) != 0;
+ }
+ });
}
protected IASTTranslationUnit parseCWithExtension(String code, final int extensions) throws Exception {
- return parse(code,
- new GCCScannerExtensionConfiguration() {
- @Override
- public boolean supportSlashPercentComments() {
- return (extensions & SLASH_PERCENT_COMMENT) != 0;
- }
- },
- new GCCParserExtensionConfiguration() {
- @Override
- public boolean supportExtendedSizeofOperator() {
- return (extensions & SIZEOF_EXTENSION) != 0;
- }
- @Override
- public boolean supportFunctionStyleAssembler() {
- return (extensions & FUNCTION_STYLE_ASM) != 0;
- }
+ return parse(code, new GCCScannerExtensionConfiguration() {
+ @Override
+ public boolean supportSlashPercentComments() {
+ return (extensions & SLASH_PERCENT_COMMENT) != 0;
+ }
+ }, new GCCParserExtensionConfiguration() {
+ @Override
+ public boolean supportExtendedSizeofOperator() {
+ return (extensions & SIZEOF_EXTENSION) != 0;
}
- );
+
+ @Override
+ public boolean supportFunctionStyleAssembler() {
+ return (extensions & FUNCTION_STYLE_ASM) != 0;
+ }
+ });
}
// parclass ExampleClass {
- // };
- public void testPOP_parclass() throws Exception {
- IASTTranslationUnit tu= parse(getAboveComment(),
- POPCPPScannerExtensionConfiguration.getInstance(),
- POPCPPParserExtensionConfiguration.getInstance()
- );
- ICPPASTCompositeTypeSpecifier comp= getCompositeType(tu, 0);
- }
-
+ // };
+ public void testPOP_parclass() throws Exception {
+ IASTTranslationUnit tu = parse(getAboveComment(), POPCPPScannerExtensionConfiguration.getInstance(),
+ POPCPPParserExtensionConfiguration.getInstance());
+ ICPPASTCompositeTypeSpecifier comp = getCompositeType(tu, 0);
+ }
+
// parclass Table {
- // void sort([in, out, size=n] int *data, int n);
- // };
- public void testPOP_marshallingData() throws Exception {
- IASTTranslationUnit tu= parse(getAboveComment(),
- POPCPPScannerExtensionConfiguration.getInstance(),
- POPCPPParserExtensionConfiguration.getInstance()
- );
- ICPPASTCompositeTypeSpecifier comp= getCompositeType(tu, 0);
- IASTSimpleDeclaration sd= getDeclaration(comp, 0);
- assertInstance(sd.getDeclarators()[0], IASTFunctionDeclarator.class);
- }
-
- // parclass Bird {
- // public:
- // Bird(float P) @{ od.power(P);
- // od.memory(100,60);
- // od.protocol("socket http"); };
- // };
- public void testPOP_objectDescriptor() throws Exception {
- IASTTranslationUnit tu= parse(getAboveComment(),
- POPCPPScannerExtensionConfiguration.getInstance(),
- POPCPPParserExtensionConfiguration.getInstance()
- );
- ICPPASTCompositeTypeSpecifier comp= getCompositeType(tu, 0);
- IASTSimpleDeclaration sd= getDeclaration(comp, 1);
- assertInstance(sd.getDeclarators()[0], IASTFunctionDeclarator.class);
- }
-
- // @pack(Stack, Queue, List)
- // int a();
- public void testPOP_packDirective() throws Exception {
- IASTTranslationUnit tu= parse(getAboveComment(),
- POPCPPScannerExtensionConfiguration.getInstance(),
- POPCPPParserExtensionConfiguration.getInstance()
- );
- IASTSimpleDeclaration sd= getDeclaration(tu, 0);
- assertInstance(sd.getDeclarators()[0], IASTFunctionDeclarator.class);
- }
-
-
-
- // void test() {
- // sizeof(int, 1);
- // sizeof(int, 2, 2);
- // }
- public void testSizeofExtension() throws Exception {
- IASTTranslationUnit tu= parseCWithExtension(getAboveComment(), SIZEOF_EXTENSION);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- IASTUnaryExpression expr= getExpressionOfStatement(fdef, 0);
- assertEquals(IASTUnaryExpression.op_sizeof, expr.getOperator());
- assertInstance(expr.getOperand(), IASTExpressionList.class);
- expr= getExpressionOfStatement(fdef, 1);
- assertEquals(IASTUnaryExpression.op_sizeof, expr.getOperator());
- assertInstance(expr.getOperand(), IASTExpressionList.class);
-
- tu= parseCPPWithExtension(getAboveComment(), SIZEOF_EXTENSION);
- fdef= getDeclaration(tu, 0);
- expr= getExpressionOfStatement(fdef, 0);
- assertEquals(IASTUnaryExpression.op_sizeof, expr.getOperator());
- assertInstance(expr.getOperand(), IASTExpressionList.class);
- expr= getExpressionOfStatement(fdef, 1);
- assertEquals(IASTUnaryExpression.op_sizeof, expr.getOperator());
- assertInstance(expr.getOperand(), IASTExpressionList.class);
- }
-
- // asm volatile int a1() {
- // assembler code here
- // }
- // asm int a2() {
- // assembler code here
- // }
- // asm volatile a3(int) {
- // assembler code here
- // }
- // asm a4() {
- // assembler code here
- // }
- public void testFunctionStyleAssembler() throws Exception {
- IASTTranslationUnit tu= parseCWithExtension(getAboveComment(), FUNCTION_STYLE_ASM);
- IASTFunctionDefinition fdef= getDeclaration(tu, 0);
- fdef= getDeclaration(tu, 1);
- fdef= getDeclaration(tu, 2);
- fdef= getDeclaration(tu, 3);
-
- tu= parseCPPWithExtension(getAboveComment(), FUNCTION_STYLE_ASM);
- fdef= getDeclaration(tu, 0);
- fdef= getDeclaration(tu, 1);
- fdef= getDeclaration(tu, 2);
- fdef= getDeclaration(tu, 3);
- }
-
+ // void sort([in, out, size=n] int *data, int n);
+ // };
+ public void testPOP_marshallingData() throws Exception {
+ IASTTranslationUnit tu = parse(getAboveComment(), POPCPPScannerExtensionConfiguration.getInstance(),
+ POPCPPParserExtensionConfiguration.getInstance());
+ ICPPASTCompositeTypeSpecifier comp = getCompositeType(tu, 0);
+ IASTSimpleDeclaration sd = getDeclaration(comp, 0);
+ assertInstance(sd.getDeclarators()[0], IASTFunctionDeclarator.class);
+ }
+
+ // parclass Bird {
+ // public:
+ // Bird(float P) @{ od.power(P);
+ // od.memory(100,60);
+ // od.protocol("socket http"); };
+ // };
+ public void testPOP_objectDescriptor() throws Exception {
+ IASTTranslationUnit tu = parse(getAboveComment(), POPCPPScannerExtensionConfiguration.getInstance(),
+ POPCPPParserExtensionConfiguration.getInstance());
+ ICPPASTCompositeTypeSpecifier comp = getCompositeType(tu, 0);
+ IASTSimpleDeclaration sd = getDeclaration(comp, 1);
+ assertInstance(sd.getDeclarators()[0], IASTFunctionDeclarator.class);
+ }
+
+ // @pack(Stack, Queue, List)
+ // int a();
+ public void testPOP_packDirective() throws Exception {
+ IASTTranslationUnit tu = parse(getAboveComment(), POPCPPScannerExtensionConfiguration.getInstance(),
+ POPCPPParserExtensionConfiguration.getInstance());
+ IASTSimpleDeclaration sd = getDeclaration(tu, 0);
+ assertInstance(sd.getDeclarators()[0], IASTFunctionDeclarator.class);
+ }
+
+ // void test() {
+ // sizeof(int, 1);
+ // sizeof(int, 2, 2);
+ // }
+ public void testSizeofExtension() throws Exception {
+ IASTTranslationUnit tu = parseCWithExtension(getAboveComment(), SIZEOF_EXTENSION);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ IASTUnaryExpression expr = getExpressionOfStatement(fdef, 0);
+ assertEquals(IASTUnaryExpression.op_sizeof, expr.getOperator());
+ assertInstance(expr.getOperand(), IASTExpressionList.class);
+ expr = getExpressionOfStatement(fdef, 1);
+ assertEquals(IASTUnaryExpression.op_sizeof, expr.getOperator());
+ assertInstance(expr.getOperand(), IASTExpressionList.class);
+
+ tu = parseCPPWithExtension(getAboveComment(), SIZEOF_EXTENSION);
+ fdef = getDeclaration(tu, 0);
+ expr = getExpressionOfStatement(fdef, 0);
+ assertEquals(IASTUnaryExpression.op_sizeof, expr.getOperator());
+ assertInstance(expr.getOperand(), IASTExpressionList.class);
+ expr = getExpressionOfStatement(fdef, 1);
+ assertEquals(IASTUnaryExpression.op_sizeof, expr.getOperator());
+ assertInstance(expr.getOperand(), IASTExpressionList.class);
+ }
+
+ // asm volatile int a1() {
+ // assembler code here
+ // }
+ // asm int a2() {
+ // assembler code here
+ // }
+ // asm volatile a3(int) {
+ // assembler code here
+ // }
+ // asm a4() {
+ // assembler code here
+ // }
+ public void testFunctionStyleAssembler() throws Exception {
+ IASTTranslationUnit tu = parseCWithExtension(getAboveComment(), FUNCTION_STYLE_ASM);
+ IASTFunctionDefinition fdef = getDeclaration(tu, 0);
+ fdef = getDeclaration(tu, 1);
+ fdef = getDeclaration(tu, 2);
+ fdef = getDeclaration(tu, 3);
+
+ tu = parseCPPWithExtension(getAboveComment(), FUNCTION_STYLE_ASM);
+ fdef = getDeclaration(tu, 0);
+ fdef = getDeclaration(tu, 1);
+ fdef = getDeclaration(tu, 2);
+ fdef = getDeclaration(tu, 3);
+ }
+
// /% a comment %/
// int a;
public void testSlashPercentComment() throws Exception {
- IASTTranslationUnit tu= parseCWithExtension(getAboveComment(), SLASH_PERCENT_COMMENT);
+ IASTTranslationUnit tu = parseCWithExtension(getAboveComment(), SLASH_PERCENT_COMMENT);
- IASTDeclaration d= getDeclaration(tu, 0);
+ IASTDeclaration d = getDeclaration(tu, 0);
assertEquals("int a;", d.getRawSignature());
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java
index d20a2d8bf06..15e5fc21154 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java
@@ -47,1484 +47,1475 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
* @author jcamelon
*/
public class QuickParser2Tests extends TestCase {
- private static final NullLogService NULL_LOG = new NullLogService();
+ private static final NullLogService NULL_LOG = new NullLogService();
- public QuickParser2Tests() {
- super();
- }
+ public QuickParser2Tests() {
+ super();
+ }
+
+ public QuickParser2Tests(String name) {
+ super(name);
+ }
- public QuickParser2Tests(String name) {
- super(name);
- }
-
- @Override
+ @Override
protected void setUp() throws Exception {
- CPPASTNameBase.sAllowRecursionBindings= false;
- CPPASTNameBase.sAllowNameComputation= false;
+ CPPASTNameBase.sAllowRecursionBindings = false;
+ CPPASTNameBase.sAllowNameComputation = false;
+ }
+
+ /**
+ * Test code: int x = 5; Purpose: to test the simple declaration in it's
+ * simplest form.
+ */
+ public void testIntGlobal() throws Exception {
+ // Parse and get the translation Unit
+ parse("int x = 5;");
}
/**
- * Test code: int x = 5; Purpose: to test the simple declaration in it's
- * simplest form.
- */
- public void testIntGlobal() throws Exception {
- // Parse and get the translation Unit
- parse("int x = 5;");
- }
-
- /**
- * Test code: class A { } a; Purpose: tests the use of a classSpecifier in
- */
- public void testEmptyClass() throws Exception {
- // Parse and get the translation unit
- Writer code = new StringWriter();
- code.write("class A { } a;");
- parse(code.toString());
- }
-
- /**
- * Test code: class A { public: int x; }; Purpose: tests a declaration in a
- * class scope.
- */
- public void testSimpleClassMember() throws Exception {
- // Parse and get the translaton unit
- Writer code = new StringWriter();
- code.write("class A { public: int x; };");
- parse(code.toString());
- }
-
- protected void parse(String code, boolean expectedToPass,
- ParserLanguage lang) throws Exception {
- parse(code, expectedToPass, lang, false);
- }
-
- protected void parse(String code, boolean expectedToPass) throws Exception {
- parse(code, expectedToPass, ParserLanguage.CPP);
- }
-
- /**
- * @param code
- */
- protected void parse(String code) throws Exception {
- parse(code, true, ParserLanguage.CPP);
- }
-
- public void testNamespaceDefinition() throws Exception {
- for (int i = 0; i < 2; ++i) {
- if (i == 0)
- parse("namespace KingJohn { int x; }");
- else
- parse("namespace { int x; }");
- }
- }
-
- public void testLinkageSpecification() throws Exception {
- for (int i = 0; i < 2; ++i) {
- if (i == 0)
- parse("extern \"C\" { int x(void); }");
- else
- parse("extern \"ADA\" int x(void);");
- }
- }
-
- public void testEnumSpecifier() throws Exception {
- Writer code = new StringWriter();
- code.write("enum { yo, go = 3, away };\n");
- code.write("enum hasAString { last = 666 };");
- parse(code.toString());
- }
-
- public void testTypedef() throws Exception {
- parse("typedef const struct A * const cpStructA;");
- }
-
- public void testUsingClauses() throws Exception {
- Writer code = new StringWriter();
- code.write("using namespace A::B::C;\n");
- code.write("using namespace C;\n");
- code.write("using B::f;\n");
- code.write("using ::f;\n");
- code.write("using typename crap::de::crap;");
- parse(code.toString());
- }
-
- /**
- * Test code: class A : public B, private C, virtual protected D { public:
- * int x, y; float a,b,c; } Purpose: tests a declaration in a class scope.
- */
- public void testSimpleClassMembers() throws Exception {
- // Parse and get the translaton unit
- Writer code = new StringWriter();
- code.write("class A : public B, private C, virtual protected D { public: int x, y; float a,b,c; };");
- parse(code.toString());
- }
-
- /**
- * Test code: int myFunction(void);
- */
- public void testSimpleFunctionDeclaration() throws Exception {
- // Parse and get the translaton unit
- Writer code = new StringWriter();
- code.write("void myFunction(void);");
- parse(code.toString());
- }
-
- /**
- * Test code: bool myFunction(int parm1 = 3 * 4, double parm2);
- *
- * @throws Exception
- */
- public void testFunctionDeclarationWithParameters() throws Exception {
- // Parse and get the translaton unit
- Writer code = new StringWriter();
- code.write("bool myFunction(int parm1 = 3 * 4, double parm2);");
- parse(code.toString());
- }
-
- public void testAssignmentExpressions() throws Exception {
- parse("int x = y = z = 5;");
- }
-
- public void testBug39348() throws Exception {
- parse("unsigned char a[sizeof (struct sss)];");
- }
-
- public void testBug39501() throws Exception {
- parse("struct A { A() throw (int); };");
- }
-
- public void testBug39349() throws Exception {
- parse("enum foo { foo1 = 0, foo2 = 0xffffffffffffffffULL, foo3 = 0xf0fffffffffffffeLLU };");
- }
-
- public void testBug39544() throws Exception {
- parse("wchar_t wc = L'X';");
- }
-
- public void testBug36290() throws Exception {
- parse("typedef void (A:: * pMethod) (void); ");
- parse("typedef void (boo) (void); ");
- parse("typedef void boo (void); ");
- }
-
- public void testBug36769B() throws Exception {
- parse("class X { operator int(); }; \n");
- parse("class X { operator int*(); }; \n");
- parse("class X { operator int&(); }; \n");
- parse("class X { operator A(); }; \n");
- parse("class X { operator A*(); }; \n");
- parse("class X { operator A&(); }; \n");
-
- parse("X::operator int() { } \n");
- parse("X::operator int*() { } \n");
- parse("X::operator int&() { } \n");
- parse("X::operator A() { } \n");
- parse("X::operator A*() { } \n");
- parse("X::operator A&() { } \n");
-
- parse("template <class A,B> class X<A,C> { operator int(); }; \n");
- parse("template <class A,B> class X<A,C> { operator int*(); }; \n");
- parse("template <class A,B> class X<A,C> { operator int&(); }; \n");
- parse("template <class A,B> class X<A,C> { operator A(); }; \n");
- parse("template <class A,B> class X<A,C> { operator A*(); }; \n");
- parse("template <class A,B> class X<A,C> { operator A&(); }; \n");
-
- parse("template <class A,B> X<A,C>::operator int() { }; \n");
- parse("template <class A,B> X<A,C>::operator int*() { }; \n");
- parse("template <class A,B> X<A,C>::operator int&() { }; \n");
- parse("template <class A,B> X<A,C>::operator A() { }; \n");
- parse("template <class A,B> X<A,C>::operator A*() { }; \n");
- parse("template <class A,B> X<A,C>::operator A&() { }; \n");
- }
+ * Test code: class A { } a; Purpose: tests the use of a classSpecifier in
+ */
+ public void testEmptyClass() throws Exception {
+ // Parse and get the translation unit
+ Writer code = new StringWriter();
+ code.write("class A { } a;");
+ parse(code.toString());
+ }
+
+ /**
+ * Test code: class A { public: int x; }; Purpose: tests a declaration in a
+ * class scope.
+ */
+ public void testSimpleClassMember() throws Exception {
+ // Parse and get the translaton unit
+ Writer code = new StringWriter();
+ code.write("class A { public: int x; };");
+ parse(code.toString());
+ }
+
+ protected void parse(String code, boolean expectedToPass, ParserLanguage lang) throws Exception {
+ parse(code, expectedToPass, lang, false);
+ }
+
+ protected void parse(String code, boolean expectedToPass) throws Exception {
+ parse(code, expectedToPass, ParserLanguage.CPP);
+ }
+
+ /**
+ * @param code
+ */
+ protected void parse(String code) throws Exception {
+ parse(code, true, ParserLanguage.CPP);
+ }
+
+ public void testNamespaceDefinition() throws Exception {
+ for (int i = 0; i < 2; ++i) {
+ if (i == 0)
+ parse("namespace KingJohn { int x; }");
+ else
+ parse("namespace { int x; }");
+ }
+ }
+
+ public void testLinkageSpecification() throws Exception {
+ for (int i = 0; i < 2; ++i) {
+ if (i == 0)
+ parse("extern \"C\" { int x(void); }");
+ else
+ parse("extern \"ADA\" int x(void);");
+ }
+ }
+
+ public void testEnumSpecifier() throws Exception {
+ Writer code = new StringWriter();
+ code.write("enum { yo, go = 3, away };\n");
+ code.write("enum hasAString { last = 666 };");
+ parse(code.toString());
+ }
+
+ public void testTypedef() throws Exception {
+ parse("typedef const struct A * const cpStructA;");
+ }
+
+ public void testUsingClauses() throws Exception {
+ Writer code = new StringWriter();
+ code.write("using namespace A::B::C;\n");
+ code.write("using namespace C;\n");
+ code.write("using B::f;\n");
+ code.write("using ::f;\n");
+ code.write("using typename crap::de::crap;");
+ parse(code.toString());
+ }
+
+ /**
+ * Test code: class A : public B, private C, virtual protected D { public:
+ * int x, y; float a,b,c; } Purpose: tests a declaration in a class scope.
+ */
+ public void testSimpleClassMembers() throws Exception {
+ // Parse and get the translaton unit
+ Writer code = new StringWriter();
+ code.write("class A : public B, private C, virtual protected D { public: int x, y; float a,b,c; };");
+ parse(code.toString());
+ }
+
+ /**
+ * Test code: int myFunction(void);
+ */
+ public void testSimpleFunctionDeclaration() throws Exception {
+ // Parse and get the translaton unit
+ Writer code = new StringWriter();
+ code.write("void myFunction(void);");
+ parse(code.toString());
+ }
+
+ /**
+ * Test code: bool myFunction(int parm1 = 3 * 4, double parm2);
+ *
+ * @throws Exception
+ */
+ public void testFunctionDeclarationWithParameters() throws Exception {
+ // Parse and get the translaton unit
+ Writer code = new StringWriter();
+ code.write("bool myFunction(int parm1 = 3 * 4, double parm2);");
+ parse(code.toString());
+ }
+
+ public void testAssignmentExpressions() throws Exception {
+ parse("int x = y = z = 5;");
+ }
+
+ public void testBug39348() throws Exception {
+ parse("unsigned char a[sizeof (struct sss)];");
+ }
+
+ public void testBug39501() throws Exception {
+ parse("struct A { A() throw (int); };");
+ }
+
+ public void testBug39349() throws Exception {
+ parse("enum foo { foo1 = 0, foo2 = 0xffffffffffffffffULL, foo3 = 0xf0fffffffffffffeLLU };");
+ }
+
+ public void testBug39544() throws Exception {
+ parse("wchar_t wc = L'X';");
+ }
+
+ public void testBug36290() throws Exception {
+ parse("typedef void (A:: * pMethod) (void); ");
+ parse("typedef void (boo) (void); ");
+ parse("typedef void boo (void); ");
+ }
+
+ public void testBug36769B() throws Exception {
+ parse("class X { operator int(); }; \n");
+ parse("class X { operator int*(); }; \n");
+ parse("class X { operator int&(); }; \n");
+ parse("class X { operator A(); }; \n");
+ parse("class X { operator A*(); }; \n");
+ parse("class X { operator A&(); }; \n");
+
+ parse("X::operator int() { } \n");
+ parse("X::operator int*() { } \n");
+ parse("X::operator int&() { } \n");
+ parse("X::operator A() { } \n");
+ parse("X::operator A*() { } \n");
+ parse("X::operator A&() { } \n");
+
+ parse("template <class A,B> class X<A,C> { operator int(); }; \n");
+ parse("template <class A,B> class X<A,C> { operator int*(); }; \n");
+ parse("template <class A,B> class X<A,C> { operator int&(); }; \n");
+ parse("template <class A,B> class X<A,C> { operator A(); }; \n");
+ parse("template <class A,B> class X<A,C> { operator A*(); }; \n");
+ parse("template <class A,B> class X<A,C> { operator A&(); }; \n");
+
+ parse("template <class A,B> X<A,C>::operator int() { }; \n");
+ parse("template <class A,B> X<A,C>::operator int*() { }; \n");
+ parse("template <class A,B> X<A,C>::operator int&() { }; \n");
+ parse("template <class A,B> X<A,C>::operator A() { }; \n");
+ parse("template <class A,B> X<A,C>::operator A*() { }; \n");
+ parse("template <class A,B> X<A,C>::operator A&() { }; \n");
+ }
// failing, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=236856
- public void _testBug36932C() throws Exception {
- parse("X::X() : var(new int) {}");
- parse("X::X() : var(new int(5)) {}");
- parse("X::X() : var(new int(B)) {}");
- parse("X::X() : var(new int(B,C)) {}");
- parse("X::X() : var(new int[5]) {}");
- parse("X::X() : var(new int[5][10]) {}");
- parse("X::X() : var(new int[B]) {}");
- parse("X::X() : var(new int[B][C][D]) {}");
-
- parse("X::X() : var(new A) {}");
- parse("X::X() : var(new A(5)) {}");
- parse("X::X() : var(new A(B)) {}");
- parse("X::X() : var(new A(B,C)) {}");
- parse("X::X() : var(new A[5]) {}");
- parse("X::X() : var(new A[5][10]) {}");
- parse("X::X() : var(new A[B]) {}");
- parse("X::X() : var(new A[B][C][D]) {}");
-
- parse("X::X() : var(new (int)) {}");
- parse("X::X() : var(new (int)(5)) {}");
- parse("X::X() : var(new (int)(B)) {}");
- parse("X::X() : var(new (int)(B,C)) {}");
- parse("X::X() : var(new (int[5])) {}");
- parse("X::X() : var(new (int[5][10])) {}");
- parse("X::X() : var(new (int[B])) {}");
- parse("X::X() : var(new (int[B][C][D])) {}");
-
- parse("X::X() : var(new (A)) {}");
- parse("X::X() : var(new (A)(5)) {}");
- parse("X::X() : var(new (A)(B)) {}");
- parse("X::X() : var(new (A)(B,C)) {}");
- parse("X::X() : var(new (A[5])) {}");
- parse("X::X() : var(new (A[5][10])) {}");
- parse("X::X() : var(new (A[B])) {}");
- parse("X::X() : var(new (A[B][C][D])) {}");
-
- parse("X::X() : var(new (0) int) {}");
- parse("X::X() : var(new (0) int(5)) {}");
- parse("X::X() : var(new (0) int(B)) {}");
- parse("X::X() : var(new (0) int(B,C)) {}");
- parse("X::X() : var(new (0) int[5]) {}");
- parse("X::X() : var(new (0) int[5][10]) {}");
- parse("X::X() : var(new (0) int[B]) {}");
- parse("X::X() : var(new (0) int[B][C][D]) {}");
-
- parse("X::X() : var(new (0) A) {}");
- parse("X::X() : var(new (0) A(5)) {}");
- parse("X::X() : var(new (0) A(B)) {}");
- parse("X::X() : var(new (0) A(B,C)) {}");
- parse("X::X() : var(new (0) A[5]) {}");
- parse("X::X() : var(new (0) A[5][10]) {}");
- parse("X::X() : var(new (0) A[B]) {}");
- parse("X::X() : var(new (0) A[B][C][D]) {}");
-
- parse("X::X() : var(new (0) (int)) {}");
- parse("X::X() : var(new (0) (int)(5)) {}");
- parse("X::X() : var(new (0) (int)(B)) {}");
- parse("X::X() : var(new (0) (int)(B,C)) {}");
- parse("X::X() : var(new (0) (int[5])) {}");
- parse("X::X() : var(new (0) (int[5][10])) {}");
- parse("X::X() : var(new (0) (int[B])) {}");
- parse("X::X() : var(new (0) (int[B][C][D])) {}");
-
- parse("X::X() : var(new (0) (A)) {}");
- parse("X::X() : var(new (0) (A)(5)) {}");
- parse("X::X() : var(new (0) (A)(B)) {}");
- parse("X::X() : var(new (0) (A)(B,C)) {}");
- parse("X::X() : var(new (0) (A[5])) {}");
- parse("X::X() : var(new (0) (A[5][10])) {}");
- parse("X::X() : var(new (0) (A[B])) {}");
- parse("X::X() : var(new (0) (A[B][C][D])) {}");
-
- parse("X::X() : var(new (P) int) {}");
- parse("X::X() : var(new (P) int(5)) {}");
- parse("X::X() : var(new (P) int(B)) {}");
- parse("X::X() : var(new (P) int(B,C)) {}");
- parse("X::X() : var(new (P) int[5]) {}");
- parse("X::X() : var(new (P) int[5][10]) {}");
- parse("X::X() : var(new (P) int[B]) {}");
- parse("X::X() : var(new (P) int[B][C][D]) {}");
-
- parse("X::X() : var(new (P) A) {}");
- parse("X::X() : var(new (P) A(5)) {}");
- parse("X::X() : var(new (P) A(B)) {}");
- parse("X::X() : var(new (P) A(B,C)) {}");
- parse("X::X() : var(new (P) A[5]) {}");
- parse("X::X() : var(new (P) A[5][10]) {}");
- parse("X::X() : var(new (P) A[B]) {}");
- parse("X::X() : var(new (P) A[B][C][D]) {}");
-
- parse("X::X() : var(new (P) (int)) {}");
- parse("X::X() : var(new (P) (int)(5)) {}");
- parse("X::X() : var(new (P) (int)(B)) {}");
- parse("X::X() : var(new (P) (int)(B,C)) {}");
- parse("X::X() : var(new (P) (int[5])) {}");
- parse("X::X() : var(new (P) (int[5][10])) {}");
- parse("X::X() : var(new (P) (int[B])) {}");
- parse("X::X() : var(new (P) (int[B][C][D])) {}");
-
- parse("X::X() : var(new (P) (A)) {}");
- parse("X::X() : var(new (P) (A)(5)) {}");
- parse("X::X() : var(new (P) (A)(B)) {}");
- parse("X::X() : var(new (P) (A)(B,C)) {}");
- parse("X::X() : var(new (P) (A[5])) {}");
- parse("X::X() : var(new (P) (A[5][10])) {}");
- parse("X::X() : var(new (P) (A[B])) {}");
- parse("X::X() : var(new (P) (A[B][C][D])) {}");
- }
-
- public void testBugSingleton192() throws Exception {
- parse("int Test::* pMember_;");
- }
-
- public void testBug36931() throws Exception {
- parse("A::nested::nested(){}; ");
- parse("int A::nested::foo() {} ");
- parse("int A::nested::operator+() {} ");
- parse("A::nested::operator int() {} ");
- parse("static const int A::nested::i = 1; ");
-
- parse("template <class B,C> A<B>::nested::nested(){}; ");
- parse("template <class B,C> int A::nested<B,D>::foo() {} ");
- parse("template <class B,C> int A<B,C>::nested<C,B>::operator+() {} ");
- parse("template <class B,C> A::nested::operator int() {} ");
- }
-
- public void testBug37019() throws Exception {
- parse("static const A a(1, 0);");
- }
-
- public void testBug36766and36769A() throws Exception {
- Writer code = new StringWriter();
- code.write("template <class _CharT, class _Alloc>\n");
- code.write("rope<_CharT, _Alloc>::rope(size_t __n, _CharT __c,\n");
- code.write("const allocator_type& __a): _Base(__a)\n");
- code.write("{}\n");
- parse(code.toString());
- }
-
- public void testBug36766and36769B() throws Exception {
- Writer code = new StringWriter();
- code.write("template<class _CharT>\n");
- code.write("bool _Rope_insert_char_consumer<_CharT>::operator()\n");
- code.write("(const _CharT* __leaf, size_t __n)\n");
- code.write("{}\n");
- parse(code.toString());
- }
-
- public void testBug36766and36769C() throws Exception {
- //TODO - requires CPPVisitor
- Writer code = new StringWriter();
- code.write("template <class _CharT, class _Alloc>\n");
- code.write("_Rope_char_ref_proxy<_CharT, _Alloc>&\n");
- code
- .write("_Rope_char_ref_proxy<_CharT, _Alloc>::operator= (_CharT __c)\n");
- code.write("{}\n");
- parse(code.toString());
- }
-
- public void testBug36766and36769D() throws Exception {
- //TODO - requires CPPVisitor
- Writer code = new StringWriter();
- code.write("template <class _CharT, class _Alloc>\n");
- code.write("rope<_CharT, _Alloc>::~rope()\n");
- code.write("{}\n");
- parse(code.toString());
- }
-
- public void testBug36932A() throws Exception {
- parse("A::A() : var(new char[ (unsigned)bufSize ]) {}");
- }
+ public void _testBug36932C() throws Exception {
+ parse("X::X() : var(new int) {}");
+ parse("X::X() : var(new int(5)) {}");
+ parse("X::X() : var(new int(B)) {}");
+ parse("X::X() : var(new int(B,C)) {}");
+ parse("X::X() : var(new int[5]) {}");
+ parse("X::X() : var(new int[5][10]) {}");
+ parse("X::X() : var(new int[B]) {}");
+ parse("X::X() : var(new int[B][C][D]) {}");
+
+ parse("X::X() : var(new A) {}");
+ parse("X::X() : var(new A(5)) {}");
+ parse("X::X() : var(new A(B)) {}");
+ parse("X::X() : var(new A(B,C)) {}");
+ parse("X::X() : var(new A[5]) {}");
+ parse("X::X() : var(new A[5][10]) {}");
+ parse("X::X() : var(new A[B]) {}");
+ parse("X::X() : var(new A[B][C][D]) {}");
+
+ parse("X::X() : var(new (int)) {}");
+ parse("X::X() : var(new (int)(5)) {}");
+ parse("X::X() : var(new (int)(B)) {}");
+ parse("X::X() : var(new (int)(B,C)) {}");
+ parse("X::X() : var(new (int[5])) {}");
+ parse("X::X() : var(new (int[5][10])) {}");
+ parse("X::X() : var(new (int[B])) {}");
+ parse("X::X() : var(new (int[B][C][D])) {}");
+
+ parse("X::X() : var(new (A)) {}");
+ parse("X::X() : var(new (A)(5)) {}");
+ parse("X::X() : var(new (A)(B)) {}");
+ parse("X::X() : var(new (A)(B,C)) {}");
+ parse("X::X() : var(new (A[5])) {}");
+ parse("X::X() : var(new (A[5][10])) {}");
+ parse("X::X() : var(new (A[B])) {}");
+ parse("X::X() : var(new (A[B][C][D])) {}");
+
+ parse("X::X() : var(new (0) int) {}");
+ parse("X::X() : var(new (0) int(5)) {}");
+ parse("X::X() : var(new (0) int(B)) {}");
+ parse("X::X() : var(new (0) int(B,C)) {}");
+ parse("X::X() : var(new (0) int[5]) {}");
+ parse("X::X() : var(new (0) int[5][10]) {}");
+ parse("X::X() : var(new (0) int[B]) {}");
+ parse("X::X() : var(new (0) int[B][C][D]) {}");
+
+ parse("X::X() : var(new (0) A) {}");
+ parse("X::X() : var(new (0) A(5)) {}");
+ parse("X::X() : var(new (0) A(B)) {}");
+ parse("X::X() : var(new (0) A(B,C)) {}");
+ parse("X::X() : var(new (0) A[5]) {}");
+ parse("X::X() : var(new (0) A[5][10]) {}");
+ parse("X::X() : var(new (0) A[B]) {}");
+ parse("X::X() : var(new (0) A[B][C][D]) {}");
+
+ parse("X::X() : var(new (0) (int)) {}");
+ parse("X::X() : var(new (0) (int)(5)) {}");
+ parse("X::X() : var(new (0) (int)(B)) {}");
+ parse("X::X() : var(new (0) (int)(B,C)) {}");
+ parse("X::X() : var(new (0) (int[5])) {}");
+ parse("X::X() : var(new (0) (int[5][10])) {}");
+ parse("X::X() : var(new (0) (int[B])) {}");
+ parse("X::X() : var(new (0) (int[B][C][D])) {}");
+
+ parse("X::X() : var(new (0) (A)) {}");
+ parse("X::X() : var(new (0) (A)(5)) {}");
+ parse("X::X() : var(new (0) (A)(B)) {}");
+ parse("X::X() : var(new (0) (A)(B,C)) {}");
+ parse("X::X() : var(new (0) (A[5])) {}");
+ parse("X::X() : var(new (0) (A[5][10])) {}");
+ parse("X::X() : var(new (0) (A[B])) {}");
+ parse("X::X() : var(new (0) (A[B][C][D])) {}");
+
+ parse("X::X() : var(new (P) int) {}");
+ parse("X::X() : var(new (P) int(5)) {}");
+ parse("X::X() : var(new (P) int(B)) {}");
+ parse("X::X() : var(new (P) int(B,C)) {}");
+ parse("X::X() : var(new (P) int[5]) {}");
+ parse("X::X() : var(new (P) int[5][10]) {}");
+ parse("X::X() : var(new (P) int[B]) {}");
+ parse("X::X() : var(new (P) int[B][C][D]) {}");
+
+ parse("X::X() : var(new (P) A) {}");
+ parse("X::X() : var(new (P) A(5)) {}");
+ parse("X::X() : var(new (P) A(B)) {}");
+ parse("X::X() : var(new (P) A(B,C)) {}");
+ parse("X::X() : var(new (P) A[5]) {}");
+ parse("X::X() : var(new (P) A[5][10]) {}");
+ parse("X::X() : var(new (P) A[B]) {}");
+ parse("X::X() : var(new (P) A[B][C][D]) {}");
+
+ parse("X::X() : var(new (P) (int)) {}");
+ parse("X::X() : var(new (P) (int)(5)) {}");
+ parse("X::X() : var(new (P) (int)(B)) {}");
+ parse("X::X() : var(new (P) (int)(B,C)) {}");
+ parse("X::X() : var(new (P) (int[5])) {}");
+ parse("X::X() : var(new (P) (int[5][10])) {}");
+ parse("X::X() : var(new (P) (int[B])) {}");
+ parse("X::X() : var(new (P) (int[B][C][D])) {}");
+
+ parse("X::X() : var(new (P) (A)) {}");
+ parse("X::X() : var(new (P) (A)(5)) {}");
+ parse("X::X() : var(new (P) (A)(B)) {}");
+ parse("X::X() : var(new (P) (A)(B,C)) {}");
+ parse("X::X() : var(new (P) (A[5])) {}");
+ parse("X::X() : var(new (P) (A[5][10])) {}");
+ parse("X::X() : var(new (P) (A[B])) {}");
+ parse("X::X() : var(new (P) (A[B][C][D])) {}");
+ }
+
+ public void testBugSingleton192() throws Exception {
+ parse("int Test::* pMember_;");
+ }
+
+ public void testBug36931() throws Exception {
+ parse("A::nested::nested(){}; ");
+ parse("int A::nested::foo() {} ");
+ parse("int A::nested::operator+() {} ");
+ parse("A::nested::operator int() {} ");
+ parse("static const int A::nested::i = 1; ");
+
+ parse("template <class B,C> A<B>::nested::nested(){}; ");
+ parse("template <class B,C> int A::nested<B,D>::foo() {} ");
+ parse("template <class B,C> int A<B,C>::nested<C,B>::operator+() {} ");
+ parse("template <class B,C> A::nested::operator int() {} ");
+ }
+
+ public void testBug37019() throws Exception {
+ parse("static const A a(1, 0);");
+ }
+
+ public void testBug36766and36769A() throws Exception {
+ Writer code = new StringWriter();
+ code.write("template <class _CharT, class _Alloc>\n");
+ code.write("rope<_CharT, _Alloc>::rope(size_t __n, _CharT __c,\n");
+ code.write("const allocator_type& __a): _Base(__a)\n");
+ code.write("{}\n");
+ parse(code.toString());
+ }
+
+ public void testBug36766and36769B() throws Exception {
+ Writer code = new StringWriter();
+ code.write("template<class _CharT>\n");
+ code.write("bool _Rope_insert_char_consumer<_CharT>::operator()\n");
+ code.write("(const _CharT* __leaf, size_t __n)\n");
+ code.write("{}\n");
+ parse(code.toString());
+ }
+
+ public void testBug36766and36769C() throws Exception {
+ //TODO - requires CPPVisitor
+ Writer code = new StringWriter();
+ code.write("template <class _CharT, class _Alloc>\n");
+ code.write("_Rope_char_ref_proxy<_CharT, _Alloc>&\n");
+ code.write("_Rope_char_ref_proxy<_CharT, _Alloc>::operator= (_CharT __c)\n");
+ code.write("{}\n");
+ parse(code.toString());
+ }
+
+ public void testBug36766and36769D() throws Exception {
+ //TODO - requires CPPVisitor
+ Writer code = new StringWriter();
+ code.write("template <class _CharT, class _Alloc>\n");
+ code.write("rope<_CharT, _Alloc>::~rope()\n");
+ code.write("{}\n");
+ parse(code.toString());
+ }
+
+ public void testBug36932A() throws Exception {
+ parse("A::A() : var(new char[ (unsigned)bufSize ]) {}");
+ }
// failing, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=236856
- public void _testBug36932B() throws Exception {
- parse(" p = new int; ");
- parse(" p = new int(5); ");
- parse(" p = new int(B); ");
- parse(" p = new int(B,C); ");
- parse(" p = new int[5]; ");
- parse(" p = new int[5][10]; ");
- parse(" p = new int[B]; ");
- parse(" p = new int[B][C][D]; ");
-
- parse(" p = new A; ");
- parse(" p = new A(5); ");
- parse(" p = new A(B); ");
- parse(" p = new A(B,C); ");
- parse(" p = new A[5]; ");
- parse(" p = new A[5][10]; ");
- parse(" p = new A[B]; ");
- parse(" p = new A[B][C][D]; ");
-
- parse(" p = new (int); ");
- parse(" p = new (int)(5); ");
- parse(" p = new (int)(B); ");
- parse(" p = new (int)(B,C); ");
- parse(" p = new (int[5]); ");
- parse(" p = new (int[5][10]); ");
- parse(" p = new (int[B]); ");
- parse(" p = new (int[B][C][D]); ");
-
- parse(" p = new (A); ");
- parse(" p = new (A)(5); ");
- parse(" p = new (A)(B); ");
- parse(" p = new (A)(B,C); ");
- parse(" p = new (A[5]); ");
- parse(" p = new (A[5][10]); ");
- parse(" p = new (A[B]); ");
- parse(" p = new (A[B][C][D]); ");
-
- parse(" p = new (0) int; ");
- parse(" p = new (0) int(5); ");
- parse(" p = new (0) int(B); ");
- parse(" p = new (0) int(B,C); ");
- parse(" p = new (0) int[5]; ");
- parse(" p = new (0) int[5][10]; ");
- parse(" p = new (0) int[B]; ");
- parse(" p = new (0) int[B][C][D]; ");
-
- parse(" p = new (0) A; ");
- parse(" p = new (0) A(5); ");
- parse(" p = new (0) A(B); ");
- parse(" p = new (0) A(B,C); ");
- parse(" p = new (0) A[5]; ");
- parse(" p = new (0) A[5][10]; ");
- parse(" p = new (0) A[B]; ");
- parse(" p = new (0) A[B][C][D]; ");
-
- parse(" p = new (0) (int); ");
- parse(" p = new (0) (int)(5); ");
- parse(" p = new (0) (int)(B); ");
- parse(" p = new (0) (int)(B,C); ");
- parse(" p = new (0) (int[5]); ");
- parse(" p = new (0) (int[5][10]); ");
- parse(" p = new (0) (int[B]); ");
- parse(" p = new (0) (int[B][C][D]); ");
-
- parse(" p = new (0) (A); ");
- parse(" p = new (0) (A)(5); ");
- parse(" p = new (0) (A)(B); ");
- parse(" p = new (0) (A)(B,C); ");
- parse(" p = new (0) (A[5]); ");
- parse(" p = new (0) (A[5][10]); ");
- parse(" p = new (0) (A[B]); ");
- parse(" p = new (0) (A[B][C][D]); ");
-
- parse(" p = new (P) int; ");
- parse(" p = new (P) int(5); ");
- parse(" p = new (P) int(B); ");
- parse(" p = new (P) int(B,C); ");
- parse(" p = new (P) int[5]; ");
- parse(" p = new (P) int[5][10]; ");
- parse(" p = new (P) int[B]; ");
- parse(" p = new (P) int[B][C][D]; ");
-
- parse(" p = new (P) A; ");
- parse(" p = new (P) A(5); ");
- parse(" p = new (P) A(B); ");
- parse(" p = new (P) A(B,C); ");
- parse(" p = new (P) A[5]; ");
- parse(" p = new (P) A[5][10]; ");
- parse(" p = new (P) A[B]; ");
- parse(" p = new (P) A[B][C][D]; ");
-
- parse(" p = new (P) (int); ");
- parse(" p = new (P) (int)(5); ");
- parse(" p = new (P) (int)(B); ");
- parse(" p = new (P) (int)(B,C); ");
- parse(" p = new (P) (int[5]); ");
- parse(" p = new (P) (int[5][10]); ");
- parse(" p = new (P) (int[B]); ");
- parse(" p = new (P) (int[B][C][D]); ");
-
- parse(" p = new (P) (A); ");
- parse(" p = new (P) (A)(5); ");
- parse(" p = new (P) (A)(B); ");
- parse(" p = new (P) (A)(B,C); ");
- parse(" p = new (P) (A[5]); ");
- parse(" p = new (P) (A[5][10]); ");
- parse(" p = new (P) (A[B]); ");
- parse(" p = new (P) (A[B][C][D]); ");
- }
-
- public void testBug36769A() throws Exception {
- parse("template <class A, B> cls<A, C>::operator otherType() const {}\n");
- parse("template <class A, B> cls<A, C>::cls() {}\n");
- parse("template <class A, B> cls<A, C>::~cls() {}\n");
- }
-
- public void testBug36714() throws Exception {
- Writer code = new StringWriter();
- code.write("unsigned long a = 0UL;\n");
- code.write("unsigned long a2 = 0L; \n");
- parse(code.toString());
- }
-
- public void testBugFunctor758() throws Exception {
- parse(
- "class Functor {"+
- "template <typename Fun> Functor(Fun fun) : spImpl_(new FunctorHandler<Functor, Fun>(fun)){}" +
- "};"
- );
- }
-
- public void testBug36932() throws Exception {
- parse("A::A(): b(new int(5)), b(new B), c(new int) {}");
- }
-
- public void testBug36704() throws Exception {
- Writer code = new StringWriter();
- code.write("template<typename T, typename U> class Typelist;");
- code.write("template<typename T> struct Length {};");
- code.write("template <class T, class U>\n");
- code.write("struct Length< Typelist<T, U> >\n");
- code.write("{\n");
- code.write("enum { value = 1 + Length<U>::value };\n");
- code.write("};\n");
- parse(code.toString());
- }
-
- public void testBug36699() throws Exception {
- Writer code = new StringWriter();
- code.write("template < template <class> class ThreadingModel = DEFAULT_THREADING,\n");
- code.write("std::size_t chunkSize = DEFAULT_CHUNK_SIZE,\n");
- code.write("std::size_t maxSmallObjectSize = MAX_SMALL_OBJECT_SIZE >\n");
- code.write("class SmallObject : public ThreadingModel<\n");
- code.write("SmallObject<ThreadingModel, chunkSize, maxSmallObjectSize> >\n");
- code.write("{};\n");
- parse(code.toString());
- }
-
- public void testBug36691() throws Exception {
- Writer code = new StringWriter();
- code.write("template <class T, class H>\n");
- code.write("typename H::template Rebind<T>::Result& Field(H& obj)\n");
- code.write("{ return obj; }\n");
- parse(code.toString());
- }
-
- public void testBug36702() throws Exception {
- Writer code = new StringWriter();
- code.write("void mad_decoder_init(struct mad_decoder *, void *,\n");
- code.write(" enum mad_flow (*)(void *, struct mad_stream *),\n");
- code.write(" enum mad_flow (*)(void *, struct mad_header const *),\n");
- code.write(" enum mad_flow (*)(void *,\n");
- code.write(" struct mad_stream const *,\n");
- code.write(" struct mad_frame *),\n");
- code.write(" enum mad_flow (*)(void *,\n");
- code.write(" struct mad_header const *,\n");
- code.write(" struct mad_pcm *),\n");
- code.write(" enum mad_flow (*)(void *,\n");
- code.write(" struct mad_stream *,\n");
- code.write(" struct mad_frame *),\n");
- code.write(" enum mad_flow (*)(void *, void *, unsigned int *)\n");
- code.write(");\n");
-
- parse(code.toString());
- }
-
- public void testBug36852() throws Exception {
- Writer code = new StringWriter();
- code.write("int CBT::senseToAllRect(double id_standardQuot = DOSE, double id_minToleranz =15.0,\n");
- code.write("double id_maxToleranz = 15.0, unsigned int iui_minY = 0, \n");
- code.write("unsigned int iui_maxY = HEIGHT);\n");
- parse(code.toString());
- }
-
- public void testBug36689() throws Exception {
- Writer code = new StringWriter();
- code.write("template\n");
- code.write("<\n");
- code.write("class AbstractFact,\n");
- code.write("template <class, class> class Creator = OpNewFactoryUnit,\n");
- code.write("class TList = typename AbstractFact::ProductList\n");
- code.write(">\n");
- code.write("class ConcreteFactory\n");
- code.write(": public GenLinearHierarchy<\n");
- code.write("typename TL::Reverse<TList>::Result, Creator, AbstractFact>\n");
- code.write("{\n");
- code.write("public:\n");
- code.write("typedef typename AbstractFact::ProductList ProductList;\n");
- code.write("typedef TList ConcreteProductList;\n");
- code.write("};\n");
- parse(code.toString());
- }
-
- public void testBug36707() throws Exception {
- parse("enum { exists = sizeof(typename H::Small) == sizeof((H::Test(H::MakeT()))) };");
- }
-
- public void testBug36717() throws Exception {
- parse("enum { eA = A::b };");
- }
-
- public void testBug36693() throws Exception {
- parse("FixedAllocator::Chunk* FixedAllocator::VicinityFind(void* p){}");
- }
-
- public void testWeirdExpression() throws Exception {
- parse("int x = rhs.spImpl_.get();");
- }
-
- public void testBug36696() throws Exception {
- Writer code = new StringWriter();
- code.write("template<typename T> class RefCounted {");
- code.write("template <typename P1> RefCounted(const RefCounted<P1>& rhs)\n");
- code.write(": pCount_(reinterpret_cast<const RefCounted&>(rhs).pCount_) {}\n");
- code.write("};");
- parse(code.toString());
- }
-
- public void testArrayOfPointerToFunctions() throws Exception {
- parse("unsigned char (*main_data)[MAD_BUFFER_MDLEN];");
- }
-
- public void testBug36073() throws Exception {
- StringWriter writer = new StringWriter();
- writer.write("class A{\n");
- writer.write("int x;\n");
- writer.write("public:\n");
- writer.write("A(const A&);\n");
- writer.write("};\n");
- writer.write("A::A(const A&v) : x(v.x) { }\n");
- parse(writer.toString());
- }
-
- public void testTemplateSpecialization() throws Exception {
- parse("template<> class stream<char> { /* ... */ };");
- }
-
- public void testTemplateInstantiation() throws Exception {
- parse("template class Array<char>;");
- }
-
- /**
- * Test code: "class A { int floor(double input), someInt; };"
- */
- public void testMultipleDeclarators() throws Exception {
- // Parse and get the translation unit
- parse("class A { int floor(double input), someInt; };");
- }
-
- public void testFunctionModifiers() throws Exception {
- parse("class A {virtual void foo(void) const throw (yay, nay, we::dont::care) = 0;};");
- }
-
- public void testArrays() throws Exception {
- parse("int x[5][];");
- }
-
- public void testElaboratedParms() throws Exception {
- parse("int x(struct A myA) { /* junk */ }");
- }
-
- public void testMemberDeclarations() throws Exception {
- Writer code = new StringWriter();
- code.write("class A {\n");
- code.write("public:\n");
- code.write(" int is0;\n");
- code.write("private:\n");
- code.write(" int is1;\n");
- code.write("protected:\n");
- code.write(" int is2;\n");
- code.write("};");
- parse(code.toString());
- }
-
- public void testPointerOperators() throws Exception {
- parse("int * x = 0, & y, * const * volatile * z;");
- }
-
- public void testBug26467() throws Exception {
- StringWriter code = new StringWriter();
- code.write("struct foo { int fooInt; char fooChar; };\n");
- code.write("typedef struct foo fooStruct;\n");
- code.write("typedef struct { int anonInt; char anonChar; } anonStruct;\n");
- parse(code.toString());
- }
-
- public void testASMDefinition() throws Exception {
- parse("asm(\"mov ep1 ds2\");");
- }
-
- public void testConstructorChain() throws Exception {
- //TODO - requires CPPVisitor in order to reduce ambiguities
- parse("TrafficLight_Actor::TrafficLight_Actor(RTController * rtg_rts, RTActorRef * rtg_ref) : RTActor(rtg_rts, rtg_ref), myId(0) {}");
- }
-
- public void testBug36237() throws Exception {
- parse("A::A():B((char *)0){}");
- }
-
- public void testBug36532() throws Exception {
- try {
- parse("template<int f() {\n");
- fail("We should not make it this far");
- } catch (ParserException pe) {
- } catch (Exception e) {
- fail("We should have gotten a ParserException rather than" + e);
- }
- }
-
- public void testPreprocessor() throws Exception {
- parse("#include <stdio.h>\n#define DEF VALUE\n");
- }
-
- public void testTemplateDeclarationOfFunction() throws Exception {
- parse("template<class A, typename B=C> A aTemplatedFunction(B bInstance);");
- }
-
- public void testTemplateDeclarationOfClass() throws Exception {
- parse("template<class T, typename Tibor = junk, class, typename, int x, float y,template <class Y> class, template<class A> class AClass> class myarray { /* ... */ };");
- }
-
- public void testBug35906() throws Exception {
- StringWriter code = new StringWriter();
- code.write("void TTest::MTest() {}\n");
- code.write("struct TTest::STest *TTest::FTest (int i) {}\n");
- parse(code.toString());
- }
-
- public void testBug36288() throws Exception {
- parse("int foo() {}\nlong foo2(){}");
- }
-
- public void testBug36250() throws Exception {
- parse("int f(int = 0);");
- }
-
- public void testBug36240() throws Exception {
- parse("A & A::operator=(A){}");
- }
-
- public void testBug36254() throws Exception {
- parse("unsigned i;\nvoid f(unsigned p1 = 0);");
- }
-
- public void testBug36432() throws Exception {
- Writer code = new StringWriter();
- code.write("#define CMD_GET \"g\"\n");
- code.write("#define CMD_ACTION \"a\"\n");
- code.write("#define CMD_QUIT \"q\"\n");
- code
- .write("static const memevent_cmd_func memevent_cmd_funcs[sizeof memevent_cmds - 1] = {\n");
- code.write("memevent_get,\n");
- code.write("memevent_action,\n");
- code.write("memevent_quit,\n");
- code.write("};\n");
- parse(code.toString());
- }
-
- public void testBug36594() throws Exception {
- parse("const int n = sizeof(A) / sizeof(B);");
- }
-
- public void testBug36794() throws Exception {
- parse("template<> class allocator<void> {};");
- }
-
- public void testBug36799() throws Exception {
- parse("static const int __WORD_BIT = int(CHAR_BIT*sizeof(unsigned int));");
- }
-
- public void testBug36764() throws Exception {
- parse("struct{ int x : 4; int y : 8; };");
- }
-
- public void testOrder() throws Exception {
- //TODO - requires CPPVisitor
- Writer code = new StringWriter();
- code.write("#define __SGI_STL_INTERNAL_ALGOBASE_H\n");
- code.write("#include <string.h>\n");
- code.write("template <class _Tp>\n");
- code.write("inline void swap(_Tp& __a, _Tp& __b) {\n");
- code.write("__STL_REQUIRES(_Tp, _Assignable);\n");
- code.write("_Tp __tmp = __a;\n");
- code.write("__a = __b;\n");
- code.write("__b = __tmp;\n");
- code.write("}\n");
- parse(code.toString());
- }
-
- public void testBug36771() throws Exception {
- Writer code = new StringWriter();
- code.write("#include /**/ \"foo.h\"\n");
-
- parse(code.toString());
- }
-
- public void testBug36811() throws Exception {
- Writer code = new StringWriter();
- code.write("using namespace std;\n");
- code.write("class Test {};");
- parse(code.toString());
- }
-
- public void testBug36708() throws Exception {
- parse("enum { isPointer = PointerTraits<T>::result };");
- }
-
- public void testBug36690() throws Exception {
- parse(
- "class Functor {" +
- "Functor(const Functor& rhs) : spImpl_(Impl::Clone(rhs.spImpl_.get())){}" +
- "};"
- );
- }
-
- public void testBug36703() throws Exception {
- parse("const std::type_info& Get() const;");
- }
-
- public void testBug36692() throws Exception {
- Writer code = new StringWriter();
- code.write("template <typename T, typename Destroyer>\n");
- code.write("void SetLongevity(T* pDynObject, unsigned int longevity,\n");
- code.write("Destroyer d = Private::Deleter<T>::Delete){}\n");
- parse(code.toString());
- }
-
- public void testBug36551() throws Exception {
- Writer code = new StringWriter();
- code.write("class TextFrame {\n");
- code.write("BAD_MACRO()\n");
- code.write("};");
- parse(code.toString(), false);
- }
-
-// public void testBug36247() throws Exception {
-// Writer code = new StringWriter();
-// code.write("class A {\n");
-// code.write("INLINE_DEF int f ();\n");
-// code.write("INLINE_DEF A g ();");
-// code.write("INLINE_DEF A * h ();");
-// code.write("INLINE_DEF A & unlock(void);");
-// code.write("};");
-// parse(code.toString());
-// }
-
- public void testStruct() throws Exception {
- StringWriter writer = new StringWriter();
- writer.write("struct mad_bitptr { unsigned char const *byte;\n");
- writer.write("unsigned short cache;\n unsigned short left;};");
- parse(writer.toString());
- }
-
- public void testBug36559() throws Exception {
- Writer code = new StringWriter();
- code.write("namespace myNameSpace {\n");
- code.write("template<typename T=short> class B {};\n");
- code.write("template<> class B<int> {};\n");
- code.write("}\n");
- parse(code.toString());
- }
-
- public void testPointersToFunctions() throws Exception {
- Writer code = new StringWriter();
- code.write("void (*name)(void);\n");
- code
- .write("static void * (* const orig_malloc_hook)(const char *file, int line, size_t size);\n");
-
- parse(code.toString());
- }
-
- public void testBug36600() throws Exception {
- parse("enum mad_flow (*input_func)(void *, struct mad_stream *);");
- }
-
- public void testBug36713() throws Exception {
- Writer code = new StringWriter();
- code.write("A (* const fPtr) (void *); \n");
- code.write("A (* const fPtr2) (A *); \n");
- parse(code.toString());
- }
-
- // K&R Test hasn't been ported from DOMTests
- // still need to figure out how to represent these in the AST
- // public void testOldKRFunctionDeclarations() throws Exception
- // {
- // // Parse and get the translaton unit
- // Writer code = new StringWriter();
- // code.write("bool myFunction(parm1, parm2, parm3)\n");
- // code.write("const char* parm1;\n");
- // code.write("int (*parm2)(float);\n");
- // code.write("{}");
- // TranslationUnit translationUnit = parse(code.toString());
- //
- // // Get the declaration
- // List declarations = translationUnit.getDeclarations();
- // assertEquals(1, declarations.size());
- // SimpleDeclaration simpleDeclaration =
- // (SimpleDeclaration)declarations.get(0);
- // assertEquals(simpleDeclaration.getDeclSpecifier().getType(),
- // DeclSpecifier.t_bool);
- // List declarators = simpleDeclaration.getDeclarators();
- // assertEquals(1, declarators.size());
- // Declarator functionDeclarator = (Declarator)declarators.get(0);
- // assertEquals(functionDeclarator.getName().toString(), "myFunction");
- //
- // ParameterDeclarationClause pdc = functionDeclarator.getParms();
- // assertNotNull(pdc);
- // List parameterDecls = pdc.getDeclarations();
- // assertEquals(3, parameterDecls.size());
- // ParameterDeclaration parm1 = (ParameterDeclaration)parameterDecls.get(0
- //);
- // assertNotNull(parm1.getDeclSpecifier().getName());
- // assertEquals("parm1", parm1.getDeclSpecifier().getName().toString());
- // List parm1Decls = parm1.getDeclarators();
- // assertEquals(1, parm1Decls.size());
- //
- // ParameterDeclaration parm2 = (ParameterDeclaration)parameterDecls.get(1
- //);
- // assertNotNull(parm2.getDeclSpecifier().getName());
- // assertEquals("parm2", parm2.getDeclSpecifier().getName().toString());
- // List parm2Decls = parm2.getDeclarators();
- // assertEquals(1, parm2Decls.size());
- //
- // ParameterDeclaration parm3 = (ParameterDeclaration)parameterDecls.get(2
- //);
- // assertNotNull(parm3.getDeclSpecifier().getName());
- // assertEquals("parm3", parm3.getDeclSpecifier().getName().toString());
- // List parm3Decls = parm3.getDeclarators();
- // assertEquals(1, parm3Decls.size());
- //
- // OldKRParameterDeclarationClause clause = pdc.getOldKRParms();
- // assertNotNull(clause);
- // assertEquals(clause.getDeclarations().size(), 2);
- // SimpleDeclaration decl1 =
- // (SimpleDeclaration)clause.getDeclarations().get(0);
- // assertEquals(decl1.getDeclarators().size(), 1);
- // assertTrue(decl1.getDeclSpecifier().isConst());
- // assertFalse(decl1.getDeclSpecifier().isVolatile());
- // assertEquals(decl1.getDeclSpecifier().getType(), DeclSpecifier.t_char);
- // Declarator declarator1 = (Declarator)decl1.getDeclarators().get(0);
- // assertEquals(declarator1.getName().toString(), "parm1");
- // List ptrOps1 = declarator1.getPointerOperators();
- // assertNotNull(ptrOps1);
- // assertEquals(1, ptrOps1.size());
- // PointerOperator po1 = (PointerOperator)ptrOps1.get(0);
- // assertNotNull(po1);
- // assertFalse(po1.isConst());
- // assertFalse(po1.isVolatile());
- // assertEquals(po1.getType(), PointerOperator.t_pointer);
- //
- // SimpleDeclaration declaration =
- // (SimpleDeclaration)clause.getDeclarations().get(1);
- // assertEquals(declaration.getDeclSpecifier().getType(),
- // DeclSpecifier.t_int);
- // assertEquals(declaration.getDeclarators().size(), 1);
- // assertNull(((Declarator)declaration.getDeclarators().get(0)).getName()
- //);
- // assertNotNull(
- // ((Declarator)declaration.getDeclarators().get(0)).getDeclarator());
- // assertEquals(
- // ((Declarator)declaration.getDeclarators().get(0)).getDeclarator().getName().toString(),
- // "parm2");
- // ParameterDeclarationClause clause2 =
- // ((Declarator)declaration.getDeclarators().get(0)).getParms();
- // assertEquals(clause2.getDeclarations().size(), 1);
- // assertEquals(
- // ((ParameterDeclaration)clause2.getDeclarations().get(0)).getDeclarators().size(),
- // 1);
- // assertNull(
- // ((Declarator)((ParameterDeclaration)clause2.getDeclarations().get(0)).getDeclarators().get(0)).getName()
- //);
- // assertEquals(
- // ((ParameterDeclaration)clause2.getDeclarations().get(0)).getDeclSpecifier().getType(),
- // DeclSpecifier.t_float);
- // }
-
- public void testPointersToMemberFunctions() throws Exception {
- parse("void (A::*name)(void);");
- }
-
- public void testBug39550() throws Exception {
- parse("double x = 0x1.fp1;");
- }
-
- // digraphs/trigraphs have been temporarily remove
- public void testBug39552A(int x) throws Exception {
- Writer code = new StringWriter();
- code.write("%:define glue(x, y) x %:%: y /* #define glue(x, y) x ## y. */\n");
- code.write("#ifndef glue\n");
- code.write("#error glue not defined!\n");
- code.write("#endif\n");
- code.write("%:define str(x) %:x /* #define str(x) #x */\n");
- code.write("int main (int argc, char *argv<::>) /* argv[] */\n");
- code.write("glue (<, %) /* { */\n");
- code.write(" /* di_str[] = */\n");
- code.write(" const char di_str glue(<, :)glue(:, >) = str(%:%:<::><%%>%:);\n");
- code.write(" /* Check the glue macro actually pastes, and that the spelling of\n");
- code.write(" all digraphs is preserved. */\n");
- code.write(" if (glue(strc, mp) (di_str, \"%:%:<::><%%>%:\"))\n");
- code.write(" err (\"Digraph spelling not preserved!\");\n");
- code.write(" return 0;\n");
- code.write("glue (%, >) /* } */\n");
-
- parse(code.toString());
- }
-
- // digraphs/trigraphs have been temporarily remove
- public void testBug39552B(int x) throws Exception {
- Writer code = new StringWriter();
-
- code.write("??=include <stdio.h>\n");
- code.write("??=define TWELVE 1??/\n");
- code.write("2\n");
- code.write("static const char str??(??) = \"0123456789??/n\";\n");
- code.write("int\n");
- code.write("main(void)\n");
- code.write("??<\n");
- code.write(" unsigned char x = 5;\n");
- code.write(" if (sizeof str != TWELVE)\n");
- code.write(" abort ();\n");
- code.write(" /* Test ^=, the only multi-character token to come from trigraphs. */\n");
- code.write(" x ??'= 3;\n");
- code.write(" if (x != 6)\n");
- code.write(" abort ();\n");
- code.write(" if ((5 ??! 3) != 7)\n");
- code.write(" abort ();\n");
- code.write(" return 0;\n");
- code.write("??>\n");
-
- parse(code.toString());
- }
-
- public void testBug39553() throws Exception {
- parse("#define COMP_INC \"foobar.h\" \n" + "#include COMP_INC\n"); //$NON-NLS-2$
- }
-
- public void testBug39537() throws Exception {
- parse("typedef foo<(U::id > 0)> foobar;");
- }
-
- public void testBug39546() throws Exception {
- parse("signed char c = (signed char) 0xffffffff;");
- }
-
- public void testIndirectDeclarators() throws Exception {
- parse("void (*x)(int);");
- }
-
- public void testBug39532() throws Exception {
- parse("class N1::N2::B : public A {};");
- }
-
- public void testBug39540() throws Exception {
- parse("class {} const null;");
- }
-
- public void testBug39530() throws Exception {
- parse("X sPassed(-1);");
- }
-
- public void testBug39526() throws Exception {
- parse("UnitList unit_list (String(\"keV\"));");
- }
-
- public void testBug39535() throws Exception {
- parse("namespace bar = foo;");
- }
-
- public void testBug39504B() throws Exception {
- parse("int y = sizeof (int*);");
- }
-
- public void testBug39505A() throws Exception {
- parse("int AD::* gp_down = static_cast<int AD::*>(gp_stat);");
- }
-
- public void testBug39505B() throws Exception {
- parse("int* gp_down = static_cast<int*>(gp_stat);");
- }
-
- public void testBug42985() throws Exception {
- parse("const int x = 4; int y = ::x;");
- }
-
- public void testBug40419() throws Exception {
- Writer code = new StringWriter();
- try {
- code.write("template <class T, class U> struct SuperSubclass {\n");
- code.write("enum { value = (::Loki::Conversion<const volatile U*, const volatile T*>::exists && \n");
- code.write("!::Loki::Conversion<const volatile T*, const volatile void*>::sameType) }; };");
- } catch (IOException e) {
- }
- parse(code.toString());
- }
-
- public void testBug39556() throws Exception {
- parse("int *restrict ip_fn (void);", true, ParserLanguage.C);
- }
-
- /**
- * Test code: struct Example { Example(); Example(int); ~Example();};
- * Purpose: tests a declaration in a class scope.
- */
- public void testBug43371() throws Exception {
- // Parse and get the translaton unit
- Writer code = new StringWriter();
- code.write("struct Example { Example(); Example(int); ~Example();};");
- parse(code.toString());
- }
-
- public void testBug43644() throws Exception {
- parse("void foo();{ int x; }", false);
- }
-
- public void testBug43062() throws Exception {
- parse("class X { operator short (); operator int unsigned(); operator int signed(); };");
- }
-
- public void testBug39531() throws Exception {
- parse("class AString { operator char const *() const; };");
- }
-
- public void testBug40007() throws Exception {
- parse("int y = #;", false);
- }
-
- public void testBug40759() throws Exception {
- parse("#define X SomeName \n class X {};");
- }
-
- public void testBug44633() throws Exception {
- Writer writer = new StringWriter();
- writer.write("template <typename T> class A {};\n");
- writer.write("class B { template <typename T> friend class A;\n");
- writer.write("void method();\n");
- writer.write("};\n");
- parse(writer.toString());
- }
-
- public void testBug39525() throws Exception {
- parse("C &(C::*DD)(const C &x) = &C::operator=;");
- }
-
- public void testBug41935() throws Exception {
- parse("namespace A { int x; } namespace B = A;");
- }
-
- public void testBug39528() throws Exception {
- Writer code = new StringWriter();
- try {
- code.write("struct B: public A {\n");
- code.write(" A a;\n");
- code.write(" B() try : A(1), a(2)\n");
- code.write(" { throw 1; }\n");
- code.write(" catch (...)\n");
- code.write(" { if (c != 3) r |= 1; }\n");
- code.write("};\n");
- } catch (IOException e) {
- }
- parse(code.toString());
- }
-
- public void testBug39538() throws Exception {
- parse("template C::operator int<float> ();");
- }
-
- public void testBug39536() throws Exception {
- Writer writer = new StringWriter();
- writer.write("template<class E>\n");
- writer.write("class X {\n");
- writer.write("X<E>(); // This fails \n");
- writer.write("inline X<E>(int); // This also fails \n");
- writer.write("inline ~X<E>(); // This works fine \n");
- writer.write("};\n");
- parse(writer.toString());
- }
-
- public void testBug39536A() throws Exception {
- parse("template<class E> class X { X<E>(); };");
- }
-
- public void testBug39536B() throws Exception {
- parse("template<class E> class X { inline X<E>(int); };");
- }
-
- public void testBug39542() throws Exception {
- parse("void f(int a, struct {int b[a];} c) {}");
- }
-
- //Here starts C99-specific section
- public void testBug39549() throws Exception {
- parse("struct X x = { .b = 40, .z = { sizeof(X), 42 }, .t[3] = 2, .t.f[3].x = A * B };", true, ParserLanguage.C);
- // with trailing commas
- parse("struct X x = { .b = 40, .z = { sizeof(X), 42,}, .t[3] = 2, .t.f[3].x = A * B ,};", true, ParserLanguage.C);
- }
-
- public void testBug39551A() throws Exception {
- parse("extern float _Complex conjf (float _Complex);", true, ParserLanguage.C);
- }
-
- public void testBug39551B() throws Exception {
- parse("_Imaginary double id = 99.99 * __I__;", true, ParserLanguage.C);
- }
-
- public void testCBool() throws Exception {
- parse("_Bool x;", true, ParserLanguage.C);
- }
-
- public void testBug39678() throws Exception {
- parse("char *s = L\"a\" \"b\";");
- }
-
- public void testBug43110() throws Exception {
- parse("void x(int y, ...);");
- }
-
- // public void testBug44370() throws Exception
- // {
- // parse("#define SWAP(x,y) {x|=y;y|=x;x|=y;}\n");
- // Iterator macros = quickParseCallback.getMacros();
- // assertNotNull(macros);
- // assertTrue(macros.hasNext());
- // IASTMacro swap = (IASTMacro) macros.next();
- // assertFalse(macros.hasNext());
- // assertEquals(swap.getName(), "SWAP");
- // assertEquals(swap.getMacroType(),
- // IMacroDescriptor.MacroType.FUNCTION_LIKE);
- // String[] params = swap.getParameters();
- // assertEquals(params.length, 2);
- // assertEquals(params[0], "x");
- // assertEquals(params[1], "y");
- // String completeSignature = swap.getCompleteSignature().trim();
- // assertEquals(completeSignature, "#define SWAP(x,y) {x|=y;y|=x;x|=y;}");
- //
- // assertEquals(swap.getExpansionSignature().trim(),"{x|=y;y|=x;x|=y;}");
- //
- // IToken[] tokens = swap.getTokenizedExpansion();
- // validateToken(tokens[0], IToken.tLBRACE);
- // validateIdentifier(tokens[1], "x");
- // validateToken(tokens[2], IToken.tBITORASSIGN);
- // validateIdentifier(tokens[3], "y");
- // validateToken(tokens[4], IToken.tSEMI);
- // validateIdentifier(tokens[5], "y");
- // validateToken(tokens[6], IToken.tBITORASSIGN);
- // validateIdentifier(tokens[7], "x");
- // validateToken(tokens[8], IToken.tSEMI);
- // validateIdentifier(tokens[9], "x");
- // validateToken(tokens[10], IToken.tBITORASSIGN);
- // validateIdentifier(tokens[11], "y");
- // validateToken(tokens[12], IToken.tSEMI);
- // validateToken(tokens[13], IToken.tRBRACE);
- // }
- // /**
- // * @param token
- // * @param string
- // */
- // private void validateIdentifier(IToken token, String identifierName) {
- // validateToken(token, IToken.tIDENTIFIER);
- // assertEquals(token.getImage(), identifierName);
- // }
- // /**
- // * @param token
- // * @param i
- // */
- // private void validateToken(IToken token, int signal) {
- // assertEquals(token.getType(), signal);
- // }
-
- public void testBug47752() throws Exception {
- //TODO requires CPPVisitor
- parse("void func(cFoo bar) try { } catch (const char * error){ }");
- }
-
- public void testBug47628() throws Exception {
- Writer writer = new StringWriter();
- writer.write("void h(char) { }\n");
- writer.write("void h(unsigned char) { }\n");
- writer.write("void h(signed char) { } // not shown in outline, parsed as char\n");
- parse(writer.toString());
- }
-
- public void testBug44336() throws Exception {
- parse("class A {}; typedef typename A foo;");
- }
-
- public void testBug39705() throws Exception {
- parse("#ident \"@(#)filename.c 1.3 90/02/12\"");
- }
-
- public void testBug45235() throws Exception {
- parse("class A { friend class B; friend void f(); }; ");
- }
-
- public void testBug59179() throws Exception {
- parse("class __decl main{ int main; };", false);
- }
-
- public void testBug57652() throws Exception {
- parse("struct file_operations driver_fops = { open: device_open, release: device_release };", true, ParserLanguage.C, true);
- }
-
- protected void parse(String code, boolean expectedToPass,
- ParserLanguage lang, boolean gcc) throws Exception {
+ public void _testBug36932B() throws Exception {
+ parse(" p = new int; ");
+ parse(" p = new int(5); ");
+ parse(" p = new int(B); ");
+ parse(" p = new int(B,C); ");
+ parse(" p = new int[5]; ");
+ parse(" p = new int[5][10]; ");
+ parse(" p = new int[B]; ");
+ parse(" p = new int[B][C][D]; ");
+
+ parse(" p = new A; ");
+ parse(" p = new A(5); ");
+ parse(" p = new A(B); ");
+ parse(" p = new A(B,C); ");
+ parse(" p = new A[5]; ");
+ parse(" p = new A[5][10]; ");
+ parse(" p = new A[B]; ");
+ parse(" p = new A[B][C][D]; ");
+
+ parse(" p = new (int); ");
+ parse(" p = new (int)(5); ");
+ parse(" p = new (int)(B); ");
+ parse(" p = new (int)(B,C); ");
+ parse(" p = new (int[5]); ");
+ parse(" p = new (int[5][10]); ");
+ parse(" p = new (int[B]); ");
+ parse(" p = new (int[B][C][D]); ");
+
+ parse(" p = new (A); ");
+ parse(" p = new (A)(5); ");
+ parse(" p = new (A)(B); ");
+ parse(" p = new (A)(B,C); ");
+ parse(" p = new (A[5]); ");
+ parse(" p = new (A[5][10]); ");
+ parse(" p = new (A[B]); ");
+ parse(" p = new (A[B][C][D]); ");
+
+ parse(" p = new (0) int; ");
+ parse(" p = new (0) int(5); ");
+ parse(" p = new (0) int(B); ");
+ parse(" p = new (0) int(B,C); ");
+ parse(" p = new (0) int[5]; ");
+ parse(" p = new (0) int[5][10]; ");
+ parse(" p = new (0) int[B]; ");
+ parse(" p = new (0) int[B][C][D]; ");
+
+ parse(" p = new (0) A; ");
+ parse(" p = new (0) A(5); ");
+ parse(" p = new (0) A(B); ");
+ parse(" p = new (0) A(B,C); ");
+ parse(" p = new (0) A[5]; ");
+ parse(" p = new (0) A[5][10]; ");
+ parse(" p = new (0) A[B]; ");
+ parse(" p = new (0) A[B][C][D]; ");
+
+ parse(" p = new (0) (int); ");
+ parse(" p = new (0) (int)(5); ");
+ parse(" p = new (0) (int)(B); ");
+ parse(" p = new (0) (int)(B,C); ");
+ parse(" p = new (0) (int[5]); ");
+ parse(" p = new (0) (int[5][10]); ");
+ parse(" p = new (0) (int[B]); ");
+ parse(" p = new (0) (int[B][C][D]); ");
+
+ parse(" p = new (0) (A); ");
+ parse(" p = new (0) (A)(5); ");
+ parse(" p = new (0) (A)(B); ");
+ parse(" p = new (0) (A)(B,C); ");
+ parse(" p = new (0) (A[5]); ");
+ parse(" p = new (0) (A[5][10]); ");
+ parse(" p = new (0) (A[B]); ");
+ parse(" p = new (0) (A[B][C][D]); ");
+
+ parse(" p = new (P) int; ");
+ parse(" p = new (P) int(5); ");
+ parse(" p = new (P) int(B); ");
+ parse(" p = new (P) int(B,C); ");
+ parse(" p = new (P) int[5]; ");
+ parse(" p = new (P) int[5][10]; ");
+ parse(" p = new (P) int[B]; ");
+ parse(" p = new (P) int[B][C][D]; ");
+
+ parse(" p = new (P) A; ");
+ parse(" p = new (P) A(5); ");
+ parse(" p = new (P) A(B); ");
+ parse(" p = new (P) A(B,C); ");
+ parse(" p = new (P) A[5]; ");
+ parse(" p = new (P) A[5][10]; ");
+ parse(" p = new (P) A[B]; ");
+ parse(" p = new (P) A[B][C][D]; ");
+
+ parse(" p = new (P) (int); ");
+ parse(" p = new (P) (int)(5); ");
+ parse(" p = new (P) (int)(B); ");
+ parse(" p = new (P) (int)(B,C); ");
+ parse(" p = new (P) (int[5]); ");
+ parse(" p = new (P) (int[5][10]); ");
+ parse(" p = new (P) (int[B]); ");
+ parse(" p = new (P) (int[B][C][D]); ");
+
+ parse(" p = new (P) (A); ");
+ parse(" p = new (P) (A)(5); ");
+ parse(" p = new (P) (A)(B); ");
+ parse(" p = new (P) (A)(B,C); ");
+ parse(" p = new (P) (A[5]); ");
+ parse(" p = new (P) (A[5][10]); ");
+ parse(" p = new (P) (A[B]); ");
+ parse(" p = new (P) (A[B][C][D]); ");
+ }
+
+ public void testBug36769A() throws Exception {
+ parse("template <class A, B> cls<A, C>::operator otherType() const {}\n");
+ parse("template <class A, B> cls<A, C>::cls() {}\n");
+ parse("template <class A, B> cls<A, C>::~cls() {}\n");
+ }
+
+ public void testBug36714() throws Exception {
+ Writer code = new StringWriter();
+ code.write("unsigned long a = 0UL;\n");
+ code.write("unsigned long a2 = 0L; \n");
+ parse(code.toString());
+ }
+
+ public void testBugFunctor758() throws Exception {
+ parse("class Functor {"
+ + "template <typename Fun> Functor(Fun fun) : spImpl_(new FunctorHandler<Functor, Fun>(fun)){}" + "};");
+ }
+
+ public void testBug36932() throws Exception {
+ parse("A::A(): b(new int(5)), b(new B), c(new int) {}");
+ }
+
+ public void testBug36704() throws Exception {
+ Writer code = new StringWriter();
+ code.write("template<typename T, typename U> class Typelist;");
+ code.write("template<typename T> struct Length {};");
+ code.write("template <class T, class U>\n");
+ code.write("struct Length< Typelist<T, U> >\n");
+ code.write("{\n");
+ code.write("enum { value = 1 + Length<U>::value };\n");
+ code.write("};\n");
+ parse(code.toString());
+ }
+
+ public void testBug36699() throws Exception {
+ Writer code = new StringWriter();
+ code.write("template < template <class> class ThreadingModel = DEFAULT_THREADING,\n");
+ code.write("std::size_t chunkSize = DEFAULT_CHUNK_SIZE,\n");
+ code.write("std::size_t maxSmallObjectSize = MAX_SMALL_OBJECT_SIZE >\n");
+ code.write("class SmallObject : public ThreadingModel<\n");
+ code.write("SmallObject<ThreadingModel, chunkSize, maxSmallObjectSize> >\n");
+ code.write("{};\n");
+ parse(code.toString());
+ }
+
+ public void testBug36691() throws Exception {
+ Writer code = new StringWriter();
+ code.write("template <class T, class H>\n");
+ code.write("typename H::template Rebind<T>::Result& Field(H& obj)\n");
+ code.write("{ return obj; }\n");
+ parse(code.toString());
+ }
+
+ public void testBug36702() throws Exception {
+ Writer code = new StringWriter();
+ code.write("void mad_decoder_init(struct mad_decoder *, void *,\n");
+ code.write(" enum mad_flow (*)(void *, struct mad_stream *),\n");
+ code.write(" enum mad_flow (*)(void *, struct mad_header const *),\n");
+ code.write(" enum mad_flow (*)(void *,\n");
+ code.write(" struct mad_stream const *,\n");
+ code.write(" struct mad_frame *),\n");
+ code.write(" enum mad_flow (*)(void *,\n");
+ code.write(" struct mad_header const *,\n");
+ code.write(" struct mad_pcm *),\n");
+ code.write(" enum mad_flow (*)(void *,\n");
+ code.write(" struct mad_stream *,\n");
+ code.write(" struct mad_frame *),\n");
+ code.write(" enum mad_flow (*)(void *, void *, unsigned int *)\n");
+ code.write(");\n");
+
+ parse(code.toString());
+ }
+
+ public void testBug36852() throws Exception {
+ Writer code = new StringWriter();
+ code.write("int CBT::senseToAllRect(double id_standardQuot = DOSE, double id_minToleranz =15.0,\n");
+ code.write("double id_maxToleranz = 15.0, unsigned int iui_minY = 0, \n");
+ code.write("unsigned int iui_maxY = HEIGHT);\n");
+ parse(code.toString());
+ }
+
+ public void testBug36689() throws Exception {
+ Writer code = new StringWriter();
+ code.write("template\n");
+ code.write("<\n");
+ code.write("class AbstractFact,\n");
+ code.write("template <class, class> class Creator = OpNewFactoryUnit,\n");
+ code.write("class TList = typename AbstractFact::ProductList\n");
+ code.write(">\n");
+ code.write("class ConcreteFactory\n");
+ code.write(": public GenLinearHierarchy<\n");
+ code.write("typename TL::Reverse<TList>::Result, Creator, AbstractFact>\n");
+ code.write("{\n");
+ code.write("public:\n");
+ code.write("typedef typename AbstractFact::ProductList ProductList;\n");
+ code.write("typedef TList ConcreteProductList;\n");
+ code.write("};\n");
+ parse(code.toString());
+ }
+
+ public void testBug36707() throws Exception {
+ parse("enum { exists = sizeof(typename H::Small) == sizeof((H::Test(H::MakeT()))) };");
+ }
+
+ public void testBug36717() throws Exception {
+ parse("enum { eA = A::b };");
+ }
+
+ public void testBug36693() throws Exception {
+ parse("FixedAllocator::Chunk* FixedAllocator::VicinityFind(void* p){}");
+ }
+
+ public void testWeirdExpression() throws Exception {
+ parse("int x = rhs.spImpl_.get();");
+ }
+
+ public void testBug36696() throws Exception {
+ Writer code = new StringWriter();
+ code.write("template<typename T> class RefCounted {");
+ code.write("template <typename P1> RefCounted(const RefCounted<P1>& rhs)\n");
+ code.write(": pCount_(reinterpret_cast<const RefCounted&>(rhs).pCount_) {}\n");
+ code.write("};");
+ parse(code.toString());
+ }
+
+ public void testArrayOfPointerToFunctions() throws Exception {
+ parse("unsigned char (*main_data)[MAD_BUFFER_MDLEN];");
+ }
+
+ public void testBug36073() throws Exception {
+ StringWriter writer = new StringWriter();
+ writer.write("class A{\n");
+ writer.write("int x;\n");
+ writer.write("public:\n");
+ writer.write("A(const A&);\n");
+ writer.write("};\n");
+ writer.write("A::A(const A&v) : x(v.x) { }\n");
+ parse(writer.toString());
+ }
+
+ public void testTemplateSpecialization() throws Exception {
+ parse("template<> class stream<char> { /* ... */ };");
+ }
+
+ public void testTemplateInstantiation() throws Exception {
+ parse("template class Array<char>;");
+ }
+
+ /**
+ * Test code: "class A { int floor(double input), someInt; };"
+ */
+ public void testMultipleDeclarators() throws Exception {
+ // Parse and get the translation unit
+ parse("class A { int floor(double input), someInt; };");
+ }
+
+ public void testFunctionModifiers() throws Exception {
+ parse("class A {virtual void foo(void) const throw (yay, nay, we::dont::care) = 0;};");
+ }
+
+ public void testArrays() throws Exception {
+ parse("int x[5][];");
+ }
+
+ public void testElaboratedParms() throws Exception {
+ parse("int x(struct A myA) { /* junk */ }");
+ }
+
+ public void testMemberDeclarations() throws Exception {
+ Writer code = new StringWriter();
+ code.write("class A {\n");
+ code.write("public:\n");
+ code.write(" int is0;\n");
+ code.write("private:\n");
+ code.write(" int is1;\n");
+ code.write("protected:\n");
+ code.write(" int is2;\n");
+ code.write("};");
+ parse(code.toString());
+ }
+
+ public void testPointerOperators() throws Exception {
+ parse("int * x = 0, & y, * const * volatile * z;");
+ }
+
+ public void testBug26467() throws Exception {
+ StringWriter code = new StringWriter();
+ code.write("struct foo { int fooInt; char fooChar; };\n");
+ code.write("typedef struct foo fooStruct;\n");
+ code.write("typedef struct { int anonInt; char anonChar; } anonStruct;\n");
+ parse(code.toString());
+ }
+
+ public void testASMDefinition() throws Exception {
+ parse("asm(\"mov ep1 ds2\");");
+ }
+
+ public void testConstructorChain() throws Exception {
+ //TODO - requires CPPVisitor in order to reduce ambiguities
+ parse("TrafficLight_Actor::TrafficLight_Actor(RTController * rtg_rts, RTActorRef * rtg_ref) : RTActor(rtg_rts, rtg_ref), myId(0) {}");
+ }
+
+ public void testBug36237() throws Exception {
+ parse("A::A():B((char *)0){}");
+ }
+
+ public void testBug36532() throws Exception {
+ try {
+ parse("template<int f() {\n");
+ fail("We should not make it this far");
+ } catch (ParserException pe) {
+ } catch (Exception e) {
+ fail("We should have gotten a ParserException rather than" + e);
+ }
+ }
+
+ public void testPreprocessor() throws Exception {
+ parse("#include <stdio.h>\n#define DEF VALUE\n");
+ }
+
+ public void testTemplateDeclarationOfFunction() throws Exception {
+ parse("template<class A, typename B=C> A aTemplatedFunction(B bInstance);");
+ }
+
+ public void testTemplateDeclarationOfClass() throws Exception {
+ parse("template<class T, typename Tibor = junk, class, typename, int x, float y,template <class Y> class, template<class A> class AClass> class myarray { /* ... */ };");
+ }
+
+ public void testBug35906() throws Exception {
+ StringWriter code = new StringWriter();
+ code.write("void TTest::MTest() {}\n");
+ code.write("struct TTest::STest *TTest::FTest (int i) {}\n");
+ parse(code.toString());
+ }
+
+ public void testBug36288() throws Exception {
+ parse("int foo() {}\nlong foo2(){}");
+ }
+
+ public void testBug36250() throws Exception {
+ parse("int f(int = 0);");
+ }
+
+ public void testBug36240() throws Exception {
+ parse("A & A::operator=(A){}");
+ }
+
+ public void testBug36254() throws Exception {
+ parse("unsigned i;\nvoid f(unsigned p1 = 0);");
+ }
+
+ public void testBug36432() throws Exception {
+ Writer code = new StringWriter();
+ code.write("#define CMD_GET \"g\"\n");
+ code.write("#define CMD_ACTION \"a\"\n");
+ code.write("#define CMD_QUIT \"q\"\n");
+ code.write("static const memevent_cmd_func memevent_cmd_funcs[sizeof memevent_cmds - 1] = {\n");
+ code.write("memevent_get,\n");
+ code.write("memevent_action,\n");
+ code.write("memevent_quit,\n");
+ code.write("};\n");
+ parse(code.toString());
+ }
+
+ public void testBug36594() throws Exception {
+ parse("const int n = sizeof(A) / sizeof(B);");
+ }
+
+ public void testBug36794() throws Exception {
+ parse("template<> class allocator<void> {};");
+ }
+
+ public void testBug36799() throws Exception {
+ parse("static const int __WORD_BIT = int(CHAR_BIT*sizeof(unsigned int));");
+ }
+
+ public void testBug36764() throws Exception {
+ parse("struct{ int x : 4; int y : 8; };");
+ }
+
+ public void testOrder() throws Exception {
+ //TODO - requires CPPVisitor
+ Writer code = new StringWriter();
+ code.write("#define __SGI_STL_INTERNAL_ALGOBASE_H\n");
+ code.write("#include <string.h>\n");
+ code.write("template <class _Tp>\n");
+ code.write("inline void swap(_Tp& __a, _Tp& __b) {\n");
+ code.write("__STL_REQUIRES(_Tp, _Assignable);\n");
+ code.write("_Tp __tmp = __a;\n");
+ code.write("__a = __b;\n");
+ code.write("__b = __tmp;\n");
+ code.write("}\n");
+ parse(code.toString());
+ }
+
+ public void testBug36771() throws Exception {
+ Writer code = new StringWriter();
+ code.write("#include /**/ \"foo.h\"\n");
+
+ parse(code.toString());
+ }
+
+ public void testBug36811() throws Exception {
+ Writer code = new StringWriter();
+ code.write("using namespace std;\n");
+ code.write("class Test {};");
+ parse(code.toString());
+ }
+
+ public void testBug36708() throws Exception {
+ parse("enum { isPointer = PointerTraits<T>::result };");
+ }
+
+ public void testBug36690() throws Exception {
+ parse("class Functor {" + "Functor(const Functor& rhs) : spImpl_(Impl::Clone(rhs.spImpl_.get())){}" + "};");
+ }
+
+ public void testBug36703() throws Exception {
+ parse("const std::type_info& Get() const;");
+ }
+
+ public void testBug36692() throws Exception {
+ Writer code = new StringWriter();
+ code.write("template <typename T, typename Destroyer>\n");
+ code.write("void SetLongevity(T* pDynObject, unsigned int longevity,\n");
+ code.write("Destroyer d = Private::Deleter<T>::Delete){}\n");
+ parse(code.toString());
+ }
+
+ public void testBug36551() throws Exception {
+ Writer code = new StringWriter();
+ code.write("class TextFrame {\n");
+ code.write("BAD_MACRO()\n");
+ code.write("};");
+ parse(code.toString(), false);
+ }
+
+ // public void testBug36247() throws Exception {
+ // Writer code = new StringWriter();
+ // code.write("class A {\n");
+ // code.write("INLINE_DEF int f ();\n");
+ // code.write("INLINE_DEF A g ();");
+ // code.write("INLINE_DEF A * h ();");
+ // code.write("INLINE_DEF A & unlock(void);");
+ // code.write("};");
+ // parse(code.toString());
+ // }
+
+ public void testStruct() throws Exception {
+ StringWriter writer = new StringWriter();
+ writer.write("struct mad_bitptr { unsigned char const *byte;\n");
+ writer.write("unsigned short cache;\n unsigned short left;};");
+ parse(writer.toString());
+ }
+
+ public void testBug36559() throws Exception {
+ Writer code = new StringWriter();
+ code.write("namespace myNameSpace {\n");
+ code.write("template<typename T=short> class B {};\n");
+ code.write("template<> class B<int> {};\n");
+ code.write("}\n");
+ parse(code.toString());
+ }
+
+ public void testPointersToFunctions() throws Exception {
+ Writer code = new StringWriter();
+ code.write("void (*name)(void);\n");
+ code.write("static void * (* const orig_malloc_hook)(const char *file, int line, size_t size);\n");
+
+ parse(code.toString());
+ }
+
+ public void testBug36600() throws Exception {
+ parse("enum mad_flow (*input_func)(void *, struct mad_stream *);");
+ }
+
+ public void testBug36713() throws Exception {
+ Writer code = new StringWriter();
+ code.write("A (* const fPtr) (void *); \n");
+ code.write("A (* const fPtr2) (A *); \n");
+ parse(code.toString());
+ }
+
+ // K&R Test hasn't been ported from DOMTests
+ // still need to figure out how to represent these in the AST
+ // public void testOldKRFunctionDeclarations() throws Exception
+ // {
+ // // Parse and get the translaton unit
+ // Writer code = new StringWriter();
+ // code.write("bool myFunction(parm1, parm2, parm3)\n");
+ // code.write("const char* parm1;\n");
+ // code.write("int (*parm2)(float);\n");
+ // code.write("{}");
+ // TranslationUnit translationUnit = parse(code.toString());
+ //
+ // // Get the declaration
+ // List declarations = translationUnit.getDeclarations();
+ // assertEquals(1, declarations.size());
+ // SimpleDeclaration simpleDeclaration =
+ // (SimpleDeclaration)declarations.get(0);
+ // assertEquals(simpleDeclaration.getDeclSpecifier().getType(),
+ // DeclSpecifier.t_bool);
+ // List declarators = simpleDeclaration.getDeclarators();
+ // assertEquals(1, declarators.size());
+ // Declarator functionDeclarator = (Declarator)declarators.get(0);
+ // assertEquals(functionDeclarator.getName().toString(), "myFunction");
+ //
+ // ParameterDeclarationClause pdc = functionDeclarator.getParms();
+ // assertNotNull(pdc);
+ // List parameterDecls = pdc.getDeclarations();
+ // assertEquals(3, parameterDecls.size());
+ // ParameterDeclaration parm1 = (ParameterDeclaration)parameterDecls.get(0
+ //);
+ // assertNotNull(parm1.getDeclSpecifier().getName());
+ // assertEquals("parm1", parm1.getDeclSpecifier().getName().toString());
+ // List parm1Decls = parm1.getDeclarators();
+ // assertEquals(1, parm1Decls.size());
+ //
+ // ParameterDeclaration parm2 = (ParameterDeclaration)parameterDecls.get(1
+ //);
+ // assertNotNull(parm2.getDeclSpecifier().getName());
+ // assertEquals("parm2", parm2.getDeclSpecifier().getName().toString());
+ // List parm2Decls = parm2.getDeclarators();
+ // assertEquals(1, parm2Decls.size());
+ //
+ // ParameterDeclaration parm3 = (ParameterDeclaration)parameterDecls.get(2
+ //);
+ // assertNotNull(parm3.getDeclSpecifier().getName());
+ // assertEquals("parm3", parm3.getDeclSpecifier().getName().toString());
+ // List parm3Decls = parm3.getDeclarators();
+ // assertEquals(1, parm3Decls.size());
+ //
+ // OldKRParameterDeclarationClause clause = pdc.getOldKRParms();
+ // assertNotNull(clause);
+ // assertEquals(clause.getDeclarations().size(), 2);
+ // SimpleDeclaration decl1 =
+ // (SimpleDeclaration)clause.getDeclarations().get(0);
+ // assertEquals(decl1.getDeclarators().size(), 1);
+ // assertTrue(decl1.getDeclSpecifier().isConst());
+ // assertFalse(decl1.getDeclSpecifier().isVolatile());
+ // assertEquals(decl1.getDeclSpecifier().getType(), DeclSpecifier.t_char);
+ // Declarator declarator1 = (Declarator)decl1.getDeclarators().get(0);
+ // assertEquals(declarator1.getName().toString(), "parm1");
+ // List ptrOps1 = declarator1.getPointerOperators();
+ // assertNotNull(ptrOps1);
+ // assertEquals(1, ptrOps1.size());
+ // PointerOperator po1 = (PointerOperator)ptrOps1.get(0);
+ // assertNotNull(po1);
+ // assertFalse(po1.isConst());
+ // assertFalse(po1.isVolatile());
+ // assertEquals(po1.getType(), PointerOperator.t_pointer);
+ //
+ // SimpleDeclaration declaration =
+ // (SimpleDeclaration)clause.getDeclarations().get(1);
+ // assertEquals(declaration.getDeclSpecifier().getType(),
+ // DeclSpecifier.t_int);
+ // assertEquals(declaration.getDeclarators().size(), 1);
+ // assertNull(((Declarator)declaration.getDeclarators().get(0)).getName()
+ //);
+ // assertNotNull(
+ // ((Declarator)declaration.getDeclarators().get(0)).getDeclarator());
+ // assertEquals(
+ // ((Declarator)declaration.getDeclarators().get(0)).getDeclarator().getName().toString(),
+ // "parm2");
+ // ParameterDeclarationClause clause2 =
+ // ((Declarator)declaration.getDeclarators().get(0)).getParms();
+ // assertEquals(clause2.getDeclarations().size(), 1);
+ // assertEquals(
+ // ((ParameterDeclaration)clause2.getDeclarations().get(0)).getDeclarators().size(),
+ // 1);
+ // assertNull(
+ // ((Declarator)((ParameterDeclaration)clause2.getDeclarations().get(0)).getDeclarators().get(0)).getName()
+ //);
+ // assertEquals(
+ // ((ParameterDeclaration)clause2.getDeclarations().get(0)).getDeclSpecifier().getType(),
+ // DeclSpecifier.t_float);
+ // }
+
+ public void testPointersToMemberFunctions() throws Exception {
+ parse("void (A::*name)(void);");
+ }
+
+ public void testBug39550() throws Exception {
+ parse("double x = 0x1.fp1;");
+ }
+
+ // digraphs/trigraphs have been temporarily remove
+ public void testBug39552A(int x) throws Exception {
+ Writer code = new StringWriter();
+ code.write("%:define glue(x, y) x %:%: y /* #define glue(x, y) x ## y. */\n");
+ code.write("#ifndef glue\n");
+ code.write("#error glue not defined!\n");
+ code.write("#endif\n");
+ code.write("%:define str(x) %:x /* #define str(x) #x */\n");
+ code.write("int main (int argc, char *argv<::>) /* argv[] */\n");
+ code.write("glue (<, %) /* { */\n");
+ code.write(" /* di_str[] = */\n");
+ code.write(" const char di_str glue(<, :)glue(:, >) = str(%:%:<::><%%>%:);\n");
+ code.write(" /* Check the glue macro actually pastes, and that the spelling of\n");
+ code.write(" all digraphs is preserved. */\n");
+ code.write(" if (glue(strc, mp) (di_str, \"%:%:<::><%%>%:\"))\n");
+ code.write(" err (\"Digraph spelling not preserved!\");\n");
+ code.write(" return 0;\n");
+ code.write("glue (%, >) /* } */\n");
+
+ parse(code.toString());
+ }
+
+ // digraphs/trigraphs have been temporarily remove
+ public void testBug39552B(int x) throws Exception {
+ Writer code = new StringWriter();
+
+ code.write("??=include <stdio.h>\n");
+ code.write("??=define TWELVE 1??/\n");
+ code.write("2\n");
+ code.write("static const char str??(??) = \"0123456789??/n\";\n");
+ code.write("int\n");
+ code.write("main(void)\n");
+ code.write("??<\n");
+ code.write(" unsigned char x = 5;\n");
+ code.write(" if (sizeof str != TWELVE)\n");
+ code.write(" abort ();\n");
+ code.write(" /* Test ^=, the only multi-character token to come from trigraphs. */\n");
+ code.write(" x ??'= 3;\n");
+ code.write(" if (x != 6)\n");
+ code.write(" abort ();\n");
+ code.write(" if ((5 ??! 3) != 7)\n");
+ code.write(" abort ();\n");
+ code.write(" return 0;\n");
+ code.write("??>\n");
+
+ parse(code.toString());
+ }
+
+ public void testBug39553() throws Exception {
+ parse("#define COMP_INC \"foobar.h\" \n" + "#include COMP_INC\n"); //$NON-NLS-2$
+ }
+
+ public void testBug39537() throws Exception {
+ parse("typedef foo<(U::id > 0)> foobar;");
+ }
+
+ public void testBug39546() throws Exception {
+ parse("signed char c = (signed char) 0xffffffff;");
+ }
+
+ public void testIndirectDeclarators() throws Exception {
+ parse("void (*x)(int);");
+ }
+
+ public void testBug39532() throws Exception {
+ parse("class N1::N2::B : public A {};");
+ }
+
+ public void testBug39540() throws Exception {
+ parse("class {} const null;");
+ }
+
+ public void testBug39530() throws Exception {
+ parse("X sPassed(-1);");
+ }
+
+ public void testBug39526() throws Exception {
+ parse("UnitList unit_list (String(\"keV\"));");
+ }
+
+ public void testBug39535() throws Exception {
+ parse("namespace bar = foo;");
+ }
+
+ public void testBug39504B() throws Exception {
+ parse("int y = sizeof (int*);");
+ }
+
+ public void testBug39505A() throws Exception {
+ parse("int AD::* gp_down = static_cast<int AD::*>(gp_stat);");
+ }
+
+ public void testBug39505B() throws Exception {
+ parse("int* gp_down = static_cast<int*>(gp_stat);");
+ }
+
+ public void testBug42985() throws Exception {
+ parse("const int x = 4; int y = ::x;");
+ }
+
+ public void testBug40419() throws Exception {
+ Writer code = new StringWriter();
+ try {
+ code.write("template <class T, class U> struct SuperSubclass {\n");
+ code.write("enum { value = (::Loki::Conversion<const volatile U*, const volatile T*>::exists && \n");
+ code.write("!::Loki::Conversion<const volatile T*, const volatile void*>::sameType) }; };");
+ } catch (IOException e) {
+ }
+ parse(code.toString());
+ }
+
+ public void testBug39556() throws Exception {
+ parse("int *restrict ip_fn (void);", true, ParserLanguage.C);
+ }
+
+ /**
+ * Test code: struct Example { Example(); Example(int); ~Example();};
+ * Purpose: tests a declaration in a class scope.
+ */
+ public void testBug43371() throws Exception {
+ // Parse and get the translaton unit
+ Writer code = new StringWriter();
+ code.write("struct Example { Example(); Example(int); ~Example();};");
+ parse(code.toString());
+ }
+
+ public void testBug43644() throws Exception {
+ parse("void foo();{ int x; }", false);
+ }
+
+ public void testBug43062() throws Exception {
+ parse("class X { operator short (); operator int unsigned(); operator int signed(); };");
+ }
+
+ public void testBug39531() throws Exception {
+ parse("class AString { operator char const *() const; };");
+ }
+
+ public void testBug40007() throws Exception {
+ parse("int y = #;", false);
+ }
+
+ public void testBug40759() throws Exception {
+ parse("#define X SomeName \n class X {};");
+ }
+
+ public void testBug44633() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("template <typename T> class A {};\n");
+ writer.write("class B { template <typename T> friend class A;\n");
+ writer.write("void method();\n");
+ writer.write("};\n");
+ parse(writer.toString());
+ }
+
+ public void testBug39525() throws Exception {
+ parse("C &(C::*DD)(const C &x) = &C::operator=;");
+ }
+
+ public void testBug41935() throws Exception {
+ parse("namespace A { int x; } namespace B = A;");
+ }
+
+ public void testBug39528() throws Exception {
+ Writer code = new StringWriter();
+ try {
+ code.write("struct B: public A {\n");
+ code.write(" A a;\n");
+ code.write(" B() try : A(1), a(2)\n");
+ code.write(" { throw 1; }\n");
+ code.write(" catch (...)\n");
+ code.write(" { if (c != 3) r |= 1; }\n");
+ code.write("};\n");
+ } catch (IOException e) {
+ }
+ parse(code.toString());
+ }
+
+ public void testBug39538() throws Exception {
+ parse("template C::operator int<float> ();");
+ }
+
+ public void testBug39536() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("template<class E>\n");
+ writer.write("class X {\n");
+ writer.write("X<E>(); // This fails \n");
+ writer.write("inline X<E>(int); // This also fails \n");
+ writer.write("inline ~X<E>(); // This works fine \n");
+ writer.write("};\n");
+ parse(writer.toString());
+ }
+
+ public void testBug39536A() throws Exception {
+ parse("template<class E> class X { X<E>(); };");
+ }
+
+ public void testBug39536B() throws Exception {
+ parse("template<class E> class X { inline X<E>(int); };");
+ }
+
+ public void testBug39542() throws Exception {
+ parse("void f(int a, struct {int b[a];} c) {}");
+ }
+
+ //Here starts C99-specific section
+ public void testBug39549() throws Exception {
+ parse("struct X x = { .b = 40, .z = { sizeof(X), 42 }, .t[3] = 2, .t.f[3].x = A * B };", true,
+ ParserLanguage.C);
+ // with trailing commas
+ parse("struct X x = { .b = 40, .z = { sizeof(X), 42,}, .t[3] = 2, .t.f[3].x = A * B ,};", true,
+ ParserLanguage.C);
+ }
+
+ public void testBug39551A() throws Exception {
+ parse("extern float _Complex conjf (float _Complex);", true, ParserLanguage.C);
+ }
+
+ public void testBug39551B() throws Exception {
+ parse("_Imaginary double id = 99.99 * __I__;", true, ParserLanguage.C);
+ }
+
+ public void testCBool() throws Exception {
+ parse("_Bool x;", true, ParserLanguage.C);
+ }
+
+ public void testBug39678() throws Exception {
+ parse("char *s = L\"a\" \"b\";");
+ }
+
+ public void testBug43110() throws Exception {
+ parse("void x(int y, ...);");
+ }
+
+ // public void testBug44370() throws Exception
+ // {
+ // parse("#define SWAP(x,y) {x|=y;y|=x;x|=y;}\n");
+ // Iterator macros = quickParseCallback.getMacros();
+ // assertNotNull(macros);
+ // assertTrue(macros.hasNext());
+ // IASTMacro swap = (IASTMacro) macros.next();
+ // assertFalse(macros.hasNext());
+ // assertEquals(swap.getName(), "SWAP");
+ // assertEquals(swap.getMacroType(),
+ // IMacroDescriptor.MacroType.FUNCTION_LIKE);
+ // String[] params = swap.getParameters();
+ // assertEquals(params.length, 2);
+ // assertEquals(params[0], "x");
+ // assertEquals(params[1], "y");
+ // String completeSignature = swap.getCompleteSignature().trim();
+ // assertEquals(completeSignature, "#define SWAP(x,y) {x|=y;y|=x;x|=y;}");
+ //
+ // assertEquals(swap.getExpansionSignature().trim(),"{x|=y;y|=x;x|=y;}");
+ //
+ // IToken[] tokens = swap.getTokenizedExpansion();
+ // validateToken(tokens[0], IToken.tLBRACE);
+ // validateIdentifier(tokens[1], "x");
+ // validateToken(tokens[2], IToken.tBITORASSIGN);
+ // validateIdentifier(tokens[3], "y");
+ // validateToken(tokens[4], IToken.tSEMI);
+ // validateIdentifier(tokens[5], "y");
+ // validateToken(tokens[6], IToken.tBITORASSIGN);
+ // validateIdentifier(tokens[7], "x");
+ // validateToken(tokens[8], IToken.tSEMI);
+ // validateIdentifier(tokens[9], "x");
+ // validateToken(tokens[10], IToken.tBITORASSIGN);
+ // validateIdentifier(tokens[11], "y");
+ // validateToken(tokens[12], IToken.tSEMI);
+ // validateToken(tokens[13], IToken.tRBRACE);
+ // }
+ // /**
+ // * @param token
+ // * @param string
+ // */
+ // private void validateIdentifier(IToken token, String identifierName) {
+ // validateToken(token, IToken.tIDENTIFIER);
+ // assertEquals(token.getImage(), identifierName);
+ // }
+ // /**
+ // * @param token
+ // * @param i
+ // */
+ // private void validateToken(IToken token, int signal) {
+ // assertEquals(token.getType(), signal);
+ // }
+
+ public void testBug47752() throws Exception {
+ //TODO requires CPPVisitor
+ parse("void func(cFoo bar) try { } catch (const char * error){ }");
+ }
+
+ public void testBug47628() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("void h(char) { }\n");
+ writer.write("void h(unsigned char) { }\n");
+ writer.write("void h(signed char) { } // not shown in outline, parsed as char\n");
+ parse(writer.toString());
+ }
+
+ public void testBug44336() throws Exception {
+ parse("class A {}; typedef typename A foo;");
+ }
+
+ public void testBug39705() throws Exception {
+ parse("#ident \"@(#)filename.c 1.3 90/02/12\"");
+ }
+
+ public void testBug45235() throws Exception {
+ parse("class A { friend class B; friend void f(); }; ");
+ }
+
+ public void testBug59179() throws Exception {
+ parse("class __decl main{ int main; };", false);
+ }
+
+ public void testBug57652() throws Exception {
+ parse("struct file_operations driver_fops = { open: device_open, release: device_release };", true,
+ ParserLanguage.C, true);
+ }
+
+ protected void parse(String code, boolean expectedToPass, ParserLanguage lang, boolean gcc) throws Exception {
FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
- IScannerInfo scannerInfo = new ScannerInfo();
- IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
- ISourceCodeParser parser2 = null;
- if (lang == ParserLanguage.CPP) {
- ICPPParserExtensionConfiguration config = null;
- if (gcc)
- config = new GPPParserExtensionConfiguration();
- else
- config = new ANSICPPParserExtensionConfiguration();
- parser2 = new GNUCPPSourceParser(scanner, ParserMode.QUICK_PARSE, NULL_LOG, config);
- } else {
- ICParserExtensionConfiguration config = null;
- if (gcc)
- config = new GCCParserExtensionConfiguration();
- else
- config = new ANSICParserExtensionConfiguration();
-
- parser2 = new GNUCSourceParser(scanner, ParserMode.QUICK_PARSE, NULL_LOG, config);
- }
- IASTTranslationUnit tu = parser2.parse();
- if (parser2.encounteredError() && expectedToPass)
- throw new ParserException("FAILURE");
- if (expectedToPass) {
- if (lang == ParserLanguage.C) {
- IASTProblem[] problems = CVisitor.getProblems(tu);
- assertEquals(problems.length, 0);
- } else if (lang == ParserLanguage.CPP) {
- IASTProblem[] problems = CPPVisitor.getProblems(tu);
- assertEquals(problems.length, 0);
- }
- }
- }
-
- public void testBug60142() throws Exception {
- parse("unsigned long var;");
- }
-
- public void testBug61431() throws Exception {
- for (int i = 0; i < 2; ++i) {
- ParserLanguage language = (i == 0) ? ParserLanguage.C : ParserLanguage.CPP;
- parse("int k[][] = { {0, {1}, {2,3}};", false, language);
- }
- }
-
- public void testBadIdentifier() throws Exception {
- parse("class 0302 { private: int stinks; };", false);
- }
-
- public void testBug67622() throws Exception {
- parse("const char * x = __FILE__;");
- }
-
- public void testBug68116() throws Exception {
- StringBuilder buffer = new StringBuilder("char dummy[] = \"0123456789");
- for (int i = 0; i < 5000; ++i)
- buffer.append("0123456789");
- buffer.append("\";");
- parse(buffer.toString());
- }
-
- public void testBug69161() throws Exception {
- Writer writer = new StringWriter();
- writer.write("#define MACRO(s) s\n ");
- writer.write("char *testQueries[] =\n");
- writer.write("{\n");
- writer.write("MACRO(\",\"),\n");
- writer.write("MACRO(\"(\"),\n");
- writer.write("MACRO(\")\")\n");
- writer.write("};\n");
- parse(writer.toString());
- }
-
- public void testBug73524() throws Exception {
- Writer writer = new StringWriter();
- writer.write("static char fmt_1002[] = \"(/,\\002At iterate\\002,i5,4x,\\002f= \\002,1p,d12\\\r\n");
- writer.write(".5,4x,\\002|proj g|= \\002,1p,d12.5)\";");
- parse(writer.toString(), true, ParserLanguage.C);
- }
-
- public void testBug39694() throws Exception {
- parse("int ab$cd = 1;");
- }
-
- public void testBug39704A() throws Exception {
- StringWriter writer = new StringWriter();
- writer.write("#define __declspec(x) __attribute__((x))");
- writer.write("__declspec (dllimport) int foo;");
- parse(writer.toString());
- }
-
- public void testBug39704D() throws Exception {
- StringWriter writer = new StringWriter();
- writer.write("#define __declspec(x) __attribute__((x))");
- writer.write("__declspec(dllexport) int func1 (int a) {}");
- parse(writer.toString());
- }
-
- public void testBug39695() throws Exception {
- parse("int a = __alignof__ (int);", true, ParserLanguage.CPP, true);
- }
-
- public void testBug39684() throws Exception {
- parse("typeof(foo(1)) bar () { return foo(1); }", true, ParserLanguage.CPP, true);
- }
-
- public void testBug39703() throws Exception {
- Writer code = new StringWriter();
- code.write("/* __extension__ enables GNU C mode for the duration of the declaration. */\n");
- code.write("__extension__ struct G {\n");
- code.write(" struct { char z; };\n");
- code.write(" char g;\n");
- code.write("};\n");
- parse(code.toString(), true, ParserLanguage.CPP, true);
- }
-
- public void testBug39698A() throws Exception {
- parse("int c = a <? b;", true, ParserLanguage.CPP, true);
- }
-
- public void testBug39698B() throws Exception {
- parse("int c = a >? b;", true, ParserLanguage.CPP, true);
- }
-
- public void testBug39554() throws Exception {
- parse("_Pragma(\"foobar\")", true, ParserLanguage.C);
- }
-
- public void testBug39704B() throws Exception {
- parse("extern int (* import) (void) __attribute__((dllimport));", true, ParserLanguage.CPP, true);
- }
-
- public void testBug39704C() throws Exception {
- parse("int func2 (void) __attribute__((dllexport));", true, ParserLanguage.CPP, true);
- }
-
- public void testBug39686() throws Exception {
- Writer code = new StringWriter();
- code.write("__complex__ double x; // complex double\n");
- code.write("__complex__ short int a; // complex short int\n");
- code.write("__complex__ float y = 2.5fi; // 2.5 imaginary float literal\n");
- code.write("__complex__ int a = 3i; // imaginary intege r literal\n");
- code.write("double v = __real__ x; // real part of expression\n");
- code.write("double w = __imag__ x; // imaginary part of expression\n");
- parse(code.toString(), true, ParserLanguage.C, true);
- }
-
- public void testBug39681() throws Exception {
- Writer code = new StringWriter();
- code.write("double\n");
- code.write("foo (double a, double b)\n");
- code.write("{\n");
- code.write(" double square (double z) { return z * z; }\n");
- code.write(" return square (a) + square (b);\n");
- code.write("}\n");
- parse(code.toString());
- }
-
- public void testBug39677() throws Exception {
- parse("B::B() : a(({ 1; })) {}", true, ParserLanguage.CPP, true);
- Writer writer = new StringWriter();
- writer.write("B::B() : a(({ int y = foo (); int z;\n");
- writer.write("if (y > 0) z = y;\n");
- writer.write("else z = - y;\n");
- writer.write("z; })) {}\n");
- parse(writer.toString(), true, ParserLanguage.CPP, true);
- writer = new StringWriter();
- writer.write("int x = ({ int y = foo (); int z;\n");
- writer.write("if (y > 0) z = y;\n");
- writer.write("else z = - y;\n");
- writer.write("z; });\n");
- parse(writer.toString(), true, ParserLanguage.CPP, true);
- writer = new StringWriter();
- writer.write("typeof({ int y = foo (); int z;\n");
- writer.write("if (y > 0) z = y;\n");
- writer.write("else z = - y;\n");
- writer.write("z; }) zoot;\n");
- parse(writer.toString(), true, ParserLanguage.CPP, true);
- }
-
- public void testBug39701A() throws Exception {
- parse("extern template int max (int, int);", true, ParserLanguage.CPP, true);
- }
-
- public void testBug39701B() throws Exception {
- parse("inline template class Foo<int>;", true, ParserLanguage.CPP, true);
- }
-
- public void testBug39701C() throws Exception {
- parse("static template class Foo<int>;", true, ParserLanguage.CPP, true);
- }
+ IScannerInfo scannerInfo = new ScannerInfo();
+ IScanner scanner = AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
+ ISourceCodeParser parser2 = null;
+ if (lang == ParserLanguage.CPP) {
+ ICPPParserExtensionConfiguration config = null;
+ if (gcc)
+ config = new GPPParserExtensionConfiguration();
+ else
+ config = new ANSICPPParserExtensionConfiguration();
+ parser2 = new GNUCPPSourceParser(scanner, ParserMode.QUICK_PARSE, NULL_LOG, config);
+ } else {
+ ICParserExtensionConfiguration config = null;
+ if (gcc)
+ config = new GCCParserExtensionConfiguration();
+ else
+ config = new ANSICParserExtensionConfiguration();
+
+ parser2 = new GNUCSourceParser(scanner, ParserMode.QUICK_PARSE, NULL_LOG, config);
+ }
+ IASTTranslationUnit tu = parser2.parse();
+ if (parser2.encounteredError() && expectedToPass)
+ throw new ParserException("FAILURE");
+ if (expectedToPass) {
+ if (lang == ParserLanguage.C) {
+ IASTProblem[] problems = CVisitor.getProblems(tu);
+ assertEquals(problems.length, 0);
+ } else if (lang == ParserLanguage.CPP) {
+ IASTProblem[] problems = CPPVisitor.getProblems(tu);
+ assertEquals(problems.length, 0);
+ }
+ }
+ }
+
+ public void testBug60142() throws Exception {
+ parse("unsigned long var;");
+ }
+
+ public void testBug61431() throws Exception {
+ for (int i = 0; i < 2; ++i) {
+ ParserLanguage language = (i == 0) ? ParserLanguage.C : ParserLanguage.CPP;
+ parse("int k[][] = { {0, {1}, {2,3}};", false, language);
+ }
+ }
+
+ public void testBadIdentifier() throws Exception {
+ parse("class 0302 { private: int stinks; };", false);
+ }
+
+ public void testBug67622() throws Exception {
+ parse("const char * x = __FILE__;");
+ }
+
+ public void testBug68116() throws Exception {
+ StringBuilder buffer = new StringBuilder("char dummy[] = \"0123456789");
+ for (int i = 0; i < 5000; ++i)
+ buffer.append("0123456789");
+ buffer.append("\";");
+ parse(buffer.toString());
+ }
+
+ public void testBug69161() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("#define MACRO(s) s\n ");
+ writer.write("char *testQueries[] =\n");
+ writer.write("{\n");
+ writer.write("MACRO(\",\"),\n");
+ writer.write("MACRO(\"(\"),\n");
+ writer.write("MACRO(\")\")\n");
+ writer.write("};\n");
+ parse(writer.toString());
+ }
+
+ public void testBug73524() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("static char fmt_1002[] = \"(/,\\002At iterate\\002,i5,4x,\\002f= \\002,1p,d12\\\r\n");
+ writer.write(".5,4x,\\002|proj g|= \\002,1p,d12.5)\";");
+ parse(writer.toString(), true, ParserLanguage.C);
+ }
+
+ public void testBug39694() throws Exception {
+ parse("int ab$cd = 1;");
+ }
+
+ public void testBug39704A() throws Exception {
+ StringWriter writer = new StringWriter();
+ writer.write("#define __declspec(x) __attribute__((x))");
+ writer.write("__declspec (dllimport) int foo;");
+ parse(writer.toString());
+ }
+
+ public void testBug39704D() throws Exception {
+ StringWriter writer = new StringWriter();
+ writer.write("#define __declspec(x) __attribute__((x))");
+ writer.write("__declspec(dllexport) int func1 (int a) {}");
+ parse(writer.toString());
+ }
+
+ public void testBug39695() throws Exception {
+ parse("int a = __alignof__ (int);", true, ParserLanguage.CPP, true);
+ }
+
+ public void testBug39684() throws Exception {
+ parse("typeof(foo(1)) bar () { return foo(1); }", true, ParserLanguage.CPP, true);
+ }
+
+ public void testBug39703() throws Exception {
+ Writer code = new StringWriter();
+ code.write("/* __extension__ enables GNU C mode for the duration of the declaration. */\n");
+ code.write("__extension__ struct G {\n");
+ code.write(" struct { char z; };\n");
+ code.write(" char g;\n");
+ code.write("};\n");
+ parse(code.toString(), true, ParserLanguage.CPP, true);
+ }
+
+ public void testBug39698A() throws Exception {
+ parse("int c = a <? b;", true, ParserLanguage.CPP, true);
+ }
+
+ public void testBug39698B() throws Exception {
+ parse("int c = a >? b;", true, ParserLanguage.CPP, true);
+ }
+
+ public void testBug39554() throws Exception {
+ parse("_Pragma(\"foobar\")", true, ParserLanguage.C);
+ }
+
+ public void testBug39704B() throws Exception {
+ parse("extern int (* import) (void) __attribute__((dllimport));", true, ParserLanguage.CPP, true);
+ }
+
+ public void testBug39704C() throws Exception {
+ parse("int func2 (void) __attribute__((dllexport));", true, ParserLanguage.CPP, true);
+ }
+
+ public void testBug39686() throws Exception {
+ Writer code = new StringWriter();
+ code.write("__complex__ double x; // complex double\n");
+ code.write("__complex__ short int a; // complex short int\n");
+ code.write("__complex__ float y = 2.5fi; // 2.5 imaginary float literal\n");
+ code.write("__complex__ int a = 3i; // imaginary intege r literal\n");
+ code.write("double v = __real__ x; // real part of expression\n");
+ code.write("double w = __imag__ x; // imaginary part of expression\n");
+ parse(code.toString(), true, ParserLanguage.C, true);
+ }
+
+ public void testBug39681() throws Exception {
+ Writer code = new StringWriter();
+ code.write("double\n");
+ code.write("foo (double a, double b)\n");
+ code.write("{\n");
+ code.write(" double square (double z) { return z * z; }\n");
+ code.write(" return square (a) + square (b);\n");
+ code.write("}\n");
+ parse(code.toString());
+ }
+
+ public void testBug39677() throws Exception {
+ parse("B::B() : a(({ 1; })) {}", true, ParserLanguage.CPP, true);
+ Writer writer = new StringWriter();
+ writer.write("B::B() : a(({ int y = foo (); int z;\n");
+ writer.write("if (y > 0) z = y;\n");
+ writer.write("else z = - y;\n");
+ writer.write("z; })) {}\n");
+ parse(writer.toString(), true, ParserLanguage.CPP, true);
+ writer = new StringWriter();
+ writer.write("int x = ({ int y = foo (); int z;\n");
+ writer.write("if (y > 0) z = y;\n");
+ writer.write("else z = - y;\n");
+ writer.write("z; });\n");
+ parse(writer.toString(), true, ParserLanguage.CPP, true);
+ writer = new StringWriter();
+ writer.write("typeof({ int y = foo (); int z;\n");
+ writer.write("if (y > 0) z = y;\n");
+ writer.write("else z = - y;\n");
+ writer.write("z; }) zoot;\n");
+ parse(writer.toString(), true, ParserLanguage.CPP, true);
+ }
+
+ public void testBug39701A() throws Exception {
+ parse("extern template int max (int, int);", true, ParserLanguage.CPP, true);
+ }
+
+ public void testBug39701B() throws Exception {
+ parse("inline template class Foo<int>;", true, ParserLanguage.CPP, true);
+ }
+
+ public void testBug39701C() throws Exception {
+ parse("static template class Foo<int>;", true, ParserLanguage.CPP, true);
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticTestBase.java
index f2cad1b1f41..3cd2404c478 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticTestBase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticTestBase.java
@@ -46,71 +46,74 @@ public class SemanticTestBase extends BaseTestCase {
public SemanticTestBase() {
super();
}
+
public SemanticTestBase(String name) {
super(name);
}
-
- protected static class CommonCTypes {
- public static IType pointerToVoid = pointerTo(CBasicType.VOID);
- public static IType pointerToConstVoid = pointerTo(constOf(CBasicType.VOID));
- public static IType pointerToInt = pointerTo(CBasicType.INT);
- public static IType pointerToConstInt = pointerTo(constOf(CBasicType.INT));
- public static IType pointerToVolatileInt = pointerTo(volatileOf(CBasicType.INT));
- public static IType pointerToConstVolatileInt = pointerTo(constVolatileOf(CBasicType.INT));
-
- private static IType pointerTo(IType type) {
- return new CPointerType(type, 0);
- }
- private static IType constOf(IType type) {
- return new CQualifierType(type, true, false, false);
- }
- private static IType volatileOf(IType type) {
- return new CQualifierType(type, false, true, false);
- }
- private static IType constVolatileOf(IType type) {
- return new CQualifierType(type, true, true, false);
- }
- }
-
- protected static class CommonCPPTypes {
- public static IType char_ = CPPBasicType.CHAR;
- public static IType int_ = CPPBasicType.INT;
- public static IType void_ = CPPBasicType.VOID;
- public static IType constChar = constOf(char_);
- public static IType constInt = constOf(int_);
- public static IType pointerToInt = pointerTo(int_);
- public static IType pointerToConstChar = pointerTo(constChar);
- public static IType pointerToConstInt = pointerTo(constInt);
- public static IType referenceToInt = referenceTo(int_);
- public static IType referenceToConstInt = referenceTo(constInt);
- public static IType rvalueReferenceToInt = rvalueReferenceTo(int_);
- public static IType rvalueReferenceToConstInt = rvalueReferenceTo(constInt);
-
- private static IType pointerTo(IType type) {
- return new CPPPointerType(type);
- }
-
- private static IType constOf(IType type) {
- return new CPPQualifierType(type, true, false);
- }
-
- private static IType referenceTo(IType type) {
- return new CPPReferenceType(type, false);
- }
-
- private static IType rvalueReferenceTo(IType type) {
- return new CPPReferenceType(type, true);
- }
- }
-
+
+ protected static class CommonCTypes {
+ public static IType pointerToVoid = pointerTo(CBasicType.VOID);
+ public static IType pointerToConstVoid = pointerTo(constOf(CBasicType.VOID));
+ public static IType pointerToInt = pointerTo(CBasicType.INT);
+ public static IType pointerToConstInt = pointerTo(constOf(CBasicType.INT));
+ public static IType pointerToVolatileInt = pointerTo(volatileOf(CBasicType.INT));
+ public static IType pointerToConstVolatileInt = pointerTo(constVolatileOf(CBasicType.INT));
+
+ private static IType pointerTo(IType type) {
+ return new CPointerType(type, 0);
+ }
+
+ private static IType constOf(IType type) {
+ return new CQualifierType(type, true, false, false);
+ }
+
+ private static IType volatileOf(IType type) {
+ return new CQualifierType(type, false, true, false);
+ }
+
+ private static IType constVolatileOf(IType type) {
+ return new CQualifierType(type, true, true, false);
+ }
+ }
+
+ protected static class CommonCPPTypes {
+ public static IType char_ = CPPBasicType.CHAR;
+ public static IType int_ = CPPBasicType.INT;
+ public static IType void_ = CPPBasicType.VOID;
+ public static IType constChar = constOf(char_);
+ public static IType constInt = constOf(int_);
+ public static IType pointerToInt = pointerTo(int_);
+ public static IType pointerToConstChar = pointerTo(constChar);
+ public static IType pointerToConstInt = pointerTo(constInt);
+ public static IType referenceToInt = referenceTo(int_);
+ public static IType referenceToConstInt = referenceTo(constInt);
+ public static IType rvalueReferenceToInt = rvalueReferenceTo(int_);
+ public static IType rvalueReferenceToConstInt = rvalueReferenceTo(constInt);
+
+ private static IType pointerTo(IType type) {
+ return new CPPPointerType(type);
+ }
+
+ private static IType constOf(IType type) {
+ return new CPPQualifierType(type, true, false);
+ }
+
+ private static IType referenceTo(IType type) {
+ return new CPPReferenceType(type, false);
+ }
+
+ private static IType rvalueReferenceTo(IType type) {
+ return new CPPReferenceType(type, true);
+ }
+ }
+
protected static void assertSameType(IType expected, IType actual) {
assertNotNull(expected);
assertNotNull(actual);
- assertTrue("Expected same types, but the types were: '" +
- ASTTypeUtil.getType(expected, false) + "' and '" + ASTTypeUtil.getType(actual, false) + "'",
- expected.isSameType(actual));
+ assertTrue("Expected same types, but the types were: '" + ASTTypeUtil.getType(expected, false) + "' and '"
+ + ASTTypeUtil.getType(actual, false) + "'", expected.isSameType(actual));
}
-
+
protected static SizeAndAlignment getSizeAndAlignment(IType type, IASTNode lookupPoint) {
try {
CPPSemantics.pushLookupPoint(lookupPoint);
@@ -124,71 +127,71 @@ public class SemanticTestBase extends BaseTestCase {
protected String contents;
protected IASTTranslationUnit tu;
- public BindingAssertionHelper(String contents, IASTTranslationUnit tu) {
- this.contents = contents;
- this.tu = tu;
+ public BindingAssertionHelper(String contents, IASTTranslationUnit tu) {
+ this.contents = contents;
+ this.tu = tu;
}
- public IASTTranslationUnit getTranslationUnit() {
- return tu;
- }
+ public IASTTranslationUnit getTranslationUnit() {
+ return tu;
+ }
public IProblemBinding assertProblem(String section, int len) {
- if (len <= 0)
- len= section.length() + len;
- IBinding binding= binding(section, len);
- assertTrue("Non-ProblemBinding for name: " + section.substring(0, len),
- binding instanceof IProblemBinding);
- return (IProblemBinding) binding;
- }
-
- public IProblemBinding assertProblem(String context, int len, int problemId) {
- IProblemBinding problemBinding = assertProblem(context, len);
- assertEquals(problemId, problemBinding.getID());
- return problemBinding;
- }
-
- public IProblemBinding assertProblem(String context, String name) {
- IBinding binding= binding(context, name);
- assertTrue("Non-ProblemBinding for name: " + name, binding instanceof IProblemBinding);
- return (IProblemBinding) binding;
- }
-
- public IProblemBinding assertProblem(String context, String name, int problemId) {
- IProblemBinding problemBinding = assertProblem(context, name);
- assertEquals(problemId, problemBinding.getID());
- return problemBinding;
- }
-
- public <T extends IBinding> T assertNonProblem(String section, int len) {
- if (len <= 0)
- len= section.length() + len;
- IBinding binding= binding(section, len);
- if (binding instanceof IProblemBinding) {
- IProblemBinding problem= (IProblemBinding) binding;
- fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID()) + ")");
- }
- if (binding == null) {
- fail("Null binding resolved for name: " + section.substring(0, len));
- }
- return (T) binding;
- }
-
- private int getIdentifierOffset(String str) {
- for (int i = 0; i < str.length(); ++i) {
- if (Character.isJavaIdentifierPart(str.charAt(i)))
- return i;
- }
- fail("Didn't find identifier in \"" + str + "\"");
- return -1;
- }
-
- private int getIdentifierLength(String str, int offset) {
- int i;
- for (i = offset; i < str.length() && Character.isJavaIdentifierPart(str.charAt(i)); ++i) {
- }
- return i;
- }
+ if (len <= 0)
+ len = section.length() + len;
+ IBinding binding = binding(section, len);
+ assertTrue("Non-ProblemBinding for name: " + section.substring(0, len), binding instanceof IProblemBinding);
+ return (IProblemBinding) binding;
+ }
+
+ public IProblemBinding assertProblem(String context, int len, int problemId) {
+ IProblemBinding problemBinding = assertProblem(context, len);
+ assertEquals(problemId, problemBinding.getID());
+ return problemBinding;
+ }
+
+ public IProblemBinding assertProblem(String context, String name) {
+ IBinding binding = binding(context, name);
+ assertTrue("Non-ProblemBinding for name: " + name, binding instanceof IProblemBinding);
+ return (IProblemBinding) binding;
+ }
+
+ public IProblemBinding assertProblem(String context, String name, int problemId) {
+ IProblemBinding problemBinding = assertProblem(context, name);
+ assertEquals(problemId, problemBinding.getID());
+ return problemBinding;
+ }
+
+ public <T extends IBinding> T assertNonProblem(String section, int len) {
+ if (len <= 0)
+ len = section.length() + len;
+ IBinding binding = binding(section, len);
+ if (binding instanceof IProblemBinding) {
+ IProblemBinding problem = (IProblemBinding) binding;
+ fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID())
+ + ")");
+ }
+ if (binding == null) {
+ fail("Null binding resolved for name: " + section.substring(0, len));
+ }
+ return (T) binding;
+ }
+
+ private int getIdentifierOffset(String str) {
+ for (int i = 0; i < str.length(); ++i) {
+ if (Character.isJavaIdentifierPart(str.charAt(i)))
+ return i;
+ }
+ fail("Didn't find identifier in \"" + str + "\"");
+ return -1;
+ }
+
+ private int getIdentifierLength(String str, int offset) {
+ int i;
+ for (i = offset; i < str.length() && Character.isJavaIdentifierPart(str.charAt(i)); ++i) {
+ }
+ return i;
+ }
public IProblemBinding assertProblemOnFirstIdentifier(String section) {
int offset = getIdentifierOffset(section);
@@ -209,20 +212,20 @@ public class SemanticTestBase extends BaseTestCase {
}
public void assertNoName(String section, int len) {
- IASTName name= findName(section, len);
+ IASTName name = findName(section, len);
if (name != null) {
String selection = section.substring(0, len);
fail("Found unexpected \"" + selection + "\": " + name.resolveBinding());
}
- }
-
- /**
- * Asserts that there is exactly one name at the given location and that
- * it resolves to the given type of binding.
- */
- public IASTImplicitName assertImplicitName(String section, int len, Class<?> bindingClass) {
- IASTName name = findImplicitName(section, len);
- final String selection = section.substring(0, len);
+ }
+
+ /**
+ * Asserts that there is exactly one name at the given location and that
+ * it resolves to the given type of binding.
+ */
+ public IASTImplicitName assertImplicitName(String section, int len, Class<?> bindingClass) {
+ IASTName name = findImplicitName(section, len);
+ final String selection = section.substring(0, len);
assertNotNull("Did not find \"" + selection + "\"", name);
assertInstance(name, IASTImplicitName.class);
@@ -241,171 +244,170 @@ public class SemanticTestBase extends BaseTestCase {
assertTrue(found);
}
- assertEquals(selection, name.getRawSignature());
- IBinding binding = name.resolveBinding();
- assertNotNull(binding);
- assertInstance(binding, bindingClass);
- return (IASTImplicitName) name;
- }
-
- public void assertNoImplicitName(String section, int len) {
- IASTName name = findImplicitName(section, len);
- final String selection = section.substring(0, len);
- assertNull("found name \"" + selection + "\"", name);
- }
-
- public IASTImplicitName[] getImplicitNames(String section) {
- return getImplicitNames(section, section.length());
- }
-
- public IASTImplicitName[] getImplicitNames(String section, int len) {
- IASTName name = findImplicitName(section, len);
- IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
+ assertEquals(selection, name.getRawSignature());
+ IBinding binding = name.resolveBinding();
+ assertNotNull(binding);
+ assertInstance(binding, bindingClass);
+ return (IASTImplicitName) name;
+ }
+
+ public void assertNoImplicitName(String section, int len) {
+ IASTName name = findImplicitName(section, len);
+ final String selection = section.substring(0, len);
+ assertNull("found name \"" + selection + "\"", name);
+ }
+
+ public IASTImplicitName[] getImplicitNames(String section) {
+ return getImplicitNames(section, section.length());
+ }
+
+ public IASTImplicitName[] getImplicitNames(String section, int len) {
+ IASTName name = findImplicitName(section, len);
+ IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
IASTImplicitName[] implicits = owner.getImplicitNames();
return implicits;
- }
-
- public IASTImplicitDestructorName[] getImplicitDestructorNames(String section) {
- return getImplicitDestructorNames(section, section.length());
- }
-
- public IASTImplicitDestructorName[] getImplicitDestructorNames(String section, int len) {
- final int offset = contents.indexOf(section);
- assertTrue(offset >= 0);
- IASTNodeSelector selector = tu.getNodeSelector(null);
- IASTNode enclosingNode = selector.findEnclosingNode(offset, len);
- if (!(enclosingNode instanceof IASTImplicitDestructorNameOwner))
- return IASTImplicitDestructorName.EMPTY_NAME_ARRAY;
- return ((IASTImplicitDestructorNameOwner) enclosingNode).getImplicitDestructorNames();
- }
-
- public IASTName findName(String section, int len) {
- final int offset = contents.indexOf(section);
- assertTrue("Section \"" + section + "\" not found", offset >= 0);
- IASTNodeSelector selector = tu.getNodeSelector(null);
- return selector.findName(offset, len);
- }
-
- public IASTName findName(String context, String name) {
- if (context == null) {
- context = contents;
- }
- int offset = contents.indexOf(context);
- assertTrue("Context \"" + context + "\" not found", offset >= 0);
- int nameOffset = context.indexOf(name);
- assertTrue("Name \"" + name + "\" not found", nameOffset >= 0);
- IASTNodeSelector selector = tu.getNodeSelector(null);
- return selector.findName(offset + nameOffset, name.length());
- }
-
- public IASTName findName(String name) {
- return findName(contents, name);
- }
-
- public IASTImplicitName findImplicitName(String section, int len) {
- final int offset = contents.indexOf(section);
- assertTrue(offset >= 0);
- IASTNodeSelector selector = tu.getNodeSelector(null);
- return selector.findImplicitName(offset, len);
- }
-
- public <T extends IASTNode> T assertNode(String context, String nodeText, Class... cs) {
- if (context == null) {
- context = contents;
- }
- int offset = contents.indexOf(context);
- assertTrue("Context \"" + context + "\" not found", offset >= 0);
- int nodeOffset = context.indexOf(nodeText);
- assertTrue("Node \"" + nodeText + "\" not found", nodeOffset >= 0);
- IASTNodeSelector selector = tu.getNodeSelector(null);
- IASTNode node = selector.findNode(offset + nodeOffset, nodeText.length());
- return assertType(node, cs);
- }
-
- public <T extends IASTNode> T assertNode(String nodeText, Class... cs) {
- return assertNode(contents, nodeText, cs);
- }
-
- private String renderProblemID(int i) {
- try {
- for (Field field : IProblemBinding.class.getDeclaredFields()) {
- if (field.getName().startsWith("SEMANTIC_")) {
- if (field.getType() == int.class) {
- Integer ci= (Integer) field.get(null);
- if (ci.intValue() == i) {
- return field.getName();
- }
- }
- }
- }
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- return "Unknown problem ID";
- }
-
- public <T extends IBinding> T assertNonProblem(String section, int len, Class... cs) {
- if (len <= 0)
- len += section.length();
- IBinding binding= binding(section, len);
- assertTrue("ProblemBinding for name: " + section.substring(0, len),
- !(binding instanceof IProblemBinding));
- return assertType(binding, cs);
- }
-
- public <T extends IBinding> T assertNonProblem(String section, Class... cs) {
- return assertNonProblem(section, section.length(), cs);
- }
-
- public <T extends IBinding> T assertNonProblem(String context, String name, Class... cs) {
- IBinding binding= binding(context, name);
- assertTrue("ProblemBinding for name: " + name, !(binding instanceof IProblemBinding));
- return assertType(binding, cs);
- }
-
- public void assertVariableType(String variableName, IType expectedType) {
- IVariable var = assertNonProblem(variableName);
- assertSameType(expectedType, var.getType());
- }
-
- public void assertVariableTypeProblem(String variableName) {
- IVariable var = assertNonProblem(variableName);
- assertInstance(var.getType(), IProblemType.class);
- }
-
- public void assertVariableValue(String variableName, long expectedValue) {
- IVariable var = assertNonProblem(variableName);
- BaseTestCase.assertVariableValue(var, expectedValue);
- }
+ }
+
+ public IASTImplicitDestructorName[] getImplicitDestructorNames(String section) {
+ return getImplicitDestructorNames(section, section.length());
+ }
+
+ public IASTImplicitDestructorName[] getImplicitDestructorNames(String section, int len) {
+ final int offset = contents.indexOf(section);
+ assertTrue(offset >= 0);
+ IASTNodeSelector selector = tu.getNodeSelector(null);
+ IASTNode enclosingNode = selector.findEnclosingNode(offset, len);
+ if (!(enclosingNode instanceof IASTImplicitDestructorNameOwner))
+ return IASTImplicitDestructorName.EMPTY_NAME_ARRAY;
+ return ((IASTImplicitDestructorNameOwner) enclosingNode).getImplicitDestructorNames();
+ }
+
+ public IASTName findName(String section, int len) {
+ final int offset = contents.indexOf(section);
+ assertTrue("Section \"" + section + "\" not found", offset >= 0);
+ IASTNodeSelector selector = tu.getNodeSelector(null);
+ return selector.findName(offset, len);
+ }
+
+ public IASTName findName(String context, String name) {
+ if (context == null) {
+ context = contents;
+ }
+ int offset = contents.indexOf(context);
+ assertTrue("Context \"" + context + "\" not found", offset >= 0);
+ int nameOffset = context.indexOf(name);
+ assertTrue("Name \"" + name + "\" not found", nameOffset >= 0);
+ IASTNodeSelector selector = tu.getNodeSelector(null);
+ return selector.findName(offset + nameOffset, name.length());
+ }
+
+ public IASTName findName(String name) {
+ return findName(contents, name);
+ }
+
+ public IASTImplicitName findImplicitName(String section, int len) {
+ final int offset = contents.indexOf(section);
+ assertTrue(offset >= 0);
+ IASTNodeSelector selector = tu.getNodeSelector(null);
+ return selector.findImplicitName(offset, len);
+ }
+
+ public <T extends IASTNode> T assertNode(String context, String nodeText, Class... cs) {
+ if (context == null) {
+ context = contents;
+ }
+ int offset = contents.indexOf(context);
+ assertTrue("Context \"" + context + "\" not found", offset >= 0);
+ int nodeOffset = context.indexOf(nodeText);
+ assertTrue("Node \"" + nodeText + "\" not found", nodeOffset >= 0);
+ IASTNodeSelector selector = tu.getNodeSelector(null);
+ IASTNode node = selector.findNode(offset + nodeOffset, nodeText.length());
+ return assertType(node, cs);
+ }
+
+ public <T extends IASTNode> T assertNode(String nodeText, Class... cs) {
+ return assertNode(contents, nodeText, cs);
+ }
+
+ private String renderProblemID(int i) {
+ try {
+ for (Field field : IProblemBinding.class.getDeclaredFields()) {
+ if (field.getName().startsWith("SEMANTIC_")) {
+ if (field.getType() == int.class) {
+ Integer ci = (Integer) field.get(null);
+ if (ci.intValue() == i) {
+ return field.getName();
+ }
+ }
+ }
+ }
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ return "Unknown problem ID";
+ }
+
+ public <T extends IBinding> T assertNonProblem(String section, int len, Class... cs) {
+ if (len <= 0)
+ len += section.length();
+ IBinding binding = binding(section, len);
+ assertTrue("ProblemBinding for name: " + section.substring(0, len), !(binding instanceof IProblemBinding));
+ return assertType(binding, cs);
+ }
+
+ public <T extends IBinding> T assertNonProblem(String section, Class... cs) {
+ return assertNonProblem(section, section.length(), cs);
+ }
+
+ public <T extends IBinding> T assertNonProblem(String context, String name, Class... cs) {
+ IBinding binding = binding(context, name);
+ assertTrue("ProblemBinding for name: " + name, !(binding instanceof IProblemBinding));
+ return assertType(binding, cs);
+ }
+
+ public void assertVariableType(String variableName, IType expectedType) {
+ IVariable var = assertNonProblem(variableName);
+ assertSameType(expectedType, var.getType());
+ }
+
+ public void assertVariableTypeProblem(String variableName) {
+ IVariable var = assertNonProblem(variableName);
+ assertInstance(var.getType(), IProblemType.class);
+ }
+
+ public void assertVariableValue(String variableName, long expectedValue) {
+ IVariable var = assertNonProblem(variableName);
+ BaseTestCase.assertVariableValue(var, expectedValue);
+ }
public <T, U extends T> U assertType(T obj, Class... cs) {
- for (Class c : cs) {
- assertInstance(obj, c);
- }
- return (U) obj;
+ for (Class c : cs) {
+ assertInstance(obj, c);
+ }
+ return (U) obj;
}
- private IBinding binding(String section, int len) {
- IASTName astName = findName(section, len);
- final String selection = section.substring(0, len);
+ private IBinding binding(String section, int len) {
+ IASTName astName = findName(section, len);
+ final String selection = section.substring(0, len);
assertNotNull("No AST name for \"" + selection + "\"", astName);
- assertEquals(selection, astName.getRawSignature());
+ assertEquals(selection, astName.getRawSignature());
- IBinding binding = astName.resolveBinding();
- assertNotNull("No binding for " + astName.getRawSignature(), binding);
+ IBinding binding = astName.resolveBinding();
+ assertNotNull("No binding for " + astName.getRawSignature(), binding);
- return astName.resolveBinding();
- }
+ return astName.resolveBinding();
+ }
- private IBinding binding(String context, String name) {
- IASTName astName = findName(context, name);
+ private IBinding binding(String context, String name) {
+ IASTName astName = findName(context, name);
assertNotNull("No AST name for \"" + name + "\"", astName);
- assertEquals(name, astName.getRawSignature());
+ assertEquals(name, astName.getRawSignature());
- IBinding binding = astName.resolveBinding();
- assertNotNull("No binding for " + astName.getRawSignature(), binding);
+ IBinding binding = astName.resolveBinding();
+ assertNotNull("No binding for " + astName.getRawSignature(), binding);
- return astName.resolveBinding();
- }
+ return astName.resolveBinding();
+ }
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticsTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticsTests.java
index 9272b92d59c..64c81fa054d 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticsTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticsTests.java
@@ -25,9 +25,12 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
*/
public class SemanticsTests extends AST2TestBase {
- public SemanticsTests() {}
- public SemanticsTests(String name) { super(name); }
-
+ public SemanticsTests() {
+ }
+
+ public SemanticsTests(String name) {
+ super(name);
+ }
// class A {};
// class B {};
@@ -62,7 +65,7 @@ public class SemanticsTests extends AST2TestBase {
// void operator +(X x) {} // Addition
// A operator +=(int y) {} // Addition with assignment
// B operator -(X x) {} // Subtraction
- // void operator -=(int y) {} // Subtraction with assignment
+ // void operator -=(int y) {} // Subtraction with assignment
// void operator ->*(int z){} // ptr-to-member selection
// void operator /(int x) {} // division
// void operator /=(int y) {} // division with assignment
@@ -85,29 +88,31 @@ public class SemanticsTests extends AST2TestBase {
// void operator()(int a, int b, int c) {} // function call
//
// void operator[](int i) {} // subscripting
- //
+ //
// operator A(); // conversion
// operator B(); // conversion
// };
public void testConversionOperators() throws Exception {
// Test getDeclaredConversionOperators()
- BindingAssertionHelper ba= new AST2AssertionHelper(getAboveComment(), true);
- ICPPClassType c= ba.assertNonProblem("X {", 1, ICPPClassType.class);
- ICPPMethod[] cops= SemanticUtil.getDeclaredConversionOperators(c);
+ BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), true);
+ ICPPClassType c = ba.assertNonProblem("X {", 1, ICPPClassType.class);
+ ICPPMethod[] cops = SemanticUtil.getDeclaredConversionOperators(c);
assertEquals(2, cops.length);
- Set actual= new HashSet();
- actual.add(cops[0].getName()); actual.add(cops[1].getName());
- Set expected= new HashSet();
- expected.add("operator A"); expected.add("operator B");
+ Set actual = new HashSet();
+ actual.add(cops[0].getName());
+ actual.add(cops[1].getName());
+ Set expected = new HashSet();
+ expected.add("operator A");
+ expected.add("operator B");
assertEquals(expected, actual);
// Test isConversionOperator()
- ICPPMethod[] dms= c.getDeclaredMethods();
+ ICPPMethod[] dms = c.getDeclaredMethods();
assertEquals(48, dms.length);
-
- for(ICPPMethod method : dms) {
- String name= method.getName();
- boolean isConvOp= name.equals("operator A") || name.equals("operator B");
+
+ for (ICPPMethod method : dms) {
+ String name = method.getName();
+ boolean isConvOp = name.equals("operator A") || name.equals("operator B");
assertEquals(isConvOp, SemanticUtil.isConversionOperator(method));
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TaskParserTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TaskParserTest.java
index b6d188ae877..f72697dba37 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TaskParserTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TaskParserTest.java
@@ -22,41 +22,27 @@ import org.eclipse.cdt.internal.core.pdom.indexer.TodoTaskParser;
import org.eclipse.cdt.internal.core.pdom.indexer.TodoTaskParser.Task;
public class TaskParserTest extends AST2TestBase {
-
+
public static TestSuite suite() {
return suite(TaskParserTest.class);
}
public void testTaskParser() throws Exception {
- final char[][] taskTags = new char[][] {
- "TODO".toCharArray(),
- "TODO(my name):".toCharArray(),
- "FIXME".toCharArray()
- };
- final int PRIORITY_LOW = 1;
- final int PRIORITY_NORMAL = 2;
- final int PRIORITY_HIGH = 3;
- final int[] taskPriorities = new int[] {
- PRIORITY_LOW,
- PRIORITY_NORMAL,
- PRIORITY_HIGH
- };
+ final char[][] taskTags = new char[][] { "TODO".toCharArray(), "TODO(my name):".toCharArray(),
+ "FIXME".toCharArray() };
+ final int PRIORITY_LOW = 1;
+ final int PRIORITY_NORMAL = 2;
+ final int PRIORITY_HIGH = 3;
+ final int[] taskPriorities = new int[] { PRIORITY_LOW, PRIORITY_NORMAL, PRIORITY_HIGH };
final boolean isTaskCaseSensitive = true;
-
- String code = "/* TODO tag 1\n" +
- " * FIXME tag 2\n" +
- " */\n" +
- "\n" +
- "// TODO(my name): tag 3\n" +
- "// TODO(his name): tag 4\n" +
- "// todo Not a tag\n" +
- "// TODO FIXME tag 5\n" +
- "\n" +
- "const char* x = \"TODO Not a tag\";";
+
+ String code = "/* TODO tag 1\n" + " * FIXME tag 2\n" + " */\n" + "\n" + "// TODO(my name): tag 3\n"
+ + "// TODO(his name): tag 4\n" + "// todo Not a tag\n" + "// TODO FIXME tag 5\n" + "\n"
+ + "const char* x = \"TODO Not a tag\";";
IASTTranslationUnit tu = parse(code, ParserLanguage.CPP, false, true);
- TodoTaskParser parser = new TodoTaskParser(taskTags, taskPriorities, isTaskCaseSensitive);
+ TodoTaskParser parser = new TodoTaskParser(taskTags, taskPriorities, isTaskCaseSensitive);
Task[] tasks = parser.parse(tu.getComments());
-
+
assertEquals(6, tasks.length);
assertEquals("TODO", tasks[0].getTag());
assertEquals("tag 1", tasks[0].getMessage());
@@ -64,17 +50,17 @@ public class TaskParserTest extends AST2TestBase {
assertEquals(1, tasks[0].getLineNumber());
assertEquals(3, tasks[0].getStart());
assertEquals(13, tasks[0].getEnd());
-
+
assertEquals("FIXME", tasks[1].getTag());
assertEquals("tag 2", tasks[1].getMessage());
assertEquals(PRIORITY_HIGH, tasks[1].getPriority());
assertEquals(2, tasks[1].getLineNumber());
-
+
assertEquals("TODO(my name):", tasks[2].getTag());
assertEquals("tag 3", tasks[2].getMessage());
assertEquals(PRIORITY_NORMAL, tasks[2].getPriority());
assertEquals(5, tasks[2].getLineNumber());
-
+
assertEquals("TODO", tasks[3].getTag());
assertEquals("(his name): tag 4", tasks[3].getMessage());
assertEquals(PRIORITY_LOW, tasks[3].getPriority());
@@ -84,7 +70,7 @@ public class TaskParserTest extends AST2TestBase {
assertEquals("tag 5", tasks[4].getMessage());
assertEquals(PRIORITY_LOW, tasks[4].getPriority());
assertEquals(8, tasks[4].getLineNumber());
-
+
assertEquals("FIXME", tasks[5].getTag());
assertEquals("tag 5", tasks[5].getMessage());
assertEquals(PRIORITY_HIGH, tasks[5].getPriority());
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TestLexerLog.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TestLexerLog.java
index ce182e83f4c..a818a6fc9e6 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TestLexerLog.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TestLexerLog.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2;
import java.util.ArrayList;
@@ -19,12 +19,12 @@ import org.eclipse.cdt.internal.core.parser.scanner.AbstractCharArray;
import org.eclipse.cdt.internal.core.parser.scanner.ILexerLog;
public class TestLexerLog implements ILexerLog {
- private ArrayList fComments= new ArrayList();
- private ArrayList fProblems= new ArrayList();
+ private ArrayList fComments = new ArrayList();
+ private ArrayList fProblems = new ArrayList();
private String fInput;
-
+
public void setInput(String input) {
- fInput= input;
+ fInput = input;
}
@Override
@@ -40,7 +40,7 @@ public class TestLexerLog implements ILexerLog {
public String createString(int problemID, String image) {
return String.valueOf(problemID) + ":" + image;
}
-
+
public void clear() {
fComments.clear();
fProblems.clear();
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TypeTraitsTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TypeTraitsTests.java
index 6ff2b1458ba..9d620b3868b 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TypeTraitsTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TypeTraitsTests.java
@@ -40,7 +40,7 @@ public class TypeTraitsTests extends AST2TestBase {
}
protected BindingAssertionHelper getAssertionHelper() throws ParserException, IOException {
- String code= getAboveComment();
+ String code = getAboveComment();
return new AST2AssertionHelper(code, true);
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/VariableReadWriteFlagsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/VariableReadWriteFlagsTest.java
index 31e81dd4ebd..852cbdcb42c 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/VariableReadWriteFlagsTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/VariableReadWriteFlagsTest.java
@@ -46,9 +46,8 @@ public class VariableReadWriteFlagsTest extends AST2TestBase {
}
int getReadWriteFlags(IASTName variable) {
- return isCPP ?
- CPPVariableReadWriteFlags.getReadWriteFlags(variable) :
- CVariableReadWriteFlags.getReadWriteFlags(variable);
+ return isCPP ? CPPVariableReadWriteFlags.getReadWriteFlags(variable)
+ : CVariableReadWriteFlags.getReadWriteFlags(variable);
}
private String flagsToString(int flags) {
@@ -79,12 +78,12 @@ public class VariableReadWriteFlagsTest extends AST2TestBase {
}
protected AssertionHelper getCAssertionHelper() throws ParserException, IOException {
- String code= getAboveComment();
+ String code = getAboveComment();
return new AssertionHelper(code, false);
}
protected AssertionHelper getCPPAssertionHelper() throws ParserException, IOException {
- String code= getAboveComment();
+ String code = getAboveComment();
return new AssertionHelper(code, true);
}
@@ -218,7 +217,7 @@ public class VariableReadWriteFlagsTest extends AST2TestBase {
a.assertReadWriteFlags("ap->m()", "ap", READ);
a.assertReadWriteFlags("(*ap).m()", "ap", READ);
}
-
+
// void variadic(...);
// void test() {
// int waldo;
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/GenericLambdaIndexTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/GenericLambdaIndexTests.java
index 61a39836f60..25013a2e934 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/GenericLambdaIndexTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/GenericLambdaIndexTests.java
@@ -20,9 +20,9 @@ public class GenericLambdaIndexTests extends IndexBindingResolutionTestBase {
public GenericLambdaIndexTests() {
setStrategy(new SinglePDOMTestStrategy(true));
}
-
+
// auto Identity = [](auto a){ return a; };
-
+
// auto three = Identity(3);
// auto hello = Identity("hello");
public void testBasicCall() throws Exception {
@@ -30,10 +30,10 @@ public class GenericLambdaIndexTests extends IndexBindingResolutionTestBase {
helper.assertVariableType("three", CommonCPPTypes.int_);
helper.assertVariableType("hello", CommonCPPTypes.pointerToConstChar);
}
-
+
// // Adapted from the example in [expr.prim.lambda] p7 in the standard.
// auto Identity = [](auto a){ return a; };
-
+
// void f1(int(*)(int));
// void f2(char(*)(int));
// void g(int(*)(int));
@@ -55,7 +55,7 @@ public class GenericLambdaIndexTests extends IndexBindingResolutionTestBase {
IFunction hCall = helper.assertNonProblem("h(Id", "h");
assertSame(h1, hCall);
}
-
+
// template <typename... T>
// struct tuple {};
//
@@ -70,7 +70,7 @@ public class GenericLambdaIndexTests extends IndexBindingResolutionTestBase {
// Cat bar(tuple<int, char, float>);
//
// void waldo(Cat);
-
+
// int main() {
// waldo(foo(L(42, 'x')));
// waldo(bar(L(42, 'x', 42.0f)));
@@ -78,7 +78,7 @@ public class GenericLambdaIndexTests extends IndexBindingResolutionTestBase {
public void testVariadicAutoParameter() throws Exception {
checkBindings();
}
-
+
// // Adapted from the example in [expr.prim.lambda] p6 in the standard.
// namespace std {
// struct ostream {
@@ -100,7 +100,7 @@ public class GenericLambdaIndexTests extends IndexBindingResolutionTestBase {
// });
// auto q = p(1, 'a', 3.14);
// void waldo(const std::ostream&);
-
+
// int main() {
// waldo(q());
// }
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/GenericLambdaTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/GenericLambdaTests.java
index 1622e92d62f..dd16e67f70d 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/GenericLambdaTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/GenericLambdaTests.java
@@ -25,7 +25,7 @@ public class GenericLambdaTests extends AST2CPPTestBase {
helper.assertVariableType("three", CommonCPPTypes.int_);
helper.assertVariableType("hello", CommonCPPTypes.pointerToConstChar);
}
-
+
// // Adapted from the example in [expr.prim.lambda] p7 in the standard.
// auto Identity = [](auto a){ return a; };
// void f1(int(*)(int));
@@ -52,7 +52,7 @@ public class GenericLambdaTests extends AST2CPPTestBase {
assertSame(h1, hCall);
helper.assertNonProblem("j([]", "j");
}
-
+
// template <typename... T>
// struct tuple {};
//
@@ -75,7 +75,7 @@ public class GenericLambdaTests extends AST2CPPTestBase {
public void testVariadicAutoParameter() throws Exception {
parseAndCheckBindings();
}
-
+
// // Adapted from the example in [expr.prim.lambda] p6 in the standard.
// namespace std {
// struct ostream {
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/InitCaptureTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/InitCaptureTests.java
index 85b7dfcdc2c..2e38a3f274f 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/InitCaptureTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/InitCaptureTests.java
@@ -24,7 +24,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int main() {
// [var1 { 3 }] { }();
// }
- public void testLambdaInitCaptures_413527_1a() throws Exception {
+ public void testLambdaInitCaptures_413527_1a() throws Exception {
parseAndCheckBindings();
}
@@ -32,7 +32,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int var2 {};
// [var1 { 3 }, var2] { }();
// }
- public void testLambdaInitCaptures_413527_1b() throws Exception {
+ public void testLambdaInitCaptures_413527_1b() throws Exception {
parseAndCheckBindings();
}
@@ -40,7 +40,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int var2 {};
// [var1 { 3 }, var2] { }();
// }
- public void testLambdaInitCaptures_413527_1c() throws Exception {
+ public void testLambdaInitCaptures_413527_1c() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableType("var2", CommonCPPTypes.int_);
helper.assertVariableType("var1", CommonCPPTypes.int_);
@@ -49,7 +49,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int main() {
// [var1(3)] { }();
// }
- public void testLambdaInitCaptures_413527_2a() throws Exception {
+ public void testLambdaInitCaptures_413527_2a() throws Exception {
parseAndCheckBindings();
}
@@ -57,7 +57,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int var2 { };
// [var1(3), var2] { }();
// }
- public void testLambdaInitCaptures_413527_2b() throws Exception {
+ public void testLambdaInitCaptures_413527_2b() throws Exception {
parseAndCheckBindings();
}
@@ -65,7 +65,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int var2 { };
// [var1(3), var2] { }();
// }
- public void testLambdaInitCaptures_413527_2c() throws Exception {
+ public void testLambdaInitCaptures_413527_2c() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableType("var2", CommonCPPTypes.int_);
helper.assertVariableType("var1", CommonCPPTypes.int_);
@@ -75,7 +75,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int var2 { };
// [var1( { 3, 3 } ), var2] { }();
// }
- public void testLambdaInitCaptures_413527_2d() throws Exception {
+ public void testLambdaInitCaptures_413527_2d() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableType("var2", CommonCPPTypes.int_);
// #include <initalizer_list> missing
@@ -85,7 +85,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int main() {
// [var1 = 3] { }();
// }
- public void testLambdaInitCaptures_413527_3a() throws Exception {
+ public void testLambdaInitCaptures_413527_3a() throws Exception {
parseAndCheckBindings();
}
@@ -93,7 +93,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int var2 { };
// [var1 = 3, var2] { }();
// }
- public void testLambdaInitCaptures_413527_3b() throws Exception {
+ public void testLambdaInitCaptures_413527_3b() throws Exception {
parseAndCheckBindings();
}
@@ -101,7 +101,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int var2 { };
// [var1 = 3, var2] { }();
// }
- public void testLambdaInitCaptures_413527_3c() throws Exception {
+ public void testLambdaInitCaptures_413527_3c() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableType("var2", CommonCPPTypes.int_);
helper.assertVariableType("var1", CommonCPPTypes.int_);
@@ -115,7 +115,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// int var2 { };
// [var1 = { 3, 4 }, var2] { }();
// }
- public void testLambdaInitCaptures_413527_3d() throws Exception {
+ public void testLambdaInitCaptures_413527_3d() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableType("var2", CommonCPPTypes.int_);
// #include <initalizer_list> missing
@@ -127,7 +127,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// auto var3 = var1;
// }();
// }
- public void testLambdaInitCaptures_413527_4a() throws Exception {
+ public void testLambdaInitCaptures_413527_4a() throws Exception {
parseAndCheckBindings();
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableType("var1", CommonCPPTypes.int_);
@@ -139,7 +139,7 @@ public class InitCaptureTests extends AST2CPPTestBase {
// var1++;
// }();
// }
- public void testLambdaInitCaptures_413527_4b() throws Exception {
+ public void testLambdaInitCaptures_413527_4b() throws Exception {
parseAndCheckBindings();
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableType("var1", CommonCPPTypes.int_);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/ReturnTypeDeductionIndexTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/ReturnTypeDeductionIndexTests.java
index 7f5857379c5..ebcbd0e93ff 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/ReturnTypeDeductionIndexTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/ReturnTypeDeductionIndexTests.java
@@ -16,22 +16,22 @@ public class ReturnTypeDeductionIndexTests extends IndexBindingResolutionTestBas
public ReturnTypeDeductionIndexTests() {
setStrategy(new SinglePDOMTestStrategy(true));
}
-
+
// struct A {
// auto f();
// };
// auto A::f() { return 42; }
-
+
// auto waldo = A().f();
public void testOutOfLineMethod1() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableType("waldo", CommonCPPTypes.int_);
}
-
+
// struct A {
// auto f();
// };
-
+
// auto A::f() { return 42; }
// auto waldo = A().f();
public void _testOutOfLineMethod2() throws Exception {
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/ReturnTypeDeductionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/ReturnTypeDeductionTests.java
index bbf15374815..904d90a17ae 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/ReturnTypeDeductionTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/ReturnTypeDeductionTests.java
@@ -26,19 +26,19 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
ICPPFunction f = bh.assertNonProblem(functionName);
return f.getType().getReturnType();
}
-
+
private void assertReturnType(String functionName, IType returnType) throws Exception {
assertSameType(getReturnType(functionName), returnType);
}
-
+
private void assertReturnTypeProblem(String functionName) throws Exception {
assertInstance(getReturnType(functionName), IProblemType.class);
}
-
+
private void assertReturnTypeValid(String functionName) throws Exception {
assertFalse(getReturnType(functionName) instanceof IProblemType);
}
-
+
private IType getLambdaReturnType(String lambdaName) throws Exception {
BindingAssertionHelper bh = getAssertionHelper();
ICPPVariable lambda = bh.assertNonProblem(lambdaName);
@@ -47,20 +47,20 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
ICPPFunction f = ((CPPClosureType) lambdaType).getFunctionCallOperator();
return f.getType().getReturnType();
}
-
+
private void assertLambdaReturnType(String lambdaName, IType returnType) throws Exception {
assertSameType(getLambdaReturnType(lambdaName), returnType);
}
-
+
private void assertLambdaReturnTypeValid(String lambdaName) throws Exception {
assertFalse(getLambdaReturnType(lambdaName) instanceof IProblemType);
}
-
+
// auto f() { return 42; }
public void testSingleReturn() throws Exception {
assertReturnType("f", CommonCPPTypes.int_);
}
-
+
// auto f(int x) {
// if (x < 10)
// return 42;
@@ -70,7 +70,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
public void testMultipleReturnsSameType() throws Exception {
assertReturnType("f", CommonCPPTypes.int_);
}
-
+
// struct S {};
// auto f(const S& s, bool c) {
// if (c)
@@ -81,7 +81,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
public void testMultipleReturnsDifferingByConst() throws Exception {
assertReturnTypeValid("f");
}
-
+
// auto f(int x) {
// if (x < 10)
// return 42;
@@ -98,7 +98,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
public void testFullyRecursiveFunction() throws Exception {
assertReturnTypeProblem("f");
}
-
+
// auto sum(int i) {
// if (i == 1)
// return i;
@@ -108,7 +108,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
public void testPartiallyRecursiveFunction() throws Exception {
assertReturnType("sum", CommonCPPTypes.int_);
}
-
+
// template <typename T>
// auto f(T t) {
// return t;
@@ -119,7 +119,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
ITypedef t = bh.assertNonProblem("fint_t");
assertSameType(t, CommonCPPTypes.int_);
}
-
+
// template <typename T> auto f(T t) { return t; }
// template <typename T> auto f(T* t) { return *t; }
// void g() { int (*p)(int*) = &f; }
@@ -129,7 +129,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
ICPPTemplateInstance fi = bh.assertNonProblem("f;", 1);
assertSame(f2, fi.getSpecializedBinding());
}
-
+
// struct A { static int i; };
// auto& f1() { return A::i; }
// auto&& f2() { return A::i; }
@@ -143,7 +143,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
assertReturnType("f4", CommonCPPTypes.referenceToConstInt);
assertReturnType("f5", CommonCPPTypes.rvalueReferenceToConstInt);
}
-
+
// struct A { static int i; };
// auto* f1() { return &A::i; }
// const auto* f2() { return &A::i; }
@@ -151,7 +151,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
assertReturnType("f1", CommonCPPTypes.pointerToInt);
assertReturnType("f2", CommonCPPTypes.pointerToConstInt);
}
-
+
// auto f1() {}
// auto& f2() {}
// auto* f3() {}
@@ -160,7 +160,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
assertReturnTypeProblem("f2");
assertReturnTypeProblem("f3");
}
-
+
// struct A { static int i; };
// auto f1() -> auto { return 42; }
// auto f2() -> auto& { return A::i; }
@@ -180,7 +180,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
assertReturnType("f7", CommonCPPTypes.pointerToInt);
assertReturnType("f8", CommonCPPTypes.pointerToConstInt);
}
-
+
// int i;
// auto f1 = []() -> auto { return 42; };
// auto f2 = []() -> auto& { return i; };
@@ -192,7 +192,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
assertLambdaReturnType("f3", CommonCPPTypes.referenceToInt);
assertLambdaReturnType("f4", CommonCPPTypes.rvalueReferenceToInt);
}
-
+
// struct S {};
// auto f = [](const S& s, bool c) {
// if (c)
@@ -203,7 +203,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
public void testLambdaWithMultipleReturnsDifferingByConst() throws Exception {
assertLambdaReturnTypeValid("f");
}
-
+
// struct A {
// virtual auto f() { return 42; }
// virtual decltype(auto) g() { return 42; }
@@ -212,12 +212,12 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
assertReturnTypeProblem("f");
assertReturnTypeProblem("g");
}
-
+
// auto f() { return {1, 2, 3}; }
public void testInitializerList() throws Exception {
assertReturnTypeProblem("f");
}
-
+
// int f(int);
// int g(int);
// template <typename T>
@@ -237,14 +237,14 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
BindingAssertionHelper bh = getAssertionHelper();
bh.assertNonProblem("foo(cond", "foo");
}
-
+
// decltype(auto) f() { return 42; }
- // decltype(auto) g(int* arg) { return *arg; }
+ // decltype(auto) g(int* arg) { return *arg; }
public void testDecltypeAuto() throws Exception {
assertReturnType("f", CommonCPPTypes.int_);
assertReturnType("g", CommonCPPTypes.referenceToInt);
}
-
+
// auto f() -> decltype(auto) { return 42; }
// auto g(int* arg) -> decltype(auto) { return *arg; }
// auto L1 = []() -> decltype(auto) { return 42; };
@@ -255,7 +255,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
assertLambdaReturnType("L1", CommonCPPTypes.int_);
assertLambdaReturnType("L2", CommonCPPTypes.referenceToInt);
}
-
+
// int i;
// decltype(auto)& f() { return i; }
// decltype(auto)* g() { return &i; }
@@ -267,14 +267,14 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
assertReturnTypeProblem("f2");
assertReturnTypeProblem("g2");
}
-
+
// auto f();
// auto waldo = f();
public void testUseWithoutDefinition() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableTypeProblem("waldo");
}
-
+
// auto f();
// auto f() { return 42; }
// auto waldo = f();
@@ -282,7 +282,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableType("waldo", CommonCPPTypes.int_);
}
-
+
// auto f();
// auto waldo = f();
// auto f() { return 42; }
@@ -292,7 +292,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableTypeProblem("waldo");
}
-
+
// auto f() { return 42; }
// int f();
public void testRedeclaration() throws Exception {
@@ -303,7 +303,7 @@ public class ReturnTypeDeductionTests extends AST2CPPTestBase {
ICPPFunction intFunction = helper.assertNonProblem("int f", "f");
assertNotSame(autoFunction, intFunction);
}
-
+
// struct A {
// auto f();
// };
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/VariableTemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/VariableTemplateTests.java
index 00b057adc73..599d01d92ad 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/VariableTemplateTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/VariableTemplateTests.java
@@ -120,8 +120,8 @@ public class VariableTemplateTests extends AST2CPPTestBase {
BindingAssertionHelper ah = getAssertionHelper(ParserLanguage.CPP);
ICPPFieldTemplate template = ah.assertNonProblem("pi<int>", "pi", ICPPFieldTemplate.class);
- ICPPVariableInstance inst = ah.assertNonProblem("pi<int>", "pi<int>",
- ICPPVariableInstance.class, ICPPField.class);
+ ICPPVariableInstance inst = ah.assertNonProblem("pi<int>", "pi<int>", ICPPVariableInstance.class,
+ ICPPField.class);
assertEquals("3", inst.getInitialValue().toString());
assertEquals(template, inst.getSpecializedBinding());
@@ -159,8 +159,8 @@ public class VariableTemplateTests extends AST2CPPTestBase {
BindingAssertionHelper ah = getAssertionHelper(ParserLanguage.CPP);
ICPPFieldTemplate template = ah.assertNonProblem("pi<int>", "pi", ICPPFieldTemplate.class);
- ICPPVariableInstance inst = ah.assertNonProblem("pi<int> = ", "pi<int>",
- ICPPVariableInstance.class, ICPPField.class);
+ ICPPVariableInstance inst = ah.assertNonProblem("pi<int> = ", "pi<int>", ICPPVariableInstance.class,
+ ICPPField.class);
ICPPVariableInstance ref = ah.assertNonProblem("pi<int>;", "pi<int>", ICPPVariableInstance.class);
assertEquals("4", inst.getInitialValue().toString());
@@ -284,8 +284,8 @@ public class VariableTemplateTests extends AST2CPPTestBase {
BindingAssertionHelper ah = getAssertionHelper(ParserLanguage.CPP);
- ICPPFieldTemplate template = ah.assertNonProblem("once = ", "once",
- ICPPField.class, ICPPTemplateDefinition.class);
+ ICPPFieldTemplate template = ah.assertNonProblem("once = ", "once", ICPPField.class,
+ ICPPTemplateDefinition.class);
CPPFieldTemplateSpecialization useName = ah.assertNonProblem("S<Vec>::once<int>", "once");
ICPPVariableInstance useId = ah.assertNonProblem("S<Vec>::once<int>", ICPPField.class);
@@ -320,7 +320,7 @@ public class VariableTemplateTests extends AST2CPPTestBase {
// struct meta {
// static const bool value = true;
// };
- //
+ //
// template <typename T>
// constexpr bool var = meta<T>::value;
//
@@ -334,7 +334,7 @@ public class VariableTemplateTests extends AST2CPPTestBase {
// }
public void test_bug494216() throws Exception {
parseAndCheckBindings();
-
+
BindingAssertionHelper ah = getAssertionHelper(ParserLanguage.CPP);
ICPPVariable waldo = ah.assertNonProblem("waldo");
IType type = waldo.getType();
@@ -343,7 +343,7 @@ public class VariableTemplateTests extends AST2CPPTestBase {
assertEquals(1, args.length);
assertValue(args[0].getNonTypeValue(), 1);
}
-
+
// template<typename T, typename = class _, typename... P>
// constexpr bool type_in_pack{type_in_pack<T, P...>};
//
@@ -357,14 +357,14 @@ public class VariableTemplateTests extends AST2CPPTestBase {
// constexpr bool waldo2 = type_in_pack<int, float, char>;
public void testStackOverflow_513429() throws Exception {
parseAndCheckBindings();
-
+
BindingAssertionHelper ah = getAssertionHelper(ParserLanguage.CPP);
ICPPVariable waldo1 = ah.assertNonProblem("waldo1");
assertVariableValue(waldo1, 1);
ICPPVariable waldo2 = ah.assertNonProblem("waldo2");
assertVariableValue(waldo2, 0);
}
-
+
// template <typename R>
// auto L = []{ return R{}; };
//
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/AllConstexprEvalTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/AllConstexprEvalTests.java
index 7284ccabbfd..16deda4065f 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/AllConstexprEvalTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/AllConstexprEvalTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ArrayTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ArrayTests.java
index a8d9c991062..7d33789eed2 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ArrayTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ArrayTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,15 +15,25 @@ import junit.framework.TestSuite;
public class ArrayTests extends TestBase {
public static class NonIndexing extends ArrayTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends ArrayTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int f() {
// int foo[3][2] { {1,2}, {2, 3},{ 4, 5} };
// return foo[2][1];
@@ -33,7 +43,7 @@ public class ArrayTests extends TestBase {
public void testInitializationOfMultiDimensionalArrays() throws Exception {
assertEvaluationEquals(5);
}
-
+
// constexpr int f() {
// int foo[3] { 1, 2, 3 };
// foo[1] = foo[0] + foo[2];
@@ -44,7 +54,7 @@ public class ArrayTests extends TestBase {
public void testAssignmentOfArrays() throws Exception {
assertEvaluationEquals(4);
}
-
+
// constexpr int f() {
// int foo[3][2] { {1,2}, {2, 3},{ 4, 5} };
// foo[0][1] = 3;
@@ -55,17 +65,17 @@ public class ArrayTests extends TestBase {
public void testAssignmentOfMultiDimensionalArrays() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int a[2][2] { { 1, 2 }, { 3, 4 } };
// constexpr int f() {
// return a[0][0];
// }
-
+
// constexpr auto x = f();
public void testGlobalArrayAccessValue() throws Exception {
assertEvaluationEquals(1);
}
-
+
// constexpr int f() {
// int x[2][2] { { 1, 2 }, { 3, 4 } };
// int &xref { x[1][1] };
@@ -74,23 +84,23 @@ public class ArrayTests extends TestBase {
// xref = xref * xref2;
// return x[1][1];
// }
-
+
// constexpr auto x = f();
public void testReferenceToArrayCell() throws Exception {
assertEvaluationEquals(25);
}
-
+
// constexpr int f() {
// int bar[2] { 3, 7 };
// (*bar)++;
// return bar[0];
// }
-
+
// constexpr int x = f();
public void testPointerDereferencingOnArrayName() throws Exception {
assertEvaluationEquals(4);
}
-
+
// class S {
// int arr[4];
// public:
@@ -104,12 +114,12 @@ public class ArrayTests extends TestBase {
// int *ptr = s.getPtr();
// return *ptr;
// }
-
+
// constexpr int x = f();
public void testPointerToArrayReturnedFromMemberFunction1() throws Exception {
assertEvaluationEquals(5);
}
-
+
// class S {
// int arr[4];
// public:
@@ -124,7 +134,7 @@ public class ArrayTests extends TestBase {
// ptr += 2;
// return *ptr;
// }
-
+
// constexpr int x = f();
public void testPointerToArrayReturnedFromMemberFunction2() throws Exception {
assertEvaluationEquals(9);
@@ -152,35 +162,35 @@ public class ArrayTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testPointerToArrayReturnedFromMemberFunction3() throws Exception {
assertEvaluationEquals(32);
}
-
+
// constexpr int f() {
// int arr[] = {1, 2, 3};
// int (&arrRef)[3] = arr;
// return arrRef[2];
// }
-
+
// constexpr int x = f();
public void testReferenceToArray1() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int f() {
// int arr[] = {1, 2, 3};
// int (&arrRef)[3] = arr;
// arrRef[2] *= 2;
// return arr[2];
// }
-
+
// constexpr int x = f();
public void testReferenceToArray2() throws Exception {
assertEvaluationEquals(6);
}
-
+
// constexpr int f() {
// int arr[] = {1, 2, 3};
// int (&arrRef)[3] = arr;
@@ -189,24 +199,24 @@ public class ArrayTests extends TestBase {
// }
// return arr[2];
// }
-
+
// constexpr int x = f();
public void testReferenceToArray3() throws Exception {
assertEvaluationEquals(6);
}
-
+
// constexpr int f() {
// int bar[2][2] { { 3, 5 }, {7, 11 } };
// int * bar_ptr { bar[1] };
// (*bar_ptr)++;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerArithmeticsOnMultidimensionalArray() throws Exception {
assertEvaluationEquals(8);
}
-
+
// constexpr void g(int * array) {
// array[0] = 1337;
// }
@@ -215,12 +225,12 @@ public class ArrayTests extends TestBase {
// g(bar);
// return bar[0];
// }
-
+
// constexpr int x = f();
public void testPassArrayToFunctionAsPointerAndModifyCell() throws Exception {
assertEvaluationEquals(1337);
}
-
+
// constexpr void g(int array[2][2]) {
// array[1][0] = 1337;
// }
@@ -229,17 +239,17 @@ public class ArrayTests extends TestBase {
// g(bar);
// return bar[1][0];
// }
-
+
// constexpr int x = f();
public void testPassMultiDimensionalArrayToFunctionAsPointerAndModifyCell() throws Exception {
assertEvaluationEquals(1337);
}
-
+
// constexpr int f() {
// int foo[] { 1, 2, 3, 4, 5 };
// return foo[2];
// }
-
+
// constexpr int x = f();
public void testInitializationOfArrays() throws Exception {
assertEvaluationEquals(3);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryExpressionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryExpressionTests.java
index 282150cd325..abe0a57b9fa 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryExpressionTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryExpressionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,15 +15,25 @@ import junit.framework.TestSuite;
public class BinaryExpressionTests extends TestBase {
public static class NonIndexing extends BinaryExpressionTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends BinaryExpressionTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr bool f() {
// bool a { true };
// return a && false;
@@ -33,24 +43,24 @@ public class BinaryExpressionTests extends TestBase {
public void testSimpleBooleanValues() throws Exception {
assertEvaluationEquals(false);
}
-
+
// constexpr int f() {
// int x = 5;
// (x=3)++;
// return x;
// }
-
+
// constexpr auto x = f();
public void testAssignmentReturnsLValue() throws Exception {
assertEvaluationEquals(4);
}
-
+
// constexpr int addTwice(int op1, int op2) {
// op1 += op2;
// op1 += op2;
// return op1;
// }
-
+
// constexpr int x = addTwice(2, 5);
public void testBinaryExpressionSequence() throws Exception {
assertEvaluationEquals(12);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryOperatorOverloadingTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryOperatorOverloadingTests.java
index 0369528592c..2052811815a 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryOperatorOverloadingTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryOperatorOverloadingTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,15 +15,25 @@ import junit.framework.TestSuite;
public class BinaryOperatorOverloadingTests extends TestBase {
public static class NonIndexing extends BinaryOperatorOverloadingTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends BinaryOperatorOverloadingTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// struct S {
// constexpr S(int x):x{x} {}
// constexpr int operator+(S const& other) {
@@ -42,9 +52,9 @@ public class BinaryOperatorOverloadingTests extends TestBase {
// constexpr int x = f();
public void testOverloadedPlusOperatorAsMemberFunction() throws Exception {
- assertEvaluationEquals(12);
+ assertEvaluationEquals(12);
}
-
+
// struct S {
// constexpr S(int x):x{x} {}
// constexpr S operator*(S const& other) {
@@ -62,9 +72,9 @@ public class BinaryOperatorOverloadingTests extends TestBase {
// constexpr int x = f();
public void testOverloadedMultiplicationOperatorAsMemberFunction() throws Exception {
- assertEvaluationEquals(12);
+ assertEvaluationEquals(12);
}
-
+
// struct S {
// constexpr S(int x, int y):x{x}, y{y} {}
// int x, y;
@@ -82,9 +92,9 @@ public class BinaryOperatorOverloadingTests extends TestBase {
// constexpr int x = f();
public void testOverloadedPlusOperatorAsNonMemberFunction() throws Exception {
- assertEvaluationEquals(14);
+ assertEvaluationEquals(14);
}
-
+
// struct S {
// constexpr S(int x, int y):x{x*2}, y{y+1} {
// }
@@ -100,7 +110,7 @@ public class BinaryOperatorOverloadingTests extends TestBase {
// S result{s1 + s2};
// return result.y;
// }
-
+
// constexpr int x = f();
public void testOverloadedOperatorPlusComplex1() throws Exception {
assertEvaluationEquals(24);
@@ -121,12 +131,12 @@ public class BinaryOperatorOverloadingTests extends TestBase {
// S result = s1 + s2;
// return result.x;
// }
-
+
// constexpr int x = f();
public void testOverloadedOperatorPlusComplex2() throws Exception {
assertEvaluationEquals(24);
}
-
+
// struct S {
// constexpr S(int x, int y):x{x*2}, y{y+1} {
// }
@@ -141,12 +151,12 @@ public class BinaryOperatorOverloadingTests extends TestBase {
// S result{s1 + s2};
// return result.y;
// }
-
+
// constexpr int x = f();
public void testOverloadedOperatorPlusComplex3() throws Exception {
assertEvaluationEquals(24);
}
-
+
// class Point {
// int x, y;
// public:
@@ -160,12 +170,12 @@ public class BinaryOperatorOverloadingTests extends TestBase {
// Point p2{2,4};
// return p1 == p2 ? 20 : 40;
// }
-
+
// constexpr int x = f();
public void testOverloadedOperatorEquals() throws Exception {
assertEvaluationEquals(20);
}
-
+
// class Point {
// int x, y;
// public:
@@ -183,7 +193,7 @@ public class BinaryOperatorOverloadingTests extends TestBase {
// p1 = p2;
// return p1.getY();
// }
-
+
// constexpr int x = f();
public void testOverloadedOperatorAssign() throws Exception {
assertEvaluationEquals(10);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/CStringValueTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/CStringValueTests.java
index 40c743eb8a0..12cf893691d 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/CStringValueTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/CStringValueTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,72 +15,82 @@ import junit.framework.TestSuite;
public class CStringValueTests extends TestBase {
public static class NonIndexing extends CStringValueTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends CStringValueTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr auto x = "Hello, World!";
public void testWithoutPrefix() throws Exception {
assertEvaluationEquals("Hello, World!");
}
-
+
// constexpr auto y = "Hello, World!";
// constexpr auto x = y;
public void testStringAssignment() throws Exception {
assertEvaluationEquals("Hello, World!");
}
-
+
// constexpr auto x = L"Hello, World!";
public void testLPrefix() throws Exception {
assertEvaluationEquals("Hello, World!");
}
-
+
// constexpr auto x = u8"Hello, World!";
public void testu8Prefix() throws Exception {
assertEvaluationEquals("Hello, World!");
}
-
+
// constexpr auto x = u"Hello, World!";
public void testuPrefix() throws Exception {
assertEvaluationEquals("Hello, World!");
}
-
+
// constexpr auto x = U"Hello, World!";
public void testUPrefix() throws Exception {
assertEvaluationEquals("Hello, World!");
}
-
+
//constexpr auto x = R"(This is
//a "raw" \n\n
// literal\0end)";
public void testRawStringLiteral() throws Exception {
assertEvaluationEquals("This is\na \"raw\" \\n\\n\n\tliteral\\0end");
}
-
+
//constexpr auto x = R"ab(This is)"
//a "raw" literal)ab";
public void testRawStringLiteralWithDelimiter() throws Exception {
assertEvaluationEquals("This is)\"\na \"raw\" literal");
}
-
+
// constexpr auto x = "line 1\n"
// "line 2\n"
// "line 3";
public void testCStringLiteralConcatenation() throws Exception {
assertEvaluationEquals("line 1\nline 2\nline 3");
}
-
+
// constexpr auto x = "PI = \u03C0";
public void test16bitUnicodeEscapeSequence() throws Exception {
assertEvaluationEquals("PI = \u03C0");
}
-
+
// constexpr int len(const char *str) {
// int len = 0;
// while(str[len] != '\0') {
@@ -97,5 +107,5 @@ public class CStringValueTests extends TestBase {
// constexpr int x = f();
public void testCStringParam() throws Exception {
assertEvaluationEquals(5);
- }
+ }
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ClassTemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ClassTemplateTests.java
index 23fb769cfb6..85853da3d15 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ClassTemplateTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ClassTemplateTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,15 +15,25 @@ import junit.framework.TestSuite;
public class ClassTemplateTests extends TestBase {
public static class NonIndexing extends ClassTemplateTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends ClassTemplateTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// template<typename T>
// struct Point {
// T x;
@@ -36,12 +46,12 @@ public class ClassTemplateTests extends TestBase {
// Point<int> a{3,4} ;
// return a.len();
// }
-
+
// constexpr int x = f();
public void testInstantiationOfClassTemplate() throws Exception {
assertEvaluationEquals(25);
}
-
+
// template<int X>
// struct Multiplier {
// int y;
@@ -53,12 +63,12 @@ public class ClassTemplateTests extends TestBase {
// Multiplier<5> m{7};
// return m.product();
// }
-
+
// constexpr int x = f();
public void testInstantiationOfClassTemplateWithNontypeTemplateParameter1() throws Exception {
assertEvaluationEquals(35);
}
-
+
// template<int X, int Y>
// struct Multiplier {
// int x = X;
@@ -71,12 +81,12 @@ public class ClassTemplateTests extends TestBase {
// Multiplier<5, 7> m{};
// return m.product();
// }
-
+
// constexpr int x = f();
public void testInstantiationOfClassTemplateWithNontypeTemplateParameter2() throws Exception {
assertEvaluationEquals(35);
}
-
+
// template<int X, int Y>
// struct Adder {
// constexpr int sum() {
@@ -96,7 +106,7 @@ public class ClassTemplateTests extends TestBase {
public void testAliasTemplate1() throws Exception {
assertEvaluationEquals(17);
}
-
+
// template<int T>
// struct X {
// constexpr int get() const {
@@ -110,12 +120,12 @@ public class ClassTemplateTests extends TestBase {
// S<5> s{};
// return s.get();
// }
-
+
// constexpr int x = f();
public void testInstantiationOfBaseClassTemplate1() throws Exception {
assertEvaluationEquals(10);
}
-
+
// template<int T>
// struct X {
// int x = 2*T;
@@ -134,10 +144,10 @@ public class ClassTemplateTests extends TestBase {
public void testInstantiationOfBaseClassTemplate2() throws Exception {
assertEvaluationEquals(30);
}
-
+
// template<int I>
// struct S {
- // constexpr S():x{I*2} {}
+ // constexpr S():x{I*2} {}
// int x;
// };
//
@@ -145,7 +155,7 @@ public class ClassTemplateTests extends TestBase {
// S<5> s{};
// return s.x;
// }
-
+
// constexpr int x = f();
public void testTemplateArgumentInMemberInitializerList() throws Exception {
assertEvaluationEquals(10);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ConstructorTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ConstructorTests.java
index 37db3e108d1..bd597e750b2 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ConstructorTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ConstructorTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -17,18 +17,33 @@ import junit.framework.TestSuite;
public class ConstructorTests extends TestBase {
public static class NonIndexing extends ConstructorTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends ConstructorTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
+ }
+
+ public ConstructorTests() {
+ setStrategy(new NonIndexingTestStrategy());
}
-
- public ConstructorTests() {setStrategy(new NonIndexingTestStrategy()); }
- public static TestSuite suite() {return suite(NonIndexing.class);}
-
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
+
// struct S {
// int x;
// constexpr S(int i) : x{i*i} {}
@@ -37,12 +52,12 @@ public class ConstructorTests extends TestBase {
// S s(5);
// return s.x;
// }
-
+
// constexpr auto x = f();
public void testConstexprConstructorChainInitializers() throws Exception {
assertEvaluationEquals(25);
}
-
+
// struct S {
// int x;
// constexpr S(int i) : x{i*i} { x++; }
@@ -51,12 +66,12 @@ public class ConstructorTests extends TestBase {
// S s(5);
// return s.x;
// }
-
+
// constexpr auto x = f();
public void testConstexprConstructorConstructorBody() throws Exception {
assertEvaluationEquals(26);
}
-
+
// struct S {
// int x;
// constexpr S(int i) : x{i*i} { x++; }
@@ -65,12 +80,12 @@ public class ConstructorTests extends TestBase {
// S s = S(5);
// return s.x;
// }
-
+
// constexpr auto x = f();
public void testConstexprConstructorCopyConstruction() throws Exception {
assertEvaluationEquals(26);
}
-
+
// struct S {
// int x;
// constexpr S(int i) : x{i*i} { x++; }
@@ -79,14 +94,14 @@ public class ConstructorTests extends TestBase {
// S s = S(5);
// return s.x;
// }
-
+
// constexpr auto var = f();
public void testIdempotence() throws Exception {
// Querying a value a second time should produce the same result.
assertEvaluationEquals(26);
assertEvaluationEquals(26);
}
-
+
// struct S {
// int x;
// constexpr S() : x{5} { x++; x++; }
@@ -95,12 +110,12 @@ public class ConstructorTests extends TestBase {
// S s;
// return s.x;
// }
-
+
// constexpr auto x = f();
public void testConstexprConstructorDefaultConstruction() throws Exception {
assertEvaluationEquals(7);
}
-
+
// struct Base {
// int base_member;
// constexpr Base(int i) : base_member(i) {}
@@ -113,12 +128,12 @@ public class ConstructorTests extends TestBase {
// Derived t(1);
// return t.base_member + t.derived_member;
// }
-
+
// constexpr auto x = f();
public void testConstexprConstructorInheritance() throws Exception {
assertEvaluationEquals(3);
}
-
+
// struct point {
// int x, y;
// };
@@ -127,12 +142,12 @@ public class ConstructorTests extends TestBase {
// point p{2,3};
// return p.y;
// }
-
+
// constexpr int x = f();
public void testInitializationOfCompositeValues() throws Exception {
assertEvaluationEquals(3);
}
-
+
// struct T {
// constexpr T(int i):x{2*i} {}
// constexpr int get() const { return x; }
@@ -145,12 +160,12 @@ public class ConstructorTests extends TestBase {
// S s;
// return s.t.get();
// }
-
+
// constexpr int x = f();
public void testNestedConstructorCall() throws Exception {
assertEvaluationEquals(4);
}
-
+
// struct S {
// constexpr int get() const {
// return x + y;
@@ -162,12 +177,12 @@ public class ConstructorTests extends TestBase {
// constexpr int f(S s) {
// return s.get();
// }
-
+
// constexpr int x = f(S{});
public void testImplicitConstructorOfLiteralTypeWithImplicitDestructorIsConstexpr() throws Exception {
assertEvaluationEquals(6);
}
-
+
// struct S {
// constexpr int get() const {
// return x + y;
@@ -180,12 +195,12 @@ public class ConstructorTests extends TestBase {
// constexpr int f(S s) {
// return s.get();
// }
-
+
// constexpr int x = f(S{});
public void testImplicitConstructorOfLiteralTypeWithDefaultedDestructorIsConstexpr() throws Exception {
assertEvaluationEquals(6);
}
-
+
// struct S {
// constexpr int get() const {
// return x + y;
@@ -198,12 +213,12 @@ public class ConstructorTests extends TestBase {
// constexpr int f(S s) {
// return s.get();
// }
-
+
// constexpr int x = f(S{});
public void testImplicitConstructorOfLiteralTypeWithUserDefinedDestructorIsNotConstexpr() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// struct S {
// int x = 2;
// int y = 4;
@@ -211,12 +226,12 @@ public class ConstructorTests extends TestBase {
// constexpr int f(S s) {
// return s.x;
// }
-
+
// constexpr int x = f(S{});
public void testImplicitConstructorOfAggregateTypeIsConstexpr() throws Exception {
assertEvaluationEquals(2);
}
-
+
// struct S {
// S() {}
// int x = 2;
@@ -225,12 +240,12 @@ public class ConstructorTests extends TestBase {
// constexpr int f(S s) {
// return s.x;
// }
-
+
// constexpr int x = f(S{});
public void testUserDefinedDefaultConstructorIsNotConstexpr() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// struct S {
// constexpr S(int x):x{x+1} {
// }
@@ -240,12 +255,12 @@ public class ConstructorTests extends TestBase {
// S s(5);
// return s.x;
// }
-
+
// constexpr int x = f();
public void testCtorCall() throws Exception {
assertEvaluationEquals(6);
}
-
+
// struct S {
// constexpr S(int x):x{x} {
// }
@@ -263,7 +278,7 @@ public class ConstructorTests extends TestBase {
public void testArgumentEvaluation() throws Exception {
assertEvaluationEquals(50);
}
-
+
// struct B {
// int x, y;
// };
@@ -275,12 +290,12 @@ public class ConstructorTests extends TestBase {
// A a{1, 2, 3, { 4, 5 } };
// return a.b.y;
// }
-
+
// constexpr int x = f();
public void testInitializationOfNestedCompositeValues() throws Exception {
assertEvaluationEquals(5);
}
-
+
// struct point {
// int x, y;
// };
@@ -295,7 +310,7 @@ public class ConstructorTests extends TestBase {
public void testAssignmentOfCompositeValues() throws Exception {
assertEvaluationEquals(9);
}
-
+
// struct B {
// int x, y;
// };
@@ -308,13 +323,13 @@ public class ConstructorTests extends TestBase {
// A a{1, 2, 3, { 4, 5 } };
// a.b.y = a.k + a.b.x; // 3 + 4
// return a.b.y;
- // }
-
+ // }
+
// constexpr int x = f();
public void testAssignmentOfNestedCompositeValues() throws Exception {
assertEvaluationEquals(7);
}
-
+
// struct S {
// int x = 1, y = 3;
// };
@@ -323,12 +338,12 @@ public class ConstructorTests extends TestBase {
// s.x++;
// return s.x;
// }
-
+
// constexpr auto x = f();
public void testStructDefaultInitialization() throws Exception {
assertEvaluationEquals(2);
}
-
+
// struct S {
// int x = 1, y = 3;
// };
@@ -337,12 +352,12 @@ public class ConstructorTests extends TestBase {
// s.x++;
// return s.x;
// }
-
+
// constexpr auto x = f();
public void testStructDefaultInitializationOverride() throws Exception {
assertEvaluationEquals(6);
}
-
+
// struct T {
// int a = 7;
// };
@@ -355,12 +370,12 @@ public class ConstructorTests extends TestBase {
// s.t.a++;
// return s.t.a;
// }
-
+
// constexpr auto x = f();
public void testNestedStructDefaultInitialization() throws Exception {
assertEvaluationEquals(8);
}
-
+
// struct S {
// constexpr S(int x, int y):x{x}, y{y*2} {}
// constexpr int getY() const {
@@ -373,22 +388,22 @@ public class ConstructorTests extends TestBase {
// constexpr S f() {
// return S{3, 5};
// }
-
+
// constexpr int x = f().getY();
public void testSimpleTypeConstructorExpression2() throws Exception {
assertEvaluationEquals(10);
}
-
+
// struct S {
// int x, y;
// };
// constexpr S s{1,5};
-
+
// constexpr int x = s.y;
public void testInitialValueOfComposite() throws Exception {
assertEvaluationEquals(5);
}
-
+
// struct Point {
// constexpr Point(int x, int y):x{x}, y{y*2} {
// }
@@ -398,12 +413,12 @@ public class ConstructorTests extends TestBase {
// Point p{5, 6};
// return p.y;
// }
-
+
// constexpr int x = f();
public void testCtorInitializerList() throws Exception {
assertEvaluationEquals(12);
}
-
+
// struct Point {
// constexpr Point(int x, int y):x{x}, y{y*2} {
// }
@@ -413,12 +428,12 @@ public class ConstructorTests extends TestBase {
// Point p(5, 6);
// return p.y;
// }
-
+
// constexpr int x = f();
public void testCtorConstructorInitializer() throws Exception {
assertEvaluationEquals(12);
}
-
+
// struct Point {
// constexpr Point(int x, int y):x{x}, y{y*2} {
// }
@@ -428,12 +443,12 @@ public class ConstructorTests extends TestBase {
// Point p = {5, 6};
// return p.y;
// }
-
+
// constexpr int x = f();
public void testCtorEqualsInitializer() throws Exception {
assertEvaluationEquals(12);
}
-
+
// struct S {
// constexpr S(int x):x{x*2} {
// }
@@ -443,12 +458,12 @@ public class ConstructorTests extends TestBase {
// S s = 6;
// return s.x;
// }
-
+
// constexpr int x = f();
public void testCtorImplicitConversion() throws Exception {
assertEvaluationEquals(12);
}
-
+
// struct Point {
// constexpr Point(int x, int y):x{x}, y{y*2} {
// }
@@ -459,12 +474,12 @@ public class ConstructorTests extends TestBase {
// Point p2 = p1;
// return p2.y;
// }
-
+
// constexpr int x = f();
public void testCtorLvalueCopyConstruction() throws Exception {
assertEvaluationEquals(12);
}
-
+
// struct Point {
// constexpr Point(int x, int y):x{x}, y{y*2} {
// }
@@ -474,12 +489,12 @@ public class ConstructorTests extends TestBase {
// Point p = Point{5, 6};
// return p.y;
// }
-
+
// constexpr int x = f();
public void testCtorRvalueCopyConstruction() throws Exception {
assertEvaluationEquals(12);
}
-
+
// struct T {
// int y = 7, z = 11;
// };
@@ -493,22 +508,22 @@ public class ConstructorTests extends TestBase {
// s.t.z++;
// return s.t.y + s.t.z;
// }
-
+
// constexpr auto x = f();
public void testNestedStructDefaultInitializationOverride() throws Exception {
assertEvaluationEquals(22);
}
-
- // struct T {
+
+ // struct T {
// int member;
// constexpr T(int i) : member(i) {}
// };
-
+
// constexpr auto x = T(2).member;
public void testFundamentalTypeDirectInitializationWithParenthesis() throws Exception {
assertEvaluationEquals(2);
}
-
+
// struct Base {
// int x = 5;
// };
@@ -519,15 +534,15 @@ public class ConstructorTests extends TestBase {
// Derived d{};
// return d.x;
// }
-
+
// constexpr int x = f();
public void testInheritedMemberVariable1() throws Exception {
assertEvaluationEquals(5);
}
-
+
// struct X {
// constexpr X(int y):y{2*y} {}
- // int y;
+ // int y;
// };
// struct Base {
// X x{5};
@@ -539,12 +554,12 @@ public class ConstructorTests extends TestBase {
// Derived d{};
// return d.n;
// }
-
+
// constexpr int x = f();
public void testInheritedMemberVariable2() throws Exception {
assertEvaluationEquals(20);
}
-
+
// struct S {
// constexpr S(int x):x{x} {
// }
@@ -565,7 +580,7 @@ public class ConstructorTests extends TestBase {
// int value = 42;
// };
// constexpr S waldo{23};
-
+
// constexpr int x = waldo.value;
public void testDirectInitializedVariable_510151() throws Exception {
assertEvaluationEquals(23);
@@ -575,7 +590,7 @@ public class ConstructorTests extends TestBase {
// int value = 42;
// };
// constexpr S waldo{};
-
+
// constexpr int x = waldo.value;
public void testDirectDefaultInitializedVariable_510151() throws Exception {
assertEvaluationEquals(42);
@@ -585,7 +600,7 @@ public class ConstructorTests extends TestBase {
// int value = 42;
// };
// constexpr S waldo;
-
+
// constexpr int x = waldo.value;
public void testDefaultInitializedVariable_510151() throws Exception {
assertEvaluationEquals(42);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/DoWhileStatementTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/DoWhileStatementTests.java
index ed0d30398c2..c0f21f23527 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/DoWhileStatementTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/DoWhileStatementTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -17,15 +17,25 @@ import junit.framework.TestSuite;
public class DoWhileStatementTests extends TestBase {
public static class NonIndexing extends DoWhileStatementTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends DoWhileStatementTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// int i { 0 };
@@ -35,12 +45,12 @@ public class DoWhileStatementTests extends TestBase {
// } while (i <= n);
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testDoWhile() throws Exception {
assertEvaluationEquals(55);
}
-
+
// constexpr int f() {
// int sum { 0 };
// do {
@@ -48,12 +58,12 @@ public class DoWhileStatementTests extends TestBase {
// } while (true);
// return sum;
// }
-
+
// constexpr int x = f();
public void testDoWhileInfiniteLoop() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f() {
// int sum { 0 };
// do {
@@ -61,12 +71,12 @@ public class DoWhileStatementTests extends TestBase {
// } while (true);
// return sum;
// }
-
+
// constexpr int x = f();
public void testDoWhileReturn() throws Exception {
assertEvaluationEquals(42);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// do
@@ -74,12 +84,12 @@ public class DoWhileStatementTests extends TestBase {
// while(n > 0);
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testDoWhileWithNonCompoundBodyStatement() throws Exception {
assertEvaluationEquals(10);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// do
@@ -87,7 +97,7 @@ public class DoWhileStatementTests extends TestBase {
// while(n > 0);
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testDoWhileWithReturnInNonCompoundBodyStatement() throws Exception {
assertEvaluationEquals(42);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FloatingPointValueTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FloatingPointValueTests.java
index d5aee57ebae..d17f8b3b7ed 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FloatingPointValueTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FloatingPointValueTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,98 +15,108 @@ import junit.framework.TestSuite;
public class FloatingPointValueTests extends TestBase {
public static class NonIndexing extends FloatingPointValueTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends FloatingPointValueTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr auto x = 2.5;
public void testDoubleLiteral() throws Exception {
assertEvaluationEquals(2.5);
}
-
+
// constexpr auto x = .5f;
public void testFloatLiteral() throws Exception {
assertEvaluationEquals(0.5);
}
-
+
// constexpr auto x = 2.l;
public void testLongDoubleLiteral() throws Exception {
assertEvaluationEquals(2.0);
}
-
+
// constexpr auto x = 123.456e-67;
public void testDoubleLiteralWithScientificNotation() throws Exception {
assertEvaluationEquals(123.456e-67);
}
-
+
// constexpr auto x = .1E4f;
public void testFloatLiteralWithScientificNotation() throws Exception {
assertEvaluationEquals(.1E4f);
}
-
+
// constexpr double f() {
// double x = 5.5;
// double y = 2.1;
// return x * 4 + y / 3;
// }
-
+
// constexpr double x = f();
public void testBinaryOperationsWithFloatingPointNumbers() throws Exception {
assertEvaluationEquals(22.7);
}
-
+
// constexpr bool f() {
// double x = 5.0;
// int y = 5;
// return x == y;
// }
-
+
// constexpr bool x = f();
public void testComparisonBetweenFloatingPointValueAndIntegralValue1() throws Exception {
assertEvaluationEquals(true);
}
-
+
// constexpr bool f() {
// double x = 5.1;
// int y = 5;
// return x == y;
// }
-
+
// constexpr bool x = f();
public void testComparisonBetweenFloatingPointValueAndIntegralValue2() throws Exception {
assertEvaluationEquals(false);
}
-
+
// constexpr auto x = float{} + float();
public void testFloatDefaultValue() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto f() {
// float x{};
// return x;
// }
-
+
// constexpr auto x = f();
public void testFloatValueInitialization() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto x = double{} + double();
public void testDoubleDefaultValue() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto f() {
// double x{};
// return x;
// }
-
+
// constexpr auto x = f();
public void testDoubleValueInitialization() throws Exception {
assertEvaluationEquals(0);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ForStatementTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ForStatementTests.java
index 8184b64b920..81257e33b9e 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ForStatementTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ForStatementTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -17,15 +17,25 @@ import junit.framework.TestSuite;
public class ForStatementTests extends TestBase {
public static class NonIndexing extends ForStatementTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends ForStatementTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// for (int i = 0; i <= n; i++) {
@@ -33,12 +43,12 @@ public class ForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testSimpleIndexBasedForLoop() throws Exception {
assertEvaluationEquals(55);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// for (int i = 0; i <= n; i++) {
@@ -47,12 +57,12 @@ public class ForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testReturnInIndexBasedForLoop() throws Exception {
assertEvaluationEquals(42);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// for (int i = 0; true; i++) {
@@ -60,12 +70,12 @@ public class ForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testInfiniteLoopInIndexBasedForLoop() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// int i { 0 };
@@ -74,12 +84,12 @@ public class ForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testIndexBasedForLoopWithEmptyInitializationStatement() throws Exception {
assertEvaluationEquals(45);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// for (int i = 0; i < n;) {
@@ -87,36 +97,36 @@ public class ForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testIndexBasedForLoopWithEmptyIterationSequence() throws Exception {
assertEvaluationEquals(45);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// for (int i = 0; i <= n; i++)
// sum += i;
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testIndexBasedForLoopWithNonCompoundBodyStatement() throws Exception {
assertEvaluationEquals(55);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// for (int i = 0; i <= n; i++)
// return 42;
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testIndexBasedForLoopWithReturnInNonCompoundBodyStatement() throws Exception {
assertEvaluationEquals(42);
}
-
+
// constexpr int f() {
// int sum = 0;
// for(int i = 0; i < 10; ++i) {
@@ -126,12 +136,12 @@ public class ForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testIndexBasedForLoopWithContinueStatement() throws Exception {
assertEvaluationEquals(10);
}
-
+
// constexpr int f() {
// int sum = 0;
// int arr[] = {1,2,3,4,5,6,7,8,9,10};
@@ -143,12 +153,12 @@ public class ForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testIndexBasedForLoopWithNestedContinueStatement() throws Exception {
assertEvaluationEquals(30);
}
-
+
// constexpr int f() {
// int sum = 0;
// int arr[] = {1,2,3,4,5,6,7,8,9,10};
@@ -160,12 +170,12 @@ public class ForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testIndexBasedForLoopWithNestedBreakStatement() throws Exception {
assertEvaluationEquals(15);
}
-
+
// constexpr int triple(int x) {
// return x * 3;
// }
@@ -176,12 +186,12 @@ public class ForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testDeclarationInForStatementCondition1() throws Exception {
assertEvaluationEquals(30);
}
-
+
// constexpr int f() {
// int count = 0;
// for(;;) {
@@ -191,18 +201,18 @@ public class ForStatementTests extends TestBase {
// }
// return count;
// }
-
+
// constexpr int x = f();
public void testInfiniteForLoop() throws Exception {
assertEvaluationEquals(12);
}
-
+
// constexpr int fac(int n) {
// int result = 1;
// for(int i = 1; i <= n; result *= i++);
// return result;
// }
-
+
// constexpr int x = fac(5);
public void testForLoopWithNullStatementAsBody() throws Exception {
assertEvaluationEquals(120);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTemplateTests.java
index 3c4f6b35917..24e530ba9e8 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTemplateTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTemplateTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,25 +15,35 @@ import junit.framework.TestSuite;
public class FunctionTemplateTests extends TestBase {
public static class NonIndexing extends FunctionTemplateTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends FunctionTemplateTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// template<typename T>
// constexpr T add(T a, T b) {
// return a + b;
// }
-
+
// constexpr auto x = add(5.5, 6.3);
public void testImplicitTemplateInstantiation() throws Exception {
assertEvaluationEquals(11.8);
}
-
+
// class Integer {
// int i;
// public:
@@ -45,23 +55,23 @@ public class FunctionTemplateTests extends TestBase {
// T t{10};
// return t.get();
// }
-
+
// constexpr int x = f<Integer>();
public void testExplicitTemplateInstantiation() throws Exception {
assertEvaluationEquals(10);
}
-
+
// template<int I>
// constexpr int f() {
// int result = I * 4;
// return result;
// }
-
+
// constexpr int x = f<5>();
public void testTemplateWithNonTypeTemplateParameter() throws Exception {
assertEvaluationEquals(20);
}
-
+
// template<typename T>
// constexpr T sum(T v) {
// return v;
@@ -70,22 +80,22 @@ public class FunctionTemplateTests extends TestBase {
// constexpr T sum(T first, Args... args) {
// return first + sum(args...);
// }
-
+
// constexpr int x = sum(1,2,3,4,5);
public void testVariadicTemplate() throws Exception {
assertEvaluationEquals(15);
}
-
+
// template<typename... Args>
// constexpr int count(Args... args) {
// return sizeof...(args);
// }
-
+
// constexpr int x = count(1,2,3,4,5);
public void testParameterPackSizeof() throws Exception {
assertEvaluationEquals(5);
}
-
+
// class Integer {
// int i;
// public:
@@ -104,12 +114,12 @@ public class FunctionTemplateTests extends TestBase {
// }
// return total.get();
// }
-
+
// constexpr int x = fac(Integer{5});
public void testTemplateInstantiationOfForLoop() throws Exception {
assertEvaluationEquals(120);
}
-
+
// class Integer {
// int i;
// public:
@@ -129,23 +139,23 @@ public class FunctionTemplateTests extends TestBase {
// } while (i <= n);
// return sum.get();
// }
-
+
// constexpr int x = f(Integer{10});
public void testTemplateInstantiationOfDoWhileLoop() throws Exception {
assertEvaluationEquals(55);
}
-
+
// template<typename T>
// constexpr T add(T a, T b) {
// ;
// return a + b;
// }
-
+
// constexpr auto x = add(5.5, 6.3);
public void testNullStatementInFunctionTemplate() throws Exception {
assertEvaluationEquals(11.8);
}
-
+
// class Integer {
// int i;
// public:
@@ -155,7 +165,7 @@ public class FunctionTemplateTests extends TestBase {
// constexpr Integer& operator++() { ++i; return *this; }
// constexpr Integer& operator*=(Integer const& rhs) { i *= rhs.i; return *this; }
// };
- //
+ //
// template<typename T>
// constexpr int fac(T n) {
// T total{1};
@@ -166,12 +176,12 @@ public class FunctionTemplateTests extends TestBase {
// }
// return total.get();
// }
-
+
// constexpr int x = fac(Integer{5});
public void testTemplateInstantiationOfWhileLoop() throws Exception {
assertEvaluationEquals(120);
}
-
+
// template<typename T>
// constexpr T div(T a, T b) {
// if(b > 0) {
@@ -179,24 +189,24 @@ public class FunctionTemplateTests extends TestBase {
// }
// return -1;
// }
-
+
// constexpr auto x = div(11.5, 2.0);
public void testTemplateInstantiationOfIfStatement() throws Exception {
assertEvaluationEquals(5.75);
}
-
+
// constexpr int count(int first) { return 1; }
// constexpr int count(double first) { return 4; }
// template<typename T, typename... Args>
// constexpr int count(T first, Args... args) {
// return count(first) + count(args...);
// }
-
+
// constexpr int x = count(1, 0.5, 3.4, 5, 2.2);
public void testVariadicTemplateWithVaryingTypes() throws Exception {
assertEvaluationEquals(14);
}
-
+
// template<typename... Args>
// constexpr int sum(Args... args) {
// int sum = 0;
@@ -205,12 +215,12 @@ public class FunctionTemplateTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr long long x = sum(1,2,3,4,5);
public void testExpansionOfVariadicTemplateParameterIntoInitializerList() throws Exception {
assertEvaluationEquals(15);
}
-
+
// template<typename... Args>
// constexpr int sum(Args... args) {
// int sum = 0;
@@ -219,12 +229,12 @@ public class FunctionTemplateTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr long long x = sum(1,2,3,4,5);
public void testExpressionInVariadicTemplateParameterExpansion1() throws Exception {
assertEvaluationEquals(30);
}
-
+
// template<typename... Indices>
// constexpr int sumOfPrimes(Indices... indices) {
// // all prime numbers below 100
@@ -235,12 +245,12 @@ public class FunctionTemplateTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = sumOfPrimes(0, 4, 9, 11, 19);
public void testExpressionInVariadicTemplateParameterExpansion2() throws Exception {
assertEvaluationEquals(150);
}
-
+
// template<unsigned... Ints>
// class index_sequence{};
//
@@ -254,12 +264,12 @@ public class FunctionTemplateTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = sumOfPrimes(index_sequence<0, 4, 9, 11, 19>{});
public void testIndexSequence1() throws Exception {
assertEvaluationEquals(150);
}
-
+
// template<typename T, int size>
// constexpr int getArrayLength(T(&)[size]){
// return size;
@@ -268,12 +278,12 @@ public class FunctionTemplateTests extends TestBase {
// int arr[10]{};
// return getArrayLength(arr);
// }
-
+
// constexpr int x = f();
public void testFunctionTemplateWithArrayParameter1() throws Exception {
assertEvaluationEquals(10);
}
-
+
// template<typename T, int size>
// constexpr void doubleArrayContents(T(&arr)[size]) {
// for(int i = 0; i < size; i++) {
@@ -285,12 +295,12 @@ public class FunctionTemplateTests extends TestBase {
// doubleArrayContents(arr);
// return arr[3];
// }
-
+
// constexpr int x = f();
public void testFunctionTemplateWithArrayParameter2() throws Exception {
assertEvaluationEquals(8);
}
-
+
// struct S {
// constexpr S(int n):x{n*2} {}
// constexpr int get() { return x; }
@@ -300,14 +310,14 @@ public class FunctionTemplateTests extends TestBase {
// template<int N>
// constexpr int f() {
// S s{N};
- // return s.get();
+ // return s.get();
// }
-
+
// constexpr int x = f<10>();
public void testInstantiationOfConstructorInFunctionTemplate1() throws Exception {
assertEvaluationEquals(20);
}
-
+
// struct Number {
// constexpr Number(int):isFP{false} {}
// constexpr Number(double):isFP{true} {}
@@ -318,13 +328,13 @@ public class FunctionTemplateTests extends TestBase {
// template<typename T>
// constexpr bool f() {
// Number n{T{}};
- // return n.isFloatingPoint();
+ // return n.isFloatingPoint();
// }
// constexpr bool x = f<double>();
public void testInstantiationOfConstructorInFunctionTemplate2() throws Exception {
assertEvaluationEquals(true);
}
-
+
// template<int A, int B>
// struct Adder {
// constexpr int sum() {
@@ -344,12 +354,12 @@ public class FunctionTemplateTests extends TestBase {
// return 4;
// }
// }
-
+
// constexpr int x = f<9,2>();
public void testInstantiationOfSwitchStatement() throws Exception {
assertEvaluationEquals(2);
}
-
+
// template<typename T>
// constexpr int f() {
// typedef T myType;
@@ -357,12 +367,12 @@ public class FunctionTemplateTests extends TestBase {
// x *= 5;
// return x;
// }
-
+
// constexpr int x = f<int>();
public void testInstantiationOfTypedefDeclaration() throws Exception {
assertEvaluationEquals(25);
}
-
+
// template<typename T>
// constexpr int f() {
// using myint = T;
@@ -370,7 +380,7 @@ public class FunctionTemplateTests extends TestBase {
// x *= 5;
// return x;
// }
-
+
// constexpr int x = f<int>();
public void testInstantiationOfAliasDeclaration() throws Exception {
assertEvaluationEquals(25);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTests.java
index 58a276b0643..63fb951fef9 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -22,15 +22,25 @@ import junit.framework.TestSuite;
public class FunctionTests extends TestBase {
public static class NonIndexing extends FunctionTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends FunctionTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// struct S {
// int x;
// };
@@ -41,33 +51,33 @@ public class FunctionTests extends TestBase {
// S s{5};
// return g(s);
// }
-
+
// constexpr int x = f();
public void testAccessMemberOfCompositeParameter() throws Exception {
assertEvaluationEquals(5);
}
-
+
// constexpr int function(int n) { return n > 0 ? n + function(n-1) : n; }
-
+
// constexpr int x = function(10);
public void testRecursion() throws Exception {
assertEvaluationEquals(55);
}
-
- // constexpr int helper(int n) {
+
+ // constexpr int helper(int n) {
// int m = 5;
// return m + n;
// }
- // constexpr int function() {
+ // constexpr int function() {
// int value = helper(5);
// return value + helper(5);
// }
-
+
// constexpr int x = function();
public void testEvaluationOfConstexprFunctionCalls() throws Exception {
assertEvaluationEquals(20);
}
-
+
// constexpr int g(int i) {
// i++;
// return i;
@@ -84,7 +94,7 @@ public class FunctionTests extends TestBase {
public void testFunctionReturnValueIsCopiedAndNotReferenced() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr void incr(int x) {
// x = x + 1;
// }
@@ -93,12 +103,12 @@ public class FunctionTests extends TestBase {
// incr(a);
// return a;
// }
-
+
// constexpr auto x = f();
public void testPassingIntByValue() throws Exception {
assertEvaluationEquals(5);
}
-
+
// constexpr void incr(int &x) {
// x++;
// }
@@ -107,12 +117,12 @@ public class FunctionTests extends TestBase {
// incr(a);
// return a;
// }
-
+
// constexpr auto x = f();
public void testPassingIntByReference1() throws Exception {
assertEvaluationEquals(6);
}
-
+
// constexpr void incr(int &x, int &y) {
// x++;
// y++;
@@ -122,12 +132,12 @@ public class FunctionTests extends TestBase {
// incr(a, a);
// return a;
// }
-
+
// constexpr auto x = f();
public void testPassingIntByReference2() throws Exception {
assertEvaluationEquals(7);
}
-
+
// struct S {
// int x;
// };
@@ -139,12 +149,12 @@ public class FunctionTests extends TestBase {
// g(s);
// return s.x;
// }
-
+
// constexpr int x = f();
public void testPassingCompositeByValue() throws Exception {
assertEvaluationEquals(5);
}
-
+
// struct Point { int x, y; };
// constexpr void incr(Point &point) {
// point.x++;
@@ -154,12 +164,12 @@ public class FunctionTests extends TestBase {
// incr(p);
// return p.x;
// }
-
+
// constexpr auto x = f();
public void testPassingCompositeByReference() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int a[2][2] { { 1, 2 }, { 3, 4 } };
// constexpr int const * g() {
// return a[0];
@@ -167,12 +177,12 @@ public class FunctionTests extends TestBase {
// constexpr int f() {
// return g()[1];
// }
-
+
// constexpr auto x = f();
public void testPointerReturnValue() throws Exception {
assertEvaluationEquals(2);
- }
-
+ }
+
// int const y { 5 };
// constexpr int const & g() {
// return y;
@@ -180,12 +190,12 @@ public class FunctionTests extends TestBase {
// constexpr int f() {
// return g() + 1;
// }
-
+
// constexpr auto x = f();
public void testReferenceReturnValue() throws Exception {
assertEvaluationEquals(6);
}
-
+
// constexpr void side_effect(int array[], int length) {
// for (int i = 0; i < length; ++i) {
// array[i]++;
@@ -196,12 +206,12 @@ public class FunctionTests extends TestBase {
// side_effect(array, 4);
// return array[0];
// }
-
+
// constexpr auto x = f();
public void testSideEffectsOnArrayParameter() throws Exception {
- assertEvaluationEquals(2);
+ assertEvaluationEquals(2);
}
-
+
// constexpr int f(int a) {
// {
// int a = 5;
@@ -209,48 +219,48 @@ public class FunctionTests extends TestBase {
// }
// return a;
// }
-
+
// constexpr int x = f(10);
public void testBlockScopeValueLookup1() throws Exception {
assertEvaluationEquals(5);
}
-
+
// constexpr int f(int a) {
// {
// int a = 5;
// }
// return a;
// }
-
+
// constexpr int x = f(10);
public void testBlockScopeValueLookup2() throws Exception {
assertEvaluationEquals(10);
}
-
+
// char foo();
// constexpr int almost = sizeof(foo());
-
+
// constexpr int x = almost;
public void testSizeofCallToRegularFunction() throws Exception {
assertEvaluationEquals(1);
}
-
+
// int f() {
// return 5;
// }
-
+
// int x = f();
public void testNonConstexprFunctionDoesntStoreBodyExecution() throws Exception {
IASTInitializerClause clause = getLastDeclarationInitializer();
- IASTFunctionCallExpression funcExpr = (IASTFunctionCallExpression)clause;
- IASTIdExpression idExpr = (IASTIdExpression)funcExpr.getFunctionNameExpression();
- ICPPFunction function = (ICPPFunction)idExpr.getName().resolveBinding();
+ IASTFunctionCallExpression funcExpr = (IASTFunctionCallExpression) clause;
+ IASTIdExpression idExpr = (IASTIdExpression) funcExpr.getFunctionNameExpression();
+ ICPPFunction function = (ICPPFunction) idExpr.getName().resolveBinding();
ICPPExecution bodyExec = CPPFunction.getFunctionBodyExecution(function);
assertNull(bodyExec);
}
// // Empty header file
-
+
// struct A {
// A() {}
// A& m(int p) {
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IfStatementTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IfStatementTests.java
index 94e53607466..e8c32fe5320 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IfStatementTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IfStatementTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,34 +15,44 @@ import junit.framework.TestSuite;
public class IfStatementTests extends TestBase {
public static class NonIndexing extends IfStatementTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends IfStatementTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int f() {
// if (true) {
// return 1;
- // }
+ // }
// return 0;
// }
-
+
// constexpr int x = f();
public void testSimpleIfTrueBranch() throws Exception {
assertEvaluationEquals(1);
}
-
+
// constexpr int f() {
// if (false) {
// return 1;
- // }
+ // }
// return 0;
// }
-
+
// constexpr int x = f();
public void testSimpleIfFalseBranch() throws Exception {
assertEvaluationEquals(0);
@@ -55,12 +65,12 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f();
public void testIfElseTrueBranch() throws Exception {
assertEvaluationEquals(1);
}
-
+
// constexpr int f() {
// if (false) {
// return 1;
@@ -68,12 +78,12 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f();
public void testSimpleIfElseFalseBranch() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr int f() {
// if (false) {
// return 1;
@@ -83,12 +93,12 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f();
public void testNestedIfTrueBranch() throws Exception {
assertEvaluationEquals(2);
}
-
+
// constexpr int f() {
// if (false) {
// return 1;
@@ -98,35 +108,35 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f();
public void testNestedIfFalseBranch() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr int f() {
// if (true)
// return 1;
// return 0;
// }
-
+
// constexpr int x = f();
public void testIfStatementWithNonCompoundThenClause() throws Exception {
assertEvaluationEquals(1);
}
-
+
// constexpr int f() {
// if (false)
// return 1;
// else
// return 0;
// }
-
+
// constexpr int x = f();
public void testIfStatementWithNonCompoundElseClause() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr int f() {
// int i;
// if (true) {
@@ -136,12 +146,12 @@ public class IfStatementTests extends TestBase {
// }
// return i;
// }
-
+
// constexpr int x = f();
public void testIfStatementWithNonReturnClauses() throws Exception {
assertEvaluationEquals(10);
}
-
+
// constexpr int f() {
// int i;
// if (false)
@@ -150,12 +160,12 @@ public class IfStatementTests extends TestBase {
// i = 20;
// return i;
// }
-
+
// constexpr int x = f();
public void testIfStatementWithNonReturnClausesAndNonCompoundElseClause() throws Exception {
assertEvaluationEquals(20);
}
-
+
// constexpr int f(int y) {
// if(int x = y*2) {
// return 14 / x;
@@ -163,12 +173,12 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f(1);
public void testDeclarationInIfStatementCondition1() throws Exception {
assertEvaluationEquals(7);
}
-
+
// constexpr int f(int y) {
// if(int x = y*2) {
// return 14 / x;
@@ -176,12 +186,12 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f(0);
public void testDeclarationInIfStatementCondition2() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr int g(int x) {
// return x * 2;
// }
@@ -192,12 +202,12 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f(1);
public void testDeclarationInIfStatementCondition3() throws Exception {
assertEvaluationEquals(7);
}
-
+
// constexpr int g(int x) {
// return x * 2;
// }
@@ -208,12 +218,12 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f(1);
public void testInitStatementInIfStatementCondition1() throws Exception {
assertEvaluationEquals(7);
}
-
+
// constexpr int g(int x) {
// return x * 2;
// }
@@ -224,12 +234,12 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f(1);
public void testInitStatementInIfStatementCondition2() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr int g(int x) {
// return x * 2;
// }
@@ -240,12 +250,12 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f();
public void testInitStatementInIfStatementCondition3() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr int g(int x) {
// return x * 2;
// }
@@ -257,7 +267,7 @@ public class IfStatementTests extends TestBase {
// return 0;
// }
// }
-
+
// constexpr int x = f(1);
public void testEmptyInitStatementInIfStatementCondition1() throws Exception {
assertEvaluationEquals(7);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IntegralValueTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IntegralValueTests.java
index 729db619cff..641fdfc411f 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IntegralValueTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IntegralValueTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -17,95 +17,105 @@ import junit.framework.TestSuite;
public class IntegralValueTests extends TestBase {
public static class NonIndexing extends IntegralValueTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends IntegralValueTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr auto x = int{} + int();
public void testIntDefaultValue() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto f() {
// int x{};
// return x;
// }
-
+
// constexpr auto x = f();
public void testIntValueInitialization() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto x = long{} + long();
public void testLongDefaultValue() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto f() {
// long x{};
// return x;
// }
-
+
// constexpr auto x = f();
public void testLongValueInitialization() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto x = short{} + short();
public void testShortDefaultValue() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto f() {
// short x{};
// return x;
// }
-
+
// constexpr auto x = f();
public void testShortValueInitialization() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto x = bool{} + bool();
public void testBooleanDefaulValue() throws Exception {
assertEvaluationEquals(false);
}
-
+
// constexpr auto f() {
// bool x{};
// return x;
// }
-
+
// constexpr auto x = f();
public void testBoolValueInitialization() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto x = char{} + char();
public void testCharDefaultValue() throws Exception {
assertEvaluationEquals(0);
}
-
+
// constexpr auto f() {
// char x{'c'};
// return x;
// }
-
+
// constexpr auto x = f();
public void testCharValueInitialization() throws Exception {
assertEvaluationEquals('c');
}
-
+
// constexpr int mul(int op1, int op2) {
// int result = op1 * op2;
// return result;
// }
-
+
// constexpr int x = mul(2, 5);
public void testDeclarationWithEqualsInitializerInSequence() throws Exception {
assertEvaluationEquals(10);
@@ -116,145 +126,145 @@ public class IntegralValueTests extends TestBase {
// int intermediate2 { op2 };
// return intermediate1 * intermediate2;
// }
-
+
// constexpr int x = mul(2, 5);
public void testDeclarationWithDefaultInitializationInSequence() throws Exception {
assertEvaluationEquals(10);
}
-
+
// constexpr int f() {
// int i(5);
// i++;
// return i;
// }
-
+
// constexpr int x = f();
public void testDirectInitializationOnFundamentalTypes() throws Exception {
assertEvaluationEquals(6);
}
-
+
// constexpr int f() {
// int invalid;
// return invalid;
// }
-
+
// constexpr int x = f();
public void testUseOfUninitializedVariableIsError() throws Exception {
assertEvaluationEquals(IntegralValue.UNKNOWN);
}
-
+
// constexpr auto f() {
// int x = 1, y = 1, z = 1;
// return x + y + z;
// }
-
+
// constexpr auto x = f();
public void testDeclarationWithMultipleDeclarators() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int f() {
// int i{5};
// i++;
// return i;
// }
-
+
// constexpr int x = f();
public void testSimpleTypeConstructionInitializerList() throws Exception {
assertEvaluationEquals(6);
}
-
+
// constexpr int f() {
// int i(5);
// i++;
// return i;
// }
-
+
// constexpr int x = f();
public void testSimpleTypeConstructionConstructorInitializer() throws Exception {
assertEvaluationEquals(6);
}
-
+
// constexpr int f() {
// int i = 5;
// i++;
// return i;
// }
-
+
// constexpr int x = f();
public void testSimpleTypeConstructionEqualsInitializer1() throws Exception {
assertEvaluationEquals(6);
}
-
+
// constexpr int f() {
// int i = {5};
// i++;
// return i;
// }
-
+
// constexpr int x = f();
public void testSimpleTypeConstructionEqualsInitializer2() throws Exception {
assertEvaluationEquals(6);
}
-
+
// constexpr int f() {
// int a { 3 };
// int b = a;
// b++;
// return a + b;
// }
-
+
// constexpr int x = f();
public void testCopyInitialization() throws Exception {
assertEvaluationEquals(7);
}
-
- // constexpr int f() {
- // int y = 0, x = 5;
- // x++;
- // return x;
+
+ // constexpr int f() {
+ // int y = 0, x = 5;
+ // x++;
+ // return x;
// }
-
+
// constexpr auto x = f();
public void testMultipleDeclaratorsInOneDeclaration() throws Exception {
assertEvaluationEquals(6);
}
-
+
// constexpr int f() {
// return int{5};
// }
-
+
// constexpr int x = f();
public void testSimpleTypeConstructorExpression1() throws Exception {
assertEvaluationEquals(5);
}
-
+
// constexpr int f() {
// int a { 1 }; // declaration
// a = ++a * ++a; // assignment / side effects
// return a; // returns 6
// }
-
+
// constexpr auto x = f();
public void testSideEffects2() throws Exception {
- assertEvaluationEquals(6);
+ assertEvaluationEquals(6);
}
-
+
// constexpr int x = 2;
-
+
// constexpr int y = x * 4;
public void testAccessGlobalVariableFromGlobalConstexpr() throws Exception {
assertEvaluationEquals(8);
}
-
+
// constexpr int x = 2;
// constexpr int f() { return x * 4; }
-
+
// constexpr int y = f();
public void testAccessGlobalVariableFromConstexprFunction() throws Exception {
assertEvaluationEquals(8);
}
-
+
// constexpr int x = 0x2a;
public void testHexLiteral() throws Exception {
assertEvaluationEquals(42);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberFunctionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberFunctionTests.java
index fa4ac9b99db..a9d192722f4 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberFunctionTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberFunctionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,15 +15,25 @@ import junit.framework.TestSuite;
public class MemberFunctionTests extends TestBase {
public static class NonIndexing extends MemberFunctionTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends MemberFunctionTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// struct S {
// int x, y;
// constexpr int member() {
@@ -34,12 +44,12 @@ public class MemberFunctionTests extends TestBase {
// S s{3,7};
// return s.member();
// }
-
+
// constexpr auto x = f();
public void testMemberFunctionCall() throws Exception {
assertEvaluationEquals(4);
}
-
+
// struct S {
// int x, y;
// constexpr int member() {
@@ -51,12 +61,12 @@ public class MemberFunctionTests extends TestBase {
// S s{3,7};
// return s.member();
// }
-
+
// constexpr auto x = f();
public void testMemberFunctionWithImplicitThis() throws Exception {
- assertEvaluationEquals(8);
+ assertEvaluationEquals(8);
}
-
+
// class Point {
// int x, y;
// public:
@@ -69,12 +79,12 @@ public class MemberFunctionTests extends TestBase {
// Point p{4,5};
// return p.getY();
// }
-
+
// constexpr int x = f();
public void testExternallyDefinedMemberFunction() throws Exception {
assertEvaluationEquals(5);
}
-
+
// class S {
// int x;
// public:
@@ -88,12 +98,12 @@ public class MemberFunctionTests extends TestBase {
// s.inc();
// return s.get();
// }
-
+
// constexpr int x = f();
public void testPlusEqualsWithinMemberFunction() throws Exception {
assertEvaluationEquals(50);
}
-
+
// class Point {
// int x, y;
// public:
@@ -104,12 +114,12 @@ public class MemberFunctionTests extends TestBase {
// Point p{10,40};
// return p.getY();
// }
-
+
// constexpr int x = f();
public void testMemberAccessThroughThisPointer() throws Exception {
assertEvaluationEquals(40);
}
-
+
// struct S {
// int x, y;
// constexpr int member() {
@@ -125,12 +135,12 @@ public class MemberFunctionTests extends TestBase {
// S s{3,7};
// return s.member();
// }
-
+
// constexpr auto x = f();
public void testNestedMemberFunctionCallsWithImplicitThis() throws Exception {
- assertEvaluationEquals(8);
+ assertEvaluationEquals(8);
}
-
+
// struct S {
// constexpr S(int x, int y):x{x}, y{y*2} {}
// constexpr int getY() const {
@@ -140,15 +150,15 @@ public class MemberFunctionTests extends TestBase {
// int x;
// int y;
// };
- //
+ //
// constexpr S s{3, 5};
// constexpr int f() { return s.getY(); }
-
+
// constexpr int x = f();
public void testGlobalMemberFunctionCallFromConstexprFunction() throws Exception {
assertEvaluationEquals(10);
}
-
+
// struct S {
// constexpr S(int x, int y):x{x}, y{y*2} {}
// constexpr int getY() const {
@@ -157,14 +167,14 @@ public class MemberFunctionTests extends TestBase {
// private:
// int x;
// int y;
- // };
+ // };
// constexpr S s{3, 5};
-
+
// constexpr int x = s.getY();
public void testGlobalMemberFunctionCallFromGlobalConstexpr() throws Exception {
assertEvaluationEquals(10);
}
-
+
// struct S {
// constexpr S(int x, int y):x{x}, y{y} {}
// constexpr int add(S const& other) const {
@@ -182,6 +192,6 @@ public class MemberFunctionTests extends TestBase {
// constexpr int x = f();
public void testManualAddMemberFunction() throws Exception {
- assertEvaluationEquals(15);
+ assertEvaluationEquals(15);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberVariableTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberVariableTests.java
index ad118ebbe07..ab09b0b55ff 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberVariableTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberVariableTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,27 +15,37 @@ import junit.framework.TestSuite;
public class MemberVariableTests extends TestBase {
public static class NonIndexing extends MemberVariableTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends MemberVariableTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// struct Point { int x, y; };
// constexpr int f() {
// Point p{ 2, 4 };
// p.x++;
// return p.x;
// }
-
+
// constexpr auto x = f();
public void testIncrementOnCompositeValues() throws Exception {
assertEvaluationEquals(3);
}
-
+
// struct S {
// int x, y;
// };
@@ -43,51 +53,51 @@ public class MemberVariableTests extends TestBase {
// const S s{3,7};
// return s.y;
// }
-
+
// constexpr auto x = f();
public void testMemberAccessWithConstObject() throws Exception {
assertEvaluationEquals(7);
}
-
- // struct S {
- // int x, y;
- // };
- // constexpr S s{5, 6};
- // constexpr int f() { return s.y; }
-
- // constexpr auto x = f();
- public void testGlobalMemberAccessFromConstexprFunction() throws Exception {
- assertEvaluationEquals(6);
- }
-
+
// struct S {
// int x, y;
// };
// constexpr S s{5, 6};
-
+ // constexpr int f() { return s.y; }
+
+ // constexpr auto x = f();
+ public void testGlobalMemberAccessFromConstexprFunction() throws Exception {
+ assertEvaluationEquals(6);
+ }
+
+ // struct S {
+ // int x, y;
+ // };
+ // constexpr S s{5, 6};
+
// constexpr auto x = s.y;
public void testGlobalMemberAccessFromGlobalConstexpr() throws Exception {
assertEvaluationEquals(6);
}
-
+
// struct T {
// constexpr T(int x):x{2*x}{}
// int x;
// };
// struct S {
- // T t{5};
+ // T t{5};
// int i = t.x * 2;
// };
// constexpr int f() {
// S s{};
// return s.i;
// }
-
+
// constexpr int x = f();
- public void testFieldDependsOnOtherField() throws Exception {
- assertEvaluationEquals(20);
- }
-
+ public void testFieldDependsOnOtherField() throws Exception {
+ assertEvaluationEquals(20);
+ }
+
// class S {
// int arr[4]{2,4,6,8};
// public:
@@ -100,21 +110,21 @@ public class MemberVariableTests extends TestBase {
// int *ptr = s.getPtr()+2;
// return *ptr;
// }
-
+
// constexpr int x = f();
- public void testMemberInitializationWithoutUserDefinedCtor() throws Exception {
- assertEvaluationEquals(6);
- }
-
+ public void testMemberInitializationWithoutUserDefinedCtor() throws Exception {
+ assertEvaluationEquals(6);
+ }
+
// struct S {
- // static const int x = 5;
+ // static const int x = 5;
// };
// constexpr int f() {
// return S::x;
// }
// constexpr int x = f();
- public void testAccessOfStaticField() throws Exception {
- assertEvaluationEquals(5);
- }
+ public void testAccessOfStaticField() throws Exception {
+ assertEvaluationEquals(5);
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/PointerTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/PointerTests.java
index 6be5c882c20..789684cc470 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/PointerTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/PointerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -17,27 +17,37 @@ import junit.framework.TestSuite;
public class PointerTests extends TestBase {
public static class NonIndexing extends PointerTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends PointerTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int f() {
// int bar[2] { 3, 7 };
// int * bar_ptr { bar };
// bar_ptr++;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerArithmeticsPostFixIncr() throws Exception {
assertEvaluationEquals(7);
}
-
+
// constexpr int f() {
// int bar[2] { 3, 7 };
// int * bar_ptr { bar };
@@ -45,42 +55,42 @@ public class PointerTests extends TestBase {
// bar_ptr--;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerArithmeticsPostFixDecr() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int f() {
// int n { 0 };
// int * nPtr { &n };
// nPtr++;
// return *nPtr;
// }
-
+
// constexpr int x = f();
public void testDereferencingOfPointerToInvalidMemoryShouldFail() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar + 2 };
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerArithmeticInDeclaration() throws Exception {
assertEvaluationEquals(7);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar };
// int * bar_ptr2 { bar + 3 };
// return bar_ptr2 - bar_ptr;
// }
-
+
// constexpr int x = f();
public void testSubtractionOfPointersToSameArrayShouldYieldDistance() throws Exception {
assertEvaluationEquals(3);
@@ -92,60 +102,60 @@ public class PointerTests extends TestBase {
// bar_ptr = bar_ptr + 1;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerAddition() throws Exception {
assertEvaluationEquals(5);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar };
// bar_ptr += 2;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerAdditionAndAssignment() throws Exception {
assertEvaluationEquals(7);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar + 2};
// bar_ptr = bar_ptr - 2;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerSubtraction() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar + 2 };
// bar_ptr -= 2;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerSubtractionAndAssignment() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar };
// int * bar_ptr2 { bar_ptr };
// return *bar_ptr2;
// }
-
+
// constexpr int x = f();
public void testPointerDeclarationFromPointer() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar };
@@ -153,48 +163,48 @@ public class PointerTests extends TestBase {
// bar_ptr++;
// return *bar_ptr2;
// }
-
+
// constexpr int x = f();
public void testPointersHaveSeparatePositions() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar };
// int * bar_ptr2 { bar_ptr + 1 };
// return *bar_ptr2;
// }
-
+
// constexpr int x = f();
public void testPointerAdditionInDeclaration() throws Exception {
assertEvaluationEquals(5);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar + 3 };
// int * bar_ptr2 { bar_ptr - 1 };
// return *bar_ptr2;
// }
-
+
// constexpr int x = f();
public void testPointerSubtractionInDeclaration() throws Exception {
assertEvaluationEquals(7);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar + 3 };
// bar_ptr++;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testDereferencingOnePastTheEndPointerIsInvalid() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar + 3 };
@@ -202,12 +212,13 @@ public class PointerTests extends TestBase {
// bar_ptr--;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
- public void testDereferencingIncrementedOnePastTheEndAndThenDecrementedBackInRageAgainPointerIsValid() throws Exception {
+ public void testDereferencingIncrementedOnePastTheEndAndThenDecrementedBackInRageAgainPointerIsValid()
+ throws Exception {
assertEvaluationEquals(11);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar + 3 };
@@ -215,24 +226,25 @@ public class PointerTests extends TestBase {
// bar_ptr -= 2;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
- public void testDereferencingIncrementedTWOPastTheEndAndThenDecrementedBackInRageAgainPointerIsInvalid() throws Exception {
+ public void testDereferencingIncrementedTWOPastTheEndAndThenDecrementedBackInRageAgainPointerIsInvalid()
+ throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar };
// bar_ptr--;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerWithNegativePositionIsInvalid() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar };
@@ -240,70 +252,70 @@ public class PointerTests extends TestBase {
// bar_ptr++;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerThatOnceHasNegativePositionStaysInvalid() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar + 4 };
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerDeclaredOnePastTheEndIsInvalid() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar + 4 };
// bar_ptr--;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerDeclaredOnePastTheEndAndThenDecrementedBackInRageAgainIsValid() throws Exception {
assertEvaluationEquals(11);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar + 5 };
// bar_ptr -= 2;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerDeclaredTwoPastTheEndAndThenDecrementedBackInRageAgainStaysInvalid() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar - 1 };
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerDeclaredWithNegativePositionIsInvalid() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int * bar_ptr { bar - 1 };
// bar_ptr++;
// return *bar_ptr;
// }
-
+
// constexpr int x = f();
public void testPointerDelcaredWithNegativePositionStaysInvalid() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f() {
// int a { 1 }; // declaration
// int b { 2 };
@@ -311,10 +323,10 @@ public class PointerTests extends TestBase {
// ptr = &b;
// return *ptr;
// }
-
+
// constexpr auto x = f();
public void testPointerAssignment() throws Exception {
- assertEvaluationEquals(2);
+ assertEvaluationEquals(2);
}
// constexpr auto f() {
@@ -323,12 +335,12 @@ public class PointerTests extends TestBase {
// *x_ptr = 2;
// return *x_ptr;
// }
-
+
// constexpr auto x = f();
public void testPointerValueAssignment() throws Exception {
- assertEvaluationEquals(2);
+ assertEvaluationEquals(2);
}
-
+
// struct S {
// int x, y;
// };
@@ -338,19 +350,19 @@ public class PointerTests extends TestBase {
// *s_ptr = 3;
// return *s_ptr;
// }
-
+
// constexpr auto x = f();
public void testPointerToStructMember() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int f() {
// int a { 5 };
// int * aPtr { &a };
// (*aPtr)++;
// return a;
// }
-
+
// constexpr auto x = f();
public void testPointer() throws Exception {
assertEvaluationEquals(6);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/RangeBasedForStatementTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/RangeBasedForStatementTests.java
index 9cccef19a19..35d5b3af90f 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/RangeBasedForStatementTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/RangeBasedForStatementTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -17,15 +17,25 @@ import junit.framework.TestSuite;
public class RangeBasedForStatementTests extends TestBase {
public static class NonIndexing extends RangeBasedForStatementTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends RangeBasedForStatementTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int sum { 0 };
@@ -34,12 +44,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testSimpleRangeBasedForLoop() throws Exception {
assertEvaluationEquals(26);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int sum { 0 };
@@ -48,12 +58,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testReturnInRangeBasedForLoop() throws Exception {
assertEvaluationEquals(42);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int sum { 0 };
@@ -65,12 +75,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopReferences() throws Exception {
assertEvaluationEquals(30);
- }
-
+ }
+
// constexpr void incr(int & i) {
// i++;
// }
@@ -85,12 +95,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testPassReferenceObtainedFromRangeBasedForLoopToFunctionAndModify() throws Exception {
assertEvaluationEquals(30);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int sum { 0 };
@@ -98,12 +108,12 @@ public class RangeBasedForStatementTests extends TestBase {
// sum += i;
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopWithNonCompoundBodyStatement() throws Exception {
assertEvaluationEquals(26);
}
-
+
// constexpr int f() {
// int bar[4] { 3, 5, 7, 11 };
// int sum { 0 };
@@ -111,12 +121,12 @@ public class RangeBasedForStatementTests extends TestBase {
// return 42;
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopWithReturnInNonCompoundBodyStatement() throws Exception {
assertEvaluationEquals(42);
}
-
+
// class Range {
// int arr[5];
// public:
@@ -132,12 +142,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopOverCustomType() throws Exception {
assertEvaluationEquals(15);
}
-
+
// class Range {
// int arr[5];
// public:
@@ -160,12 +170,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopThatModifiesElementsInCustomType() throws Exception {
assertEvaluationEquals(20);
}
-
+
// class Range {
// int arr1[5];
// int arr2[5];
@@ -184,12 +194,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopOverNonConstRangeChoosesNonConstBeginEnd() throws Exception {
assertEvaluationEquals(15);
}
-
+
// class Range {
// int arr1[5];
// int arr2[5];
@@ -208,12 +218,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopOverConstRangeChoosesConstBeginEnd() throws Exception {
assertEvaluationEquals(40);
}
-
+
// class Range {
// int arr1[5];
// int arr2[5];
@@ -233,12 +243,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopOverConstRefRangeChoosesConstBeginEnd() throws Exception {
assertEvaluationEquals(40);
}
-
+
// class Range {
// int arr[5];
// public:
@@ -254,12 +264,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopOverCustomTypeWithInvalidBeginMemberFunction() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// class Range {
// int arr[5];
// public:
@@ -275,12 +285,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopOverCustomTypeWithBeginMemberFunctionWithDefaultParameterValue() throws Exception {
assertEvaluationEquals(15);
}
-
+
// namespace ns {
// class Vec {
// public:
@@ -300,12 +310,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testDoesArgumentDependentLookupIfBeginEndMemberFunctionsDontExist() throws Exception {
assertEvaluationEquals(15);
}
-
+
// namespace ns {
// class Vec {
// public:
@@ -328,12 +338,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testChoosesMemberFunctionsOverFreeFunctions() throws Exception {
assertEvaluationEquals(40);
}
-
+
// namespace ns {
// class Vec {
// public:
@@ -353,12 +363,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testDoesntMixMemberFunctionsAndFreeFunctions() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// namespace ns {
// class Vec {
// int arr[5];
@@ -381,12 +391,12 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testWorksWithBeginEndTemplates() throws Exception {
assertEvaluationEquals(15);
}
-
+
// constexpr int f() {
// int sum = 0;
// for(auto x : {1,2,3,4,5}) {
@@ -394,7 +404,7 @@ public class RangeBasedForStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f();
public void testRangeBasedForLoopOverInitializerList() throws Exception {
assertEvaluationEquals(15);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ReferenceTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ReferenceTests.java
index 3de42ce94b2..7a790030299 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ReferenceTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ReferenceTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,39 +15,49 @@ import junit.framework.TestSuite;
public class ReferenceTests extends TestBase {
public static class NonIndexing extends ReferenceTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends ReferenceTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int f() {
// int a { 1 };
// int &aRef { a };
// aRef++;
// return a;
// }
-
+
// constexpr int x = f();
public void testSideEffectsOnReferences() throws Exception {
assertEvaluationEquals(2);
}
-
+
// constexpr int f() {
// int a { 1 };
// int &aRef { a };
// aRef = aRef + 1;
// return a;
// }
-
+
// constexpr int x = f();
public void testAssignmentsOnReferences() throws Exception {
assertEvaluationEquals(2);
}
-
+
// constexpr int f() {
// int a { 1 };
// int &aRef { a };
@@ -55,12 +65,12 @@ public class ReferenceTests extends TestBase {
// aRefRef++;
// return a;
// }
-
+
// constexpr auto x = f();
public void testSideEffectsOnNestedReferences() throws Exception {
assertEvaluationEquals(2);
}
-
+
// constexpr int f() {
// int a { 1 };
// int &aRef { a };
@@ -68,7 +78,7 @@ public class ReferenceTests extends TestBase {
// aRefRef = aRef + aRefRef;
// return a;
// }
-
+
// constexpr auto x = f();
public void testAssignmentOnNestedReferences() throws Exception {
assertEvaluationEquals(2);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/SwitchStatementTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/SwitchStatementTests.java
index c71c89fea78..678263064f1 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/SwitchStatementTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/SwitchStatementTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,15 +15,25 @@ import junit.framework.TestSuite;
public class SwitchStatementTests extends TestBase {
public static class NonIndexing extends SwitchStatementTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends SwitchStatementTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int f() {
// int x { 1 };
// switch (x) {
@@ -35,12 +45,12 @@ public class SwitchStatementTests extends TestBase {
// return -1;
// }
// }
-
+
// constexpr int x = f();
public void testSwitchFirstCase() throws Exception {
assertEvaluationEquals(1);
}
-
+
// constexpr int f() {
// int x { 2 };
// switch (x) {
@@ -52,12 +62,12 @@ public class SwitchStatementTests extends TestBase {
// return -1;
// }
// }
-
+
// constexpr int x = f();
public void testSwitchMiddleCase() throws Exception {
assertEvaluationEquals(2);
}
-
+
// constexpr int f() {
// int x { 3 };
// switch (x) {
@@ -69,12 +79,12 @@ public class SwitchStatementTests extends TestBase {
// return -1;
// }
// }
-
+
// constexpr int x = f();
public void testSwitchDefault() throws Exception {
assertEvaluationEquals(-1);
}
-
+
// constexpr int f() {
// int x { 1 };
// switch (x) {
@@ -85,12 +95,12 @@ public class SwitchStatementTests extends TestBase {
// return -1;
// }
// }
-
+
// constexpr int x = f();
public void testSwitchFallThrough() throws Exception {
assertEvaluationEquals(2);
}
-
+
// constexpr int f() {
// int x { 1 };
// int y = 10;
@@ -100,12 +110,12 @@ public class SwitchStatementTests extends TestBase {
// y--;
// return y;
// }
-
+
// constexpr int x = f();
public void testSwitchWithOnlyOneClause1() throws Exception {
assertEvaluationEquals(10);
}
-
+
// constexpr int f() {
// int x { 0 };
// int y = 10;
@@ -115,13 +125,12 @@ public class SwitchStatementTests extends TestBase {
// y--;
// return y;
// }
-
+
// constexpr int x = f();
public void testSwitchWithOnlyOneClause2() throws Exception {
assertEvaluationEquals(9);
}
-
-
+
// constexpr int f() {
// int x { 2 };
// int y = 2;
@@ -137,12 +146,12 @@ public class SwitchStatementTests extends TestBase {
// }
// return y;
// }
-
+
// constexpr int x = f();
public void testSwitchBreak() throws Exception {
assertEvaluationEquals(20);
}
-
+
// constexpr int f() {
// int x { 3 };
// int y = 2;
@@ -156,12 +165,12 @@ public class SwitchStatementTests extends TestBase {
// }
// return y;
// }
-
+
// constexpr int x = f();
public void testSwitchNoMatchingCaseAndNoDefault() throws Exception {
assertEvaluationEquals(2);
}
-
+
// class Point {
// int x, y;
// public:
@@ -172,7 +181,7 @@ public class SwitchStatementTests extends TestBase {
// int x { 2 };
// int y = 5;
// constexpr Point p{4, 1};
- //
+ //
// switch (x) {
// case 1:
// y = 10;
@@ -183,12 +192,12 @@ public class SwitchStatementTests extends TestBase {
// }
// return y;
// }
-
+
// constexpr int x = f();
public void testSwitchCaseConstants() throws Exception {
assertEvaluationEquals(20);
}
-
+
// constexpr int triple(int x) {
// return x * 3;
// }
@@ -204,12 +213,12 @@ public class SwitchStatementTests extends TestBase {
// return 4;
// }
// }
-
+
// constexpr int x = f(5);
public void testDeclarationInSwitchStatementController() throws Exception {
assertEvaluationEquals(3);
}
-
+
// enum Color { RED, GREEN, BLUE };
// constexpr int f(Color color) {
// switch(color) {
@@ -221,12 +230,12 @@ public class SwitchStatementTests extends TestBase {
// return 3;
// }
// }
-
+
// constexpr int x = f(BLUE);
public void testSwitchOnEnumValue() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr int f() {
// int arr[] = {1,2,1,3,5,6,1,2,0};
// int sum{};
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TestBase.java
index ad94d5cac35..3083093cf5d 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TestBase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TestBase.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -154,8 +154,9 @@ public class TestBase extends IndexBindingResolutionTestBase {
@Override
public void setUp() throws Exception {
CTestPlugin plugin = CTestPlugin.getDefault();
- StringBuilder[] builders = TestSourceReader.getContentsForTest(plugin.getBundle(), "parser", TestBase.this.getClass(), getName(), 2);
- if(builders.length == 2) {
+ StringBuilder[] builders = TestSourceReader.getContentsForTest(plugin.getBundle(), "parser",
+ TestBase.this.getClass(), getName(), 2);
+ if (builders.length == 2) {
builders[0].append(builders[1].toString());
}
testData = new StringBuilder[] { builders[0] };
@@ -178,7 +179,8 @@ public class TestBase extends IndexBindingResolutionTestBase {
}
protected static IASTTranslationUnit parse(String code) throws ParserException {
- IScanner scanner = createScanner(FileContent.create(TEST_CODE, code.toCharArray()), ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, SCANNER_INFO);
+ IScanner scanner = createScanner(FileContent.create(TEST_CODE, code.toCharArray()), ParserLanguage.CPP,
+ ParserMode.COMPLETE_PARSE, SCANNER_INFO);
AbstractGNUSourceCodeParser parser = null;
ICPPParserExtensionConfiguration config = new ANSICPPParserExtensionConfiguration();
parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TypeAliasTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TypeAliasTests.java
index f545c766a1d..f8bfe848d71 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TypeAliasTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TypeAliasTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,34 +15,44 @@ import junit.framework.TestSuite;
public class TypeAliasTests extends TestBase {
public static class NonIndexing extends TypeAliasTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends TypeAliasTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int f() {
// typedef int myint;
// myint x = 5;
// x *= 5;
// return x;
// }
-
+
// constexpr int x = f();
public void testTypedefDeclaration() throws Exception {
assertEvaluationEquals(25);
}
-
+
// constexpr int f() {
// using myint = int;
// myint x = 5;
// x *= 5;
// return x;
// }
-
+
// constexpr int x = f();
public void testAliasDeclaration() throws Exception {
assertEvaluationEquals(25);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryExpressionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryExpressionTests.java
index bdc7ee5d418..d75d427392b 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryExpressionTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryExpressionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,124 +15,134 @@ import junit.framework.TestSuite;
public class UnaryExpressionTests extends TestBase {
public static class NonIndexing extends UnaryExpressionTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends UnaryExpressionTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int doubleIncrement(int n) {
// ++n;
// ++n;
// return n;
// }
-
+
// constexpr int x = doubleIncrement(0);
public void testSimpleSequence() throws Exception {
assertEvaluationEquals(2);
}
-
- // constexpr int function() {
+
+ // constexpr int function() {
// int n { 0 };
// int m { n++ };
// int o { n++ };
// return n;
// }
-
+
// constexpr int x = function();
public void testAssignmentWithPostfixIncrSideEffects() throws Exception {
assertEvaluationEquals(2);
}
-
- // constexpr int function() {
+
+ // constexpr int function() {
// int n { 0 };
// int m { n-- };
// int o { n-- };
// return n;
// }
-
+
// constexpr int x = function();
public void testAssignmentWithPostfixDecrSideEffects() throws Exception {
assertEvaluationEquals(-2);
}
-
- // constexpr int function() {
+
+ // constexpr int function() {
// int n { 0 };
// int m { --n };
// int o { --n };
// return n;
// }
-
+
// constexpr int x = function();
public void testAssignmentWithPrefixDecrSideEffects() throws Exception {
assertEvaluationEquals(-2);
}
-
- // constexpr int function() {
+
+ // constexpr int function() {
// int n { 0 };
// int m { ++n };
// int o { ++n };
// return n;
// }
-
+
// constexpr int x = function();
public void testAssignmentWithPrefixIncrSideEffects() throws Exception {
assertEvaluationEquals(2);
}
-
- // constexpr int function() {
+
+ // constexpr int function() {
// int n { 0 };
// return n++;
// }
-
+
// constexpr int x = function();
public void testPostfixIncrSemantics() throws Exception {
assertEvaluationEquals(0);
}
-
- // constexpr int function() {
+
+ // constexpr int function() {
// int n { 0 };
// return n++;
// }
-
+
// constexpr int x = function();
public void testPostfixDecrSemantics() throws Exception {
assertEvaluationEquals(0);
}
-
- // constexpr int function() {
+
+ // constexpr int function() {
// int n { 0 };
// return ++n;
// }
-
+
// constexpr int x = function();
public void testPrefixIncrSemantics() throws Exception {
assertEvaluationEquals(1);
}
-
- // constexpr int function() {
+
+ // constexpr int function() {
// int n { 0 };
// return --n;
// }
-
+
// constexpr int x = function();
public void testPrefixDecrSemantics() throws Exception {
assertEvaluationEquals(-1);
}
-
+
// constexpr int f() {
- // int x = 2;
- // ++(++x);
- // return x;
- // }
-
- // constexpr int x = f();
- public void testPrefixIncrementReturnsLvalue() throws Exception {
- assertEvaluationEquals(4);
- }
+ // int x = 2;
+ // ++(++x);
+ // return x;
+ // }
+
+ // constexpr int x = f();
+ public void testPrefixIncrementReturnsLvalue() throws Exception {
+ assertEvaluationEquals(4);
+ }
// struct BooleanConvertible {
// bool value;
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryOperatorOverloadingTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryOperatorOverloadingTests.java
index c7d54535b1d..854f2abafca 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryOperatorOverloadingTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryOperatorOverloadingTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -15,15 +15,25 @@ import junit.framework.TestSuite;
public class UnaryOperatorOverloadingTests extends TestBase {
public static class NonIndexing extends UnaryOperatorOverloadingTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends UnaryOperatorOverloadingTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// class Point {
// int x, y;
// public:
@@ -41,12 +51,12 @@ public class UnaryOperatorOverloadingTests extends TestBase {
// ++p;
// return p.getY();
// }
-
+
// constexpr int x = f();
public void testPrefixIncrementAsMemberFunction() throws Exception {
- assertEvaluationEquals(6);
+ assertEvaluationEquals(6);
}
-
+
// class Point {
// int x, y;
// friend constexpr Point& operator++(Point&);
@@ -56,21 +66,21 @@ public class UnaryOperatorOverloadingTests extends TestBase {
// return y;
// }
// };
- //
+ //
// constexpr Point& operator++(Point& p) {
// ++p.x;
// ++p.y;
// return p;
// }
- //
+ //
// constexpr int f() {
// Point p{4,5};
// ++p;
// return p.getY();
// }
-
+
// constexpr int x = f();
public void testPrefixIncrementAsNonMemberFunction() throws Exception {
- assertEvaluationEquals(6);
+ assertEvaluationEquals(6);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UserDefinedLiteralTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UserDefinedLiteralTests.java
index febe4402ea7..cf32d1a7a2f 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UserDefinedLiteralTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UserDefinedLiteralTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -17,24 +17,34 @@ import junit.framework.TestSuite;
public class UserDefinedLiteralTests extends TestBase {
public static class NonIndexing extends UserDefinedLiteralTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends UserDefinedLiteralTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr unsigned long long operator"" _min(unsigned long long minutes) {
// return minutes * 60;
// }
-
+
// constexpr auto x = 25_min;
public void testUserDefinedIntegerLiteral() throws Exception {
- assertEvaluationEquals(1500);
+ assertEvaluationEquals(1500);
}
-
+
// constexpr unsigned long long operator"" _capitals(const char* str, unsigned long size) {
// unsigned long long count = 0;
// for(int i = 0; i < size; ++i) {
@@ -44,12 +54,12 @@ public class UserDefinedLiteralTests extends TestBase {
// }
// return count;
// }
-
+
// constexpr auto x = "HAllO"_capitals;
public void testUserDefinedStringLiteral() throws Exception {
assertEvaluationEquals(3);
}
-
+
// constexpr bool operator "" _v(char c) {
// switch(c) {
// case 'a':
@@ -62,21 +72,21 @@ public class UserDefinedLiteralTests extends TestBase {
// return false;
// }
// }
-
+
// constexpr auto x = 'a'_v;
public void testUserDefinedCharacterLiteral() throws Exception {
assertEvaluationEquals(true);
}
-
+
// constexpr long double operator"" _deg(long double deg) {
// return deg * 3.141592 / 180;
// }
-
+
// constexpr auto x = 100.0_deg;
public void testUserDefinedFloatingPointLiteral() throws Exception {
assertEvaluationEquals(1.74533);
}
-
+
// constexpr unsigned long long operator "" _l(const char *str) {
// int l = 0;
// while(str[l] != '\0') {
@@ -84,13 +94,13 @@ public class UserDefinedLiteralTests extends TestBase {
// }
// return l;
// }
-
+
// constexpr auto x = 20000_l;
public void testFallbackToRawLiteralOperator() throws Exception {
assertEvaluationEquals(5);
}
-
- // template <char... STR>
+
+ // template <char... STR>
// constexpr unsigned operator"" _l() {
// return 5;
// }
@@ -99,96 +109,96 @@ public class UserDefinedLiteralTests extends TestBase {
public void testRawLiteralOperatorTemplate() throws Exception {
assertEvaluationEquals(5);
}
-
+
// constexpr unsigned operator "" _l(unsigned long long x) {
// return 10;
- // }
+ // }
// constexpr unsigned operator "" _l(const char *str) {
// return 20;
// }
-
+
// constexpr int x = 120_l;
public void testChoosesCookedLiteralOverRawLiteralOperatorIfAvailable() throws Exception {
assertEvaluationEquals(10);
}
-
+
// constexpr unsigned operator "" _l(unsigned long long x) {
// return 10;
- // }
- // template <char... STR>
+ // }
+ // template <char... STR>
// constexpr unsigned operator"" _l() {
// return 20;
// }
-
+
// constexpr int x = 120_l;
public void testChoosesCookedLiteralOverRawLiteralTemplateIfAvailable() throws Exception {
assertEvaluationEquals(10);
}
-
+
// constexpr unsigned operator "" _l(long double x) {
// return 10;
- // }
+ // }
// constexpr unsigned operator "" _l(const char *str) {
// return 20;
// }
-
+
// constexpr int x = 120_l;
public void testFallsBackToRawLiteralOperatorIfParameterTypeDoesntMatchUnsignedLongLong() throws Exception {
assertEvaluationEquals(20);
}
-
+
// constexpr unsigned operator "" _l(long double x) {
// return 10;
- // }
- // template <char... STR>
+ // }
+ // template <char... STR>
// constexpr unsigned operator"" _l() {
// return 20;
// }
-
+
// constexpr int x = 120_l;
public void testFallsBackToRawLiteralOperatorTemplateIfParameterTypeDoesntMatchUnsignedLongLong() throws Exception {
assertEvaluationEquals(20);
}
-
+
// constexpr unsigned operator "" _l(unsigned long long x) {
// return 10;
- // }
+ // }
// constexpr unsigned operator "" _l(const char *str) {
// return 20;
// }
-
+
// constexpr int x = 120.0_l;
public void testFallsBackToRawLiteralOperatorIfParameterTypeDoesntMatchLongDouble() throws Exception {
assertEvaluationEquals(20);
}
-
+
// constexpr unsigned operator "" _l(unsigned long long x) {
// return 10;
- // }
- // template <char... STR>
+ // }
+ // template <char... STR>
// constexpr unsigned operator"" _l() {
// return 20;
// }
-
+
// constexpr int x = 120.0_l;
public void testFallsBackToRawLiteralOperatorTemplateIfParameterTypeDoesntMatchLongDouble() throws Exception {
assertEvaluationEquals(20);
}
-
+
// constexpr unsigned operator "" _l(const char *str) {
// return 20;
// }
-
+
// constexpr int x = "hello"_l;
public void testIgnoresRawLiteralOperatorForUserDefinedStringLiterals() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
- // template <char... STR>
+
+ // template <char... STR>
// constexpr unsigned operator"" _l() {
// return 20;
// }
-
+
// constexpr int x = "hello"_l;
public void testIgnoresRawLiteralOperatorTemplateForUserDefinedStringLiterals() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/WhileStatementTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/WhileStatementTests.java
index 223baf61f5f..ba5c5fe33e8 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/WhileStatementTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/WhileStatementTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
+* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
* This program and the accompanying materials
@@ -17,15 +17,25 @@ import junit.framework.TestSuite;
public class WhileStatementTests extends TestBase {
public static class NonIndexing extends WhileStatementTests {
- public NonIndexing() {setStrategy(new NonIndexingTestStrategy());}
- public static TestSuite suite() {return suite(NonIndexing.class);}
+ public NonIndexing() {
+ setStrategy(new NonIndexingTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(NonIndexing.class);
+ }
}
-
+
public static class SingleProject extends WhileStatementTests {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true, false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true, false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// while (n > 0) {
@@ -34,12 +44,12 @@ public class WhileStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testWhileLoopWithConditionalExpression() throws Exception {
assertEvaluationEquals(55);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// while (true) {
@@ -48,12 +58,12 @@ public class WhileStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testEvalShouldAbortOnWhileWitInfiniteLoop() throws Exception {
assertEvaluationEquals(IntegralValue.ERROR);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// while (true) {
@@ -62,36 +72,36 @@ public class WhileStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testReturnInWhileStatement() throws Exception {
assertEvaluationEquals(42);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// while (n > 0)
// sum += n--;
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testWhileLoopWithNonCompoundBodyStatement() throws Exception {
assertEvaluationEquals(55);
}
-
+
// constexpr int f(int n) {
// int sum { 0 };
// while (n > 0)
// return 42;
// return sum;
// }
-
+
// constexpr int x = f(10);
public void testWhileLoopWithReturnInNonCompoundBodyStatement() throws Exception {
assertEvaluationEquals(42);
}
-
+
// constexpr int triple(int x) {
// return x * 3;
// }
@@ -102,7 +112,7 @@ public class WhileStatementTests extends TestBase {
// }
// return sum;
// }
-
+
// constexpr int x = f(4);
public void testDeclarationInWhileStatementCondition1() throws Exception {
assertEvaluationEquals(30);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx17/LambdaExpressionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx17/LambdaExpressionTests.java
index dcc80902367..398a6ef19c9 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx17/LambdaExpressionTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx17/LambdaExpressionTests.java
@@ -25,7 +25,7 @@ public class LambdaExpressionTests extends AST2CPPTestBase {
// [*this] { }();
// }
// };
- public void testLambdaCaptures_535196_1() throws Exception {
+ public void testLambdaCaptures_535196_1() throws Exception {
parseAndCheckBindings();
}
@@ -36,7 +36,7 @@ public class LambdaExpressionTests extends AST2CPPTestBase {
// [*this] { bar(); }();
// }
// };
- public void testLambdaCaptures_535196_2() throws Exception {
+ public void testLambdaCaptures_535196_2() throws Exception {
parseAndCheckBindings();
}
@@ -47,7 +47,7 @@ public class LambdaExpressionTests extends AST2CPPTestBase {
// [m = 3, *this] { bar(m); }();
// }
// };
- public void testLambdaCaptures_535196_3() throws Exception {
+ public void testLambdaCaptures_535196_3() throws Exception {
parseAndCheckBindings();
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java
index 3bf6b12eca5..812761db9e7 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java
@@ -30,24 +30,20 @@ public class BasicCompletionTest extends CompletionTestBase {
assertEquals(1, names.length);
IBinding[] bindings = names[0].getCompletionContext().findBindings(names[0], true);
assertEquals(1, bindings.length);
- IVariable var = (IVariable)bindings[0];
+ IVariable var = (IVariable) bindings[0];
assertEquals("blah", var.getName());
}
-
+
public void testVar() throws Exception {
- String code =
- "int blah = 4;" +
- "int two = bl";
-
+ String code = "int blah = 4;" + "int two = bl";
+
testVar(getGPPCompletionNode(code));
testVar(getGCCCompletionNode(code));
}
public void testFunction() throws Exception {
- String code =
- "void func(int x) { }" +
- "void func2() { fu";
-
+ String code = "void func(int x) { }" + "void func2() { fu";
+
// C++
IASTCompletionNode node = getGPPCompletionNode(code);
IASTName[] names = node.getNames();
@@ -57,8 +53,8 @@ public class BasicCompletionTest extends CompletionTestBase {
IBinding[] bindings = names[0].getCompletionContext().findBindings(names[0], true);
// There should be two since they both start with fu
assertEquals(2, bindings.length);
- assertEquals("func", ((IFunction)bindings[0]).getName());
- assertEquals("func2", ((IFunction)bindings[1]).getName());
+ assertEquals("func", ((IFunction) bindings[0]).getName());
+ assertEquals("func2", ((IFunction) bindings[1]).getName());
// The other names shouldn't be hooked up
for (int i = 1; i < names.length; i++) {
assertNull(names[i].getTranslationUnit());
@@ -73,8 +69,8 @@ public class BasicCompletionTest extends CompletionTestBase {
bindings = sortBindings(names[0].getCompletionContext().findBindings(names[0], true));
// There should be two since they both start with fu
assertEquals(2, bindings.length);
- assertEquals("func", ((IFunction)bindings[0]).getName());
- assertEquals("func2", ((IFunction)bindings[1]).getName());
+ assertEquals("func", ((IFunction) bindings[0]).getName());
+ assertEquals("func2", ((IFunction) bindings[1]).getName());
// The other names shouldn't be hooked up
for (int i = 1; i < names.length; i++) {
assertNull(names[i].getTranslationUnit());
@@ -82,10 +78,8 @@ public class BasicCompletionTest extends CompletionTestBase {
}
public void testTypedef() throws Exception {
- String code =
- "void test() {typedef int blah;" +
- "bl";
-
+ String code = "void test() {typedef int blah;" + "bl";
+
// C++
IASTCompletionNode node = getGPPCompletionNode(code);
IASTName[] names = node.getNames();
@@ -93,46 +87,42 @@ public class BasicCompletionTest extends CompletionTestBase {
assertNull(names[1].getTranslationUnit());
IBinding[] bindings = names[0].getCompletionContext().findBindings(names[0], true);
assertEquals(1, bindings.length);
- assertEquals("blah", ((ITypedef)bindings[0]).getName());
-
+ assertEquals("blah", ((ITypedef) bindings[0]).getName());
+
// C
node = getGCCCompletionNode(code);
names = node.getNames();
- assert(names.length > 0);
+ assert (names.length > 0);
bindings = names[0].getCompletionContext().findBindings(names[0], true);
assertEquals(1, bindings.length);
- assertEquals("blah", ((ITypedef)bindings[0]).getName());
+ assertEquals("blah", ((ITypedef) bindings[0]).getName());
}
-
+
public void testBug181624() throws Exception {
- String code =
- "void foo() {" +
- " switch (";
-
+ String code = "void foo() {" + " switch (";
+
// C++
IASTCompletionNode node = getGPPCompletionNode(code);
assertNotNull(node);
-
+
// C
node = getGCCCompletionNode(code);
assertNotNull(node);
-
- code =
- "void foo() {" +
- " while (";
-
+
+ code = "void foo() {" + " while (";
+
// C++
node = getGPPCompletionNode(code);
assertNotNull(node);
-
+
// C
node = getGCCCompletionNode(code);
assertNotNull(node);
}
-
+
// template <typename T> class CT {};
// template <typename T> class B: public A<T> {
- // public:
+ // public:
// void doit(){}
// };
// int main() {
@@ -140,19 +130,19 @@ public class BasicCompletionTest extends CompletionTestBase {
// b.
public void testBug267911() throws Exception {
String code = getAboveComment();
- String[] expected= {"B", "doit"};
+ String[] expected = { "B", "doit" };
checkCompletion(code, true, expected);
}
-
+
// typedef struct MyType {
// int aField;
// } MyType;
// M
public void testBug279931() throws Exception {
String code = getAboveComment();
- String[] expected= {"MyType", "MyType"};
+ String[] expected = { "MyType", "MyType" };
checkCompletion(code, true, expected);
- expected= new String[] {"MyType"};
+ expected = new String[] { "MyType" };
checkCompletion(code, false, expected);
}
@@ -162,18 +152,18 @@ public class BasicCompletionTest extends CompletionTestBase {
// struct M
public void testBug279931a() throws Exception {
String code = getAboveComment();
- String[] expected= {"MyType"};
+ String[] expected = { "MyType" };
checkCompletion(code, true, expected);
checkCompletion(code, false, expected);
}
-
+
// template <t
public void testBug280934() throws Exception {
String code = getAboveComment();
- String[] expected= {};
+ String[] expected = {};
checkCompletion(code, true, expected);
}
-
+
// struct s1 {
// struct {
// int a1;
@@ -190,12 +180,12 @@ public class BasicCompletionTest extends CompletionTestBase {
// s.
public void testBug284245() throws Exception {
String code = getAboveComment();
- String[] expectedCpp= {"a1", "a2", "b", "s1", "u1", "u2"};
- String[] expectedC= {"a1", "a2", "b", "u1", "u2"};
+ String[] expectedCpp = { "a1", "a2", "b", "s1", "u1", "u2" };
+ String[] expectedC = { "a1", "a2", "b", "u1", "u2" };
checkCompletion(code, true, expectedCpp);
checkCompletion(code, false, expectedC);
}
-
+
// struct A{
// virtual void test() {}
// };
@@ -205,16 +195,16 @@ public class BasicCompletionTest extends CompletionTestBase {
// A::t
public void testQualifiedMemberAccess_Bug300139() throws Exception {
String code = getAboveComment();
- String[] expectedCpp= {"test"};
+ String[] expectedCpp = { "test" };
checkCompletion(code, true, expectedCpp);
}
-
+
// typedef int MyType;
// void func(){
// static_cast<My
public void testCastExpression_Bug301933() throws Exception {
String code = getAboveComment();
- String[] expectedCpp= {"MyType"};
+ String[] expectedCpp = { "MyType" };
checkCompletion(code, true, expectedCpp);
}
@@ -223,11 +213,11 @@ public class BasicCompletionTest extends CompletionTestBase {
// v1= 0 ? v
public void testConditionalOperator_Bug308611() throws Exception {
String code = getAboveComment();
- String[] expected= {"v1", "v2"};
+ String[] expected = { "v1", "v2" };
checkCompletion(code, true, expected);
checkCompletion(code, false, expected);
}
-
+
// struct B {
// int m;
// };
@@ -236,7 +226,7 @@ public class BasicCompletionTest extends CompletionTestBase {
// new (b->
public void testNewExpressions_Bug313982a() throws Exception {
String code = getAboveComment();
- String[] expected= {"B", "m"};
+ String[] expected = { "B", "m" };
checkCompletion(code, true, expected);
}
@@ -248,7 +238,7 @@ public class BasicCompletionTest extends CompletionTestBase {
// new (b->m) B
public void testNewExpressions_Bug313982b() throws Exception {
String code = getAboveComment();
- String[] expected= {"B"};
+ String[] expected = { "B" };
checkCompletion(code, true, expected);
}
@@ -260,26 +250,26 @@ public class BasicCompletionTest extends CompletionTestBase {
// new (b->m) (B
public void testNewExpressions_Bug313982c() throws Exception {
String code = getAboveComment();
- String[] expected= {"B"};
+ String[] expected = { "B" };
checkCompletion(code, true, expected);
}
-
+
// typedef int tint;
// void f(x) ti
public void testIncompleteKnrFunction_Bug324384() throws Exception {
String code = getAboveComment();
- String[] expected= {"tint"};
+ String[] expected = { "tint" };
checkCompletion(code, false, expected);
}
-
+
// void f(x) int y(ti
public void testIncompleteKnrFunction_Bug324384b() throws Exception {
// Content assist won't work here, just verify that we don't run out of memory
String code = getAboveComment();
- String[] expected= {};
+ String[] expected = {};
checkCompletion(code, false, expected);
}
-
+
// struct A {
// A(int, char, int){}
// };
@@ -287,10 +277,10 @@ public class BasicCompletionTest extends CompletionTestBase {
// B() : A
public void testCompletionInCtorOfMemberInitializer_327064() throws Exception {
String code = getAboveComment();
- String[] expected= {"A"};
+ String[] expected = { "A" };
checkNonPrefixCompletion(code, true, expected);
}
-
+
// struct A {
// A(int, char, int){}
// };
@@ -300,7 +290,7 @@ public class BasicCompletionTest extends CompletionTestBase {
// B::B() : A
public void testCompletionInCtorOfMemberInitializer_351009() throws Exception {
String code = getAboveComment();
- String[] expected= {"A"};
+ String[] expected = { "A" };
checkNonPrefixCompletion(code, true, expected);
}
@@ -309,16 +299,16 @@ public class BasicCompletionTest extends CompletionTestBase {
// S b
public void testCompletionInCtorOfVariable_223660() throws Exception {
String code = getAboveComment();
- String[] expected= {"b"};
+ String[] expected = { "b" };
checkNonPrefixCompletion(code, true, expected);
}
-
+
// typedef int FooBar;
// typedef int Foo_Bar;
// FB
public void testCamelCaseCompletion_CScope() throws Exception {
String code = getAboveComment();
- String[] expected= {"FooBar", "Foo_Bar"};
+ String[] expected = { "FooBar", "Foo_Bar" };
checkCompletion(code, false, expected);
}
@@ -327,17 +317,17 @@ public class BasicCompletionTest extends CompletionTestBase {
// FB
public void testCamelCaseCompletion_CPPScope() throws Exception {
String code = getAboveComment();
- String[] expected= {"FooBar", "Foo_Bar"};
+ String[] expected = { "FooBar", "Foo_Bar" };
checkCompletion(code, true, expected);
}
-
+
// class FooBar {
// FooBar();
// }
// FooBar::FB
public void testCamelCaseCompletion_CPPASTQualifiedName_CPPClassScope() throws Exception {
String code = getAboveComment();
- String[] expected= {"FooBar", "FooBar"};
+ String[] expected = { "FooBar", "FooBar" };
checkCompletion(code, true, expected);
}
@@ -350,35 +340,35 @@ public class BasicCompletionTest extends CompletionTestBase {
// s.
public void testCamelCaseCompletion_CVisitor() throws Exception {
String code = getAboveComment();
- String[] expected= {"fooBar", "foo_bar"};
+ String[] expected = { "fooBar", "foo_bar" };
checkCompletion(code, false, expected);
}
-
+
// void someFunction() {
// int abc[5];
// sizeof(ab
public void testCompletionInSizeof340664() throws Exception {
String code = getAboveComment();
- String[] expected= {"abc"};
+ String[] expected = { "abc" };
checkCompletion(code, false, expected);
checkCompletion(code, true, expected);
}
-
+
// typedef int abc;
// struct X {
// X(ab
public void testCompletionInParamlistOfCtor_338949() throws Exception {
String code = getAboveComment();
- String[] expected= {"abc"};
+ String[] expected = { "abc" };
checkCompletion(code, false, expected);
checkCompletion(code, true, expected);
}
-
+
// struct foo { int axx;};
// struct foo bar = {.a
public void testCompletionInDesignatedInitializor_353281a() throws Exception {
String code = getAboveComment();
- String[] expected= {"axx"};
+ String[] expected = { "axx" };
checkCompletion(code, false, expected);
}
@@ -388,7 +378,7 @@ public class BasicCompletionTest extends CompletionTestBase {
// struct foo bar = {.a
public void testCompletionInDesignatedInitializor_353281b() throws Exception {
String code = getAboveComment();
- String[] expected= {"axx"};
+ String[] expected = { "axx" };
checkCompletion(code, false, expected);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java
index 907f1105e61..ce2a4fc6f13 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java
@@ -51,51 +51,46 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
public class CompletionTestBase extends BaseTestCase {
- private static final IParserLogService NULL_LOG = new NullLogService();
-
- protected IASTCompletionNode getCompletionNode(String code, ParserLanguage lang, boolean useGNUExtensions) throws ParserException {
- FileContent codeReader = FileContent.create("<test-code>", code.trim().toCharArray());
- ScannerInfo scannerInfo = new ScannerInfo();
- IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
-
- ISourceCodeParser parser = null;
- if( lang == ParserLanguage.CPP )
- {
- ICPPParserExtensionConfiguration config = null;
- if (useGNUExtensions)
- config = new GPPParserExtensionConfiguration();
- else
- config = new ANSICPPParserExtensionConfiguration();
- parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE,
- NULL_LOG,
- config );
- }
- else
- {
- ICParserExtensionConfiguration config = null;
-
- if (useGNUExtensions)
- config = new GCCParserExtensionConfiguration();
- else
- config = new ANSICParserExtensionConfiguration();
-
- parser = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE,
- NULL_LOG, config );
- }
-
+ private static final IParserLogService NULL_LOG = new NullLogService();
+
+ protected IASTCompletionNode getCompletionNode(String code, ParserLanguage lang, boolean useGNUExtensions)
+ throws ParserException {
+ FileContent codeReader = FileContent.create("<test-code>", code.trim().toCharArray());
+ ScannerInfo scannerInfo = new ScannerInfo();
+ IScanner scanner = AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
+
+ ISourceCodeParser parser = null;
+ if (lang == ParserLanguage.CPP) {
+ ICPPParserExtensionConfiguration config = null;
+ if (useGNUExtensions)
+ config = new GPPParserExtensionConfiguration();
+ else
+ config = new ANSICPPParserExtensionConfiguration();
+ parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
+ } else {
+ ICParserExtensionConfiguration config = null;
+
+ if (useGNUExtensions)
+ config = new GCCParserExtensionConfiguration();
+ else
+ config = new ANSICParserExtensionConfiguration();
+
+ parser = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
+ }
+
scanner.setContentAssistMode(code.length());
- parser.parse();
+ parser.parse();
return parser.getCompletionNode();
- }
+ }
protected IASTCompletionNode getGPPCompletionNode(String code) throws ParserException {
return getCompletionNode(code, ParserLanguage.CPP, true);
}
-
+
protected IASTCompletionNode getGCCCompletionNode(String code) throws ParserException {
return getCompletionNode(code, ParserLanguage.C, true);
}
-
+
protected void checkCompletion(String code, boolean isCpp, String[] expected) throws ParserException {
checkCompletion(code, true, isCpp, expected);
}
@@ -104,48 +99,49 @@ public class CompletionTestBase extends BaseTestCase {
checkCompletion(code, false, isCpp, expected);
}
- private void checkCompletion(String code, boolean isPrefix, boolean isCpp, String[] expected) throws ParserException {
- IASTCompletionNode node = isCpp ? getGPPCompletionNode(code) : getGCCCompletionNode(code);
+ private void checkCompletion(String code, boolean isPrefix, boolean isCpp, String[] expected)
+ throws ParserException {
+ IASTCompletionNode node = isCpp ? getGPPCompletionNode(code) : getGCCCompletionNode(code);
assertNotNull(node);
- List<IBinding> bindings= proposeBindings(node, isPrefix);
- String[] names= getSortedNames(bindings);
- int len= Math.min(expected.length, names.length);
+ List<IBinding> bindings = proposeBindings(node, isPrefix);
+ String[] names = getSortedNames(bindings);
+ int len = Math.min(expected.length, names.length);
for (int i = 0; i < len; i++) {
assertEquals(expected[i], names[i]);
}
assertEquals(expected.length, names.length);
}
-
+
private static class BindingsComparator implements Comparator {
@Override
public int compare(Object o1, Object o2) {
- IBinding b1 = (IBinding)o1;
- IBinding b2 = (IBinding)o2;
+ IBinding b1 = (IBinding) o1;
+ IBinding b2 = (IBinding) o2;
return b1.getName().compareTo(b2.getName());
}
}
-
- private static BindingsComparator bindingsComparator = new BindingsComparator();
-
+
+ private static BindingsComparator bindingsComparator = new BindingsComparator();
+
protected IBinding[] sortBindings(IBinding[] bindings) {
Arrays.sort(bindings, bindingsComparator);
return bindings;
}
-
+
protected String getAboveComment() throws IOException {
return getContents(1)[0].toString();
}
-
+
protected StringBuilder[] getContents(int sections) throws IOException {
CTestPlugin plugin = CTestPlugin.getDefault();
if (plugin == null)
throw new AssertionFailedError("This test must be run as a JUnit plugin test");
return TestSourceReader.getContentsForTest(plugin.getBundle(), "parser", getClass(), getName(), sections);
}
-
+
protected List<IBinding> proposeBindings(IASTCompletionNode completionNode, boolean isPrefix) {
List<IBinding> proposals = new ArrayList<IBinding>();
- boolean handleMacros= false;
+ boolean handleMacros = false;
IASTName[] names = completionNode.getNames();
for (int i = 0; i < names.length; ++i) {
@@ -156,7 +152,7 @@ public class CompletionTestBase extends BaseTestCase {
IASTCompletionContext astContext = names[i].getCompletionContext();
if (astContext == null) {
continue;
- }
+ }
IBinding[] bindings = astContext.findBindings(names[i], isPrefix);
if (bindings != null)
for (int j = 0; j < bindings.length; ++j)
@@ -164,12 +160,12 @@ public class CompletionTestBase extends BaseTestCase {
}
return proposals;
}
-
+
protected String[] getSortedNames(List<IBinding> bindings) {
- String[] result= new String[bindings.size()];
- Iterator<IBinding> it= bindings.iterator();
+ String[] result = new String[bindings.size()];
+ Iterator<IBinding> it = bindings.iterator();
for (int i = 0; i < result.length; i++) {
- result[i]= it.next().getName();
+ result[i] = it.next().getName();
}
Arrays.sort(result);
return result;
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestSuite.java
index 3a683a3d5f0..370a6efeb7b 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestSuite.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestSuite.java
@@ -19,8 +19,8 @@ import junit.framework.TestSuite;
public class CompletionTestSuite extends TestCase {
- public static Test suite() {
- TestSuite suite= new TestSuite(CompletionTestSuite.class.getName());
+ public static Test suite() {
+ TestSuite suite = new TestSuite(CompletionTestSuite.class.getName());
suite.addTestSuite(BasicCompletionTest.class);
return suite;
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteBaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteBaseTest.java
index e0cbb2d1f61..acd394207e4 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteBaseTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteBaseTest.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite;
@@ -33,7 +33,7 @@ import org.eclipse.jface.text.TextSelection;
*/
public abstract class RewriteBaseTest extends BaseTestFramework implements ILogListener {
protected static final NullProgressMonitor NULL_PROGRESS_MONITOR = new NullProgressMonitor();
-
+
protected TreeMap<String, TestSourceFile> fileMap = new TreeMap<>();
protected String fileWithSelection;
protected TextSelection selection;
@@ -61,19 +61,18 @@ public abstract class RewriteBaseTest extends BaseTestFramework implements ILogL
}
}
}
-
+
protected void assertEquals(TestSourceFile file, IFile file2) throws Exception {
StringBuilder code = getCodeFromFile(file2);
assertEquals(file.getExpectedSource(), TestHelper.unifyNewLines(code.toString()));
}
-
+
protected void compareFiles(Map<String, TestSourceFile> testResourceFiles) throws Exception {
for (String fileName : testResourceFiles.keySet()) {
TestSourceFile file = testResourceFiles.get(fileName);
IFile iFile = project.getFile(new Path(fileName));
StringBuilder code = getCodeFromFile(iFile);
- assertEquals(TestHelper.unifyNewLines(file.getExpectedSource()),
- TestHelper.unifyNewLines(code.toString()));
+ assertEquals(TestHelper.unifyNewLines(file.getExpectedSource()), TestHelper.unifyNewLines(code.toString()));
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTester.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTester.java
index 698e3e9ffd7..201d1c450ee 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTester.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTester.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite;
@@ -38,13 +38,15 @@ import org.osgi.framework.Bundle;
* @author Emanuel Graf
*/
public class RewriteTester extends TestSuite {
- enum MatcherState{skip, inTest, inSource, inExpectedResult}
-
+ enum MatcherState {
+ skip, inTest, inSource, inExpectedResult
+ }
+
private static final String classRegexp = "//#(.*)\\s*(\\w*)*$"; //$NON-NLS-1$
private static final String testRegexp = "//!(.*)\\s*(\\w*)*$"; //$NON-NLS-1$
private static final String fileRegexp = "//@(.*)\\s*(\\w*)*$"; //$NON-NLS-1$
private static final String resultRegexp = "//=.*$"; //$NON-NLS-1$
-
+
public static Test suite(String name, String file) throws Exception {
BufferedReader in = createReader(file);
@@ -52,14 +54,14 @@ public class RewriteTester extends TestSuite {
in.close();
return createSuite(testCases, name);
}
-
+
protected static BufferedReader createReader(String file) throws IOException {
Bundle bundle = CTestPlugin.getDefault().getBundle();
Path path = new Path(file);
String file2 = FileLocator.toFileURL(FileLocator.find(bundle, path, null)).getFile();
return new BufferedReader(new FileReader(file2));
}
-
+
private static ArrayList<RewriteBaseTest> createTests(BufferedReader inputReader) throws Exception {
String line;
List<TestSourceFile> files = new ArrayList<TestSourceFile>();
@@ -69,7 +71,7 @@ public class RewriteTester extends TestSuite {
String testName = null;
String className = null;
boolean bevorFirstTest = true;
-
+
while ((line = inputReader.readLine()) != null) {
if (lineMatchesBeginOfTest(line)) {
if (!bevorFirstTest) {
@@ -95,7 +97,7 @@ public class RewriteTester extends TestSuite {
className = getNameOfClass(line);
continue;
}
-
+
switch (matcherState) {
case inSource:
if (actFile != null) {
@@ -115,9 +117,9 @@ public class RewriteTester extends TestSuite {
testCases.add(test);
return testCases;
}
-
- private static RewriteBaseTest createTestClass(String className, String testName,
- List<TestSourceFile> files) throws Exception {
+
+ private static RewriteBaseTest createTestClass(String className, String testName, List<TestSourceFile> files)
+ throws Exception {
try {
Class<?> refClass = Class.forName(className);
Constructor<?> ct = refClass.getConstructor(new Class[] { String.class, List.class });
@@ -132,20 +134,20 @@ public class RewriteTester extends TestSuite {
}
return test;
} catch (ClassNotFoundException e) {
- throw new Exception("Unknown TestClass: " + e.getMessage() +
- ". Make sure the test's sourcefile specifies a valid test class.");
+ throw new Exception("Unknown TestClass: " + e.getMessage()
+ + ". Make sure the test's sourcefile specifies a valid test class.");
} catch (SecurityException e) {
- throw new Exception("Security Exception during Test creation", e);
+ throw new Exception("Security Exception during Test creation", e);
} catch (NoSuchMethodException e) {
- throw new Exception("Test class does not provied required constructor.");
+ throw new Exception("Test class does not provied required constructor.");
} catch (IllegalArgumentException e) {
- throw new Exception("IllegalArgumentException during Test creation", e);
+ throw new Exception("IllegalArgumentException during Test creation", e);
} catch (InstantiationException e) {
- throw new Exception("InstantiationException during Test creation", e);
+ throw new Exception("InstantiationException during Test creation", e);
} catch (IllegalAccessException e) {
- throw new Exception("IllegalAccessException during Test creation", e);
+ throw new Exception("IllegalAccessException during Test creation", e);
} catch (InvocationTargetException e) {
- throw new Exception("InvocationTargetException during Test creation", e);
+ throw new Exception("InvocationTargetException during Test creation", e);
}
}
@@ -166,11 +168,11 @@ public class RewriteTester extends TestSuite {
private static boolean lineMatchesBeginOfTest(String line) {
return createMatcherFromString(testRegexp, line).find();
}
-
+
private static boolean lineMatchesClassName(String line) {
return createMatcherFromString(classRegexp, line).find();
}
-
+
private static boolean lineMatchesFileName(String line) {
return createMatcherFromString(fileRegexp, line).find();
}
@@ -178,26 +180,25 @@ public class RewriteTester extends TestSuite {
protected static Matcher createMatcherFromString(String pattern, String line) {
return Pattern.compile(pattern).matcher(line);
}
-
+
private static String getNameOfTest(String line) {
Matcher matcherBeginOfTest = createMatcherFromString(testRegexp, line);
if (matcherBeginOfTest.find())
return matcherBeginOfTest.group(1);
return "Not Named";
}
-
+
private static boolean lineMatchesBeginOfResult(String line) {
return createMatcherFromString(resultRegexp, line).find();
}
-
+
private static TestSuite createSuite(ArrayList<RewriteBaseTest> testCases, String name) {
TestSuite suite = new TestSuite(name);
Iterator<RewriteBaseTest> it = testCases.iterator();
while (it.hasNext()) {
- RewriteBaseTest subject =it.next();
+ RewriteBaseTest subject = it.next();
suite.addTest(subject);
}
return suite;
}
}
-
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTests.java
index 5ef6cea8bc6..3f96baeeda4 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTests.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite;
@@ -24,7 +24,7 @@ import org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTe
public class RewriteTests extends TestSuite {
public static Test suite() throws Exception {
- TestSuite suite = new TestSuite(RewriteTests.class.getName());
+ TestSuite suite = new TestSuite(RewriteTests.class.getName());
suite.addTest(AstWriterTestSuite.suite());
suite.addTest(CommentHandlingTestSuite.suite());
suite.addTest(ChangeGeneratorTestSuite.suite());
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/TestHelper.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/TestHelper.java
index 5470eb91fa9..b43de5014e7 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/TestHelper.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/TestHelper.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite;
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/TestSourceFile.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/TestSourceFile.java
index 60d9fc9bb2d..c75050b6696 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/TestSourceFile.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/TestSourceFile.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite;
@@ -30,12 +30,12 @@ public class TestSourceFile {
private String separator = System.getProperty("line.separator"); //$NON-NLS-1$
private int selectionStart = -1;
private int selectionEnd = -1;
-
+
protected static final String selectionStartRegex = "//\\$"; //$NON-NLS-1$
protected static final String selectionEndRegex = "\\$//"; //$NON-NLS-1$
protected static final String selectionStartLineRegex = "(.*)(" + selectionStartRegex + ")(.*)"; //$NON-NLS-1$ //$NON-NLS-2$
- protected static final String selectionEndLineRegex = "(.*)("+ selectionEndRegex + ")(.*)"; //$NON-NLS-1$ //$NON-NLS-2$
-
+ protected static final String selectionEndLineRegex = "(.*)(" + selectionEndRegex + ")(.*)"; //$NON-NLS-1$ //$NON-NLS-2$
+
public TestSourceFile(String name) {
super();
this.name = name;
@@ -57,7 +57,7 @@ public class TestSourceFile {
public String getSource() {
return source.toString();
}
-
+
public void addLineToSource(String code) {
Matcher start = createMatcherFromString(selectionStartLineRegex, code);
if (start.matches()) {
@@ -72,16 +72,16 @@ public class TestSourceFile {
source.append(code);
source.append(separator);
}
-
+
public void addLineToExpectedSource(String code) {
expectedSource.append(code);
expectedSource.append(separator);
}
-
+
public TextSelection getSelection() {
- if (selectionStart < 0 || selectionEnd <0 )
+ if (selectionStart < 0 || selectionEnd < 0)
return null;
- return new TextSelection(selectionStart, selectionEnd -selectionStart);
+ return new TextSelection(selectionStart, selectionEnd - selectionStart);
}
protected static Matcher createMatcherFromString(String pattern, String line) {
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTest.java
index e8c6d84f087..2cf218d0ba9 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTest.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.astwriter;
@@ -48,9 +48,9 @@ import org.eclipse.core.resources.IFile;
*/
public class ASTWriterTest extends RewriteBaseTest {
private static final IParserLogService NULL_LOG = new NullLogService();
-
- private IFile file;
-
+
+ private IFile file;
+
public ASTWriterTest(String name, ASTWriterTestSourceFile file) {
super(name);
fileMap.put(file.getName(), file);
@@ -65,13 +65,13 @@ public class ASTWriterTest extends RewriteBaseTest {
}
}
}
-
+
@Override
protected void runTest() throws Throwable {
file = project.getFile("ASTWritterTest.h"); //$NON-NLS-1$
compareFiles(fileMap);
}
-
+
@Override
protected void compareFiles(Map<String, TestSourceFile> testResourceFiles) throws Exception {
for (String fileName : testResourceFiles.keySet()) {
@@ -81,48 +81,48 @@ public class ASTWriterTest extends RewriteBaseTest {
TestHelper.unifyNewLines(code + System.getProperty("line.separator"))); //$NON-NLS-1$
}
}
-
+
public String generateSource(TestSourceFile testFile) throws Exception {
IASTTranslationUnit unit = getParser(testFile).parse();
- NodeCommentMap commentMap = ASTCommenter.getCommentedNodeMap(unit);
+ NodeCommentMap commentMap = ASTCommenter.getCommentedNodeMap(unit);
ASTModificationMap map = new ASTModificationMap();
map.getModificationsForNode(unit.getDeclarations()[0]);
ASTWriter writer = new ASTWriter();
return writer.write(unit, commentMap);
}
-
+
protected ISourceCodeParser getParser(TestSourceFile testFile) throws Exception {
- FileContent codeReader = FileContent.create(file);
-
- ScannerInfo scannerInfo = new ScannerInfo();
- ParserLanguage language = getLanguage(testFile);
- boolean useGNUExtensions = getGNUExtension(testFile);
-
- IScanner scanner = AST2TestBase.createScanner(codeReader, language, ParserMode.COMPLETE_PARSE, scannerInfo);
-
- ISourceCodeParser parser = null;
- if (language == ParserLanguage.CPP) {
- ICPPParserExtensionConfiguration config = null;
- if (useGNUExtensions) {
- config = new GPPParserExtensionConfiguration();
- } else {
- config = new ANSICPPParserExtensionConfiguration();
- }
- parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
- } else {
- ICParserExtensionConfiguration config = null;
-
- if (useGNUExtensions) {
- config = new GCCParserExtensionConfiguration();
- } else {
- config = new ANSICParserExtensionConfiguration();
- }
-
- parser = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
- }
- return parser;
+ FileContent codeReader = FileContent.create(file);
+
+ ScannerInfo scannerInfo = new ScannerInfo();
+ ParserLanguage language = getLanguage(testFile);
+ boolean useGNUExtensions = getGNUExtension(testFile);
+
+ IScanner scanner = AST2TestBase.createScanner(codeReader, language, ParserMode.COMPLETE_PARSE, scannerInfo);
+
+ ISourceCodeParser parser = null;
+ if (language == ParserLanguage.CPP) {
+ ICPPParserExtensionConfiguration config = null;
+ if (useGNUExtensions) {
+ config = new GPPParserExtensionConfiguration();
+ } else {
+ config = new ANSICPPParserExtensionConfiguration();
+ }
+ parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
+ } else {
+ ICParserExtensionConfiguration config = null;
+
+ if (useGNUExtensions) {
+ config = new GCCParserExtensionConfiguration();
+ } else {
+ config = new ANSICParserExtensionConfiguration();
+ }
+
+ parser = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
+ }
+ return parser;
}
-
+
private boolean getGNUExtension(TestSourceFile file) {
if (file instanceof ASTWriterTestSourceFile)
return ((ASTWriterTestSourceFile) file).isUseGNUExtensions();
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTestSourceFile.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTestSourceFile.java
index b0aee7a6974..6de1935ec1e 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTestSourceFile.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTestSourceFile.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Institute for Software - initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Institute for Software - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.astwriter;
@@ -27,7 +27,7 @@ public class ASTWriterTestSourceFile extends TestSourceFile {
public ASTWriterTestSourceFile(String name) {
super(name);
}
-
+
public void setParserLanguage(ParserLanguage lang) {
this.parserLanguage = lang;
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/AstWriterTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/AstWriterTestSuite.java
index 485508d68d6..46215cffe46 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/AstWriterTestSuite.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/AstWriterTestSuite.java
@@ -2,14 +2,14 @@
* Copyright (c) 2006, 2014 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Thomas Corbat (IFS)
*******************************************************************************/
@@ -25,34 +25,44 @@ public class AstWriterTestSuite {
public static Test suite() throws Exception {
TestSuite suite = new TestSuite("AstWriterTests");
- suite.addTest(SourceRewriteTester.suite("ExpressionTests", "resources/rewrite/ASTWriterExpressionTestSource.awts"));
+ suite.addTest(
+ SourceRewriteTester.suite("ExpressionTests", "resources/rewrite/ASTWriterExpressionTestSource.awts"));
- suite.addTest(SourceRewriteTester.suite("DelcSpecifierTests", "resources/rewrite/ASTWriterDeclSpecTestSource.awts"));
+ suite.addTest(
+ SourceRewriteTester.suite("DelcSpecifierTests", "resources/rewrite/ASTWriterDeclSpecTestSource.awts"));
suite.addTest(SourceRewriteTester.suite("Commented DelcSpecifierTests",
"resources/rewrite/ASTWriterCommentedDeclSpecTestSource.awts"));
- suite.addTest(SourceRewriteTester.suite("DeclaratorTests", "resources/rewrite/ASTWriterDeclaratorTestSource.awts"));
+ suite.addTest(
+ SourceRewriteTester.suite("DeclaratorTests", "resources/rewrite/ASTWriterDeclaratorTestSource.awts"));
suite.addTest(SourceRewriteTester.suite("Commented DeclaratorTests",
"resources/rewrite/ASTWriterCommentedDeclaratorTestSource.awts"));
- suite.addTest(SourceRewriteTester.suite("StatementsTests", "resources/rewrite/ASTWriterStatementTestSource.awts"));
+ suite.addTest(
+ SourceRewriteTester.suite("StatementsTests", "resources/rewrite/ASTWriterStatementTestSource.awts"));
suite.addTest(SourceRewriteTester.suite("Commented StatementsTests",
"resources/rewrite/ASTWriterCommentedStatementTestSource.awts"));
suite.addTest(SourceRewriteTester.suite("NameTests", "resources/rewrite/ASTWriterNameTestSource.awts"));
- suite.addTest(SourceRewriteTester.suite("Commented NameTests", "resources/rewrite/ASTWriterCommentedNameTestSource.awts"));
+ suite.addTest(SourceRewriteTester.suite("Commented NameTests",
+ "resources/rewrite/ASTWriterCommentedNameTestSource.awts"));
- suite.addTest(SourceRewriteTester.suite("InitializerTests", "resources/rewrite/ASTWriterInitializerTestSource.awts"));
+ suite.addTest(
+ SourceRewriteTester.suite("InitializerTests", "resources/rewrite/ASTWriterInitializerTestSource.awts"));
- suite.addTest(SourceRewriteTester.suite("DeclarationTests", "resources/rewrite/ASTWriterDeclarationTestSource.awts"));
+ suite.addTest(
+ SourceRewriteTester.suite("DeclarationTests", "resources/rewrite/ASTWriterDeclarationTestSource.awts"));
suite.addTest(SourceRewriteTester.suite("Commented DeclarationTests",
"resources/rewrite/ASTWriterCommentedDeclarationTestSource.awts"));
- suite.addTest(SourceRewriteTester.suite("TemplatesTests", "resources/rewrite/ASTWriterTemplateTestSource.awts"));
+ suite.addTest(
+ SourceRewriteTester.suite("TemplatesTests", "resources/rewrite/ASTWriterTemplateTestSource.awts"));
suite.addTest(SourceRewriteTester.suite("CommentTests", "resources/rewrite/ASTWriterCommentedTestSource.awts"));
- suite.addTest(SourceRewriteTester.suite("NewCommentTests", "resources/rewrite/ASTWriterCommentedTestSource2.awts"));
- suite.addTest(SourceRewriteTester.suite("AttributeTests", "resources/rewrite/ASTWriterAttributeTestSource.awts"));
+ suite.addTest(
+ SourceRewriteTester.suite("NewCommentTests", "resources/rewrite/ASTWriterCommentedTestSource2.awts"));
+ suite.addTest(
+ SourceRewriteTester.suite("AttributeTests", "resources/rewrite/ASTWriterAttributeTestSource.awts"));
suite.addTestSuite(ExpressionWriterTest.class);
return suite;
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ExpressionWriterTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ExpressionWriterTest.java
index dc78eca4d8a..1d487f4cc17 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ExpressionWriterTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ExpressionWriterTest.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* Pascal Kesseli (HSR) - Initial API and implementation
*******************************************************************************/
@@ -41,168 +41,168 @@ import org.junit.Before;
import org.junit.Test;
public class ExpressionWriterTest extends TestCase {
- private static final String BR = System.getProperty("line.separator");
- private static CPPASTSimpleDeclSpecifier INT = new CPPASTSimpleDeclSpecifier();
- private static IASTName NO_NAME = new CPPASTName(new char[] {});
- private NodeCommentMap commentMap = new NodeCommentMap();
+ private static final String BR = System.getProperty("line.separator");
+ private static CPPASTSimpleDeclSpecifier INT = new CPPASTSimpleDeclSpecifier();
+ private static IASTName NO_NAME = new CPPASTName(new char[] {});
+ private NodeCommentMap commentMap = new NodeCommentMap();
private ASTVisitor visitor;
- static {
- INT.setType(IASTSimpleDeclSpecifier.t_int);
- }
+ static {
+ INT.setType(IASTSimpleDeclSpecifier.t_int);
+ }
@Override
- @Before
+ @Before
protected void setUp() throws Exception {
visitor = new ASTWriterVisitor(commentMap);
}
- @Test
- public void testWriteLambdaExpressionEmptyIntroducerNoDeclarator() throws Exception {
- ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
- lambda.accept(visitor);
- String expected = "[] {" + BR + " return 7;" + BR + "}" + BR;
- Assert.assertEquals(expected, visitor.toString());
- }
-
- @Test
- public void testWriteLambdaExpressionDefaultCaptureByCopyNoDeclarator() {
- ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
- lambda.setCaptureDefault(ICPPASTLambdaExpression.CaptureDefault.BY_COPY);
- lambda.accept(visitor);
- String expected = "[=] {" + BR + " return 7;" + BR + "}" + BR;
- Assert.assertEquals(expected, visitor.toString());
- }
-
- @Test
- public void testWriteLambdaExpressionDefaultCaptureByReferenceNoDeclarator() {
- ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
- lambda.setCaptureDefault(ICPPASTLambdaExpression.CaptureDefault.BY_REFERENCE);
- lambda.accept(visitor);
- String expected = "[&] {" + BR + " return 7;" + BR + "}" + BR;
- Assert.assertEquals(expected, visitor.toString());
- }
-
- @Test
- public void testWriteLambdaExpressionThisCaptureNoDeclarator() {
- ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
- CPPASTCapture thisCapture = new CPPASTCapture();
- thisCapture.setIsByReference(true);
- lambda.addCapture(thisCapture);
- lambda.accept(visitor);
- String expected = "[this] {" + BR + " return 7;" + BR + "}" + BR;
- Assert.assertEquals(expected, visitor.toString());
- }
-
- @Test
- public void testWriteLambdaExpressionStarThisCaptureNoDeclarator() {
- ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
- lambda.addCapture(new CPPASTCapture());
- lambda.accept(visitor);
- String expected = "[*this] {" + BR + " return 7;" + BR + "}" + BR;
- Assert.assertEquals(expected, visitor.toString());
- }
-
- @Test
- public void testWriteLambdaExpressionMixedCaptureNoDeclarator() {
- ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
- lambda.setCaptureDefault(ICPPASTLambdaExpression.CaptureDefault.BY_COPY);
- CPPASTCapture thisCapture = new CPPASTCapture();
- thisCapture.setIsByReference(true);
- lambda.addCapture(thisCapture);
- ICPPASTCapture x = new CPPASTCapture(), y = new CPPASTCapture();
- x.setIdentifier(new CPPASTName(new char[] { 'x' }));
- x.setIsByReference(true);
- y.setIdentifier(new CPPASTName(new char[] { 'y' }));
- lambda.addCapture(x);
- lambda.addCapture(y);
- lambda.accept(visitor);
- String r = "[=, this, &x, y] {" + BR + " return 7;" + BR + "}" + BR;
- Assert.assertEquals(r, visitor.toString());
- }
-
- @Test
- public void testWriteLambdaExpressionEmptyIntroducerSimpleDeclarator() throws Exception {
- ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
- lambda.setDeclarator(getSimpleFunctionDeclarator());
- lambda.accept(visitor);
- String r = "[](int i, int j) {" + BR + " return 7;" + BR + "}" + BR;
- Assert.assertEquals(r, visitor.toString());
- }
-
- @Test
- public void testWriteLambdaExpressionEmptyIntroducerMutableDeclarator() throws Exception {
- ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
- ICPPASTFunctionDeclarator f = getSimpleFunctionDeclarator();
- f.setMutable(true);
- lambda.setDeclarator(f);
- lambda.accept(visitor);
- String r = "[](int i, int j) mutable {" + BR + " return 7;" + BR + "}" + BR;
- Assert.assertEquals(r, visitor.toString());
- }
-
- @Test
- public void testWriteLambdaExpressionEmptyIntroducerExceptionSpecificationDeclarator() throws Exception {
- ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
- ICPPASTFunctionDeclarator f = getSimpleFunctionDeclarator();
- f.addExceptionSpecificationTypeId(new CPPASTTypeId(INT, new CPPASTDeclarator(NO_NAME)));
- lambda.setDeclarator(f);
- lambda.accept(visitor);
- String r = "[](int i, int j) throw (int) {" + BR + " return 7;" + BR + "}" + BR;
- Assert.assertEquals(r, visitor.toString());
- }
-
- @Test
- public void testWriteLambdaExpressionEmptyIntroducerTrailingReturnTypeDeclarator() throws Exception {
- ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
- ICPPASTFunctionDeclarator f = getSimpleFunctionDeclarator();
- f.setTrailingReturnType(new CPPASTTypeId(INT, new CPPASTDeclarator(NO_NAME)));
- lambda.setDeclarator(f);
- lambda.accept(visitor);
- String r = "[](int i, int j) -> int {" + BR + " return 7;" + BR + "}" + BR;
- Assert.assertEquals(r, visitor.toString());
- }
-
- @Test
- public void testWriteAllEmbracingLambdaExpression() {
- ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
- ICPPASTFunctionDeclarator f = getSimpleFunctionDeclarator();
- lambda.setCaptureDefault(ICPPASTLambdaExpression.CaptureDefault.BY_REFERENCE);
- ICPPASTCapture x = new CPPASTCapture(), y = new CPPASTCapture();
- x.setIdentifier(new CPPASTName(new char[] { 'x' }));
- y.setIdentifier(new CPPASTName(new char[] { 'y' }));
- y.setIsByReference(true);
- lambda.addCapture(x);
- lambda.addCapture(y);
- CPPASTCapture thisCapture = new CPPASTCapture();
- thisCapture.setIsByReference(true);
- lambda.addCapture(thisCapture);
- f.setMutable(true);
- f.setTrailingReturnType(new CPPASTTypeId(INT, new CPPASTDeclarator(NO_NAME)));
- f.addExceptionSpecificationTypeId(new CPPASTTypeId(INT, new CPPASTDeclarator(NO_NAME)));
- lambda.setDeclarator(f);
- lambda.accept(visitor);
- String r = "[&, x, &y, this](int i, int j) mutable throw (int) -> int {" + BR + " return 7;" + BR + "}" + BR;
- Assert.assertEquals(r, visitor.toString());
- }
-
- private static ICPPASTFunctionDeclarator getSimpleFunctionDeclarator() {
- ICPPASTFunctionDeclarator f = new CPPASTFunctionDeclarator(new CPPASTName());
- IASTName name = new CPPASTName(new char[] { 'i' });
- IASTDeclarator d = new CPPASTDeclarator(name);
- f.addParameterDeclaration(new CPPASTParameterDeclaration(INT, d));
- name = new CPPASTName(new char[] { 'j' });
- d = new CPPASTDeclarator(name);
- f.addParameterDeclaration(new CPPASTParameterDeclaration(INT, d));
- return f;
- }
-
- private static ICPPASTLambdaExpression getEmptyLambdaExpression() {
- ICPPASTLambdaExpression lambda = new CPPASTLambdaExpression();
- CPPASTCompoundStatement stmt = new CPPASTCompoundStatement();
- stmt.addStatement(new CPPASTReturnStatement(new CPPASTLiteralExpression(
- IASTLiteralExpression.lk_integer_constant, new char[] { '7' })));
- lambda.setBody(stmt);
- return lambda;
- }
+ @Test
+ public void testWriteLambdaExpressionEmptyIntroducerNoDeclarator() throws Exception {
+ ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
+ lambda.accept(visitor);
+ String expected = "[] {" + BR + " return 7;" + BR + "}" + BR;
+ Assert.assertEquals(expected, visitor.toString());
+ }
+
+ @Test
+ public void testWriteLambdaExpressionDefaultCaptureByCopyNoDeclarator() {
+ ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
+ lambda.setCaptureDefault(ICPPASTLambdaExpression.CaptureDefault.BY_COPY);
+ lambda.accept(visitor);
+ String expected = "[=] {" + BR + " return 7;" + BR + "}" + BR;
+ Assert.assertEquals(expected, visitor.toString());
+ }
+
+ @Test
+ public void testWriteLambdaExpressionDefaultCaptureByReferenceNoDeclarator() {
+ ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
+ lambda.setCaptureDefault(ICPPASTLambdaExpression.CaptureDefault.BY_REFERENCE);
+ lambda.accept(visitor);
+ String expected = "[&] {" + BR + " return 7;" + BR + "}" + BR;
+ Assert.assertEquals(expected, visitor.toString());
+ }
+
+ @Test
+ public void testWriteLambdaExpressionThisCaptureNoDeclarator() {
+ ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
+ CPPASTCapture thisCapture = new CPPASTCapture();
+ thisCapture.setIsByReference(true);
+ lambda.addCapture(thisCapture);
+ lambda.accept(visitor);
+ String expected = "[this] {" + BR + " return 7;" + BR + "}" + BR;
+ Assert.assertEquals(expected, visitor.toString());
+ }
+
+ @Test
+ public void testWriteLambdaExpressionStarThisCaptureNoDeclarator() {
+ ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
+ lambda.addCapture(new CPPASTCapture());
+ lambda.accept(visitor);
+ String expected = "[*this] {" + BR + " return 7;" + BR + "}" + BR;
+ Assert.assertEquals(expected, visitor.toString());
+ }
+
+ @Test
+ public void testWriteLambdaExpressionMixedCaptureNoDeclarator() {
+ ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
+ lambda.setCaptureDefault(ICPPASTLambdaExpression.CaptureDefault.BY_COPY);
+ CPPASTCapture thisCapture = new CPPASTCapture();
+ thisCapture.setIsByReference(true);
+ lambda.addCapture(thisCapture);
+ ICPPASTCapture x = new CPPASTCapture(), y = new CPPASTCapture();
+ x.setIdentifier(new CPPASTName(new char[] { 'x' }));
+ x.setIsByReference(true);
+ y.setIdentifier(new CPPASTName(new char[] { 'y' }));
+ lambda.addCapture(x);
+ lambda.addCapture(y);
+ lambda.accept(visitor);
+ String r = "[=, this, &x, y] {" + BR + " return 7;" + BR + "}" + BR;
+ Assert.assertEquals(r, visitor.toString());
+ }
+
+ @Test
+ public void testWriteLambdaExpressionEmptyIntroducerSimpleDeclarator() throws Exception {
+ ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
+ lambda.setDeclarator(getSimpleFunctionDeclarator());
+ lambda.accept(visitor);
+ String r = "[](int i, int j) {" + BR + " return 7;" + BR + "}" + BR;
+ Assert.assertEquals(r, visitor.toString());
+ }
+
+ @Test
+ public void testWriteLambdaExpressionEmptyIntroducerMutableDeclarator() throws Exception {
+ ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
+ ICPPASTFunctionDeclarator f = getSimpleFunctionDeclarator();
+ f.setMutable(true);
+ lambda.setDeclarator(f);
+ lambda.accept(visitor);
+ String r = "[](int i, int j) mutable {" + BR + " return 7;" + BR + "}" + BR;
+ Assert.assertEquals(r, visitor.toString());
+ }
+
+ @Test
+ public void testWriteLambdaExpressionEmptyIntroducerExceptionSpecificationDeclarator() throws Exception {
+ ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
+ ICPPASTFunctionDeclarator f = getSimpleFunctionDeclarator();
+ f.addExceptionSpecificationTypeId(new CPPASTTypeId(INT, new CPPASTDeclarator(NO_NAME)));
+ lambda.setDeclarator(f);
+ lambda.accept(visitor);
+ String r = "[](int i, int j) throw (int) {" + BR + " return 7;" + BR + "}" + BR;
+ Assert.assertEquals(r, visitor.toString());
+ }
+
+ @Test
+ public void testWriteLambdaExpressionEmptyIntroducerTrailingReturnTypeDeclarator() throws Exception {
+ ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
+ ICPPASTFunctionDeclarator f = getSimpleFunctionDeclarator();
+ f.setTrailingReturnType(new CPPASTTypeId(INT, new CPPASTDeclarator(NO_NAME)));
+ lambda.setDeclarator(f);
+ lambda.accept(visitor);
+ String r = "[](int i, int j) -> int {" + BR + " return 7;" + BR + "}" + BR;
+ Assert.assertEquals(r, visitor.toString());
+ }
+
+ @Test
+ public void testWriteAllEmbracingLambdaExpression() {
+ ICPPASTLambdaExpression lambda = getEmptyLambdaExpression();
+ ICPPASTFunctionDeclarator f = getSimpleFunctionDeclarator();
+ lambda.setCaptureDefault(ICPPASTLambdaExpression.CaptureDefault.BY_REFERENCE);
+ ICPPASTCapture x = new CPPASTCapture(), y = new CPPASTCapture();
+ x.setIdentifier(new CPPASTName(new char[] { 'x' }));
+ y.setIdentifier(new CPPASTName(new char[] { 'y' }));
+ y.setIsByReference(true);
+ lambda.addCapture(x);
+ lambda.addCapture(y);
+ CPPASTCapture thisCapture = new CPPASTCapture();
+ thisCapture.setIsByReference(true);
+ lambda.addCapture(thisCapture);
+ f.setMutable(true);
+ f.setTrailingReturnType(new CPPASTTypeId(INT, new CPPASTDeclarator(NO_NAME)));
+ f.addExceptionSpecificationTypeId(new CPPASTTypeId(INT, new CPPASTDeclarator(NO_NAME)));
+ lambda.setDeclarator(f);
+ lambda.accept(visitor);
+ String r = "[&, x, &y, this](int i, int j) mutable throw (int) -> int {" + BR + " return 7;" + BR + "}" + BR;
+ Assert.assertEquals(r, visitor.toString());
+ }
+
+ private static ICPPASTFunctionDeclarator getSimpleFunctionDeclarator() {
+ ICPPASTFunctionDeclarator f = new CPPASTFunctionDeclarator(new CPPASTName());
+ IASTName name = new CPPASTName(new char[] { 'i' });
+ IASTDeclarator d = new CPPASTDeclarator(name);
+ f.addParameterDeclaration(new CPPASTParameterDeclaration(INT, d));
+ name = new CPPASTName(new char[] { 'j' });
+ d = new CPPASTDeclarator(name);
+ f.addParameterDeclaration(new CPPASTParameterDeclaration(INT, d));
+ return f;
+ }
+
+ private static ICPPASTLambdaExpression getEmptyLambdaExpression() {
+ ICPPASTLambdaExpression lambda = new CPPASTLambdaExpression();
+ CPPASTCompoundStatement stmt = new CPPASTCompoundStatement();
+ stmt.addStatement(new CPPASTReturnStatement(
+ new CPPASTLiteralExpression(IASTLiteralExpression.lk_integer_constant, new char[] { '7' })));
+ lambda.setBody(stmt);
+ return lambda;
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/SourceRewriteTester.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/SourceRewriteTester.java
index 5409752d96b..0ce052d7447 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/SourceRewriteTester.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/SourceRewriteTester.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.astwriter;
@@ -36,8 +36,10 @@ public class SourceRewriteTester extends TestSuite {
private static final String testRegexp = "//!(.*)\\s*(\\w*)*$"; //$NON-NLS-1$
private static final String codeTypeRegexp = "//%(C|CPP)( GNU)?$"; //$NON-NLS-1$
private static final String resultRegexp = "//=.*$"; //$NON-NLS-1$
-
- enum MatcherState { skip, inTest, inSource, inExpectedResult }
+
+ enum MatcherState {
+ skip, inTest, inSource, inExpectedResult
+ }
protected static BufferedReader createReader(String file) throws IOException {
Bundle bundle = CTestPlugin.getDefault().getBundle();
@@ -46,7 +48,7 @@ public class SourceRewriteTester extends TestSuite {
return new BufferedReader(new FileReader(file));
}
- public static Test suite(String name, String file)throws Exception {
+ public static Test suite(String name, String file) throws Exception {
BufferedReader in = createReader(file);
ArrayList<RewriteBaseTest> testCases = createTests(in);
in.close();
@@ -64,7 +66,7 @@ public class SourceRewriteTester extends TestSuite {
protected static boolean lineMatchesBeginOfTest(String line) {
return createMatcherFromString(testRegexp, line).find();
}
-
+
protected static boolean lineMatchesCodeType(String line) {
return createMatcherFromString(codeTypeRegexp, line).find();
}
@@ -72,7 +74,7 @@ public class SourceRewriteTester extends TestSuite {
protected static Matcher createMatcherFromString(String pattern, String line) {
return Pattern.compile(pattern).matcher(line);
}
-
+
protected static String getNameOfTest(String line) {
Matcher matcherBeginOfTest = createMatcherFromString(testRegexp, line);
if (matcherBeginOfTest.find()) {
@@ -90,7 +92,7 @@ public class SourceRewriteTester extends TestSuite {
ASTWriterTestSourceFile file = null;
MatcherState matcherState = MatcherState.skip;
ArrayList<RewriteBaseTest> testCases = new ArrayList<RewriteBaseTest>();
-
+
String line;
while ((line = inputReader.readLine()) != null) {
if (lineMatchesBeginOfTest(line)) {
@@ -109,7 +111,7 @@ public class SourceRewriteTester extends TestSuite {
}
continue;
}
-
+
switch (matcherState) {
case inSource:
if (file != null) {
@@ -153,9 +155,8 @@ public class SourceRewriteTester extends TestSuite {
}
return ParserLanguage.C;
}
-
- private static RewriteBaseTest createTestClass(String testName, ASTWriterTestSourceFile file)
- throws Exception {
+
+ private static RewriteBaseTest createTestClass(String testName, ASTWriterTestSourceFile file) throws Exception {
ASTWriterTest test = new ASTWriterTest(testName, file);
TextSelection sel = file.getSelection();
if (sel != null) {
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/AppendTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/AppendTests.java
index 6d7581395a2..8b969b3c876 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/AppendTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/AppendTests.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
@@ -129,9 +129,11 @@ public class AppendTests extends ChangeGeneratorTest {
public int visit(IASTDeclaration decl) {
if (decl instanceof ICPPASTFunctionDefinition) {
IASTIdExpression idExpression = factory.newIdExpression(factory.newName("a".toCharArray()));
- IASTInitializer initExpr = factory.newConstructorInitializer(new IASTInitializerClause[] { idExpression });
+ IASTInitializer initExpr = factory
+ .newConstructorInitializer(new IASTInitializerClause[] { idExpression });
IASTName initName = factory.newName("alpha".toCharArray());
- ICPPASTConstructorChainInitializer newInitializer = factory.newConstructorChainInitializer(initName, initExpr);
+ ICPPASTConstructorChainInitializer newInitializer = factory.newConstructorChainInitializer(initName,
+ initExpr);
addModification(null, APPEND_CHILD, decl, newInitializer);
return PROCESS_ABORT;
}
@@ -187,7 +189,8 @@ public class AppendTests extends ChangeGeneratorTest {
IASTName name = factory.newName("c".toCharArray());
IASTIdExpression leftOperand = factory.newIdExpression(name);
ICPPASTLiteralExpression rightOperand = factory.newLiteralExpression(lk_integer_constant, "9");
- ICPPASTBinaryExpression binEx = factory.newBinaryExpression(IASTBinaryExpression.op_assign, leftOperand, rightOperand);
+ ICPPASTBinaryExpression binEx = factory.newBinaryExpression(IASTBinaryExpression.op_assign,
+ leftOperand, rightOperand);
addModification(null, APPEND_CHILD, expression, binEx);
return PROCESS_ABORT;
}
@@ -248,7 +251,8 @@ public class AppendTests extends ChangeGeneratorTest {
paramDeclarator.setName(parameterName);
ICPPASTSimpleDeclSpecifier declSpec = factory.newSimpleDeclSpecifier();
declSpec.setType(IASTSimpleDeclSpecifier.t_int);
- ICPPASTParameterDeclaration insertedParameter = factory.newParameterDeclaration(declSpec, paramDeclarator);
+ ICPPASTParameterDeclaration insertedParameter = factory.newParameterDeclaration(declSpec,
+ paramDeclarator);
addModification(null, APPEND_CHILD, declarator, insertedParameter);
return PROCESS_ABORT;
}
@@ -275,7 +279,8 @@ public class AppendTests extends ChangeGeneratorTest {
ICPPASTDeclarator parameterDeclarator = factory.newDeclarator(parameterName);
ICPPASTSimpleDeclSpecifier parameterDeclSpec = factory.newSimpleDeclSpecifier();
parameterDeclSpec.setType(IASTSimpleDeclSpecifier.t_int);
- ICPPASTParameterDeclaration insertedParameter = factory.newParameterDeclaration(parameterDeclSpec, parameterDeclarator);
+ ICPPASTParameterDeclaration insertedParameter = factory.newParameterDeclaration(parameterDeclSpec,
+ parameterDeclarator);
addModification(null, APPEND_CHILD, declarator, insertedParameter);
return PROCESS_ABORT;
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTest.java
index 8259523619d..97ea5c07d61 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTest.java
@@ -72,8 +72,8 @@ public abstract class ChangeGeneratorTest extends BaseTestFramework {
}
protected StringBuilder[] getTestSource(int sections) throws IOException {
- return TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "parser",
- getClass(), getName(), sections);
+ return TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "parser", getClass(),
+ getName(), sections);
}
protected void compareResult(ASTVisitor visitor) throws Exception {
@@ -94,7 +94,8 @@ public abstract class ChangeGeneratorTest extends BaseTestFramework {
compareResult(visitor, testSources[0].toString(), testSources[0].toString(), shouldValidateAST);
}
- private void compareResult(ASTVisitor visitor, String source, String expected, boolean shouldValidateAST) throws Exception {
+ private void compareResult(ASTVisitor visitor, String source, String expected, boolean shouldValidateAST)
+ throws Exception {
final IFile testFile = importFile("source.h", source); //$NON-NLS-1$
CCorePlugin.getIndexManager().reindex(cproject);
@@ -111,14 +112,13 @@ public abstract class ChangeGeneratorTest extends BaseTestFramework {
assertFalse("Problem nodes found, AST is invalid.", validator.problemsFound());
}
- final ChangeGenerator changeGenerator =
- new ChangeGenerator(modStore, ASTCommenter.getCommentedNodeMap(unit));
+ final ChangeGenerator changeGenerator = new ChangeGenerator(modStore, ASTCommenter.getCommentedNodeMap(unit));
unit.accept(visitor);
changeGenerator.generateChange(unit);
final Document doc = new Document(source);
Change[] changes = ((CompositeChange) changeGenerator.getChange()).getChildren();
- assertThat("No changes found",changes.length, is(greaterThan(0)));
+ assertThat("No changes found", changes.length, is(greaterThan(0)));
for (Change change : changes) {
if (change instanceof TextFileChange) {
TextFileChange textChange = (TextFileChange) change;
@@ -128,7 +128,8 @@ public abstract class ChangeGeneratorTest extends BaseTestFramework {
assertEquals(TestHelper.unifyNewLines(expected), TestHelper.unifyNewLines(doc.get()));
}
- protected ASTModification addModification(ASTModification parentMod, ModificationKind kind, IASTNode targetNode, IASTNode newNode) {
+ protected ASTModification addModification(ASTModification parentMod, ModificationKind kind, IASTNode targetNode,
+ IASTNode newNode) {
ASTModification mod = new ASTModification(kind, targetNode, newNode, null);
modStore.storeModification(parentMod, mod);
return mod;
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTestSuite.java
index 01811c0b757..69cc22dd83c 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTestSuite.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTestSuite.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator;
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/CopyReplaceVisitor.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/CopyReplaceVisitor.java
index 7dfbce719e6..159d7384f84 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/CopyReplaceVisitor.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/CopyReplaceVisitor.java
@@ -60,7 +60,8 @@ public class CopyReplaceVisitor extends ASTVisitor {
private int copyReplace(IASTNode node) {
if (predicate.test(node)) {
- changeGenereatorTest.addModification(null, ModificationKind.REPLACE, node, node.copy(CopyStyle.withLocations));
+ changeGenereatorTest.addModification(null, ModificationKind.REPLACE, node,
+ node.copy(CopyStyle.withLocations));
return PROCESS_ABORT;
}
return PROCESS_CONTINUE;
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/InsertBeforeTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/InsertBeforeTests.java
index 868b83dd47f..3e9e0d9163f 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/InsertBeforeTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/InsertBeforeTests.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
@@ -128,9 +128,11 @@ public class InsertBeforeTests extends ChangeGeneratorTest {
ICPPASTConstructorChainInitializer ctorInitializer = functionDefinition.getMemberInitializers()[0];
IASTName name = factory.newName("a".toCharArray());
IASTIdExpression idExpression = factory.newIdExpression(name);
- IASTInitializer initExpression = factory.newConstructorInitializer(new IASTInitializerClause[] { idExpression });
+ IASTInitializer initExpression = factory
+ .newConstructorInitializer(new IASTInitializerClause[] { idExpression });
IASTName initName = factory.newName("alpha".toCharArray());
- ICPPASTConstructorChainInitializer newInitializer = factory.newConstructorChainInitializer(initName, initExpression);
+ ICPPASTConstructorChainInitializer newInitializer = factory.newConstructorChainInitializer(initName,
+ initExpression);
addModification(null, INSERT_BEFORE, ctorInitializer, newInitializer);
return PROCESS_ABORT;
}
@@ -191,7 +193,8 @@ public class InsertBeforeTests extends ChangeGeneratorTest {
IASTName name = factory.newName("c".toCharArray());
IASTIdExpression leftOperand = factory.newIdExpression(name);
ICPPASTLiteralExpression rightOperand = factory.newLiteralExpression(0, "9");
- ICPPASTBinaryExpression binEx = factory.newBinaryExpression(IASTBinaryExpression.op_assign, leftOperand, rightOperand);
+ ICPPASTBinaryExpression binEx = factory.newBinaryExpression(IASTBinaryExpression.op_assign,
+ leftOperand, rightOperand);
addModification(null, INSERT_BEFORE, expressions[1], binEx);
return PROCESS_ABORT;
}
@@ -223,7 +226,8 @@ public class InsertBeforeTests extends ChangeGeneratorTest {
ICPPASTDeclarator newDeclarator = factory.newDeclarator(parameterName);
ICPPASTSimpleDeclSpecifier paramDeclSpec = factory.newSimpleDeclSpecifier();
paramDeclSpec.setType(IASTSimpleDeclSpecifier.t_int);
- ICPPASTParameterDeclaration insertedParameter = factory.newParameterDeclaration(paramDeclSpec, newDeclarator);
+ ICPPASTParameterDeclaration insertedParameter = factory
+ .newParameterDeclaration(paramDeclSpec, newDeclarator);
addModification(null, INSERT_BEFORE, curParam, insertedParameter);
}
}
@@ -254,7 +258,8 @@ public class InsertBeforeTests extends ChangeGeneratorTest {
@Override
public int visit(IASTStatement statement) {
if (statement instanceof IASTCompoundStatement) {
- ASTModification compoundReplacement = addModification(null, ModificationKind.REPLACE, statement, statement);
+ ASTModification compoundReplacement = addModification(null, ModificationKind.REPLACE, statement,
+ statement);
IASTNode secondStatement = statement.getChildren()[1];
IASTNode firstNewStatement = createStatement("s1");
IASTNode secondNewStatement = createStatement("s2");
@@ -292,7 +297,8 @@ public class InsertBeforeTests extends ChangeGeneratorTest {
@Override
public int visit(IASTStatement statement) {
if (statement instanceof IASTCompoundStatement) {
- ASTModification compoundReplacement = addModification(null, ModificationKind.REPLACE, statement, statement);
+ ASTModification compoundReplacement = addModification(null, ModificationKind.REPLACE, statement,
+ statement);
IASTNode secondStatement = statement.getChildren()[1];
addModification(compoundReplacement, INSERT_BEFORE, secondStatement, secondStatement);
return PROCESS_ABORT;
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/RemoveTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/RemoveTests.java
index 31877b8de04..5b1f416c979 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/RemoveTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/RemoveTests.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ReplaceTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ReplaceTests.java
index 428a603f31a..2cb6deaaf6c 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ReplaceTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ReplaceTests.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2015 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2015 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
@@ -93,7 +93,7 @@ public class ReplaceTests extends ChangeGeneratorTest {
/**
* Adds an Attribute to an existing IASTAttributeList
- *
+ *
* @param owner IASTAttributeOwner
* @param attributeName Name of the new Attribute
* @param index Index of existing IASTAttributeList
@@ -107,7 +107,7 @@ public class ReplaceTests extends ChangeGeneratorTest {
/**
* Addds a new AttributeList to a IASTAttributeOwner
- *
+ *
* @param owner IASTAttributeOwner
* @param attributeName Name of the new Attribute
*/
@@ -185,13 +185,16 @@ public class ReplaceTests extends ChangeGeneratorTest {
public int visit(IASTDeclaration declaration) {
if (declaration instanceof ICPPASTFunctionDefinition) {
ICPPASTFunctionDefinition functionDefinition = (ICPPASTFunctionDefinition) declaration;
- ICPPASTConstructorChainInitializer[] memberInitializers = functionDefinition.getMemberInitializers();
+ ICPPASTConstructorChainInitializer[] memberInitializers = functionDefinition
+ .getMemberInitializers();
for (ICPPASTConstructorChainInitializer curInitializer : memberInitializers) {
IASTName parameterName = factory.newName("a".toCharArray());
IASTExpression idExpression = new CPPASTIdExpression(parameterName);
- IASTInitializer initExpr = factory.newConstructorInitializer(new IASTInitializerClause[] { idExpression });
+ IASTInitializer initExpr = factory
+ .newConstructorInitializer(new IASTInitializerClause[] { idExpression });
IASTName initName = factory.newName("alpha".toCharArray());
- ICPPASTConstructorChainInitializer newInitializer = new CPPASTConstructorChainInitializer(initName, initExpr);
+ ICPPASTConstructorChainInitializer newInitializer = new CPPASTConstructorChainInitializer(
+ initName, initExpr);
addModification(null, REPLACE, curInitializer, newInitializer);
}
return PROCESS_ABORT;
@@ -254,7 +257,8 @@ public class ReplaceTests extends ChangeGeneratorTest {
IASTName name = factory.newName("c".toCharArray());
IASTIdExpression leftOperand = factory.newIdExpression(name);
ICPPASTLiteralExpression rightOperand = factory.newLiteralExpression(lk_integer_constant, "9");
- ICPPASTBinaryExpression binEx = factory.newBinaryExpression(IASTBinaryExpression.op_assign, leftOperand, rightOperand);
+ ICPPASTBinaryExpression binEx = factory.newBinaryExpression(IASTBinaryExpression.op_assign,
+ leftOperand, rightOperand);
addModification(null, REPLACE, expressions[1], binEx);
return PROCESS_ABORT;
}
@@ -477,17 +481,21 @@ public class ReplaceTests extends ChangeGeneratorTest {
IASTCompoundStatement newCompoundStatement = factory.newCompoundStatement();
IASTNullStatement dummyStatement = factory.newNullStatement();
newCompoundStatement.addStatement(dummyStatement);
- ASTModification compoundReplacement = addModification(null, REPLACE, compoundStatement, newCompoundStatement);
+ ASTModification compoundReplacement = addModification(null, REPLACE, compoundStatement,
+ newCompoundStatement);
IASTName emptyName = factory.newName();
IASTExpression idExpression = factory.newIdExpression(emptyName);
- IASTExpression incrementExpression = factory.newUnaryExpression(IASTUnaryExpression.op_postFixIncr, idExpression);
+ IASTExpression incrementExpression = factory.newUnaryExpression(IASTUnaryExpression.op_postFixIncr,
+ idExpression);
IASTExpressionStatement newStatement = factory.newExpressionStatement(incrementExpression);
IASTStatement replacedStatement = compoundStatement.getStatements()[0];
- ASTModification statementModification = addModification(compoundReplacement, REPLACE, dummyStatement, newStatement);
+ ASTModification statementModification = addModification(compoundReplacement, REPLACE,
+ dummyStatement, newStatement);
IASTName xName = factory.newName("x".toCharArray());
- ASTModification nameModification = addModification(statementModification, REPLACE, emptyName, xName);
+ ASTModification nameModification = addModification(statementModification, REPLACE, emptyName,
+ xName);
return PROCESS_ABORT;
}
return PROCESS_CONTINUE;
@@ -617,9 +625,9 @@ public class ReplaceTests extends ChangeGeneratorTest {
IASTName name = factory.newName("i".toCharArray());
IASTIdExpression id = factory.newIdExpression(name);
IASTLiteralExpression value = factory.newLiteralExpression(lk_integer_constant, "42");
- ICPPASTBinaryExpression binExpr = factory.newBinaryExpression(IASTBinaryExpression.op_assign, id, value);
- IASTExpressionStatement insertStmt = new CPPASTExpressionStatement(
- binExpr);
+ ICPPASTBinaryExpression binExpr = factory.newBinaryExpression(IASTBinaryExpression.op_assign, id,
+ value);
+ IASTExpressionStatement insertStmt = new CPPASTExpressionStatement(binExpr);
IASTIdExpression incId = new CPPASTIdExpression(new CPPASTName("i".toCharArray()));
IASTUnaryExpression incExp = new CPPASTUnaryExpression(IASTUnaryExpression.op_postFixIncr, incId);
@@ -727,7 +735,8 @@ public class ReplaceTests extends ChangeGeneratorTest {
IASTName name = factory.newName("i".toCharArray());
IASTIdExpression id = factory.newIdExpression(name);
- ICPPASTUnaryExpression unaryExpr = factory.newUnaryExpression(IASTUnaryExpression.op_postFixIncr, id);
+ ICPPASTUnaryExpression unaryExpr = factory.newUnaryExpression(IASTUnaryExpression.op_postFixIncr,
+ id);
IASTExpressionStatement expr = factory.newExpressionStatement(unaryExpr);
compound.addStatement(expr);
addModification(null, REPLACE, ifStatement.getThenClause(), compound);
@@ -814,7 +823,8 @@ public class ReplaceTests extends ChangeGeneratorTest {
@Override
public int visit(IASTStatement statement) {
if (statement instanceof IASTIfStatement) {
- parentModification = addModification(null, ModificationKind.APPEND_CHILD, statement.getParent(), statement);
+ parentModification = addModification(null, ModificationKind.APPEND_CHILD, statement.getParent(),
+ statement);
}
return super.visit(statement);
}
@@ -824,7 +834,7 @@ public class ReplaceTests extends ChangeGeneratorTest {
if (name.toString().equals("three")) {
IASTName newName = factory.newName("two");
addModification(parentModification, REPLACE, name, newName);
-
+
return PROCESS_ABORT;
}
return PROCESS_CONTINUE;
@@ -863,7 +873,8 @@ public class ReplaceTests extends ChangeGeneratorTest {
@Override
public int visit(IASTStatement statement) {
if (statement instanceof IASTIfStatement) {
- parentModification = addModification(null, ModificationKind.APPEND_CHILD, statement.getParent(), statement);
+ parentModification = addModification(null, ModificationKind.APPEND_CHILD, statement.getParent(),
+ statement);
}
return super.visit(statement);
}
@@ -873,7 +884,7 @@ public class ReplaceTests extends ChangeGeneratorTest {
if (name.toString().equals("three")) {
IASTName newName = factory.newName("two");
addModification(parentModification, REPLACE, name, newName);
-
+
return PROCESS_ABORT;
}
return PROCESS_CONTINUE;
@@ -912,7 +923,8 @@ public class ReplaceTests extends ChangeGeneratorTest {
@Override
public int visit(IASTStatement statement) {
if (statement instanceof IASTIfStatement) {
- parentModification = addModification(null, ModificationKind.APPEND_CHILD, statement.getParent(), statement);
+ parentModification = addModification(null, ModificationKind.APPEND_CHILD, statement.getParent(),
+ statement);
}
return super.visit(statement);
}
@@ -922,7 +934,7 @@ public class ReplaceTests extends ChangeGeneratorTest {
if (name.toString().equals("three")) {
IASTName newName = factory.newName("two");
addModification(parentModification, REPLACE, name, newName);
-
+
return PROCESS_ABORT;
}
return PROCESS_CONTINUE;
@@ -961,7 +973,8 @@ public class ReplaceTests extends ChangeGeneratorTest {
@Override
public int visit(IASTStatement statement) {
if (statement instanceof IASTIfStatement) {
- parentModification = addModification(null, ModificationKind.APPEND_CHILD, statement.getParent(), statement);
+ parentModification = addModification(null, ModificationKind.APPEND_CHILD, statement.getParent(),
+ statement);
}
return super.visit(statement);
}
@@ -971,7 +984,7 @@ public class ReplaceTests extends ChangeGeneratorTest {
if (name.toString().equals("three")) {
IASTName newName = factory.newName("two");
addModification(parentModification, REPLACE, name, newName);
-
+
return PROCESS_ABORT;
}
return PROCESS_CONTINUE;
@@ -1010,7 +1023,8 @@ public class ReplaceTests extends ChangeGeneratorTest {
@Override
public int visit(IASTStatement statement) {
if (statement instanceof IASTIfStatement) {
- parentModification = addModification(null, ModificationKind.APPEND_CHILD, statement.getParent(), statement);
+ parentModification = addModification(null, ModificationKind.APPEND_CHILD, statement.getParent(),
+ statement);
}
return super.visit(statement);
}
@@ -1020,7 +1034,7 @@ public class ReplaceTests extends ChangeGeneratorTest {
if (name.toString().equals("three")) {
IASTName newName = factory.newName("two");
addModification(parentModification, REPLACE, name, newName);
-
+
return PROCESS_ABORT;
}
return PROCESS_CONTINUE;
@@ -1085,7 +1099,8 @@ public class ReplaceTests extends ChangeGeneratorTest {
@Override
public int visit(IASTDeclarator declarator) {
if (declarator instanceof ICPPASTFunctionDeclarator) {
- ICPPASTFunctionDeclarator newDeclarator = (ICPPASTFunctionDeclarator) declarator.copy(CopyStyle.withLocations);
+ ICPPASTFunctionDeclarator newDeclarator = (ICPPASTFunctionDeclarator) declarator
+ .copy(CopyStyle.withLocations);
newDeclarator.setPureVirtual(true);
addModification(null, ModificationKind.REPLACE, declarator, newDeclarator);
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTest.java
index b3fafa92fbe..549742c906c 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTest.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Institute for Software - initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Institute for Software - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.comenthandler;
@@ -42,7 +42,7 @@ import org.eclipse.core.runtime.Path;
* /resources/rewrite/CommentHandlingTestSource.rts.<br>
* This file contains the source code and the expected output for all the tests.
* Following a little example how such a test looks like:<br><br>
- *
+ *
* <code><pre>
* //!NameOfTheTest - will be used as JUnit test name
* //#org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTest
@@ -54,18 +54,18 @@ import org.eclipse.core.runtime.Path;
* //myFreestandingComment
* //myFreestandingComment2
* };
- *
+ *
* //=
* =>leading
* void aMethod(); = //myLeadingComment
- *
+ *
* =>trailing
* void aMethod(); = //myTrailingComment
- *
+ *
* =>freestanding
* void aMethod(); = //myFreestandingComment , //myFreestandingComment2
* </pre></code>
- *
+ *
* The second line (//#org.eclipse.cdt...) indicates the test class (in this case this class).<br>
* The "//=" indicates the beginning of the expected test result.<br>
* The test result contains three sections (separated by "=>leading", "=>trailing" and
@@ -73,7 +73,7 @@ import org.eclipse.core.runtime.Path;
* Each section contains the raw signature of the node to which a comment is assigned plus " = "
* and the comment. If there are several comments assigned to the same node they are concatenated
* with a " , ".
- *
+ *
* @author Guido Zgraggen IFS, Lukas Felber IFS
*/
public class CommentHandlingTest extends RewriteBaseTest {
@@ -87,7 +87,7 @@ public class CommentHandlingTest extends RewriteBaseTest {
private static final String LEADING_COMMENT_TITLE = "<<<=== Leading Comment Test Section ===>>>"; //$NON-NLS-1$
private static final String TRAILING_COMMENT_TITLE = "<<<=== Trailing Comment Test Section ===>>>"; //$NON-NLS-1$
private static final String FREESTANDING_COMMENT_TITLE = "<<<=== Freestanding Comment Test Section ===>>>"; //$NON-NLS-1$
-
+
public CommentHandlingTest(String name, List<TestSourceFile> files) {
super(name, files);
}
@@ -97,7 +97,7 @@ public class CommentHandlingTest extends RewriteBaseTest {
if (fileMap.isEmpty()) {
fail("No file for testing"); //$NON-NLS-1$
}
-
+
for (String fileName : fileMap.keySet()) {
TestSourceFile file = fileMap.get(fileName);
NodeCommentMap nodeMap = getNodeMapForFile(fileName);
@@ -110,17 +110,17 @@ public class CommentHandlingTest extends RewriteBaseTest {
}
private StringBuilder buildExpectedResult(TestSourceFile file) {
- Matcher matcher = Pattern.compile(CommentHandlingTest.getSeparatingRegexp(),
- Pattern.MULTILINE | Pattern.DOTALL).matcher(file.getExpectedSource());
+ Matcher matcher = Pattern.compile(CommentHandlingTest.getSeparatingRegexp(), Pattern.MULTILINE | Pattern.DOTALL)
+ .matcher(file.getExpectedSource());
if (!matcher.find()) {
fail("Missing expected section. Expected result code must be of the following format:\n\"=>leading\n...\n=>trailing\n...\n=>freestanding\""); //$NON-NLS-1$
}
StringBuilder expectedResultBuilder = new StringBuilder();
-
+
String leadingResult = matcher.group(1);
String trailingResult = matcher.group(2);
String freestandingResult = matcher.group(3);
-
+
appendLineTrimmed(expectedResultBuilder, LEADING_COMMENT_TITLE);
appendLineTrimmed(expectedResultBuilder, leadingResult);
appendLineTrimmed(expectedResultBuilder, TRAILING_COMMENT_TITLE);
@@ -176,16 +176,16 @@ public class CommentHandlingTest extends RewriteBaseTest {
}
private static String getSeparatingRegexp() {
- return LEADING_COMMENT_SEPARATOR + ANY_CHAR_REGEXP + TRAILING_COMMENT_SEPARATOR +
- ANY_CHAR_REGEXP + FREESTANDING_COMMENT_SEPARATOR + ANY_CHAR_REGEXP;
+ return LEADING_COMMENT_SEPARATOR + ANY_CHAR_REGEXP + TRAILING_COMMENT_SEPARATOR + ANY_CHAR_REGEXP
+ + FREESTANDING_COMMENT_SEPARATOR + ANY_CHAR_REGEXP;
}
-
+
protected IASTTranslationUnit getUnit(String fileName) throws CoreException {
- ITranslationUnit tu = (ITranslationUnit) CCorePlugin.getDefault().getCoreModel().create(
- project.getFile(fileName));
+ ITranslationUnit tu = (ITranslationUnit) CCorePlugin.getDefault().getCoreModel()
+ .create(project.getFile(fileName));
return tu.getAST();
}
-
+
private final class NodeOffsetComparator implements Comparator<IASTNode> {
@Override
public int compare(IASTNode o1, IASTNode o2) {
@@ -196,7 +196,7 @@ public class CommentHandlingTest extends RewriteBaseTest {
return offDif;
}
}
-
+
private void appendLineTrimmed(StringBuilder builderToAppendTo, String line) {
builderToAppendTo.append(line.trim());
builderToAppendTo.append(SEPARATOR);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTestSuite.java
index 812c317bad2..93c068a3eff 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTestSuite.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTestSuite.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Institute for Software - initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Institute for Software - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.comenthandler;
@@ -27,7 +27,8 @@ public class CommentHandlingTestSuite extends TestSuite {
public static Test suite() throws Exception {
TestSuite suite = new TestSuite(CommentHandlingTestSuite.class.getName());
suite.addTest(RewriteTester.suite("CommentTests", "resources/rewrite/CommentHandlingTestSource.rts")); //$NON-NLS-1$
- suite.addTest(RewriteTester.suite("CommentMultiFileTests", "resources/rewrite/CommentHandlingWithRewriteTest.rts")); //$NON-NLS-1$
+ suite.addTest(
+ RewriteTester.suite("CommentMultiFileTests", "resources/rewrite/CommentHandlingWithRewriteTest.rts")); //$NON-NLS-1$
suite.addTestSuite(NodeCommentMapTest.class);
return suite;
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/NodeCommentMapTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/NodeCommentMapTest.java
index 30a224e17b0..9548aa451e0 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/NodeCommentMapTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/NodeCommentMapTest.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Institute for Software - initial API and implementation
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Institute for Software - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.comenthandler;
@@ -29,34 +29,34 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
*/
public class NodeCommentMapTest extends TestCase {
private NodeCommentMap map;
-
+
@Override
protected void setUp() throws Exception {
map = new NodeCommentMap();
}
-
+
@Override
protected void tearDown() throws Exception {
map = null;
}
-
- public void testNoComment(){
+
+ public void testNoComment() {
ASTNode node = new CPPASTName();
assertEquals(0, map.getLeadingCommentsForNode(node).size());
assertEquals(0, map.getTrailingCommentsForNode(node).size());
assertEquals(0, map.getFreestandingCommentsForNode(node).size());
}
-
- public void testOneComment(){
+
+ public void testOneComment() {
ASTNode node = new CPPASTName();
IASTComment comm1 = new Comment();
IASTComment comm2 = new Comment();
IASTComment comm3 = new Comment();
-
+
map.addLeadingCommentToNode(node, comm1);
map.addTrailingCommentToNode(node, comm2);
map.addFreestandingCommentToNode(node, comm3);
-
+
assertEquals(1, map.getLeadingCommentsForNode(node).size());
assertEquals(1, map.getTrailingCommentsForNode(node).size());
assertEquals(1, map.getFreestandingCommentsForNode(node).size());
@@ -65,19 +65,19 @@ public class NodeCommentMapTest extends TestCase {
assertEquals(comm2, map.getTrailingCommentsForNode(node).get(0));
assertEquals(comm3, map.getFreestandingCommentsForNode(node).get(0));
}
-
- public void testTwoComment(){
+
+ public void testTwoComment() {
ASTNode node = new CPPASTName();
IASTComment com1 = new Comment();
IASTComment com2 = new Comment();
-
+
map.addLeadingCommentToNode(node, com1);
map.addLeadingCommentToNode(node, com2);
map.addTrailingCommentToNode(node, com1);
map.addTrailingCommentToNode(node, com2);
map.addFreestandingCommentToNode(node, com1);
map.addFreestandingCommentToNode(node, com2);
-
+
assertEquals(2, map.getLeadingCommentsForNode(node).size());
assertEquals(2, map.getTrailingCommentsForNode(node).size());
assertEquals(2, map.getFreestandingCommentsForNode(node).size());
@@ -90,7 +90,7 @@ public class NodeCommentMapTest extends TestCase {
assertEquals(com2, map.getFreestandingCommentsForNode(node).get(1));
}
- public void testCommentOnDifferentNodes(){
+ public void testCommentOnDifferentNodes() {
ASTNode node1 = new CPPASTName();
ASTNode node2 = new CPPASTName();
IASTComment com1 = new Comment();
@@ -100,11 +100,11 @@ public class NodeCommentMapTest extends TestCase {
map.addLeadingCommentToNode(node1, com1);
map.addLeadingCommentToNode(node2, com2);
map.addLeadingCommentToNode(node1, com3);
-
+
map.addTrailingCommentToNode(node1, com1);
map.addTrailingCommentToNode(node2, com2);
map.addTrailingCommentToNode(node1, com3);
-
+
map.addFreestandingCommentToNode(node1, com1);
map.addFreestandingCommentToNode(node2, com2);
map.addFreestandingCommentToNode(node1, com3);
@@ -115,15 +115,15 @@ public class NodeCommentMapTest extends TestCase {
assertEquals(1, map.getTrailingCommentsForNode(node2).size());
assertEquals(2, map.getFreestandingCommentsForNode(node1).size());
assertEquals(1, map.getFreestandingCommentsForNode(node2).size());
-
+
assertEquals(com1, map.getLeadingCommentsForNode(node1).get(0));
assertEquals(com2, map.getLeadingCommentsForNode(node2).get(0));
assertEquals(com3, map.getLeadingCommentsForNode(node1).get(1));
-
+
assertEquals(com1, map.getTrailingCommentsForNode(node1).get(0));
assertEquals(com2, map.getTrailingCommentsForNode(node2).get(0));
assertEquals(com3, map.getTrailingCommentsForNode(node1).get(1));
-
+
assertEquals(com1, map.getFreestandingCommentsForNode(node1).get(0));
assertEquals(com2, map.getFreestandingCommentsForNode(node2).get(0));
assertEquals(com3, map.getFreestandingCommentsForNode(node1).get(1));
@@ -198,10 +198,10 @@ public class NodeCommentMapTest extends TestCase {
assertEquals(0, allComments.size());
}
- //=== Internal Comment class for testing
+ //=== Internal Comment class for testing
private static class Comment extends ASTNode implements IASTComment {
private char[] comment;
-
+
@Override
public char[] getComment() {
return comment;
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/ExpansionExplorerTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/ExpansionExplorerTests.java
index be6ee578d25..dc1c6100ba6 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/ExpansionExplorerTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/ExpansionExplorerTests.java
@@ -31,54 +31,53 @@ import org.eclipse.text.edits.ReplaceEdit;
import junit.framework.TestSuite;
-
public class ExpansionExplorerTests extends BaseTestCase {
-
+
public static TestSuite suite() {
return suite(ExpansionExplorerTests.class);
}
-
+
private void performTest(int steps) throws Exception {
- CharSequence[] bufs= TestSourceReader.getContentsForTest(
- CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), steps+2);
- String[] input= new String[steps+2];
- int i= -1;
+ CharSequence[] bufs = TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "parser",
+ getClass(), getName(), steps + 2);
+ String[] input = new String[steps + 2];
+ int i = -1;
for (CharSequence buf : bufs) {
- input[++i]= buf.toString().trim();
+ input[++i] = buf.toString().trim();
}
- final MacroExpander expander= createExpander(input[0]);
- final String original= input[1];
-
+ final MacroExpander expander = createExpander(input[0]);
+ final String original = input[1];
+
verifyStepCount(expander, original, steps);
- verifyStep(expander, original, Integer.MAX_VALUE, original, input[steps+1]);
- for (i= 0; i < steps; i++) {
- verifyStep(expander, original, i, input[i+1], input[i+2]);
+ verifyStep(expander, original, Integer.MAX_VALUE, original, input[steps + 1]);
+ for (i = 0; i < steps; i++) {
+ verifyStep(expander, original, i, input[i + 1], input[i + 2]);
}
}
private void verifyStepCount(MacroExpander expander, String original, int steps) {
- MacroExpansionTracker tracker= new MacroExpansionTracker(Integer.MAX_VALUE);
+ MacroExpansionTracker tracker = new MacroExpansionTracker(Integer.MAX_VALUE);
expander.expand(original, tracker, "", 1, false);
assertEquals(steps, tracker.getStepCount());
}
private void verifyStep(MacroExpander expander, String original, int step, String expectedPre,
String expectedPost) {
- MacroExpansionTracker tracker= new MacroExpansionTracker(step);
+ MacroExpansionTracker tracker = new MacroExpansionTracker(step);
expander.expand(original, tracker, "", 1, false);
String pre = tracker.getCodeBeforeStep();
ReplaceEdit replacement = tracker.getReplacement();
assertNotNull(pre);
assertNotNull(replacement);
- String post= apply(pre, replacement);
-
+ String post = apply(pre, replacement);
+
assertEquals("incorrect value pre " + step, expectedPre, pre);
assertEquals("incorrect value post " + step, expectedPost, post);
}
private String apply(String pre, ReplaceEdit replacement) {
- StringBuilder buf= new StringBuilder();
+ StringBuilder buf = new StringBuilder();
buf.append(pre, 0, replacement.getOffset());
buf.append(replacement.getText());
buf.append(pre, replacement.getExclusiveEnd(), pre.length());
@@ -86,29 +85,29 @@ public class ExpansionExplorerTests extends BaseTestCase {
}
private MacroExpander createExpander(final String macrodefs) throws OffsetLimitReachedException {
- CPreprocessor cpp= new CPreprocessor(FileContent.create("<macro-expander>", macrodefs.toCharArray()),
- new ScannerInfo(), ParserLanguage.C, new NullLogService(),
+ CPreprocessor cpp = new CPreprocessor(FileContent.create("<macro-expander>", macrodefs.toCharArray()),
+ new ScannerInfo(), ParserLanguage.C, new NullLogService(),
GCCScannerExtensionConfiguration.getInstance(), IncludeFileContentProvider.getEmptyFilesProvider());
int type;
do {
- type= cpp.nextTokenRaw().getType();
+ type = cpp.nextTokenRaw().getType();
} while (type != IToken.tEND_OF_INPUT);
return cpp.getAdapter(MacroExpander.class);
}
-
+
// #define A
-
+
// B
-
+
// B
public void testNoOp() throws Exception {
performTest(0);
}
-
+
// #define A B
-
+
// A
-
+
// B
public void testObject() throws Exception {
performTest(1);
@@ -117,35 +116,34 @@ public class ExpansionExplorerTests extends BaseTestCase {
// #define A A1
// #define A1 A2
// #define A2 A
-
+
// A
-
+
// A1
-
+
// A2
-
+
// A
public void testObjectChain() throws Exception {
performTest(3);
}
// #define A(x) B+x
-
+
// A(c)
-
+
// B+c
public void testFunction() throws Exception {
performTest(1);
}
-
// #define A(x) x+x
// #define _t t
-
+
// A(_t)
-
+
// A(t)
-
+
// t+t
public void testFunctionParam() throws Exception {
performTest(2);
@@ -153,9 +151,9 @@ public class ExpansionExplorerTests extends BaseTestCase {
// #define A(x,y) x+y
// #define _t t
-
+
// A(_t, _t)
-
+
// A(t, _t)
// A(t, t)
@@ -167,9 +165,9 @@ public class ExpansionExplorerTests extends BaseTestCase {
// #define A(x,y,z) x + y + z
// #define _t t
-
+
// A ( _t , , _t )
-
+
// A ( t , , _t )
// A ( t , , t )
@@ -178,187 +176,187 @@ public class ExpansionExplorerTests extends BaseTestCase {
public void test3Params() throws Exception {
performTest(3);
}
-
- // #define m !(m)+n
+
+ // #define m !(m)+n
// #define n(n) n(m)
-
+
// m(m)
-
+
// !(m)+n(m)
-
+
// !(m)+n(!(m)+n)
-
+
// !(m)+!(m)+n(m)
-
+
// !(m)+!(m)+n(!(m)+n)
- public void testRecursiveExpansion() throws Exception {
- performTest(4);
- }
-
- // #define f(x,y) (x + y)
- // #define g(x,y) (x*y)
- // #define _a a
- // #define _b b
-
- // f( g(_a,_b), g(_b,_a) )
-
- // f( g(a,_b), g(_b,_a) )
-
- // f( g(a,b), g(_b,_a) )
-
- // f( (a*b), g(_b,_a) )
-
- // f( (a*b), g(b,_a) )
-
- // f( (a*b), g(b,a) )
-
- // f( (a*b), (b*a) )
-
- // ((a*b) + (b*a))
- public void testNestedFunctions() throws Exception {
- performTest(7);
- }
-
- // #define id(x) x
-
- // id(
- // id(a))
-
- // id(
- // a)
-
- // a
- public void testNewline() throws Exception {
- performTest(2);
- }
-
- // #define f x _a _b x
- // #define _a a
- // #define _b b
-
- // f
-
- // x _a _b x
-
- // x a _b x
-
- // x a b x
- public void testSpace() throws Exception {
- performTest(3);
- }
-
- // #define L __LINE__
- // #define x(a) a
-
- // x(L)
-
- // x(__LINE__)
-
- // x(1)
-
- // 1
- public void testLineNumber() throws Exception {
- performTest(3);
- }
-
- // #define L __LINE__
- // #define x(a,b) a,b
-
- // x(L,
- // L)
-
- // x(__LINE__,
- // L)
-
- // x(2,
- // L)
-
- // x(2,
- // __LINE__)
-
- // x(2,
- // 2)
-
- // 2,2
- public void testLineNumber2() throws Exception {
- performTest(5);
- }
-
- // #define str(x) #x
- // #define xstr(x) str(x)
-
- // xstr(__LINE__)
-
- // xstr(1)
-
- // str(1)
-
- // "1"
- public void testStringify() throws Exception {
- performTest(3);
- }
-
- // #define vararg(x, y...) bla(x, y)
- // #define _p p
-
- // vararg( _p );
-
- // vararg( p );
-
- // bla(p, );
- public void testVararg1() throws Exception {
- performTest(2);
- }
-
- // #define vararg(x, y...) bla(x, ##y)
- // #define _p p
-
- // vararg( _p );
-
- // vararg( p );
-
- // bla(p);
- public void testVararg1x() throws Exception {
- performTest(2);
- }
-
- // #define vararg(x, y...) bla(x, y)
- // #define _p p
-
- // vararg( _p , _p );
-
- // vararg( p , _p );
-
- // vararg( p , p );
-
- // bla(p, p);
- public void testVararg2() throws Exception {
- performTest(3);
- }
-
- // #define vararg(x, y...) bla(x, ## y)
- // #define _p p
-
- // vararg( _p , _p );
-
- // vararg( p , _p );
-
- // vararg( p , p );
-
- // bla(p, p);
- public void testVararg2x() throws Exception {
- performTest(3);
- }
-
- // #define func2(x,y) (x,y)
- // #define _p p
-
- // func2(_p);
-
- // func2(p);
-
- // (p,);
- public void testTooFewArgs() throws Exception {
- performTest(2);
- }
+ public void testRecursiveExpansion() throws Exception {
+ performTest(4);
+ }
+
+ // #define f(x,y) (x + y)
+ // #define g(x,y) (x*y)
+ // #define _a a
+ // #define _b b
+
+ // f( g(_a,_b), g(_b,_a) )
+
+ // f( g(a,_b), g(_b,_a) )
+
+ // f( g(a,b), g(_b,_a) )
+
+ // f( (a*b), g(_b,_a) )
+
+ // f( (a*b), g(b,_a) )
+
+ // f( (a*b), g(b,a) )
+
+ // f( (a*b), (b*a) )
+
+ // ((a*b) + (b*a))
+ public void testNestedFunctions() throws Exception {
+ performTest(7);
+ }
+
+ // #define id(x) x
+
+ // id(
+ // id(a))
+
+ // id(
+ // a)
+
+ // a
+ public void testNewline() throws Exception {
+ performTest(2);
+ }
+
+ // #define f x _a _b x
+ // #define _a a
+ // #define _b b
+
+ // f
+
+ // x _a _b x
+
+ // x a _b x
+
+ // x a b x
+ public void testSpace() throws Exception {
+ performTest(3);
+ }
+
+ // #define L __LINE__
+ // #define x(a) a
+
+ // x(L)
+
+ // x(__LINE__)
+
+ // x(1)
+
+ // 1
+ public void testLineNumber() throws Exception {
+ performTest(3);
+ }
+
+ // #define L __LINE__
+ // #define x(a,b) a,b
+
+ // x(L,
+ // L)
+
+ // x(__LINE__,
+ // L)
+
+ // x(2,
+ // L)
+
+ // x(2,
+ // __LINE__)
+
+ // x(2,
+ // 2)
+
+ // 2,2
+ public void testLineNumber2() throws Exception {
+ performTest(5);
+ }
+
+ // #define str(x) #x
+ // #define xstr(x) str(x)
+
+ // xstr(__LINE__)
+
+ // xstr(1)
+
+ // str(1)
+
+ // "1"
+ public void testStringify() throws Exception {
+ performTest(3);
+ }
+
+ // #define vararg(x, y...) bla(x, y)
+ // #define _p p
+
+ // vararg( _p );
+
+ // vararg( p );
+
+ // bla(p, );
+ public void testVararg1() throws Exception {
+ performTest(2);
+ }
+
+ // #define vararg(x, y...) bla(x, ##y)
+ // #define _p p
+
+ // vararg( _p );
+
+ // vararg( p );
+
+ // bla(p);
+ public void testVararg1x() throws Exception {
+ performTest(2);
+ }
+
+ // #define vararg(x, y...) bla(x, y)
+ // #define _p p
+
+ // vararg( _p , _p );
+
+ // vararg( p , _p );
+
+ // vararg( p , p );
+
+ // bla(p, p);
+ public void testVararg2() throws Exception {
+ performTest(3);
+ }
+
+ // #define vararg(x, y...) bla(x, ## y)
+ // #define _p p
+
+ // vararg( _p , _p );
+
+ // vararg( p , _p );
+
+ // vararg( p , p );
+
+ // bla(p, p);
+ public void testVararg2x() throws Exception {
+ performTest(3);
+ }
+
+ // #define func2(x,y) (x,y)
+ // #define _p p
+
+ // func2(_p);
+
+ // func2(p);
+
+ // (p,);
+ public void testTooFewArgs() throws Exception {
+ performTest(2);
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/FileCharArrayTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/FileCharArrayTests.java
index e993a179bda..3d9f01bbe5a 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/FileCharArrayTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/FileCharArrayTests.java
@@ -28,7 +28,7 @@ import org.eclipse.cdt.internal.core.parser.scanner.FileCharArray;
import org.eclipse.cdt.internal.core.parser.scanner.LazyCharArray;
public class FileCharArrayTests extends BaseTestCase {
-
+
public static TestSuite suite() {
return suite(FileCharArrayTests.class);
}
@@ -43,32 +43,32 @@ public class FileCharArrayTests extends BaseTestCase {
}
public void testAlignedMinus() throws IOException {
- testFile(true, LazyCharArray.CHUNK_SIZE*3-1);
+ testFile(true, LazyCharArray.CHUNK_SIZE * 3 - 1);
}
public void testAlignedEven() throws IOException {
- testFile(true, LazyCharArray.CHUNK_SIZE*3);
+ testFile(true, LazyCharArray.CHUNK_SIZE * 3);
}
public void testAlignedPlus() throws IOException {
- testFile(true, LazyCharArray.CHUNK_SIZE*3+1);
+ testFile(true, LazyCharArray.CHUNK_SIZE * 3 + 1);
}
public void testUnAlignedMinus() throws IOException {
- testFile(false, LazyCharArray.CHUNK_SIZE*3-1);
+ testFile(false, LazyCharArray.CHUNK_SIZE * 3 - 1);
}
public void testUnAlignedEven() throws IOException {
- testFile(false, LazyCharArray.CHUNK_SIZE*3);
+ testFile(false, LazyCharArray.CHUNK_SIZE * 3);
}
public void testUnAlignedPlus() throws IOException {
- testFile(false, LazyCharArray.CHUNK_SIZE*3+1);
+ testFile(false, LazyCharArray.CHUNK_SIZE * 3 + 1);
}
private void testFile(boolean aligned, int charSize) throws IOException {
createFile(aligned, charSize);
-
+
AbstractCharArray charArray;
final FileInputStream inputStream = new FileInputStream(fFile);
try {
@@ -76,33 +76,33 @@ public class FileCharArrayTests extends BaseTestCase {
} finally {
inputStream.close();
}
-
+
checkContent(charArray, LazyCharArray.CHUNK_SIZE, charSize);
assertEquals(charSize, charArray.getLength());
-
+
((LazyCharArray) charArray).testClearData();
-
+
checkContent(charArray, LazyCharArray.CHUNK_SIZE, charSize);
- assertEquals(charSize, charArray.getLength());
+ assertEquals(charSize, charArray.getLength());
}
public void checkContent(AbstractCharArray charArray, int from, int to) {
for (int i = from; i < to; i++) {
assertEquals(i % 127, charArray.get(i));
- if (i+3<=to) {
- char[] dest= new char[3];
+ if (i + 3 <= to) {
+ char[] dest = new char[3];
charArray.arraycopy(i, dest, 0, 3);
for (int j = 0; j < dest.length; j++) {
- assertEquals((i+j) % 127, dest[j]);
+ assertEquals((i + j) % 127, dest[j]);
}
}
}
}
private void createFile(boolean aligned, int charSize) throws IOException {
- fFile= File.createTempFile("data", ".txt");
- OutputStream out= new BufferedOutputStream(new FileOutputStream(fFile));
+ fFile = File.createTempFile("data", ".txt");
+ OutputStream out = new BufferedOutputStream(new FileOutputStream(fFile));
try {
if (!aligned) {
out.write(0xc2);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/FileCodeReaderFactory.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/FileCodeReaderFactory.java
index 1f3d49f7f82..25892f5cb46 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/FileCodeReaderFactory.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/FileCodeReaderFactory.java
@@ -20,16 +20,17 @@ import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent;
import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContentProvider;
public class FileCodeReaderFactory extends InternalFileContentProvider {
- private static FileCodeReaderFactory instance;
+ private static FileCodeReaderFactory instance;
- private FileCodeReaderFactory() {}
-
- @Override
+ private FileCodeReaderFactory() {
+ }
+
+ @Override
public InternalFileContent getContentForInclusion(String path, IMacroDictionary macroDictionary) {
return (InternalFileContent) FileContent.createForExternalFileLocation(path);
}
- public static FileCodeReaderFactory getInstance() {
+ public static FileCodeReaderFactory getInstance() {
if (instance == null)
instance = new FileCodeReaderFactory();
return instance;
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/InactiveCodeTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/InactiveCodeTests.java
index 3a4a8611718..24e2232eb4f 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/InactiveCodeTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/InactiveCodeTests.java
@@ -18,36 +18,35 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import junit.framework.TestSuite;
-
/**
* Tests for using the preprocessor on inactive code
*/
public class InactiveCodeTests extends PreprocessorTestsBase {
-
+
public static TestSuite suite() {
return suite(InactiveCodeTests.class);
}
-
+
@Override
protected void initializeScanner() throws Exception {
super.initializeScanner();
fScanner.setProcessInactiveCode(true);
}
-
+
private void validate(char[] activeInactive) throws Exception {
- boolean active= true;
+ boolean active = true;
for (char c : activeInactive) {
- switch(c) {
+ switch (c) {
case 'a':
if (!active) {
validateToken(IToken.tINACTIVE_CODE_END);
- active= true;
+ active = true;
}
validateIdentifier("a");
break;
case 'i':
validateToken(active ? IToken.tINACTIVE_CODE_START : IToken.tINACTIVE_CODE_SEPARATOR);
- active= false;
+ active = false;
validateIdentifier("i");
break;
default:
@@ -56,7 +55,6 @@ public class InactiveCodeTests extends PreprocessorTestsBase {
}
}
-
// #define D
// #ifdef D
// a
@@ -144,7 +142,7 @@ public class InactiveCodeTests extends PreprocessorTestsBase {
validate("aiiiaiaiiaiiaiaiia".toCharArray());
validateEOF();
}
-
+
// #if 1
// a
// #elif 1
@@ -229,7 +227,7 @@ public class InactiveCodeTests extends PreprocessorTestsBase {
validate("iiiiiaiiiiiaiiiiia".toCharArray());
validateEOF();
}
-
+
// #if 0
// i
// #define M
@@ -245,7 +243,7 @@ public class InactiveCodeTests extends PreprocessorTestsBase {
validateEOF();
assertNull(fScanner.getMacroDefinitions().get("M"));
}
-
+
// #ifdef X
// # if 0
// # endif
@@ -258,7 +256,7 @@ public class InactiveCodeTests extends PreprocessorTestsBase {
validateEOF();
validateProblemCount(0);
}
-
+
// "part1"
// #ifdef SOME_OPTION
// "part2"
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/InclusionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/InclusionTests.java
index 309e0759725..34334c1cada 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/InclusionTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/InclusionTests.java
@@ -38,7 +38,7 @@ import org.eclipse.core.runtime.NullProgressMonitor;
* Scanner2Tests ported to use the CPreprocessor
*/
public class InclusionTests extends PreprocessorTestsBase {
- public static TestSuite suite() {
+ public static TestSuite suite() {
return suite(InclusionTests.class);
}
@@ -56,256 +56,254 @@ public class InclusionTests extends PreprocessorTestsBase {
protected void tearDown() throws Exception {
if (fProject != null) {
CProjectHelper.delete(fProject);
- fProject= null;
+ fProject = null;
}
super.tearDown();
}
-
+
public final static int SIZEOF_TRUTHTABLE = 10;
private IFile importFile(String fileName, String contents) throws Exception {
- if (fProject == null) {
- fProject= CProjectHelper.createCProject(getClass().getName(), null, PDOMNullIndexer.ID);
- }
- return TestSourceReader.createFile(fProject.getProject(), fileName, contents);
+ if (fProject == null) {
+ fProject = CProjectHelper.createCProject(getClass().getName(), null, PDOMNullIndexer.ID);
+ }
+ return TestSourceReader.createFile(fProject.getProject(), fileName, contents);
+ }
+
+ private IFolder importFolder(String name) throws Exception {
+ if (fProject == null) {
+ fProject = CProjectHelper.createCProject(getClass().getName(), null, PDOMNullIndexer.ID);
+ }
+ IFolder folder = fProject.getProject().getFolder(name);
+ if (!folder.exists()) {
+ folder.create(true, true, new NullProgressMonitor());
+ }
+ return folder;
+ }
+
+ // #include "one.h"
+ // #include "f1/two.h"
+ // #include "f1/f2/three.h"
+ public void testIncludeVariables_69529() throws Exception {
+ String content = getAboveComment();
+
+ IFolder f0 = importFolder(".framework");
+ importFolder("f1.framework");
+ importFolder("f1");
+ importFolder("f1.framework/f2");
+ importFolder("f3");
+ IFile base = importFile("base.cpp", content);
+
+ importFile(".framework/one.h", "1");
+ importFile("f1.framework/two.h", "2");
+ importFile("f1.framework/f2/three.h", "3");
+
+ String[] path = { f0.getLocation().removeLastSegments(1) + "/__framework__.framework/__header__" };
+ IScannerInfo scannerInfo = new ExtendedScannerInfo(Collections.EMPTY_MAP, path, new String[] {}, null);
+ FileContent reader = FileContent.create(base);
+ initializeScanner(reader, ParserLanguage.C, ParserMode.COMPLETE_PARSE, scannerInfo);
+
+ // first file is not picked up (no framework)
+ validateInteger("2");
+ validateInteger("3");
+ validateEOF();
+ }
+
+ public void testIncludeNext() throws Exception {
+ String baseFile = "int zero; \n#include \"foo.h\""; //$NON-NLS-1$
+ String i1Next = "int one; \n#include_next <bar/foo.h>"; //$NON-NLS-1$
+ String i2Next = "int two; \n#include_next \"bar/foo.h\""; //$NON-NLS-1$
+ String i3Next = "int three; \n"; //$NON-NLS-1$
+
+ IFolder one = importFolder("one"); //$NON-NLS-1$
+ IFolder oneTwo = importFolder("one/two"); //$NON-NLS-1$
+ IFolder oneTwoBar = importFolder("one/two/bar"); //$NON-NLS-1$
+ IFolder oneThree = importFolder("one/three"); //$NON-NLS-1$
+ IFolder oneThreeBar = importFolder("one/three/bar"); //$NON-NLS-1$
+ IFile base = importFile("base.cpp", baseFile); //$NON-NLS-1$
+ importFile("one/foo.h", i1Next); //$NON-NLS-1$
+ importFile("one/two/bar/foo.h", i2Next); //$NON-NLS-1$
+ importFile("one/three/bar/foo.h", i3Next); //$NON-NLS-1$
+
+ String[] path = new String[3];
+ path[0] = one.getLocation().toOSString();
+ path[1] = oneTwo.getLocation().toOSString();
+ path[2] = oneThree.getLocation().toOSString();
+
+ IScannerInfo scannerInfo = new ExtendedScannerInfo(Collections.EMPTY_MAP, path, new String[] {}, null);
+ FileContent reader = FileContent.create(base);
+ initializeScanner(reader, ParserLanguage.C, ParserMode.COMPLETE_PARSE, scannerInfo);
+
+ validateToken(IToken.t_int);
+ validateIdentifier("zero");
+ validateToken(IToken.tSEMI);
+
+ validateToken(IToken.t_int);
+ validateIdentifier("one");
+ validateToken(IToken.tSEMI);
+
+ validateToken(IToken.t_int);
+ validateIdentifier("two");
+ validateToken(IToken.tSEMI);
+
+ validateToken(IToken.t_int);
+ validateIdentifier("three");
+ validateToken(IToken.tSEMI);
+
+ validateEOF();
+ }
+
+ public void testIncludeNext_286081() throws Exception {
+ String baseFile = "0 \n#include \"foo.h\""; //$NON-NLS-1$
+ String foo1 = "1 \n#include \"intermed.h\""; //$NON-NLS-1$
+ String intermed = "2 \n#include_next <foo.h>"; //$NON-NLS-1$
+ String foo2 = "3 \n"; //$NON-NLS-1$
+
+ IFolder one = importFolder("one"); //$NON-NLS-1$
+ IFolder two = importFolder("two"); //$NON-NLS-1$
+ IFile base = importFile("base.cpp", baseFile); //$NON-NLS-1$
+ importFile("one/foo.h", foo1); //$NON-NLS-1$
+ importFile("one/intermed.h", intermed); //$NON-NLS-1$
+ importFile("two/foo.h", foo2); //$NON-NLS-1$
+
+ String[] path = new String[2];
+ path[0] = one.getLocation().toOSString();
+ path[1] = two.getLocation().toOSString();
+
+ IScannerInfo scannerInfo = new ExtendedScannerInfo(Collections.EMPTY_MAP, path, new String[] {}, null);
+ FileContent reader = FileContent.create(base);
+ initializeScanner(reader, ParserLanguage.C, ParserMode.COMPLETE_PARSE, scannerInfo);
+
+ validateInteger("0");
+ validateInteger("1");
+ validateInteger("2");
+ validateInteger("3");
+
+ validateEOF();
}
- private IFolder importFolder(String name) throws Exception {
- if (fProject == null) {
- fProject= CProjectHelper.createCProject(getClass().getName(), null, PDOMNullIndexer.ID);
- }
- IFolder folder= fProject.getProject().getFolder(name);
- if (!folder.exists()) {
- folder.create(true, true, new NullProgressMonitor());
- }
- return folder;
+ public void testIncludePathOrdering() throws Exception {
+ // create directory structure:
+ // project/base.cpp
+ // project/foo.h
+ // project/two/foo.h
+ // project/three/foo.h
+
+ // this test sets the include path to be two;three and include foo.h (we should see the contents of two/foo.h
+ // then we change to three;two and we should see the contents of three/foo.h.
+
+ String baseFile = "#include <foo.h>"; //$NON-NLS-1$
+ String i1Next = "int one;\n"; //$NON-NLS-1$
+ String i2Next = "int two;\n"; //$NON-NLS-1$
+ String i3Next = "int three;\n"; //$NON-NLS-1$
+
+ IFile base = importFile("base.cpp", baseFile); //$NON-NLS-1$
+ importFile("foo.h", i1Next); //$NON-NLS-1$
+ IFolder twof = importFolder("two"); //$NON-NLS-1$
+ IFolder threef = importFolder("three"); //$NON-NLS-1$
+ importFile("two/foo.h", i2Next); //$NON-NLS-1$
+ importFile("three/foo.h", i3Next); //$NON-NLS-1$
+
+ String[] path = new String[2];
+ path[0] = twof.getLocation().toOSString();
+ path[1] = threef.getLocation().toOSString();
+
+ IScannerInfo scannerInfo = new ExtendedScannerInfo(Collections.EMPTY_MAP, path, new String[] {}, null);
+ FileContent reader = FileContent.create(base);
+ initializeScanner(reader, ParserLanguage.C, ParserMode.COMPLETE_PARSE, scannerInfo);
+
+ validateToken(IToken.t_int);
+ validateIdentifier("two");
+ validateToken(IToken.tSEMI);
+ validateEOF();
+
+ path[0] = threef.getLocation().toOSString();
+ path[1] = twof.getLocation().toOSString();
+
+ scannerInfo = new ExtendedScannerInfo(Collections.EMPTY_MAP, path, new String[] {}, null);
+ initializeScanner(reader, ParserLanguage.C, ParserMode.COMPLETE_PARSE, scannerInfo);
+
+ validateToken(IToken.t_int);
+ validateIdentifier("three");
+ validateToken(IToken.tSEMI);
+ validateEOF();
}
- // #include "one.h"
- // #include "f1/two.h"
- // #include "f1/f2/three.h"
- public void testIncludeVariables_69529() throws Exception {
- String content= getAboveComment();
-
- IFolder f0 = importFolder(".framework");
- importFolder("f1.framework");
- importFolder("f1");
- importFolder("f1.framework/f2");
- importFolder("f3");
- IFile base = importFile("base.cpp", content);
-
- importFile(".framework/one.h", "1");
- importFile("f1.framework/two.h", "2");
- importFile("f1.framework/f2/three.h", "3");
-
- String[] path = {
- f0.getLocation().removeLastSegments(1) + "/__framework__.framework/__header__"
- };
- IScannerInfo scannerInfo = new ExtendedScannerInfo(Collections.EMPTY_MAP, path, new String[]{}, null);
- FileContent reader= FileContent.create(base);
- initializeScanner(reader, ParserLanguage.C, ParserMode.COMPLETE_PARSE, scannerInfo);
-
- // first file is not picked up (no framework)
- validateInteger("2");
- validateInteger("3");
- validateEOF();
- }
-
- public void testIncludeNext() throws Exception {
- String baseFile = "int zero; \n#include \"foo.h\""; //$NON-NLS-1$
- String i1Next = "int one; \n#include_next <bar/foo.h>"; //$NON-NLS-1$
- String i2Next = "int two; \n#include_next \"bar/foo.h\""; //$NON-NLS-1$
- String i3Next = "int three; \n"; //$NON-NLS-1$
-
- IFolder one = importFolder("one"); //$NON-NLS-1$
- IFolder oneTwo = importFolder("one/two"); //$NON-NLS-1$
- IFolder oneTwoBar = importFolder("one/two/bar"); //$NON-NLS-1$
- IFolder oneThree = importFolder("one/three"); //$NON-NLS-1$
- IFolder oneThreeBar = importFolder("one/three/bar"); //$NON-NLS-1$
- IFile base = importFile("base.cpp", baseFile); //$NON-NLS-1$
- importFile("one/foo.h", i1Next); //$NON-NLS-1$
- importFile("one/two/bar/foo.h", i2Next); //$NON-NLS-1$
- importFile("one/three/bar/foo.h", i3Next); //$NON-NLS-1$
-
- String[] path = new String[3];
- path[0] = one.getLocation().toOSString();
- path[1] = oneTwo.getLocation().toOSString();
- path[2] = oneThree.getLocation().toOSString();
-
- IScannerInfo scannerInfo = new ExtendedScannerInfo(Collections.EMPTY_MAP, path, new String[]{}, null);
- FileContent reader= FileContent.create(base);
- initializeScanner(reader, ParserLanguage.C, ParserMode.COMPLETE_PARSE, scannerInfo);
-
- validateToken(IToken.t_int);
- validateIdentifier("zero");
- validateToken(IToken.tSEMI);
-
- validateToken(IToken.t_int);
- validateIdentifier("one");
- validateToken(IToken.tSEMI);
-
- validateToken(IToken.t_int);
- validateIdentifier("two");
- validateToken(IToken.tSEMI);
-
- validateToken(IToken.t_int);
- validateIdentifier("three");
- validateToken(IToken.tSEMI);
-
- validateEOF();
+ public void testBug91086() throws Exception {
+ IFile inclusion = importFile("file.h", "#define FOUND 666\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ StringBuilder buffer = new StringBuilder("#include \""); //$NON-NLS-1$
+ buffer.append(inclusion.getLocation().toOSString());
+ buffer.append("\"\n"); //$NON-NLS-1$
+ buffer.append("int var = FOUND;\n"); //$NON-NLS-1$
+ IFile base = importFile("base.cpp", buffer.toString()); //$NON-NLS-1$
+
+ FileContent reader = FileContent.create(base);
+ ParserLanguage lang[] = { ParserLanguage.C, ParserLanguage.CPP };
+ for (ParserLanguage element : lang) {
+ initializeScanner(reader, element, ParserMode.COMPLETE_PARSE, new ScannerInfo());
+ validateToken(IToken.t_int);
+ validateIdentifier("var");
+ validateToken(IToken.tASSIGN);
+ validateInteger("666");
+ validateToken(IToken.tSEMI);
+ validateEOF();
+ }
+ }
+
+ public void testBug156990() throws Exception {
+ IFile inclusion = importFile("file.h", "ok");
+ StringBuilder buffer = new StringBuilder("#include \"file.h\"");
+ IFile base = importFile("base.cpp", buffer.toString()); //$NON-NLS-1$
+
+ FileContent reader = FileContent.create(base);
+ initializeScanner(reader, ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, new ScannerInfo());
+ validateIdentifier("ok");
+ validateEOF();
}
- public void testIncludeNext_286081() throws Exception {
- String baseFile = "0 \n#include \"foo.h\""; //$NON-NLS-1$
- String foo1 = "1 \n#include \"intermed.h\""; //$NON-NLS-1$
- String intermed = "2 \n#include_next <foo.h>"; //$NON-NLS-1$
- String foo2 = "3 \n"; //$NON-NLS-1$
-
- IFolder one = importFolder("one"); //$NON-NLS-1$
- IFolder two = importFolder("two"); //$NON-NLS-1$
- IFile base = importFile("base.cpp", baseFile); //$NON-NLS-1$
- importFile("one/foo.h", foo1); //$NON-NLS-1$
- importFile("one/intermed.h", intermed); //$NON-NLS-1$
- importFile("two/foo.h", foo2); //$NON-NLS-1$
-
- String[] path = new String[2];
- path[0] = one.getLocation().toOSString();
- path[1] = two.getLocation().toOSString();
-
- IScannerInfo scannerInfo = new ExtendedScannerInfo(Collections.EMPTY_MAP, path, new String[]{}, null);
- FileContent reader= FileContent.create(base);
- initializeScanner(reader, ParserLanguage.C, ParserMode.COMPLETE_PARSE, scannerInfo);
-
- validateInteger("0");
- validateInteger("1");
- validateInteger("2");
- validateInteger("3");
-
- validateEOF();
+ // #include <inc/test.h>
+ public void testRelativeIncludes_243170() throws Exception {
+ String content = getAboveComment();
+
+ IFolder f0 = importFolder("f1");
+ importFolder("f1/f2");
+ importFolder("f1/f2/inc");
+ importFile("f1/f2/inc/test.h", "1");
+ IFile base = importFile("f1/base.cpp", getAboveComment());
+
+ String[] path = { "f2" }; // relative include
+ IScannerInfo scannerInfo = new ExtendedScannerInfo(Collections.EMPTY_MAP, path, new String[] {}, null);
+ FileContent reader = FileContent.create(base);
+ initializeScanner(reader, ParserLanguage.C, ParserMode.COMPLETE_PARSE, scannerInfo);
+
+ validateInteger("1");
+ validateEOF();
}
- public void testIncludePathOrdering() throws Exception {
- // create directory structure:
- // project/base.cpp
- // project/foo.h
- // project/two/foo.h
- // project/three/foo.h
-
- // this test sets the include path to be two;three and include foo.h (we should see the contents of two/foo.h
- // then we change to three;two and we should see the contents of three/foo.h.
-
- String baseFile = "#include <foo.h>"; //$NON-NLS-1$
- String i1Next = "int one;\n"; //$NON-NLS-1$
- String i2Next = "int two;\n"; //$NON-NLS-1$
- String i3Next = "int three;\n"; //$NON-NLS-1$
-
- IFile base = importFile( "base.cpp", baseFile ); //$NON-NLS-1$
- importFile( "foo.h", i1Next ); //$NON-NLS-1$
- IFolder twof = importFolder("two"); //$NON-NLS-1$
- IFolder threef = importFolder("three"); //$NON-NLS-1$
- importFile( "two/foo.h", i2Next ); //$NON-NLS-1$
- importFile( "three/foo.h", i3Next ); //$NON-NLS-1$
-
- String [] path = new String[2];
- path[0] = twof.getLocation().toOSString();
- path[1] = threef.getLocation().toOSString();
-
- IScannerInfo scannerInfo = new ExtendedScannerInfo( Collections.EMPTY_MAP, path, new String[]{}, null );
- FileContent reader= FileContent.create(base);
- initializeScanner(reader, ParserLanguage.C, ParserMode.COMPLETE_PARSE, scannerInfo);
-
- validateToken(IToken.t_int);
- validateIdentifier("two");
- validateToken(IToken.tSEMI);
- validateEOF();
-
- path[0] = threef.getLocation().toOSString();
- path[1] = twof.getLocation().toOSString();
-
- scannerInfo = new ExtendedScannerInfo( Collections.EMPTY_MAP, path, new String[]{}, null );
- initializeScanner(reader, ParserLanguage.C, ParserMode.COMPLETE_PARSE, scannerInfo);
-
- validateToken(IToken.t_int);
- validateIdentifier("three");
- validateToken(IToken.tSEMI);
- validateEOF();
+ // #include "test.h"
+ public void testSuppressingUseOfCurrentFileDirectory() throws Exception {
+ String content = getAboveComment();
+
+ importFolder("f1");
+ IFolder inc = importFolder("f1/inc");
+ importFile("f1/test.h", "1");
+ importFile("f1/inc/test.h", "2");
+ IFile base = importFile("f1/base.cpp", getAboveComment());
+
+ String[] path = { inc.getLocation().toFile().toString() };
+ IScannerInfo scannerInfo = new ExtendedScannerInfo(Collections.EMPTY_MAP, path, new String[] {}, null);
+ FileContent reader = FileContent.create(base);
+ initializeScanner(reader, ParserLanguage.C, ParserMode.COMPLETE_PARSE, scannerInfo);
+
+ validateInteger("1");
+ validateEOF();
+
+ path = new String[] { inc.getLocation().toFile().toString(), "-" }; // Suppress use of current file directory
+ scannerInfo = new ExtendedScannerInfo(Collections.EMPTY_MAP, path, new String[] {}, null);
+ reader = FileContent.create(base);
+ initializeScanner(reader, ParserLanguage.C, ParserMode.COMPLETE_PARSE, scannerInfo);
+
+ validateInteger("2");
+ validateEOF();
}
-
- public void testBug91086() throws Exception {
- IFile inclusion = importFile( "file.h", "#define FOUND 666\n" ); //$NON-NLS-1$ //$NON-NLS-2$
- StringBuilder buffer = new StringBuilder( "#include \"" ); //$NON-NLS-1$
- buffer.append( inclusion.getLocation().toOSString() );
- buffer.append( "\"\n"); //$NON-NLS-1$
- buffer.append( "int var = FOUND;\n"); //$NON-NLS-1$
- IFile base = importFile( "base.cpp", buffer.toString() ); //$NON-NLS-1$
-
- FileContent reader= FileContent.create(base);
- ParserLanguage lang[]= {ParserLanguage.C, ParserLanguage.CPP};
- for (ParserLanguage element : lang) {
- initializeScanner(reader, element, ParserMode.COMPLETE_PARSE, new ScannerInfo());
- validateToken(IToken.t_int);
- validateIdentifier("var");
- validateToken(IToken.tASSIGN);
- validateInteger("666");
- validateToken(IToken.tSEMI);
- validateEOF();
- }
- }
-
- public void testBug156990() throws Exception {
- IFile inclusion = importFile( "file.h", "ok" );
- StringBuilder buffer = new StringBuilder( "#include \"file.h\"" );
- IFile base = importFile( "base.cpp", buffer.toString() ); //$NON-NLS-1$
-
- FileContent reader= FileContent.create(base);
- initializeScanner(reader, ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, new ScannerInfo());
- validateIdentifier("ok");
- validateEOF();
- }
-
- // #include <inc/test.h>
- public void testRelativeIncludes_243170() throws Exception {
- String content= getAboveComment();
-
- IFolder f0 = importFolder("f1");
- importFolder("f1/f2");
- importFolder("f1/f2/inc");
- importFile("f1/f2/inc/test.h", "1");
- IFile base = importFile("f1/base.cpp", getAboveComment());
-
- String[] path = {"f2"}; // relative include
- IScannerInfo scannerInfo = new ExtendedScannerInfo(Collections.EMPTY_MAP, path, new String[]{}, null);
- FileContent reader= FileContent.create(base);
- initializeScanner(reader, ParserLanguage.C, ParserMode.COMPLETE_PARSE, scannerInfo);
-
- validateInteger("1");
- validateEOF();
- }
-
- // #include "test.h"
- public void testSuppressingUseOfCurrentFileDirectory() throws Exception {
- String content= getAboveComment();
-
- importFolder("f1");
- IFolder inc = importFolder("f1/inc");
- importFile("f1/test.h", "1");
- importFile("f1/inc/test.h", "2");
- IFile base = importFile("f1/base.cpp", getAboveComment());
-
- String[] path = {inc.getLocation().toFile().toString()};
- IScannerInfo scannerInfo = new ExtendedScannerInfo(Collections.EMPTY_MAP, path, new String[]{}, null);
- FileContent reader= FileContent.create(base);
- initializeScanner(reader, ParserLanguage.C, ParserMode.COMPLETE_PARSE, scannerInfo);
-
- validateInteger("1");
- validateEOF();
-
- path = new String[] {inc.getLocation().toFile().toString(), "-"}; // Suppress use of current file directory
- scannerInfo = new ExtendedScannerInfo(Collections.EMPTY_MAP, path, new String[]{}, null);
- reader= FileContent.create(base);
- initializeScanner(reader, ParserLanguage.C, ParserMode.COMPLETE_PARSE, scannerInfo);
-
- validateInteger("2");
- validateEOF();
- }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LexerTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LexerTests.java
index c8ecaa34283..def54b471f9 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LexerTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LexerTests.java
@@ -25,7 +25,6 @@ import org.eclipse.cdt.internal.core.parser.scanner.Lexer;
import org.eclipse.cdt.internal.core.parser.scanner.Lexer.LexerOptions;
import org.eclipse.cdt.internal.core.parser.scanner.Token;
-
public class LexerTests extends BaseTestCase {
private static final LexerOptions DEFAULT_OPTIONS = new LexerOptions();
private static final LexerOptions NO_DOLLAR = new LexerOptions();
@@ -33,22 +32,22 @@ public class LexerTests extends BaseTestCase {
private static final LexerOptions SLASH_PERCENT = new LexerOptions();
private static final LexerOptions CPP_OPTIONS = new LexerOptions();
static {
- NO_DOLLAR.fSupportDollarInIdentifiers= false;
- NO_MINMAX.fSupportMinAndMax= false;
- SLASH_PERCENT.fSupportSlashPercentComments= true;
- CPP_OPTIONS.fSupportRawStringLiterals= true;
- CPP_OPTIONS.fSupportDigitSeparators= true;
+ NO_DOLLAR.fSupportDollarInIdentifiers = false;
+ NO_MINMAX.fSupportMinAndMax = false;
+ SLASH_PERCENT.fSupportSlashPercentComments = true;
+ CPP_OPTIONS.fSupportRawStringLiterals = true;
+ CPP_OPTIONS.fSupportDigitSeparators = true;
}
-
- static String TRIGRAPH_REPLACES_CHARS= "#^[]|{}~\\";
- static String TRIGRAPH_CHARS= "='()!<>-/";
+
+ static String TRIGRAPH_REPLACES_CHARS = "#^[]|{}~\\";
+ static String TRIGRAPH_CHARS = "='()!<>-/";
public static TestSuite suite() {
return suite(LexerTests.class);
}
private Lexer fLexer;
- private final TestLexerLog fLog= new TestLexerLog();
+ private final TestLexerLog fLog = new TestLexerLog();
private int fLastEndOffset;
public LexerTests() {
@@ -65,33 +64,33 @@ public class LexerTests extends BaseTestCase {
private void init(String input, LexerOptions options) throws Exception {
fLog.clear();
- fLexer= new Lexer(input.toCharArray(), options, fLog, null);
+ fLexer = new Lexer(input.toCharArray(), options, fLog, null);
fLog.setInput(input);
fLexer.nextToken();
- fLastEndOffset= 0;
+ fLastEndOffset = 0;
}
private void nextDirective() throws Exception {
- IToken t= fLexer.nextDirective();
+ IToken t = fLexer.nextDirective();
assertNotNull(t);
- fLastEndOffset= t.getOffset();
+ fLastEndOffset = t.getOffset();
}
-
+
private void token(int tokenType) throws Exception {
token(tokenType, null);
}
-
+
private void token(int tokenType, String image) throws Exception {
- Token t= fLexer.currentToken();
+ Token t = fLexer.currentToken();
assertEquals(tokenType, t.getType());
assertEquals(fLastEndOffset, t.getOffset());
- fLastEndOffset= t.getEndOffset();
+ fLastEndOffset = t.getEndOffset();
if (image != null) {
assertEquals(image, new String(t.getCharImage()));
}
fLexer.nextToken();
}
-
+
private void integer(String expectedImage) throws Exception {
token(IToken.tINTEGER, expectedImage);
}
@@ -151,30 +150,30 @@ public class LexerTests extends BaseTestCase {
private void wch(String expectedImage) throws Exception {
token(IToken.tLCHAR, expectedImage);
}
-
+
private void utf16ch(String expectedImage) throws Exception {
token(IToken.tUTF16CHAR, expectedImage);
}
-
+
private void utf32ch(String expectedImage) throws Exception {
token(IToken.tUTF32CHAR, expectedImage);
}
private void eof() throws Exception {
- IToken t= fLexer.nextToken();
+ IToken t = fLexer.nextToken();
assertEquals("superfluous token " + t, IToken.tEND_OF_INPUT, t.getType());
assertEquals(0, fLog.getProblemCount());
assertEquals(0, fLog.getCommentCount());
}
-
+
private void nl() throws Exception {
token(Lexer.tNEWLINE);
}
private void ws() throws Exception {
- int offset= fLexer.currentToken().getOffset();
+ int offset = fLexer.currentToken().getOffset();
assertTrue(offset > fLastEndOffset);
- fLastEndOffset= offset;
+ fLastEndOffset = offset;
}
private void problem(int kind, String img) throws Exception {
@@ -190,7 +189,7 @@ public class LexerTests extends BaseTestCase {
init("\"??=??/??'??(??)??!??<??>??-\"");
str("#\\^[]|{}~");
eof();
-
+
init("??=??'??(??)??!??<??>??-");
token(IToken.tPOUND);
token(IToken.tXOR);
@@ -201,7 +200,7 @@ public class LexerTests extends BaseTestCase {
token(IToken.tRBRACE);
token(IToken.tBITCOMPLEMENT);
eof();
-
+
init("a??/\nb");
id("ab");
eof();
@@ -210,19 +209,19 @@ public class LexerTests extends BaseTestCase {
public void testLessColonColon() throws Exception {
// 2.5-3
// <: is treated as digraph [
- init("<::>");
+ init("<::>");
token(IToken.tLBRACKET);
token(IToken.tRBRACKET);
eof();
// <: is treated as digraph [
- init("<:::");
+ init("<:::");
token(IToken.tLBRACKET);
token(IToken.tCOLONCOLON);
eof();
// <:: is treated as < and ::
- init("<::A");
+ init("<::A");
token(IToken.tLT);
token(IToken.tCOLONCOLON);
token(IToken.tIDENTIFIER);
@@ -231,75 +230,79 @@ public class LexerTests extends BaseTestCase {
public void testWindowsLineEnding() throws Exception {
init("\n\n");
- nl(); nl(); eof();
+ nl();
+ nl();
+ eof();
init("\r\n\r\n");
- nl(); nl(); eof();
+ nl();
+ nl();
+ eof();
}
-
+
public void testLineSplicingTrigraph() throws Exception {
// a trigraph cannot be spliced
- init("??\\\n=");
+ init("??\\\n=");
token(IToken.tQUESTION);
token(IToken.tQUESTION);
token(IToken.tASSIGN);
eof();
- init("??\\\r\n=");
+ init("??\\\r\n=");
token(IToken.tQUESTION);
token(IToken.tQUESTION);
token(IToken.tASSIGN);
eof();
-
+
// trigraph can be used to splice a line
init("a??/\nb");
id("ab");
eof();
}
-
+
public void testLineSplicingStringLiteral() throws Exception {
// splicing in string literal
- init("\"a\\\nb\"");
- str("ab");
+ init("\"a\\\nb\"");
+ str("ab");
eof();
init("\"a\\\r\nb\"");
- str("ab");
+ str("ab");
eof();
}
public void testLineSplicingCharLiteral() throws Exception {
- init("'a\\\nb'");
- ch("'ab'");
+ init("'a\\\nb'");
+ ch("'ab'");
eof();
init("'a\\\r\nb'");
- ch("'ab'");
+ ch("'ab'");
eof();
}
public void testLineSplicingHeaderName() throws Exception {
- init("p\"a\\\nb\"");
+ init("p\"a\\\nb\"");
fLexer.setInsideIncludeDirective(true);
id("p");
- token(Lexer.tQUOTE_HEADER_NAME, "\"ab\"");
+ token(Lexer.tQUOTE_HEADER_NAME, "\"ab\"");
eof();
init("p\"a\\\r\nb\"");
fLexer.setInsideIncludeDirective(true);
id("p");
- token(Lexer.tQUOTE_HEADER_NAME, "\"ab\"");
+ token(Lexer.tQUOTE_HEADER_NAME, "\"ab\"");
eof();
- init("p<a\\\nb>");
+ init("p<a\\\nb>");
fLexer.setInsideIncludeDirective(true);
id("p");
- token(Lexer.tSYSTEM_HEADER_NAME, "<ab>");
+ token(Lexer.tSYSTEM_HEADER_NAME, "<ab>");
eof();
init("p<a\\\r\nb>");
fLexer.setInsideIncludeDirective(true);
id("p");
- token(Lexer.tSYSTEM_HEADER_NAME, "<ab>");
+ token(Lexer.tSYSTEM_HEADER_NAME, "<ab>");
eof();
}
@@ -350,7 +353,7 @@ public class LexerTests extends BaseTestCase {
nl();
id("a");
eof();
-
+
init("/* // /* \n xxx*/a");
comment("/* // /* \n xxx*/");
id("a");
@@ -363,7 +366,7 @@ public class LexerTests extends BaseTestCase {
nl();
id("a");
eof();
-
+
init("/% // /% \n xxx%/a", SLASH_PERCENT);
comment("/% // /% \n xxx%/");
id("a");
@@ -401,57 +404,67 @@ public class LexerTests extends BaseTestCase {
token(Lexer.tSYSTEM_HEADER_NAME, "<'\"/*//>");
eof();
}
-
+
public void testIdentifier() throws Exception {
- final String ident= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$\\u1234\\U123456780123456789";
- int unc1= ident.indexOf('\\');
+ final String ident = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$\\u1234\\U123456780123456789";
+ int unc1 = ident.indexOf('\\');
for (int i = 0; i <= unc1; i++) {
- String id= ident.substring(i);
- init(id);
+ String id = ident.substring(i);
+ init(id);
id(id);
eof();
}
- String id= ident.substring(ident.indexOf('\\', unc1+1));
- init(id);
+ String id = ident.substring(ident.indexOf('\\', unc1 + 1));
+ init(id);
id(id);
eof();
-
- for (int i= 0; i <10; i++) {
- String nonid= ident.substring(ident.length()-i-1);
+
+ for (int i = 0; i < 10; i++) {
+ String nonid = ident.substring(ident.length() - i - 1);
init(nonid);
integer(nonid);
eof();
}
-
- init(ident, NO_DOLLAR);
+
+ init(ident, NO_DOLLAR);
final int idxDollar = ident.indexOf('$');
id(ident.substring(0, idxDollar));
token(Lexer.tOTHER_CHARACTER, "$");
- id(ident.substring(idxDollar+1));
+ id(ident.substring(idxDollar + 1));
}
-
+
public void testNumber() throws Exception {
- final String number= ".0123456789.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_" +
- "\\uaaaa\\Uaaaaaaaae+e-E+E-";
+ final String number = ".0123456789.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"
+ + "\\uaaaa\\Uaaaaaaaae+e-E+E-";
for (int i = 0; i < 11; i++) {
- String n= number.substring(i);
- init(n);
+ String n = number.substring(i);
+ init(n);
floating(n);
eof();
}
- int idxPlus= number.indexOf('+');
+ int idxPlus = number.indexOf('+');
for (int i = 11; i < number.length(); i++) {
- String n= number.substring(i);
+ String n = number.substring(i);
init(n);
- int startString= 0;
- if (i==11) {token(IToken.tDOT); startString=1;}
- if (i<idxPlus) id(n.substring(startString, idxPlus-i));
- if (i<idxPlus+1) token(IToken.tPLUS);
- if (i<idxPlus+2) id("e");
- if (i<idxPlus+3) token(IToken.tMINUS);
- if (i<idxPlus+4) id("E");
- if (i<idxPlus+5) token(IToken.tPLUS);
- if (i<idxPlus+6) id("E");
+ int startString = 0;
+ if (i == 11) {
+ token(IToken.tDOT);
+ startString = 1;
+ }
+ if (i < idxPlus)
+ id(n.substring(startString, idxPlus - i));
+ if (i < idxPlus + 1)
+ token(IToken.tPLUS);
+ if (i < idxPlus + 2)
+ id("e");
+ if (i < idxPlus + 3)
+ token(IToken.tMINUS);
+ if (i < idxPlus + 4)
+ id("E");
+ if (i < idxPlus + 5)
+ token(IToken.tPLUS);
+ if (i < idxPlus + 6)
+ id("E");
token(IToken.tMINUS);
eof();
}
@@ -466,73 +479,73 @@ public class LexerTests extends BaseTestCase {
}
public void testCharLiteral() throws Exception {
- String lit= "'abc0123\\'\".:; \\\\'";
+ String lit = "'abc0123\\'\".:; \\\\'";
init(lit);
ch(lit);
eof();
- String lit2= 'L'+lit;
+ String lit2 = 'L' + lit;
init(lit2);
wch(lit2);
eof();
-
- lit2= 'u'+lit;
+
+ lit2 = 'u' + lit;
init(lit2);
utf16ch(lit2);
eof();
-
- lit2= 'U'+lit;
+
+ lit2 = 'U' + lit;
init(lit2);
utf32ch(lit2);
eof();
- lit= "'ut\n";
+ lit = "'ut\n";
init(lit);
problem(IProblem.SCANNER_BAD_CHARACTER, "'ut");
ch("'ut");
nl();
eof();
- lit2= 'L'+lit;
+ lit2 = 'L' + lit;
init(lit2);
problem(IProblem.SCANNER_BAD_CHARACTER, "L'ut");
wch("L'ut");
nl();
eof();
-
- lit2= 'u'+lit;
+
+ lit2 = 'u' + lit;
init(lit2);
problem(IProblem.SCANNER_BAD_CHARACTER, "u'ut");
utf16ch("u'ut");
nl();
eof();
-
- lit2= 'U'+lit;
+
+ lit2 = 'U' + lit;
init(lit2);
problem(IProblem.SCANNER_BAD_CHARACTER, "U'ut");
utf32ch("U'ut");
nl();
eof();
-
- lit= "'ut\\'";
+
+ lit = "'ut\\'";
init(lit);
problem(IProblem.SCANNER_BAD_CHARACTER, lit);
ch("'ut\\'");
eof();
- lit2= 'L'+lit;
+ lit2 = 'L' + lit;
init(lit2);
problem(IProblem.SCANNER_BAD_CHARACTER, lit2);
wch("L'ut\\'");
eof();
-
- lit2= 'u'+lit;
+
+ lit2 = 'u' + lit;
init(lit2);
problem(IProblem.SCANNER_BAD_CHARACTER, lit2);
utf16ch("u'ut\\'");
eof();
-
- lit2= 'U'+lit;
+
+ lit2 = 'U' + lit;
init(lit2);
problem(IProblem.SCANNER_BAD_CHARACTER, lit2);
utf32ch("U'ut\\'");
@@ -540,7 +553,7 @@ public class LexerTests extends BaseTestCase {
}
public void testStringLiteral() throws Exception {
- String lit= "abc0123\\\"'.:; \\\\";
+ String lit = "abc0123\\\"'.:; \\\\";
init('"' + lit + '"');
str(lit);
eof();
@@ -556,12 +569,12 @@ public class LexerTests extends BaseTestCase {
init("u\"" + lit + '"');
utf16str(lit);
eof();
-
+
init("U\"" + lit + '"');
utf32str(lit);
eof();
- lit= "ut\n";
+ lit = "ut\n";
init('"' + lit);
problem(IProblem.SCANNER_UNBOUNDED_STRING, "\"ut");
token(IToken.tSTRING, "\"ut");
@@ -573,38 +586,38 @@ public class LexerTests extends BaseTestCase {
token(IToken.tLSTRING, "L\"ut");
nl();
eof();
-
+
init("u\"" + lit);
problem(IProblem.SCANNER_UNBOUNDED_STRING, "u\"ut");
token(IToken.tUTF16STRING, "u\"ut");
nl();
eof();
-
+
init("U\"" + lit);
problem(IProblem.SCANNER_UNBOUNDED_STRING, "U\"ut");
token(IToken.tUTF32STRING, "U\"ut");
nl();
eof();
-
- lit= "\"ut\\\"";
+
+ lit = "\"ut\\\"";
init(lit);
problem(IProblem.SCANNER_UNBOUNDED_STRING, lit);
token(IToken.tSTRING, "\"ut\\\"");
eof();
- String lit2= 'L'+lit;
+ String lit2 = 'L' + lit;
init(lit2);
problem(IProblem.SCANNER_UNBOUNDED_STRING, lit2);
token(IToken.tLSTRING, "L\"ut\\\"");
eof();
-
- lit2= 'u'+lit;
+
+ lit2 = 'u' + lit;
init(lit2);
problem(IProblem.SCANNER_UNBOUNDED_STRING, lit2);
token(IToken.tUTF16STRING, "u\"ut\\\"");
eof();
-
- lit2= 'U'+lit;
+
+ lit2 = 'U' + lit;
init(lit2);
problem(IProblem.SCANNER_UNBOUNDED_STRING, lit2);
token(IToken.tUTF32STRING, "U\"ut\\\"");
@@ -612,7 +625,7 @@ public class LexerTests extends BaseTestCase {
}
public void testRawStringLiteral() throws Exception {
- String lit= "abc0123\\\"'.:; \\\\ \n\"(";
+ String lit = "abc0123\\\"'.:; \\\\ \n\"(";
init("R\"(" + lit + ")\"", CPP_OPTIONS);
rstr("", lit);
eof();
@@ -628,7 +641,7 @@ public class LexerTests extends BaseTestCase {
init("uR\"(" + lit + ")\"", CPP_OPTIONS);
utf16rstr("", lit);
eof();
-
+
init("UR\"(" + lit + ")\"", CPP_OPTIONS);
utf32rstr("", lit);
eof();
@@ -642,30 +655,35 @@ public class LexerTests extends BaseTestCase {
problem(IProblem.SCANNER_UNBOUNDED_STRING, "LR\"(ut");
token(IToken.tLSTRING, "LR\"(ut");
eof();
-
+
init("uR\"p()", CPP_OPTIONS);
problem(IProblem.SCANNER_UNBOUNDED_STRING, "uR\"p()");
token(IToken.tUTF16STRING, "uR\"p()");
eof();
-
+
init("UR\"(ut", CPP_OPTIONS);
problem(IProblem.SCANNER_UNBOUNDED_STRING, "UR\"(ut");
token(IToken.tUTF32STRING, "UR\"(ut");
eof();
-
+
init("R\"+=(Text)=+\"Text)+=\"", CPP_OPTIONS);
rstr("+=", "Text)=+\"Text");
eof();
-
+
init("UR uR LR u8R U8R\"\"", CPP_OPTIONS);
- id("UR"); ws();
- id("uR"); ws();
- id("LR"); ws();
- id("u8R"); ws();
- id("U8R"); str("");
+ id("UR");
+ ws();
+ id("uR");
+ ws();
+ id("LR");
+ ws();
+ id("u8R");
+ ws();
+ id("U8R");
+ str("");
eof();
}
-
+
public void testRawStringLiteralInInactiveCode() throws Exception {
init("start\n" + "inactive: Rbla\n" + "#end", CPP_OPTIONS);
id("start");
@@ -684,37 +702,34 @@ public class LexerTests extends BaseTestCase {
}
public void testOperatorAndPunctuators() throws Exception {
- final String ops= "{}[]###()<::><%%>%:%:%:;:...?.::..*+-*/%^&|~=!<>+=-=*=/=%=" +
- "^=&=|=<<>><<=>>===!=<=>=&&||++--,->*-><?>?\\";
- final int[] tokens= new int[] {
- IToken.tLBRACE, IToken.tRBRACE, IToken.tLBRACKET, IToken.tRBRACKET, IToken.tPOUNDPOUND,
- IToken.tPOUND, IToken.tLPAREN, IToken.tRPAREN, IToken.tLBRACKET, IToken.tRBRACKET,
- IToken.tLBRACE, IToken.tRBRACE, IToken.tPOUNDPOUND, IToken.tPOUND, IToken.tSEMI,
- IToken.tCOLON, IToken.tELLIPSIS, IToken.tQUESTION, IToken.tDOT, IToken.tCOLONCOLON, IToken.tDOT,
- IToken.tDOTSTAR, IToken.tPLUS, IToken.tMINUS, IToken.tSTAR, IToken.tDIV, IToken.tMOD,
- IToken.tXOR, IToken.tAMPER, IToken.tBITOR, IToken.tBITCOMPLEMENT, IToken.tASSIGN, IToken.tNOT,
- IToken.tLT, IToken.tGT, IToken.tPLUSASSIGN, IToken.tMINUSASSIGN, IToken.tSTARASSIGN,
- IToken.tDIVASSIGN, IToken.tMODASSIGN, IToken.tXORASSIGN, IToken.tAMPERASSIGN,
- IToken.tBITORASSIGN, IToken.tSHIFTL, IToken.tSHIFTR, IToken.tSHIFTLASSIGN,
- IToken.tSHIFTRASSIGN, IToken.tEQUAL, IToken.tNOTEQUAL, IToken.tLTEQUAL, IToken.tGTEQUAL,
- IToken.tAND, IToken.tOR, IToken.tINCR, IToken.tDECR, IToken.tCOMMA, IToken.tARROWSTAR,
- IToken.tARROW, IGCCToken.tMIN, IGCCToken.tMAX, Lexer.tOTHER_CHARACTER,
- };
-
- for (int splices=0; splices<9; splices++) {
- for (int trigraphs= 0; trigraphs<6; trigraphs++) {
- StringBuilder buf= new StringBuilder();
- String input= useTrigraphs(ops.toCharArray(), trigraphs);
- init(instertLineSplices(input, splices));
+ final String ops = "{}[]###()<::><%%>%:%:%:;:...?.::..*+-*/%^&|~=!<>+=-=*=/=%="
+ + "^=&=|=<<>><<=>>===!=<=>=&&||++--,->*-><?>?\\";
+ final int[] tokens = new int[] { IToken.tLBRACE, IToken.tRBRACE, IToken.tLBRACKET, IToken.tRBRACKET,
+ IToken.tPOUNDPOUND, IToken.tPOUND, IToken.tLPAREN, IToken.tRPAREN, IToken.tLBRACKET, IToken.tRBRACKET,
+ IToken.tLBRACE, IToken.tRBRACE, IToken.tPOUNDPOUND, IToken.tPOUND, IToken.tSEMI, IToken.tCOLON,
+ IToken.tELLIPSIS, IToken.tQUESTION, IToken.tDOT, IToken.tCOLONCOLON, IToken.tDOT, IToken.tDOTSTAR,
+ IToken.tPLUS, IToken.tMINUS, IToken.tSTAR, IToken.tDIV, IToken.tMOD, IToken.tXOR, IToken.tAMPER,
+ IToken.tBITOR, IToken.tBITCOMPLEMENT, IToken.tASSIGN, IToken.tNOT, IToken.tLT, IToken.tGT,
+ IToken.tPLUSASSIGN, IToken.tMINUSASSIGN, IToken.tSTARASSIGN, IToken.tDIVASSIGN, IToken.tMODASSIGN,
+ IToken.tXORASSIGN, IToken.tAMPERASSIGN, IToken.tBITORASSIGN, IToken.tSHIFTL, IToken.tSHIFTR,
+ IToken.tSHIFTLASSIGN, IToken.tSHIFTRASSIGN, IToken.tEQUAL, IToken.tNOTEQUAL, IToken.tLTEQUAL,
+ IToken.tGTEQUAL, IToken.tAND, IToken.tOR, IToken.tINCR, IToken.tDECR, IToken.tCOMMA, IToken.tARROWSTAR,
+ IToken.tARROW, IGCCToken.tMIN, IGCCToken.tMAX, Lexer.tOTHER_CHARACTER, };
+
+ for (int splices = 0; splices < 9; splices++) {
+ for (int trigraphs = 0; trigraphs < 6; trigraphs++) {
+ StringBuilder buf = new StringBuilder();
+ String input = useTrigraphs(ops.toCharArray(), trigraphs);
+ init(instertLineSplices(input, splices));
for (int token2 : tokens) {
- Token token= fLexer.currentToken();
+ Token token = fLexer.currentToken();
buf.append(token.getCharImage());
token(token2);
}
eof();
assertEquals(ops, buf.toString()); // check token image
- init(input, NO_MINMAX);
+ init(input, NO_MINMAX);
for (int token : tokens) {
switch (token) {
case IGCCToken.tMIN:
@@ -727,7 +742,7 @@ public class LexerTests extends BaseTestCase {
break;
default:
token(token);
- break;
+ break;
}
}
eof();
@@ -736,17 +751,17 @@ public class LexerTests extends BaseTestCase {
}
private String instertLineSplices(String input, int splices) {
- int m1= splices%3;
- int m2= (splices-m1)/3;
- char[] c= input.toCharArray();
- StringBuilder result= new StringBuilder();
+ int m1 = splices % 3;
+ int m2 = (splices - m1) / 3;
+ char[] c = input.toCharArray();
+ StringBuilder result = new StringBuilder();
for (int i = 0; i < c.length; i++) {
result.append(c[i]);
- if (c[i]=='?' && i+2 < c.length && c[i+1] == '?' && TRIGRAPH_CHARS.indexOf(c[i+2]) >= 0) {
+ if (c[i] == '?' && i + 2 < c.length && c[i + 1] == '?' && TRIGRAPH_CHARS.indexOf(c[i + 2]) >= 0) {
result.append(c[++i]);
result.append(c[++i]);
}
- switch(m1) {
+ switch (m1) {
case 1:
result.append("\\\n");
break;
@@ -754,7 +769,7 @@ public class LexerTests extends BaseTestCase {
result.append("\\ \n");
break;
}
- switch(m2) {
+ switch (m2) {
case 1:
result.append("\\\r\n");
break;
@@ -771,40 +786,38 @@ public class LexerTests extends BaseTestCase {
return new String(input);
}
- boolean yes= mode > 1;
- StringBuilder result= new StringBuilder();
+ boolean yes = mode > 1;
+ StringBuilder result = new StringBuilder();
for (char c : input) {
- int idx= TRIGRAPH_REPLACES_CHARS.indexOf(c);
+ int idx = TRIGRAPH_REPLACES_CHARS.indexOf(c);
if (idx > 0) {
if (yes) {
result.append("??");
result.append(TRIGRAPH_CHARS.charAt(idx));
- }
- else {
+ } else {
result.append(c);
}
if (mode < 3) {
- yes= !yes;
+ yes = !yes;
}
- }
- else {
+ } else {
result.append(c);
}
}
return result.toString();
}
-
+
public void testLineSplicingOperator() throws Exception {
// splicing in operator
init("|\\\n|");
token(IToken.tOR);
eof();
-
+
init("|\\\r\n|");
- token(IToken.tOR);
+ token(IToken.tOR);
eof();
}
-
+
public void testNextDirective() throws Exception {
init("#if \n /*\n#*/ \"#\" '#' \\\n# ??/\n# \n## \n#\\\n# \n#??/\n# \n#ok \r\n#");
token(IToken.tPOUND);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LocationMapTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LocationMapTests.java
index 93de7438dd7..d3394d519bf 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LocationMapTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LocationMapTests.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.core.parser.tests.scanner;
import java.io.IOException;
@@ -63,58 +63,71 @@ public class LocationMapTests extends BaseTestCase {
private int fEndOffset;
public Loc(String file, int offset, int endOffset) {
- fFile= file;
- fOffset= offset;
- fEndOffset= endOffset;
+ fFile = file;
+ fOffset = offset;
+ fEndOffset = endOffset;
}
+
@Override
public int getEndingLineNumber() {
return 0;
}
+
@Override
public String getFileName() {
return fFile;
}
+
@Override
public int getNodeLength() {
return fEndOffset - fOffset;
}
+
@Override
public int getNodeOffset() {
return fOffset;
}
+
@Override
public int getStartingLineNumber() {
return 0;
}
+
@Override
public IASTFileLocation asFileLocation() {
return this;
}
+
@Override
public IASTPreprocessorIncludeStatement getContextInclusionStatement() {
return null;
}
+
@Override
public char[] getSimpleID() {
return new char[0];
}
+
@Override
public char[] toCharArray() {
return getSimpleID();
}
+
@Override
public boolean isDeclaration() {
return false;
}
+
@Override
public boolean isReference() {
return false;
}
+
@Override
public boolean isDefinition() {
return true;
}
+
@Override
public IASTFileLocation getFileLocation() {
return this;
@@ -126,11 +139,11 @@ public class LocationMapTests extends BaseTestCase {
private static final int ROLE_UNCLEAR = IASTNameOwner.r_unclear;
private static final int ROLE_REFERENCE = IASTNameOwner.r_reference;
private static final ASTNodeProperty PROP_PST = IASTTranslationUnit.PREPROCESSOR_STATEMENT;
- final static char[] DIGITS= "0123456789abcdef".toCharArray();
- final static char[] LONGDIGITS= new char[1024];
+ final static char[] DIGITS = "0123456789abcdef".toCharArray();
+ final static char[] LONGDIGITS = new char[1024];
static {
for (int i = 0; i < LONGDIGITS.length; i++) {
- LONGDIGITS[i]= (char) i;
+ LONGDIGITS[i] = (char) i;
}
}
private LocationMap fLocationMap;
@@ -144,47 +157,47 @@ public class LocationMapTests extends BaseTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- fLocationMap= new LocationMap(new LexerOptions());
+ fLocationMap = new LocationMap(new LexerOptions());
}
@Override
protected void tearDown() throws Exception {
- fLocationMap= null;
+ fLocationMap = null;
super.tearDown();
}
protected StringBuilder[] getContents(int sections) throws IOException {
- return TestSourceReader.getContentsForTest(
- CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), sections);
+ return TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "parser", getClass(),
+ getName(), sections);
}
private void init(char[] content) {
fContent = new CharArray(content);
fLocationMap.pushTranslationUnit(FN, fContent);
- fTu= new CPPASTTranslationUnit();
+ fTu = new CPPASTTranslationUnit();
fTu.setLocationResolver(fLocationMap);
}
- private void checkASTNode(IASTNode node, IASTNode parent, ASTNodeProperty property,
- String filename, int offset, int length, int line, int endline, String sig) {
+ private void checkASTNode(IASTNode node, IASTNode parent, ASTNodeProperty property, String filename, int offset,
+ int length, int line, int endline, String sig) {
assertTrue(node.contains(node));
assertSame(parent, node.getParent());
assertEquals(property, node.getPropertyInParent());
assertSame(parent.getTranslationUnit(), node.getTranslationUnit());
assertEquals(filename, node.getContainingFilename());
-
+
if (offset >= 0) {
- IASTFileLocation loc= node.getFileLocation();
+ IASTFileLocation loc = node.getFileLocation();
checkLocation(loc, filename, offset, length, line, endline);
assertEquals(sig, node.getRawSignature());
} else {
assertNull(node.getFileLocation());
}
}
-
- private void checkName(IASTName name, IBinding binding, String nameString,
- IASTNode parent, ASTNodeProperty property, int role,
- String filename, int offset, int length, int line, int endline, String sig) {
+
+ private void checkName(IASTName name, IBinding binding, String nameString, IASTNode parent,
+ ASTNodeProperty property, int role, String filename, int offset, int length, int line, int endline,
+ String sig) {
assertSame(binding, name.getBinding());
assertSame(binding, name.resolveBinding());
assertEquals(Linkage.CPP_LINKAGE, name.getLinkage());
@@ -194,7 +207,7 @@ public class LocationMapTests extends BaseTestCase {
assertEquals(name.isDefinition(), role == ROLE_DEFINITION);
assertEquals(name.isReference(), role == IASTNameOwner.r_reference);
}
-
+
private void checkLocation(IASTFileLocation loc, String filename, int offset, int length, int line, int endline) {
if (loc == null) {
assertEquals(0, offset);
@@ -207,9 +220,9 @@ public class LocationMapTests extends BaseTestCase {
assertEquals(endline, loc.getEndingLineNumber());
}
}
-
- private void checkComment(IASTComment comment, String content, boolean blockComment,
- String filename, int offset, int length, int line, int endline) {
+
+ private void checkComment(IASTComment comment, String content, boolean blockComment, String filename, int offset,
+ int length, int line, int endline) {
assertEquals(content, new String(comment.getComment()));
assertEquals(blockComment, comment.isBlockComment());
checkASTNode(comment, fTu, PROP_PST, filename, offset, length, line, endline, content);
@@ -218,46 +231,48 @@ public class LocationMapTests extends BaseTestCase {
assertEquals(blockComment, comment.isBlockComment());
}
- private void checkProblem(IASTProblem problem, int id, String arg, String marked,
- String filename, int offset, int length, int line, int endline) {
+ private void checkProblem(IASTProblem problem, int id, String arg, String marked, String filename, int offset,
+ int length, int line, int endline) {
assertEquals(id, problem.getID());
if (arg != null) {
assertEquals(arg, problem.getArguments()[0]);
}
assertFalse(problem.isError());
assertTrue(problem.isWarning());
- checkASTNode(problem, fTu, IASTTranslationUnit.SCANNER_PROBLEM, filename, offset, length, line, endline, marked);
+ checkASTNode(problem, fTu, IASTTranslationUnit.SCANNER_PROBLEM, filename, offset, length, line, endline,
+ marked);
}
- private void checkError(IASTPreprocessorStatement s, String directive, String condition,
- String filename, int offset, int length, int line) {
- IASTPreprocessorErrorStatement st= (IASTPreprocessorErrorStatement) s;
+ private void checkError(IASTPreprocessorStatement s, String directive, String condition, String filename,
+ int offset, int length, int line) {
+ IASTPreprocessorErrorStatement st = (IASTPreprocessorErrorStatement) s;
assertEquals(condition, new String(st.getMessage()));
checkASTNode(st, fTu, PROP_PST, filename, offset, length, line, line, directive);
}
- private void checkPragma(IASTPreprocessorStatement s, String directive, String condition,
- String filename, int offset, int length, int line) {
- IASTPreprocessorPragmaStatement st= (IASTPreprocessorPragmaStatement) s;
+ private void checkPragma(IASTPreprocessorStatement s, String directive, String condition, String filename,
+ int offset, int length, int line) {
+ IASTPreprocessorPragmaStatement st = (IASTPreprocessorPragmaStatement) s;
assertEquals(condition, new String(st.getMessage()));
checkASTNode(st, fTu, PROP_PST, filename, offset, length, line, line, directive);
}
- private void checkInclude(IASTPreprocessorIncludeStatement include, String directive,
- String nameImage, String name, String fileTarget, boolean user, boolean active,
- String filename, int offset, int length, int line, int nameOffset, int nameLength) {
+ private void checkInclude(IASTPreprocessorIncludeStatement include, String directive, String nameImage, String name,
+ String fileTarget, boolean user, boolean active, String filename, int offset, int length, int line,
+ int nameOffset, int nameLength) {
assertEquals(fileTarget, include.getPath());
assertEquals(user, !include.isSystemInclude());
assertEquals(active, include.isActive());
assertEquals(fileTarget.length() > 0, include.isResolved());
-
- checkName(include.getName(), null, name, include, IASTPreprocessorIncludeStatement.INCLUDE_NAME, ROLE_UNCLEAR, filename, nameOffset, nameLength, line, line, nameImage);
+
+ checkName(include.getName(), null, name, include, IASTPreprocessorIncludeStatement.INCLUDE_NAME, ROLE_UNCLEAR,
+ filename, nameOffset, nameLength, line, line, nameImage);
checkASTNode(include, fTu, PROP_PST, filename, offset, length, line, line, directive);
}
private void checkIf(IASTPreprocessorStatement s, String directive, String condition, boolean active,
String filename, int offset, int length, int line) {
- IASTPreprocessorIfStatement st= (IASTPreprocessorIfStatement) s;
+ IASTPreprocessorIfStatement st = (IASTPreprocessorIfStatement) s;
assertEquals(condition, new String(st.getCondition()));
assertEquals(active, st.taken());
checkASTNode(st, fTu, PROP_PST, filename, offset, length, line, line, directive);
@@ -265,7 +280,7 @@ public class LocationMapTests extends BaseTestCase {
private void checkIfdef(IASTPreprocessorStatement s, String directive, String condition, boolean active,
String filename, int offset, int length, int line) {
- IASTPreprocessorIfdefStatement st= (IASTPreprocessorIfdefStatement) s;
+ IASTPreprocessorIfdefStatement st = (IASTPreprocessorIfdefStatement) s;
assertEquals(condition, new String(st.getCondition()));
assertEquals(active, st.taken());
checkASTNode(st, fTu, PROP_PST, filename, offset, length, line, line, directive);
@@ -273,7 +288,7 @@ public class LocationMapTests extends BaseTestCase {
private void checkIfndef(IASTPreprocessorStatement s, String directive, String condition, boolean active,
String filename, int offset, int length, int line) {
- IASTPreprocessorIfndefStatement st= (IASTPreprocessorIfndefStatement) s;
+ IASTPreprocessorIfndefStatement st = (IASTPreprocessorIfndefStatement) s;
assertEquals(condition, new String(st.getCondition()));
assertEquals(active, st.taken());
checkASTNode(st, fTu, PROP_PST, filename, offset, length, line, line, directive);
@@ -281,50 +296,53 @@ public class LocationMapTests extends BaseTestCase {
private void checkElif(IASTPreprocessorStatement s, String directive, String condition, boolean active,
String filename, int offset, int length, int line) {
- IASTPreprocessorElifStatement st= (IASTPreprocessorElifStatement) s;
+ IASTPreprocessorElifStatement st = (IASTPreprocessorElifStatement) s;
assertEquals(condition, new String(st.getCondition()));
assertEquals(active, st.taken());
checkASTNode(st, fTu, PROP_PST, filename, offset, length, line, line, directive);
}
- private void checkElse(IASTPreprocessorStatement s, String directive, boolean active,
- String filename, int offset, int length, int line) {
- IASTPreprocessorElseStatement st= (IASTPreprocessorElseStatement) s;
+ private void checkElse(IASTPreprocessorStatement s, String directive, boolean active, String filename, int offset,
+ int length, int line) {
+ IASTPreprocessorElseStatement st = (IASTPreprocessorElseStatement) s;
assertEquals(active, st.taken());
checkASTNode(st, fTu, PROP_PST, filename, offset, length, line, line, directive);
}
- private void checkEndif(IASTPreprocessorStatement s, String directive,
- String filename, int offset, int length, int line) {
- IASTPreprocessorEndifStatement st= (IASTPreprocessorEndifStatement) s;
+ private void checkEndif(IASTPreprocessorStatement s, String directive, String filename, int offset, int length,
+ int line) {
+ IASTPreprocessorEndifStatement st = (IASTPreprocessorEndifStatement) s;
checkASTNode(st, fTu, PROP_PST, filename, offset, length, line, line, directive);
}
- private void checkMacroDefinition(IASTPreprocessorMacroDefinition macro, IMacroBinding binding, String image, String name,
- String nameImage, String expansion, String[] parameters,
- String filename, int offset, int length, int line, int nameOffset, int nameLength) {
+ private void checkMacroDefinition(IASTPreprocessorMacroDefinition macro, IMacroBinding binding, String image,
+ String name, String nameImage, String expansion, String[] parameters, String filename, int offset,
+ int length, int line, int nameOffset, int nameLength) {
assertEquals(expansion, macro.getExpansion());
- checkName(macro.getName(), binding, name, macro, IASTPreprocessorMacroDefinition.MACRO_NAME, ROLE_DEFINITION, filename, nameOffset, nameLength, line, line, nameImage);
+ checkName(macro.getName(), binding, name, macro, IASTPreprocessorMacroDefinition.MACRO_NAME, ROLE_DEFINITION,
+ filename, nameOffset, nameLength, line, line, nameImage);
checkASTNode(macro, fTu, PROP_PST, filename, offset, length, line, line, image);
-
+
if (parameters != null) {
- IASTPreprocessorFunctionStyleMacroDefinition fd= (IASTPreprocessorFunctionStyleMacroDefinition) macro;
- IASTFunctionStyleMacroParameter[] params= fd.getParameters();
+ IASTPreprocessorFunctionStyleMacroDefinition fd = (IASTPreprocessorFunctionStyleMacroDefinition) macro;
+ IASTFunctionStyleMacroParameter[] params = fd.getParameters();
for (int i = 0; i < params.length; i++) {
IASTFunctionStyleMacroParameter mp = params[i];
assertEquals(parameters[i], mp.getParameter());
- checkASTNode(mp, fd, IASTPreprocessorFunctionStyleMacroDefinition.PARAMETER, filename, -1, 0, -1, 0, null);
+ checkASTNode(mp, fd, IASTPreprocessorFunctionStyleMacroDefinition.PARAMETER, filename, -1, 0, -1, 0,
+ null);
}
}
- IASTName[] decls= fLocationMap.getDeclarations(binding);
+ IASTName[] decls = fLocationMap.getDeclarations(binding);
assertEquals(1, decls.length);
assertSame(macro.getName(), decls[0]);
}
- private void checkMacroUndef(IASTPreprocessorStatement s, IBinding binding, String image, String name, String nameImage,
- String filename, int offset, int length, int line, int nameOffset, int nameLength) {
- IASTPreprocessorUndefStatement st= (IASTPreprocessorUndefStatement) s;
- checkName(st.getMacroName(), binding, name, st, IASTPreprocessorStatement.MACRO_NAME, ROLE_UNCLEAR, filename, nameOffset, nameLength, line, line, nameImage);
+ private void checkMacroUndef(IASTPreprocessorStatement s, IBinding binding, String image, String name,
+ String nameImage, String filename, int offset, int length, int line, int nameOffset, int nameLength) {
+ IASTPreprocessorUndefStatement st = (IASTPreprocessorUndefStatement) s;
+ checkName(st.getMacroName(), binding, name, st, IASTPreprocessorStatement.MACRO_NAME, ROLE_UNCLEAR, filename,
+ nameOffset, nameLength, line, line, nameImage);
checkASTNode(st, fTu, PROP_PST, filename, offset, length, line, line, image);
}
@@ -333,50 +351,50 @@ public class LocationMapTests extends BaseTestCase {
fLocationMap.encounteredComment(0, 0, false, fContent);
fLocationMap.encounteredComment(1, 3, true, fContent);
fLocationMap.encounteredComment(5, 16, true, fContent);
- IASTComment[] comments= fLocationMap.getComments();
+ IASTComment[] comments = fLocationMap.getComments();
assertEquals(3, comments.length);
checkComment(comments[0], "", false, FN, 0, 0, 1, 1);
- checkComment(comments[1], "12", true, FN, 1,2,1,1);
- checkComment(comments[2], "56789abcdef", true, FN, 5,11,1,1);
+ checkComment(comments[1], "12", true, FN, 1, 2, 1, 1);
+ checkComment(comments[2], "56789abcdef", true, FN, 5, 11, 1, 1);
}
public void testProblems() {
init(DIGITS);
fLocationMap.encounterProblem(0, null, 0, 0);
fLocationMap.encounterProblem(1, "a".toCharArray(), 1, 3);
- fLocationMap.encounterProblem(2, "b".toCharArray(), 5,16);
- IASTProblem[] problems= fLocationMap.getScannerProblems();
+ fLocationMap.encounterProblem(2, "b".toCharArray(), 5, 16);
+ IASTProblem[] problems = fLocationMap.getScannerProblems();
assertEquals(3, problems.length);
- checkProblem(problems[0], 0, null, "", FN, 0,0,1,1);
- checkProblem(problems[1], 1, "a", "12", FN,1,2,1,1);
- checkProblem(problems[2], 2, "b", "56789abcdef", FN,5,11,1,1);
+ checkProblem(problems[0], 0, null, "", FN, 0, 0, 1, 1);
+ checkProblem(problems[1], 1, "a", "12", FN, 1, 2, 1, 1);
+ checkProblem(problems[2], 2, "b", "56789abcdef", FN, 5, 11, 1, 1);
}
public void testPoundError() {
init(DIGITS);
fLocationMap.encounterPoundError(0, 0, 0, 0);
fLocationMap.encounterPoundError(0, 1, 3, 16);
- IASTPreprocessorStatement[] prep= fLocationMap.getAllPreprocessorStatements();
+ IASTPreprocessorStatement[] prep = fLocationMap.getAllPreprocessorStatements();
assertEquals(2, prep.length);
- checkError(prep[0], "", "",FN,0,0,1);
- checkError(prep[1], "012", "12", FN,0,3,1);
+ checkError(prep[0], "", "", FN, 0, 0, 1);
+ checkError(prep[1], "012", "12", FN, 0, 3, 1);
}
public void testPragma() {
init(DIGITS);
fLocationMap.encounterPoundPragma(0, 0, 0, 0);
fLocationMap.encounterPoundPragma(0, 1, 3, 16);
- IASTPreprocessorStatement[] prep= fLocationMap.getAllPreprocessorStatements();
+ IASTPreprocessorStatement[] prep = fLocationMap.getAllPreprocessorStatements();
assertEquals(2, prep.length);
- checkPragma(prep[0], "", "", FN,0,0,1);
- checkPragma(prep[1], "012", "12", FN,0,3,1);
+ checkPragma(prep[0], "", "", FN, 0, 0, 1);
+ checkPragma(prep[1], "012", "12", FN, 0, 3, 1);
}
public void testIncludes() {
init(DIGITS);
fLocationMap.encounterPoundInclude(0, 0, 0, 0, "n1".toCharArray(), null, true, false, false, null);
- fLocationMap.encounterPoundInclude(0, 1, 3, 16, "n2".toCharArray(), "f2", false , true, false, null);
- IASTPreprocessorIncludeStatement[] includes= fLocationMap.getIncludeDirectives();
+ fLocationMap.encounterPoundInclude(0, 1, 3, 16, "n2".toCharArray(), "f2", false, true, false, null);
+ IASTPreprocessorIncludeStatement[] includes = fLocationMap.getIncludeDirectives();
assertEquals(2, includes.length);
checkInclude(includes[0], "", "", "n1", "", true, false, FN, 0, 0, 1, 0, 0);
checkInclude(includes[1], new String(DIGITS), "12", "n2", "f2", false, true, FN, 0, 16, 1, 1, 2);
@@ -386,7 +404,7 @@ public class LocationMapTests extends BaseTestCase {
init(DIGITS);
fLocationMap.encounterPoundIf(0, 0, 0, 0, false, IASTName.EMPTY_NAME_ARRAY);
fLocationMap.encounterPoundIf(0, 1, 3, 16, true, IASTName.EMPTY_NAME_ARRAY);
- IASTPreprocessorStatement[] prep= fLocationMap.getAllPreprocessorStatements();
+ IASTPreprocessorStatement[] prep = fLocationMap.getAllPreprocessorStatements();
assertEquals(2, prep.length);
checkIf(prep[0], "", "", false, FN, 0, 0, 1);
checkIf(prep[1], "012", "12", true, FN, 0, 3, 1);
@@ -396,7 +414,7 @@ public class LocationMapTests extends BaseTestCase {
init(DIGITS);
fLocationMap.encounterPoundIfdef(0, 0, 0, 0, false, null);
fLocationMap.encounterPoundIfdef(0, 1, 3, 16, true, null);
- IASTPreprocessorStatement[] prep= fLocationMap.getAllPreprocessorStatements();
+ IASTPreprocessorStatement[] prep = fLocationMap.getAllPreprocessorStatements();
assertEquals(2, prep.length);
checkIfdef(prep[0], "", "", false, FN, 0, 0, 1);
checkIfdef(prep[1], "012", "12", true, FN, 0, 3, 1);
@@ -406,7 +424,7 @@ public class LocationMapTests extends BaseTestCase {
init(DIGITS);
fLocationMap.encounterPoundIfndef(0, 0, 0, 0, false, null);
fLocationMap.encounterPoundIfndef(0, 1, 3, 16, true, null);
- IASTPreprocessorStatement[] prep= fLocationMap.getAllPreprocessorStatements();
+ IASTPreprocessorStatement[] prep = fLocationMap.getAllPreprocessorStatements();
assertEquals(2, prep.length);
checkIfndef(prep[0], "", "", false, FN, 0, 0, 1);
checkIfndef(prep[1], "012", "12", true, FN, 0, 3, 1);
@@ -416,7 +434,7 @@ public class LocationMapTests extends BaseTestCase {
init(DIGITS);
fLocationMap.encounterPoundElif(0, 0, 0, 0, false, IASTName.EMPTY_NAME_ARRAY);
fLocationMap.encounterPoundElif(0, 1, 3, 16, true, IASTName.EMPTY_NAME_ARRAY);
- IASTPreprocessorStatement[] prep= fLocationMap.getAllPreprocessorStatements();
+ IASTPreprocessorStatement[] prep = fLocationMap.getAllPreprocessorStatements();
assertEquals(2, prep.length);
checkElif(prep[0], "", "", false, FN, 0, 0, 1);
checkElif(prep[1], "012", "12", true, FN, 0, 3, 1);
@@ -426,86 +444,87 @@ public class LocationMapTests extends BaseTestCase {
init(DIGITS);
fLocationMap.encounterPoundElse(0, 0, false);
fLocationMap.encounterPoundElse(0, 16, true);
- IASTPreprocessorStatement[] prep= fLocationMap.getAllPreprocessorStatements();
+ IASTPreprocessorStatement[] prep = fLocationMap.getAllPreprocessorStatements();
assertEquals(2, prep.length);
checkElse(prep[0], "", false, FN, 0, 0, 1);
- checkElse(prep[1], new String(DIGITS), true, FN, 0, 16, 1);
+ checkElse(prep[1], new String(DIGITS), true, FN, 0, 16, 1);
}
public void testEndif() {
init(DIGITS);
fLocationMap.encounterPoundEndIf(0, 0);
fLocationMap.encounterPoundEndIf(0, 16);
- IASTPreprocessorStatement[] prep= fLocationMap.getAllPreprocessorStatements();
+ IASTPreprocessorStatement[] prep = fLocationMap.getAllPreprocessorStatements();
assertEquals(2, prep.length);
checkEndif(prep[0], "", FN, 0, 0, 1);
checkEndif(prep[1], new String(DIGITS), FN, 0, 16, 1);
}
public void testDefine() {
- IMacroBinding macro1= new TestMacro("n1", "exp1", null);
- final String[] params = new String[]{"p1", "p2"};
- IMacroBinding macro2= new TestMacro("n2", "exp2", params);
+ IMacroBinding macro1 = new TestMacro("n1", "exp1", null);
+ final String[] params = new String[] { "p1", "p2" };
+ IMacroBinding macro2 = new TestMacro("n2", "exp2", params);
init(DIGITS);
fLocationMap.encounterPoundDefine(0, 0, 0, 0, 0, true, macro1);
fLocationMap.encounterPoundDefine(0, 1, 3, 10, 16, true, macro2);
- IASTPreprocessorMacroDefinition[] prep= fLocationMap.getMacroDefinitions();
+ IASTPreprocessorMacroDefinition[] prep = fLocationMap.getMacroDefinitions();
assertEquals(2, prep.length);
checkMacroDefinition(prep[0], macro1, "", "n1", "", "exp1", null, FN, 0, 0, 1, 0, 0);
checkMacroDefinition(prep[1], macro2, new String(DIGITS), "n2", "12", "exp2", params, FN, 0, 16, 1, 1, 2);
}
public void testPredefine() {
- IMacroBinding macro1= new TestMacro("n1", "exp1", null);
- final String[] params = new String[]{"p1", "p2"};
- IMacroBinding macro2= new TestMacro("n2", "exp2", params);
+ IMacroBinding macro1 = new TestMacro("n1", "exp1", null);
+ final String[] params = new String[] { "p1", "p2" };
+ IMacroBinding macro2 = new TestMacro("n2", "exp2", params);
init(DIGITS);
fLocationMap.registerPredefinedMacro(macro1);
fLocationMap.registerPredefinedMacro(macro2);
- IASTPreprocessorMacroDefinition[] prep= fLocationMap.getBuiltinMacroDefinitions();
+ IASTPreprocessorMacroDefinition[] prep = fLocationMap.getBuiltinMacroDefinitions();
assertEquals(2, prep.length);
checkMacroDefinition(prep[0], macro1, "", "n1", "n1", "exp1", null, "", -1, 0, 0, -1, 0);
checkMacroDefinition(prep[1], macro2, "", "n2", "n2", "exp2", params, "", -1, 0, 0, -1, 0);
}
public void testIndexDefine() {
- IMacroBinding macro1= new TestMacro("n1", "exp1", null);
- final String[] params = new String[]{"p1", "p2"};
- IMacroBinding macro2= new TestMacro("n2", "exp2", params);
+ IMacroBinding macro1 = new TestMacro("n1", "exp1", null);
+ final String[] params = new String[] { "p1", "p2" };
+ IMacroBinding macro2 = new TestMacro("n2", "exp2", params);
init(DIGITS);
fLocationMap.registerMacroFromIndex(macro1, new Loc("fidx1", 0, 0), 0);
fLocationMap.registerMacroFromIndex(macro2, new Loc("fidx2", 1, 4), 8);
- IASTPreprocessorMacroDefinition[] prep= fLocationMap.getBuiltinMacroDefinitions();
+ IASTPreprocessorMacroDefinition[] prep = fLocationMap.getBuiltinMacroDefinitions();
assertEquals(2, prep.length);
checkMacroDefinition(prep[0], macro1, "", "n1", "n1", "exp1", null, "fidx1", -1, 0, 0, 0, 0);
checkMacroDefinition(prep[1], macro2, "", "n2", "n2", "exp2", params, "fidx2", -1, 0, 0, 1, 3);
}
public void testUndefine() {
- IMacroBinding macro1= new TestMacro("n1", "exp1", null);
+ IMacroBinding macro1 = new TestMacro("n1", "exp1", null);
init(DIGITS);
fLocationMap.encounterPoundUndef(null, 0, 0, 0, 0, "n1".toCharArray(), true);
fLocationMap.encounterPoundUndef(macro1, 0, 3, 7, 16, "n2".toCharArray(), true);
- IASTPreprocessorStatement[] prep= fLocationMap.getAllPreprocessorStatements();
+ IASTPreprocessorStatement[] prep = fLocationMap.getAllPreprocessorStatements();
assertEquals(2, prep.length);
checkMacroUndef(prep[0], null, "", "n1", "", FN, 0, 0, 1, 0, 0);
checkMacroUndef(prep[1], macro1, "0123456", "n2", "3456", FN, 0, 7, 1, 3, 4);
}
public void testMacroExpansion() {
- IMacroBinding macro1= new TestMacro("n1", "exp1", null);
- IMacroBinding macro2= new TestMacro("n2", "exp2", null);
- IMacroBinding macro3= new TestMacro("n3", "exp3", null);
+ IMacroBinding macro1 = new TestMacro("n1", "exp1", null);
+ IMacroBinding macro2 = new TestMacro("n2", "exp2", null);
+ IMacroBinding macro3 = new TestMacro("n3", "exp3", null);
init(LONGDIGITS);
assertEquals(1, fLocationMap.getCurrentLineNumber('\n'));
- assertEquals(2, fLocationMap.getCurrentLineNumber('\n'+1));
+ assertEquals(2, fLocationMap.getCurrentLineNumber('\n' + 1));
fLocationMap.registerPredefinedMacro(macro1);
fLocationMap.registerMacroFromIndex(macro2, new Loc("ifile", 2, 12), 32);
fLocationMap.encounterPoundDefine(3, 13, 33, 63, 103, true, macro3);
- IASTName name1= fLocationMap.encounterImplicitMacroExpansion(macro1, null);
- IASTName name2= fLocationMap.encounterImplicitMacroExpansion(macro2, null);
- ILocationCtx me = fLocationMap.pushMacroExpansion(110, 115, 125, 30, macro3, new IASTName[]{name1, name2}, new ImageLocationInfo[0]);
+ IASTName name1 = fLocationMap.encounterImplicitMacroExpansion(macro1, null);
+ IASTName name2 = fLocationMap.encounterImplicitMacroExpansion(macro2, null);
+ ILocationCtx me = fLocationMap.pushMacroExpansion(110, 115, 125, 30, macro3, new IASTName[] { name1, name2 },
+ new ImageLocationInfo[0]);
// Comment in expansion
fLocationMap.encounteredComment(116, 120, false, fContent);
// Comment right after expansion, reported before expansion completes.
@@ -513,37 +532,42 @@ public class LocationMapTests extends BaseTestCase {
fLocationMap.popContext(me);
checkComment(fLocationMap.getComments()[0], new String(LONGDIGITS, 116, 4), false, FN, 116, 4, 2, 2);
checkComment(fLocationMap.getComments()[1], new String(LONGDIGITS, 125, 15), false, FN, 125, 15, 2, 2);
-
- IASTName[] refs= fLocationMap.getReferences(macro3);
+
+ IASTName[] refs = fLocationMap.getReferences(macro3);
assertEquals(1, refs.length);
- IASTName macro3ref= refs[0];
- checkName(refs[0], macro3, "n3", refs[0].getParent(), IASTPreprocessorMacroExpansion.EXPANSION_NAME, ROLE_REFERENCE, FN, 110, 5, 2, 2, new String(LONGDIGITS, 110, 5));
+ IASTName macro3ref = refs[0];
+ checkName(refs[0], macro3, "n3", refs[0].getParent(), IASTPreprocessorMacroExpansion.EXPANSION_NAME,
+ ROLE_REFERENCE, FN, 110, 5, 2, 2, new String(LONGDIGITS, 110, 5));
- refs= fLocationMap.getReferences(macro1);
+ refs = fLocationMap.getReferences(macro1);
assertEquals(1, refs.length);
- checkName(refs[0], macro1, "n1", refs[0].getParent(), IASTPreprocessorMacroExpansion.NESTED_EXPANSION_NAME, ROLE_REFERENCE, FN, 110, 15, 2, 2, new String(LONGDIGITS, 110, 15));
+ checkName(refs[0], macro1, "n1", refs[0].getParent(), IASTPreprocessorMacroExpansion.NESTED_EXPANSION_NAME,
+ ROLE_REFERENCE, FN, 110, 15, 2, 2, new String(LONGDIGITS, 110, 15));
- refs= fLocationMap.getReferences(macro2);
+ refs = fLocationMap.getReferences(macro2);
assertEquals(1, refs.length);
- checkName(refs[0], macro2, "n2", refs[0].getParent(), IASTPreprocessorMacroExpansion.NESTED_EXPANSION_NAME, ROLE_REFERENCE, FN, 110, 15, 2, 2, new String(LONGDIGITS, 110, 15));
+ checkName(refs[0], macro2, "n2", refs[0].getParent(), IASTPreprocessorMacroExpansion.NESTED_EXPANSION_NAME,
+ ROLE_REFERENCE, FN, 110, 15, 2, 2, new String(LONGDIGITS, 110, 15));
}
-
+
public void testContexts() {
init(DIGITS);
assertEquals(FN, fLocationMap.getTranslationUnitPath());
assertEquals(FN, fLocationMap.getCurrentFilePath());
// number: [30,36)[46,50)
- ILocationCtx pre1= fLocationMap.pushPreInclusion(new CharArray("0102030405"), 0, false);
+ ILocationCtx pre1 = fLocationMap.pushPreInclusion(new CharArray("0102030405"), 0, false);
assertEquals(FN, fLocationMap.getCurrentFilePath());
// number: [0,6)[26,30)
- ILocationCtx pre2= fLocationMap.pushPreInclusion(new CharArray("a1a2a3a4a5"), 0, true);
+ ILocationCtx pre2 = fLocationMap.pushPreInclusion(new CharArray("a1a2a3a4a5"), 0, true);
assertEquals(FN, fLocationMap.getCurrentFilePath());
// number: [6,15)[25,26)
- ILocationCtx i1= fLocationMap.pushInclusion(0, 2, 4, 6, new CharArray("b1b2b3b4b5"), "pre1", "pre1".toCharArray(), false, false, false);
+ ILocationCtx i1 = fLocationMap.pushInclusion(0, 2, 4, 6, new CharArray("b1b2b3b4b5"), "pre1",
+ "pre1".toCharArray(), false, false, false);
assertEquals("pre1", fLocationMap.getCurrentFilePath());
fLocationMap.encounteredComment(2, 4, true, fContent);
// number: [15,25)
- ILocationCtx i2= fLocationMap.pushInclusion(6, 7, 8, 9, new CharArray("c1c2c3c4c5"), "pre11", "pre11".toCharArray(), false, false, false);
+ ILocationCtx i2 = fLocationMap.pushInclusion(6, 7, 8, 9, new CharArray("c1c2c3c4c5"), "pre11",
+ "pre11".toCharArray(), false, false, false);
assertEquals("pre11", fLocationMap.getCurrentFilePath());
fLocationMap.encounteredComment(2, 6, true, fContent);
fLocationMap.popContext(i2);
@@ -556,17 +580,18 @@ public class LocationMapTests extends BaseTestCase {
fLocationMap.popContext(pre2);
assertEquals(FN, fLocationMap.getCurrentFilePath());
// number [36, 46)
- ILocationCtx i3= fLocationMap.pushInclusion(0, 2, 4, 6, new CharArray("d1d2d3d4d5"), "pre2", "pre2".toCharArray(), false, false, false);
+ ILocationCtx i3 = fLocationMap.pushInclusion(0, 2, 4, 6, new CharArray("d1d2d3d4d5"), "pre2",
+ "pre2".toCharArray(), false, false, false);
assertEquals("pre2", fLocationMap.getCurrentFilePath());
fLocationMap.encounteredComment(0, 2, true, fContent);
fLocationMap.popContext(i3);
fLocationMap.popContext(pre1);
assertEquals(FN, fLocationMap.getCurrentFilePath());
-
- IASTComment[] comments= fLocationMap.getComments();
+
+ IASTComment[] comments = fLocationMap.getComments();
checkComment(comments[0], "b2", true, "pre1", 2, 2, 1, 1);
checkComment(comments[1], "c2c3", true, "pre11", 2, 4, 1, 1);
- checkComment(comments[2], "b3", false, "pre1", 4, 2, 1, 1);
+ checkComment(comments[2], "b3", false, "pre1", 4, 2, 1, 1);
checkComment(comments[3], "d1", true, "pre2", 0, 2, 1, 1);
checkLocation(fLocationMap.getMappedFileLocation(0, 6), FN, 0, 0, 1, 1);
@@ -592,7 +617,7 @@ public class LocationMapTests extends BaseTestCase {
checkLocation(fLocationMap.getMappedFileLocation(36, 0), "pre2", 0, 0, 1, 1);
checkLocation(fLocationMap.getMappedFileLocation(45, 0), "pre2", 9, 0, 1, 1);
checkLocation(fLocationMap.getMappedFileLocation(46, 0), FN, 0, 0, 1, 1);
-
+
checkLocation(fLocationMap.getMappedFileLocation(0, 7), FN, 0, 0, 1, 1);
checkLocation(fLocationMap.getMappedFileLocation(6, 10), "pre1", 0, 9, 1, 1);
checkLocation(fLocationMap.getMappedFileLocation(6, 20), "pre1", 0, 10, 1, 1);
@@ -602,18 +627,19 @@ public class LocationMapTests extends BaseTestCase {
checkLocation(fLocationMap.getMappedFileLocation(30, 7), FN, 0, 0, 1, 1);
checkLocation(fLocationMap.getMappedFileLocation(36, 11), FN, 0, 0, 1, 1);
checkLocation(fLocationMap.getMappedFileLocation(46, 5), FN, 0, 1, 1, 1);
-
- IDependencyTree tree= fLocationMap.getDependencyTree();
+
+ IDependencyTree tree = fLocationMap.getDependencyTree();
assertEquals(FN, tree.getTranslationUnitPath());
- IASTInclusionNode[] inclusions= tree.getInclusions();
+ IASTInclusionNode[] inclusions = tree.getInclusions();
assertEquals(2, inclusions.length);
checkInclude(inclusions[0].getIncludeDirective(), "", "", "pre1", "pre1", false, true, FN, 0, 0, 1, 0, 0);
checkInclude(inclusions[1].getIncludeDirective(), "", "", "pre2", "pre2", false, true, FN, 0, 0, 1, 0, 0);
assertEquals(0, inclusions[1].getNestedInclusions().length);
-
- inclusions= inclusions[0].getNestedInclusions();
+
+ inclusions = inclusions[0].getNestedInclusions();
assertEquals(1, inclusions.length);
- checkInclude(inclusions[0].getIncludeDirective(), "b4b", "4", "pre11", "pre11", false, true, "pre1", 6, 3, 1, 7, 1);
+ checkInclude(inclusions[0].getIncludeDirective(), "b4b", "4", "pre11", "pre11", false, true, "pre1", 6, 3, 1, 7,
+ 1);
assertEquals(0, inclusions[0].getNestedInclusions().length);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PortedScannerTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PortedScannerTests.java
index 5c8b4998ed8..5cd28844b1e 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PortedScannerTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PortedScannerTests.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
@@ -37,7 +37,7 @@ import junit.framework.TestSuite;
* Scanner2Tests ported to use the CPreprocessor.
*/
public class PortedScannerTests extends PreprocessorTestsBase {
- public static TestSuite suite() {
+ public static TestSuite suite() {
return suite(PortedScannerTests.class);
}
@@ -50,74 +50,71 @@ public class PortedScannerTests extends PreprocessorTestsBase {
}
public void testBug102825_1() throws Exception {
- StringBuilder buffer = new StringBuilder(
- "#define CURLOPTTYPE_OBJECTPOINT 10000\n");
- buffer.append("#define CINIT = CURLOPTTYPE_##OBJECTPOINT + 1\n");
- buffer.append("CINIT\n");
+ StringBuilder buffer = new StringBuilder("#define CURLOPTTYPE_OBJECTPOINT 10000\n");
+ buffer.append("#define CINIT = CURLOPTTYPE_##OBJECTPOINT + 1\n");
+ buffer.append("CINIT\n");
initializeScanner(buffer.toString());
validateToken(IToken.tASSIGN);
- validateInteger("10000");
+ validateInteger("10000");
}
public void testBug102825_2() throws Exception {
- StringBuilder buffer = new StringBuilder(
- "#define CURLOPTTYPE_OBJECTPOINT 10000\n");
- buffer.append("#define CINIT(name,type,number) = CURLOPTTYPE_##type + number\n");
- buffer.append("CINIT(FILE, OBJECTPOINT, 1)\n");
+ StringBuilder buffer = new StringBuilder("#define CURLOPTTYPE_OBJECTPOINT 10000\n");
+ buffer.append("#define CINIT(name,type,number) = CURLOPTTYPE_##type + number\n");
+ buffer.append("CINIT(FILE, OBJECTPOINT, 1)\n");
initializeScanner(buffer.toString());
validateToken(IToken.tASSIGN);
- validateInteger("10000");
+ validateInteger("10000");
}
public void testBug102825_3() throws Exception {
- StringBuilder buffer = new StringBuilder(
- "#define CURLOPTTYPE_OBJECTPOINT 10000\n");
- buffer.append("#define CINIT(name,type,number) CURLOPT_ ## name = CURLOPTTYPE_ ## type + number\n");
- buffer.append("CINIT(FILE, OBJECTPOINT, 1)\n");
+ StringBuilder buffer = new StringBuilder("#define CURLOPTTYPE_OBJECTPOINT 10000\n");
+ buffer.append("#define CINIT(name,type,number) CURLOPT_ ## name = CURLOPTTYPE_ ## type + number\n");
+ buffer.append("CINIT(FILE, OBJECTPOINT, 1)\n");
initializeScanner(buffer.toString());
- validateIdentifier("CURLOPT_FILE");
+ validateIdentifier("CURLOPT_FILE");
validateToken(IToken.tASSIGN);
- validateInteger("10000");
+ validateInteger("10000");
}
public void testBug102825_4() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append("#define glue( a, b ) a ## b\n");
- buffer.append("#define HIGHLOW \"hello\"\n");
- buffer.append("glue( HIGH, LOW )\n");
+ buffer.append("#define glue( a, b ) a ## b\n");
+ buffer.append("#define HIGHLOW \"hello\"\n");
+ buffer.append("glue( HIGH, LOW )\n");
initializeScanner(buffer.toString(), ParserMode.QUICK_PARSE);
- validateString("hello");
+ validateString("hello");
validateProblemCount(0);
}
public void testBug195610_1() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append("#define glue(x, y, z) x ## y ## z\n");
- buffer.append("glue(, b, c)\n");
+ buffer.append("#define glue(x, y, z) x ## y ## z\n");
+ buffer.append("glue(, b, c)\n");
initializeScanner(buffer.toString(), ParserMode.QUICK_PARSE);
- validateIdentifier("bc");
+ validateIdentifier("bc");
validateProblemCount(0);
}
public void testBug195610_2() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append("#define glue(x, y, z) x ## y ## z\n");
- buffer.append("glue(a, , c)\n");
+ buffer.append("#define glue(x, y, z) x ## y ## z\n");
+ buffer.append("glue(a, , c)\n");
initializeScanner(buffer.toString(), ParserMode.QUICK_PARSE);
- validateIdentifier("ac");
+ validateIdentifier("ac");
validateProblemCount(0);
}
public void testBug195610_3() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append("#define glue(x, y, z) x ## y ## z\n");
- buffer.append("glue(a, b, )\n");
+ buffer.append("#define glue(x, y, z) x ## y ## z\n");
+ buffer.append("glue(a, b, )\n");
initializeScanner(buffer.toString(), ParserMode.QUICK_PARSE);
- validateIdentifier("ab");
+ validateIdentifier("ab");
validateProblemCount(0);
}
@@ -135,13 +132,13 @@ public class PortedScannerTests extends PreprocessorTestsBase {
public String toString() {
StringBuilder s = new StringBuilder();
for (int i = 0; i < length; ++i) {
- s.append("var").append(i).append("=").append(values[i]).append(" "); //$NON-NLS-3$
+ s.append("var").append(i).append("=").append(values[i]).append(" "); //$NON-NLS-3$
}
return s.toString();
}
public String symbolName(int index) {
- return "DEFINITION" + index;
+ return "DEFINITION" + index;
}
public int symbolValue(int index) {
@@ -150,20 +147,17 @@ public class PortedScannerTests extends PreprocessorTestsBase {
public String generateCode() {
if (length < 2) {
- return "Array must have at least 2 elements";
+ return "Array must have at least 2 elements";
}
int numberOfElsifs = length - 1;
StringBuilder buffer = new StringBuilder();
- buffer.append("#if ").append(values[0]).append("\n#\tdefine ");
- buffer.append(symbolName(0)).append(" ").append(symbolValue(0));
+ buffer.append("#if ").append(values[0]).append("\n#\tdefine ");
+ buffer.append(symbolName(0)).append(" ").append(symbolValue(0));
for (int i = 0; i < numberOfElsifs; ++i)
- buffer.append("\n#elif ")
- .append(values[1 + i]).append("\n#\tdefine ")
- .append(symbolName(i + 1)).append(" ")
- .append(symbolValue(i + 1));
- buffer.append("\n#else \n#\tdefine ")
- .append(symbolName(length)).append(" ")
- .append(symbolValue(length)).append("\n#endif");
+ buffer.append("\n#elif ").append(values[1 + i]).append("\n#\tdefine ").append(symbolName(i + 1))
+ .append(" ").append(symbolValue(i + 1));
+ buffer.append("\n#else \n#\tdefine ").append(symbolName(length)).append(" ").append(symbolValue(length))
+ .append("\n#endif");
return buffer.toString();
}
@@ -229,29 +223,35 @@ public class PortedScannerTests extends PreprocessorTestsBase {
public final static int SIZEOF_TRUTHTABLE = 10;
public void testWeirdStrings() throws Exception {
- initializeScanner("Living Life L\"LONG\"");
- validateIdentifier("Living");
- validateIdentifier("Life");
- validateLString("LONG");
+ initializeScanner("Living Life L\"LONG\"");
+ validateIdentifier("Living");
+ validateIdentifier("Life");
+ validateLString("LONG");
validateEOF();
}
-
+
public void testUTFStrings() throws Exception {
IScannerExtensionConfiguration config = new GPPScannerExtensionConfiguration() {
- @Override public boolean supportUTFLiterals() { return true; }
+ @Override
+ public boolean supportUTFLiterals() {
+ return true;
+ }
};
- initializeScanner("ubiquitous u\"utf16\" User U\"utf32\"", ParserLanguage.CPP, config);
- validateIdentifier("ubiquitous");
- validateUTF16String("utf16");
- validateIdentifier("User");
- validateUTF32String("utf32");
+ initializeScanner("ubiquitous u\"utf16\" User U\"utf32\"", ParserLanguage.CPP, config);
+ validateIdentifier("ubiquitous");
+ validateUTF16String("utf16");
+ validateIdentifier("User");
+ validateUTF32String("utf32");
validateEOF();
}
-
+
public void testUTFChars() throws Exception {
IScannerExtensionConfiguration config = new GPPScannerExtensionConfiguration() {
- @Override public boolean supportUTFLiterals() { return true; }
+ @Override
+ public boolean supportUTFLiterals() {
+ return true;
+ }
};
initializeScanner("u'asdf' U'1234'", ParserLanguage.CPP, config);
validateUTF16Char("asdf");
@@ -260,204 +260,194 @@ public class PortedScannerTests extends PreprocessorTestsBase {
}
public void testNumerics() throws Exception {
- initializeScanner("3.0 0.9 .5 3. 4E5 2.01E-03 ...");
- validateFloatingPointLiteral("3.0");
- validateFloatingPointLiteral("0.9");
- validateFloatingPointLiteral(".5");
- validateFloatingPointLiteral("3.");
- validateFloatingPointLiteral("4E5");
- validateFloatingPointLiteral("2.01E-03");
+ initializeScanner("3.0 0.9 .5 3. 4E5 2.01E-03 ...");
+ validateFloatingPointLiteral("3.0");
+ validateFloatingPointLiteral("0.9");
+ validateFloatingPointLiteral(".5");
+ validateFloatingPointLiteral("3.");
+ validateFloatingPointLiteral("4E5");
+ validateFloatingPointLiteral("2.01E-03");
validateToken(IToken.tELLIPSIS);
validateEOF();
}
public void testPreprocessorDefines() throws Exception {
- initializeScanner("#define SIMPLE_NUMERIC 5\nint x = SIMPLE_NUMERIC");
+ initializeScanner("#define SIMPLE_NUMERIC 5\nint x = SIMPLE_NUMERIC");
validateToken(IToken.t_int);
- validateDefinition("SIMPLE_NUMERIC", "5");
- validateIdentifier("x");
+ validateDefinition("SIMPLE_NUMERIC", "5");
+ validateIdentifier("x");
validateToken(IToken.tASSIGN);
- validateInteger("5");
+ validateInteger("5");
validateEOF();
- initializeScanner("#define SIMPLE_STRING \"This is a simple string.\"\n\nconst char * myVariable = SIMPLE_STRING;");
+ initializeScanner(
+ "#define SIMPLE_STRING \"This is a simple string.\"\n\nconst char * myVariable = SIMPLE_STRING;");
validateToken(IToken.t_const);
- validateDefinition("SIMPLE_STRING", "\"This is a simple string.\"");
+ validateDefinition("SIMPLE_STRING", "\"This is a simple string.\"");
validateToken(IToken.t_char);
validateToken(IToken.tSTAR);
- validateIdentifier("myVariable");
+ validateIdentifier("myVariable");
validateToken(IToken.tASSIGN);
- validateString("This is a simple string.");
+ validateString("This is a simple string.");
validateToken(IToken.tSEMI);
validateEOF();
- initializeScanner("#define FOOL 5 \n int tryAFOOL = FOOL + FOOL;");
+ initializeScanner("#define FOOL 5 \n int tryAFOOL = FOOL + FOOL;");
validateToken(IToken.t_int);
- validateIdentifier("tryAFOOL");
+ validateIdentifier("tryAFOOL");
validateToken(IToken.tASSIGN);
- validateInteger("5");
+ validateInteger("5");
validateToken(IToken.tPLUS);
- validateInteger("5");
+ validateInteger("5");
validateToken(IToken.tSEMI);
validateEOF();
- initializeScanner("#define FOOL 5 \n int FOOLer = FOOL;");
+ initializeScanner("#define FOOL 5 \n int FOOLer = FOOL;");
validateToken(IToken.t_int);
- validateIdentifier("FOOLer");
+ validateIdentifier("FOOLer");
validateToken(IToken.tASSIGN);
- validateInteger("5");
+ validateInteger("5");
validateToken(IToken.tSEMI);
validateEOF();
// the case we were failing against in ctype.h
// this is a definition, not a macro!
- initializeScanner("#define _ALPHA (0x0100|_UPPER|_LOWER)");
+ initializeScanner("#define _ALPHA (0x0100|_UPPER|_LOWER)");
validateEOF();
- validateDefinition("_ALPHA", "(0x0100|_UPPER|_LOWER)");
+ validateDefinition("_ALPHA", "(0x0100|_UPPER|_LOWER)");
// test for comments after the macro
- initializeScanner("#define NO_COMMENT// ignore me");
+ initializeScanner("#define NO_COMMENT// ignore me");
validateEOF();
- validateDefinition("NO_COMMENT", "");
+ validateDefinition("NO_COMMENT", "");
- initializeScanner("#define NO_COMMENT/* ignore me*/");
+ initializeScanner("#define NO_COMMENT/* ignore me*/");
validateEOF();
- validateDefinition("NO_COMMENT", "");
+ validateDefinition("NO_COMMENT", "");
- initializeScanner("#define ANSWER 42 // i think");
+ initializeScanner("#define ANSWER 42 // i think");
validateEOF();
- validateDefinition("ANSWER", "42");
+ validateDefinition("ANSWER", "42");
- initializeScanner("#define ANSWER 42 /* i think */");
+ initializeScanner("#define ANSWER 42 /* i think */");
validateEOF();
- validateDefinition("ANSWER", "42");
+ validateDefinition("ANSWER", "42");
- initializeScanner("#define MULTILINE 3 /* comment \n that goes more than one line */");
+ initializeScanner("#define MULTILINE 3 /* comment \n that goes more than one line */");
validateEOF();
- validateDefinition("MULTILINE", "3");
+ validateDefinition("MULTILINE", "3");
- initializeScanner("#define MULTICOMMENT X /* comment1 */ + Y /* comment 2 */");
+ initializeScanner("#define MULTICOMMENT X /* comment1 */ + Y /* comment 2 */");
validateEOF();
- validateDefinition("MULTICOMMENT", "X + Y");
+ validateDefinition("MULTICOMMENT", "X + Y");
- initializeScanner("#define SIMPLE_STRING This is a simple string.\n");
+ initializeScanner("#define SIMPLE_STRING This is a simple string.\n");
validateEOF();
- validateDefinition("SIMPLE_STRING",
- "This is a simple string.");
+ validateDefinition("SIMPLE_STRING", "This is a simple string.");
- initializeScanner("# define SIMPLE_NUMERIC 5\n");
+ initializeScanner("# define SIMPLE_NUMERIC 5\n");
validateEOF();
- validateDefinition("SIMPLE_NUMERIC", "5");
+ validateDefinition("SIMPLE_NUMERIC", "5");
- initializeScanner("# define SIMPLE_NUMERIC 5\n");
+ initializeScanner("# define SIMPLE_NUMERIC 5\n");
validateEOF();
- validateDefinition("SIMPLE_NUMERIC", "5");
+ validateDefinition("SIMPLE_NUMERIC", "5");
- initializeScanner("#define SIMPLE_STRING \"This is a simple string.\"\n");
+ initializeScanner("#define SIMPLE_STRING \"This is a simple string.\"\n");
validateEOF();
- validateDefinition("SIMPLE_STRING",
- "\"This is a simple string.\"");
+ validateDefinition("SIMPLE_STRING", "\"This is a simple string.\"");
- initializeScanner("#define SIMPLE_STRING This is a simple string.\n");
+ initializeScanner("#define SIMPLE_STRING This is a simple string.\n");
validateEOF();
- validateDefinition("SIMPLE_STRING", "This is a simple string.");
+ validateDefinition("SIMPLE_STRING", "This is a simple string.");
- initializeScanner("#define FLAKE\n\nFLAKE");
+ initializeScanner("#define FLAKE\n\nFLAKE");
validateEOF();
- validateDefinition("FLAKE", "");
+ validateDefinition("FLAKE", "");
- initializeScanner("#define SIMPLE_STRING This is a simple string.\\\n Continue please.");
+ initializeScanner("#define SIMPLE_STRING This is a simple string.\\\n Continue please.");
validateEOF();
- validateDefinition("SIMPLE_STRING", "This is a simple string. Continue please.");
+ validateDefinition("SIMPLE_STRING", "This is a simple string. Continue please.");
}
public void testBug67834() throws Exception {
- initializeScanner("#if ! BAR\n" +
- "foo\n" +
- "#else\n" +
- "bar\n" +
- "#endif\n"
- );
- validateIdentifier("foo");
+ initializeScanner("#if ! BAR\n" + "foo\n" + "#else\n" + "bar\n" + "#endif\n");
+ validateIdentifier("foo");
validateEOF();
- initializeScanner("#if ! (BAR)\n" +
- "foo\n" +
- "#else\n" +
- "bar\n" +
- "#endif\n"
- );
- validateIdentifier("foo");
+ initializeScanner("#if ! (BAR)\n" + "foo\n" + "#else\n" + "bar\n" + "#endif\n");
+ validateIdentifier("foo");
validateEOF();
}
public void testConcatenation() throws Exception {
- initializeScanner("#define F1 3\n#define F2 F1##F1\nint x=F2;");
+ initializeScanner("#define F1 3\n#define F2 F1##F1\nint x=F2;");
validateToken(IToken.t_int);
- validateDefinition("F1", "3");
- validateDefinition("F2", "F1##F1");
- validateIdentifier("x");
+ validateDefinition("F1", "3");
+ validateDefinition("F2", "F1##F1");
+ validateIdentifier("x");
validateToken(IToken.tASSIGN);
- validateIdentifier("F1F1");
+ validateIdentifier("F1F1");
validateToken(IToken.tSEMI);
validateEOF();
- initializeScanner("#define PREFIX RT_\n#define RUN PREFIX##Run");
+ initializeScanner("#define PREFIX RT_\n#define RUN PREFIX##Run");
validateEOF();
- validateDefinition("PREFIX", "RT_");
- validateDefinition("RUN", "PREFIX##Run");
+ validateDefinition("PREFIX", "RT_");
+ validateDefinition("RUN", "PREFIX##Run");
- initializeScanner("#define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name\n DECLARE_HANDLE( joe )");
+ initializeScanner(
+ "#define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name\n DECLARE_HANDLE( joe )");
validateToken(IToken.t_struct);
- validateIdentifier("joe__");
+ validateIdentifier("joe__");
validateToken(IToken.tLBRACE);
validateToken(IToken.t_int);
- validateIdentifier("unused");
+ validateIdentifier("unused");
validateToken(IToken.tSEMI);
validateToken(IToken.tRBRACE);
validateToken(IToken.tSEMI);
validateToken(IToken.t_typedef);
validateToken(IToken.t_struct);
- validateIdentifier("joe__");
+ validateIdentifier("joe__");
validateToken(IToken.tSTAR);
- validateIdentifier("joe");
+ validateIdentifier("joe");
validateEOF();
}
public void testSimpleIfdef() throws Exception {
- initializeScanner("#define SYMBOL 5\n#ifdef SYMBOL\nint counter(SYMBOL);\n#endif");
+ initializeScanner("#define SYMBOL 5\n#ifdef SYMBOL\nint counter(SYMBOL);\n#endif");
validateToken(IToken.t_int);
- validateIdentifier("counter");
+ validateIdentifier("counter");
validateToken(IToken.tLPAREN);
- validateInteger("5");
+ validateInteger("5");
validateToken(IToken.tRPAREN);
validateToken(IToken.tSEMI);
validateEOF();
- initializeScanner("#define SYMBOL 5\n#ifndef SYMBOL\nint counter(SYMBOL);\n#endif");
+ initializeScanner("#define SYMBOL 5\n#ifndef SYMBOL\nint counter(SYMBOL);\n#endif");
validateEOF();
- initializeScanner("#ifndef DEFINED\n#define DEFINED 100\n#endif\nint count = DEFINED;");
+ initializeScanner("#ifndef DEFINED\n#define DEFINED 100\n#endif\nint count = DEFINED;");
validateToken(IToken.t_int);
- validateDefinition("DEFINED", "100");
+ validateDefinition("DEFINED", "100");
- validateIdentifier("count");
+ validateIdentifier("count");
validateToken(IToken.tASSIGN);
- validateInteger("100");
+ validateInteger("100");
validateToken(IToken.tSEMI);
validateEOF();
- initializeScanner("#ifndef DEFINED\n#define DEFINED 100\n#endif\nint count = DEFINED;");
- addDefinition("DEFINED", "101");
- validateDefinition("DEFINED", "101");
+ initializeScanner("#ifndef DEFINED\n#define DEFINED 100\n#endif\nint count = DEFINED;");
+ addDefinition("DEFINED", "101");
+ validateDefinition("DEFINED", "101");
validateToken(IToken.t_int);
- validateIdentifier("count");
+ validateIdentifier("count");
validateToken(IToken.tASSIGN);
- validateInteger("101");
+ validateInteger("101");
validateToken(IToken.tSEMI);
validateEOF();
- initializeScanner("/* NB: This is #if 0'd out */");
+ initializeScanner("/* NB: This is #if 0'd out */");
validateEOF();
}
@@ -471,155 +461,135 @@ public class PortedScannerTests extends PreprocessorTestsBase {
public void testMultipleLines() throws Exception {
Writer code = new StringWriter();
- code.write("#define COMPLEX_MACRO 33 \\\n");
- code.write(" + 44\n\nCOMPLEX_MACRO");
+ code.write("#define COMPLEX_MACRO 33 \\\n");
+ code.write(" + 44\n\nCOMPLEX_MACRO");
initializeScanner(code.toString());
- validateInteger("33");
+ validateInteger("33");
validateToken(IToken.tPLUS);
- validateInteger("44");
+ validateInteger("44");
}
public void testSlightlyComplexIfdefStructure() throws Exception {
- initializeScanner("#ifndef BASE\n#define BASE 10\n#endif\n#ifndef BASE\n#error BASE is defined\n#endif");
+ initializeScanner("#ifndef BASE\n#define BASE 10\n#endif\n#ifndef BASE\n#error BASE is defined\n#endif");
validateEOF();
- initializeScanner("#ifndef ONE\n#define ONE 1\n#ifdef TWO\n#define THREE ONE + TWO\n#endif\n#endif\nint three(THREE);");
+ initializeScanner(
+ "#ifndef ONE\n#define ONE 1\n#ifdef TWO\n#define THREE ONE + TWO\n#endif\n#endif\nint three(THREE);");
validateToken(IToken.t_int);
- validateDefinition("ONE", "1");
- validateAsUndefined("TWO");
- validateAsUndefined("THREE");
- validateIdentifier("three");
+ validateDefinition("ONE", "1");
+ validateAsUndefined("TWO");
+ validateAsUndefined("THREE");
+ validateIdentifier("three");
validateToken(IToken.tLPAREN);
- validateIdentifier("THREE");
+ validateIdentifier("THREE");
validateToken(IToken.tRPAREN);
validateToken(IToken.tSEMI);
validateEOF();
- initializeScanner(
- "#ifndef ONE\n" +
- "#define ONE 1\n" +
- "#ifdef TWO\n" +
- "#define THREE ONE + TWO\n" +
- "#endif\n"+
- "#endif\n"+
- "int three(THREE);");
- addDefinition("TWO", "2");
+ initializeScanner("#ifndef ONE\n" + "#define ONE 1\n" + "#ifdef TWO\n" + "#define THREE ONE + TWO\n"
+ + "#endif\n" + "#endif\n" + "int three(THREE);");
+ addDefinition("TWO", "2");
validateToken(IToken.t_int);
- validateDefinition("ONE", "1");
- validateDefinition("TWO", "2");
- validateDefinition("THREE", "ONE + TWO");
+ validateDefinition("ONE", "1");
+ validateDefinition("TWO", "2");
+ validateDefinition("THREE", "ONE + TWO");
- validateIdentifier("three");
+ validateIdentifier("three");
validateToken(IToken.tLPAREN);
- validateInteger("1");
+ validateInteger("1");
validateToken(IToken.tPLUS);
- validateInteger("2");
+ validateInteger("2");
validateToken(IToken.tRPAREN);
validateToken(IToken.tSEMI);
validateEOF();
- initializeScanner("#ifndef FOO\n#define FOO 4\n#else\n#undef FOO\n#define FOO 6\n#endif");
+ initializeScanner("#ifndef FOO\n#define FOO 4\n#else\n#undef FOO\n#define FOO 6\n#endif");
validateEOF();
- validateDefinition("FOO", "4");
+ validateDefinition("FOO", "4");
- initializeScanner("#ifndef FOO\n#define FOO 4\n#else\n#undef FOO\n#define FOO 6\n#endif");
- addDefinition("FOO", "2");
+ initializeScanner("#ifndef FOO\n#define FOO 4\n#else\n#undef FOO\n#define FOO 6\n#endif");
+ addDefinition("FOO", "2");
validateEOF();
- validateDefinition("FOO", "6");
+ validateDefinition("FOO", "6");
- initializeScanner("#ifndef ONE\n# define ONE 1\n# ifndef TWO\n# define TWO ONE + ONE \n# else\n# undef TWO\n# define TWO 2 \n# endif\n#else\n# ifndef TWO\n# define TWO ONE + ONE \n# else\n# undef TWO\n# define TWO 2 \n# endif\n#endif\n");
+ initializeScanner(
+ "#ifndef ONE\n# define ONE 1\n# ifndef TWO\n# define TWO ONE + ONE \n# else\n# undef TWO\n# define TWO 2 \n# endif\n#else\n# ifndef TWO\n# define TWO ONE + ONE \n# else\n# undef TWO\n# define TWO 2 \n# endif\n#endif\n");
validateEOF();
- validateDefinition("ONE", "1");
- validateDefinition("TWO", "ONE + ONE");
+ validateDefinition("ONE", "1");
+ validateDefinition("TWO", "ONE + ONE");
- initializeScanner("#ifndef ONE\r\n" +
- "# define ONE 1\n" +
- "# ifndef TWO\n" +
- "# define TWO ONE + ONE \n" +
- "# else\n" +
- "# undef TWO\n" +
- "# define TWO 2 \n" +
- "# endif\n" +
- "#else\n" +
- "# ifndef TWO\n" +
- "# define TWO ONE + ONE \n" +
- "# else\n" +
- "# undef TWO\n" +
- "# define TWO 2 \n" +
- "# endif\n" +
- "#endif\n");
+ initializeScanner("#ifndef ONE\r\n" + "# define ONE 1\n" + "# ifndef TWO\n"
+ + "# define TWO ONE + ONE \n" + "# else\n" + "# undef TWO\n" + "# define TWO 2 \n"
+ + "# endif\n" + "#else\n" + "# ifndef TWO\n" + "# define TWO ONE + ONE \n" + "# else\n"
+ + "# undef TWO\n" + "# define TWO 2 \n" + "# endif\n" + "#endif\n");
- addDefinition("ONE", "one");
+ addDefinition("ONE", "one");
validateEOF();
- validateDefinition("ONE", "one");
- validateDefinition("TWO", "ONE + ONE");
+ validateDefinition("ONE", "one");
+ validateDefinition("TWO", "ONE + ONE");
- initializeScanner("#ifndef ONE\n# define ONE 1\n# ifndef TWO\n# define TWO ONE + ONE \n# else\n# undef TWO\n# define TWO 2 \n# endif\n#else\n# ifndef TWO\n# define TWO ONE + ONE \n# else\n# undef TWO\n# define TWO 2 \n# endif\n#endif\n");
- addDefinition("ONE", "one");
- addDefinition("TWO", "two");
+ initializeScanner(
+ "#ifndef ONE\n# define ONE 1\n# ifndef TWO\n# define TWO ONE + ONE \n# else\n# undef TWO\n# define TWO 2 \n# endif\n#else\n# ifndef TWO\n# define TWO ONE + ONE \n# else\n# undef TWO\n# define TWO 2 \n# endif\n#endif\n");
+ addDefinition("ONE", "one");
+ addDefinition("TWO", "two");
validateEOF();
- validateDefinition("ONE", "one");
- validateDefinition("TWO", "2");
+ validateDefinition("ONE", "one");
+ validateDefinition("TWO", "2");
- initializeScanner("#ifndef ONE\n# define ONE 1\n# ifndef TWO\n# define TWO ONE + ONE \n# else\n# undef TWO\n# define TWO 2 \n# endif\n#else\n# ifndef TWO\n# define TWO ONE + ONE \n# else\n# undef TWO\n# define TWO 2 \n# endif\n#endif\n");
- addDefinition("TWO", "two");
+ initializeScanner(
+ "#ifndef ONE\n# define ONE 1\n# ifndef TWO\n# define TWO ONE + ONE \n# else\n# undef TWO\n# define TWO 2 \n# endif\n#else\n# ifndef TWO\n# define TWO ONE + ONE \n# else\n# undef TWO\n# define TWO 2 \n# endif\n#endif\n");
+ addDefinition("TWO", "two");
validateEOF();
- validateDefinition("ONE", "1");
- validateDefinition("TWO", "2");
+ validateDefinition("ONE", "1");
+ validateDefinition("TWO", "2");
}
public void testIfs() throws Exception {
- initializeScanner("#if 0\n#error NEVER\n#endif\n");
- validateEOF();
- initializeScanner("#define X 5\n#define Y 7\n#if (X < Y)\n#define Z X + Y\n#endif");
- validateEOF();
- validateDefinition("X", "5");
- validateDefinition("Y", "7");
- validateDefinition("Z", "X + Y");
-
- initializeScanner("#if T < 20\n#define Z T + 1\n#endif");
- addDefinition("X", "5");
- addDefinition("Y", "7");
- addDefinition("T", "X + Y");
- validateEOF();
- validateDefinition("X", "5");
- validateDefinition("Y", "7");
- validateDefinition("T", "X + Y");
- validateDefinition("Z", "T + 1");
-
- initializeScanner("#if ( 10 / 5 ) != 2\n#error 10/5 seems to not equal 2 anymore\n#endif\n");
- validateEOF();
-
- initializeScanner("#ifndef FIVE \n" +
- "#define FIVE 5\n" +
- "#endif \n" +
- "#ifndef TEN\n" +
- "#define TEN 2 * FIVE\n" +
- "#endif\n" +
- "#if TEN != 10\n" +
- "#define MISTAKE 1\n" +
- "#error Five does not equal 10\n" +
- "#endif\n", ParserMode.QUICK_PARSE);
- addDefinition("FIVE", "55");
- validateEOF();
- validateDefinition("FIVE", "55");
- validateDefinition("TEN", "2 * FIVE");
- validateDefinition("MISTAKE", "1");
+ initializeScanner("#if 0\n#error NEVER\n#endif\n");
+ validateEOF();
+ initializeScanner("#define X 5\n#define Y 7\n#if (X < Y)\n#define Z X + Y\n#endif");
+ validateEOF();
+ validateDefinition("X", "5");
+ validateDefinition("Y", "7");
+ validateDefinition("Z", "X + Y");
+
+ initializeScanner("#if T < 20\n#define Z T + 1\n#endif");
+ addDefinition("X", "5");
+ addDefinition("Y", "7");
+ addDefinition("T", "X + Y");
+ validateEOF();
+ validateDefinition("X", "5");
+ validateDefinition("Y", "7");
+ validateDefinition("T", "X + Y");
+ validateDefinition("Z", "T + 1");
+
+ initializeScanner("#if ( 10 / 5 ) != 2\n#error 10/5 seems to not equal 2 anymore\n#endif\n");
+ validateEOF();
+
+ initializeScanner("#ifndef FIVE \n" + "#define FIVE 5\n" + "#endif \n" + "#ifndef TEN\n"
+ + "#define TEN 2 * FIVE\n" + "#endif\n" + "#if TEN != 10\n" + "#define MISTAKE 1\n"
+ + "#error Five does not equal 10\n" + "#endif\n", ParserMode.QUICK_PARSE);
+ addDefinition("FIVE", "55");
+ validateEOF();
+ validateDefinition("FIVE", "55");
+ validateDefinition("TEN", "2 * FIVE");
+ validateDefinition("MISTAKE", "1");
validateProblemCount(1);
- initializeScanner("#if ((( FOUR / TWO ) * THREE )< FIVE )\n#error 6 is not less than 5 \n#endif\n#if ( ( FIVE * ONE ) != (( (FOUR) + ONE ) * ONE ) )\n#error 5 should equal 5\n#endif \n");
+ initializeScanner(
+ "#if ((( FOUR / TWO ) * THREE )< FIVE )\n#error 6 is not less than 5 \n#endif\n#if ( ( FIVE * ONE ) != (( (FOUR) + ONE ) * ONE ) )\n#error 5 should equal 5\n#endif \n");
- addDefinition("ONE", "1");
- addDefinition("TWO", "(ONE + ONE)");
- addDefinition("THREE", "(TWO + ONE)");
- addDefinition("FOUR", "(TWO * TWO)");
- addDefinition("FIVE", "(THREE + TWO)");
+ addDefinition("ONE", "1");
+ addDefinition("TWO", "(ONE + ONE)");
+ addDefinition("THREE", "(TWO + ONE)");
+ addDefinition("FOUR", "(TWO * TWO)");
+ addDefinition("FIVE", "(THREE + TWO)");
validateEOF();
- validateDefinition("ONE", "1");
- validateDefinition("TWO", "(ONE + ONE)");
- validateDefinition("THREE", "(TWO + ONE)");
- validateDefinition("FOUR", "(TWO * TWO)");
- validateDefinition("FIVE", "(THREE + TWO)");
+ validateDefinition("ONE", "1");
+ validateDefinition("TWO", "(ONE + ONE)");
+ validateDefinition("THREE", "(TWO + ONE)");
+ validateDefinition("FOUR", "(TWO * TWO)");
+ validateDefinition("FIVE", "(THREE + TWO)");
TruthTable table = new TruthTable(SIZEOF_TRUTHTABLE);
int numberOfRows = table.getNumberOfRows();
@@ -633,7 +603,7 @@ public class PortedScannerTests extends PreprocessorTestsBase {
validateAllDefinitions(row);
}
- initializeScanner("#if ! 0\n#error Correct!\n#endif");
+ initializeScanner("#if ! 0\n#error Correct!\n#endif");
validateEOF();
}
@@ -653,8 +623,7 @@ public class PortedScannerTests extends PreprocessorTestsBase {
validateInteger("1");
validateToken(IToken.tSEMI);
validateEOF();
- initializeScanner("#define ONE 1\n"
- + "#define SUM(a,b,c,d,e,f,g) ( a + b + c + d + e + f + g )\n"
+ initializeScanner("#define ONE 1\n" + "#define SUM(a,b,c,d,e,f,g) ( a + b + c + d + e + f + g )\n"
+ "int daSum = SUM(ONE,3,5,7,9,11,13);");
validateToken(IToken.t_int);
validateIdentifier("daSum");
@@ -677,7 +646,8 @@ public class PortedScannerTests extends PreprocessorTestsBase {
validateToken(IToken.tSEMI);
validateEOF();
- initializeScanner("#define LOG( format, var1) printf( format, var1 )\nLOG( \"My name is %s\", \"Bogdan\" );\n");
+ initializeScanner(
+ "#define LOG( format, var1) printf( format, var1 )\nLOG( \"My name is %s\", \"Bogdan\" );\n");
validateIdentifier("printf");
validateToken(IToken.tLPAREN);
validateString("My name is %s");
@@ -699,7 +669,8 @@ public class PortedScannerTests extends PreprocessorTestsBase {
validateToken(IToken.tSEMI);
validateEOF();
- initializeScanner("#define CHECK_AND_SET( x, y, z ) if( x ) { \\\n y = z; \\\n }\n\nCHECK_AND_SET( 1, balance, 5000 );\nCHECK_AND_SET( confused(), you, dumb );");
+ initializeScanner(
+ "#define CHECK_AND_SET( x, y, z ) if( x ) { \\\n y = z; \\\n }\n\nCHECK_AND_SET( 1, balance, 5000 );\nCHECK_AND_SET( confused(), you, dumb );");
validateToken(IToken.t_if);
validateToken(IToken.tLPAREN);
validateInteger("1");
@@ -727,11 +698,7 @@ public class PortedScannerTests extends PreprocessorTestsBase {
validateToken(IToken.tSEMI);
validateEOF();
- initializeScanner(
- "#define ON 7\n"+
- "#if defined(ON)\n"+
- "int itsOn = ON;\n"+
- "#endif");
+ initializeScanner("#define ON 7\n" + "#if defined(ON)\n" + "int itsOn = ON;\n" + "#endif");
validateToken(IToken.t_int);
validateIdentifier("itsOn");
validateToken(IToken.tASSIGN);
@@ -743,37 +710,37 @@ public class PortedScannerTests extends PreprocessorTestsBase {
}
public void testQuickScan() throws Exception {
- initializeScanner("#if X + 5 < 7\n int found = 1;\n#endif", ParserMode.QUICK_PARSE);
+ initializeScanner("#if X + 5 < 7\n int found = 1;\n#endif", ParserMode.QUICK_PARSE);
validateToken(IToken.t_int);
- validateIdentifier("found");
+ validateIdentifier("found");
validateToken(IToken.tASSIGN);
- validateInteger("1");
+ validateInteger("1");
validateToken(IToken.tSEMI);
validateEOF();
- initializeScanner("#if 0\n int error = 666;\n#endif");
+ initializeScanner("#if 0\n int error = 666;\n#endif");
validateEOF();
}
public void testOtherPreprocessorCommands() throws Exception {
- initializeScanner("#\n#\t\n#define MAX_SIZE 1024\n#\n# ");
+ initializeScanner("#\n#\t\n#define MAX_SIZE 1024\n#\n# ");
validateEOF();
- validateDefinition("MAX_SIZE", "1024");
+ validateDefinition("MAX_SIZE", "1024");
for (int i = 0; i < 4; ++i) {
switch (i) {
case 0:
- initializeScanner("# ape");
+ initializeScanner("# ape");
break;
case 1:
- initializeScanner("# #");
+ initializeScanner("# #");
break;
case 2:
- initializeScanner("# 32");
+ initializeScanner("# 32");
break;
case 3:
- initializeScanner("# defines");
+ initializeScanner("# defines");
break;
}
@@ -794,54 +761,54 @@ public class PortedScannerTests extends PreprocessorTestsBase {
}
public void testBug36287() throws Exception {
- initializeScanner("X::X( const X & rtg_arg ) : U( rtg_arg ) , Z( rtg_arg.Z ) , er( rtg_arg.er ){}");
- validateIdentifier("X");
+ initializeScanner("X::X( const X & rtg_arg ) : U( rtg_arg ) , Z( rtg_arg.Z ) , er( rtg_arg.er ){}");
+ validateIdentifier("X");
validateToken(IToken.tCOLONCOLON);
- validateIdentifier("X");
+ validateIdentifier("X");
validateToken(IToken.tLPAREN);
validateToken(IToken.t_const);
- validateIdentifier("X");
+ validateIdentifier("X");
validateToken(IToken.tAMPER);
- validateIdentifier("rtg_arg");
+ validateIdentifier("rtg_arg");
validateToken(IToken.tRPAREN);
validateToken(IToken.tCOLON);
- validateIdentifier("U");
+ validateIdentifier("U");
validateToken(IToken.tLPAREN);
- validateIdentifier("rtg_arg");
+ validateIdentifier("rtg_arg");
validateToken(IToken.tRPAREN);
validateToken(IToken.tCOMMA);
- validateIdentifier("Z");
+ validateIdentifier("Z");
validateToken(IToken.tLPAREN);
- validateIdentifier("rtg_arg");
+ validateIdentifier("rtg_arg");
validateToken(IToken.tDOT);
- validateIdentifier("Z");
+ validateIdentifier("Z");
validateToken(IToken.tRPAREN);
validateToken(IToken.tCOMMA);
- validateIdentifier("er");
+ validateIdentifier("er");
validateToken(IToken.tLPAREN);
- validateIdentifier("rtg_arg");
+ validateIdentifier("rtg_arg");
validateToken(IToken.tDOT);
- validateIdentifier("er");
+ validateIdentifier("er");
validateToken(IToken.tRPAREN);
validateToken(IToken.tLBRACE);
validateToken(IToken.tRBRACE);
validateEOF();
- initializeScanner("foo.*bar");
- validateIdentifier("foo");
+ initializeScanner("foo.*bar");
+ validateIdentifier("foo");
validateToken(IToken.tDOTSTAR);
- validateIdentifier("bar");
+ validateIdentifier("bar");
validateEOF();
- initializeScanner("foo...bar");
- validateIdentifier("foo");
+ initializeScanner("foo...bar");
+ validateIdentifier("foo");
validateToken(IToken.tELLIPSIS);
- validateIdentifier("bar");
+ validateIdentifier("bar");
validateEOF();
}
public void testBug35892() throws Exception {
- initializeScanner("'c'");
+ initializeScanner("'c'");
validateChar("c");
validateEOF();
}
@@ -857,50 +824,44 @@ public class PortedScannerTests extends PreprocessorTestsBase {
buffer.append('\\');
buffer.append('\\');
buffer.append('"');
- buffer.append("\n\n");
+ buffer.append("\n\n");
initializeScanner(buffer.toString());
- validateString("\\\"\\\\");
+ validateString("\\\"\\\\");
}
public void testConditionalWithBraces() throws Exception {
for (int i = 0; i < 4; ++i) {
- initializeScanner(
- "int foobar(int a) { if(a == 0) {\n"+
- "#ifdef THIS\n"+
- "} else {}\n"+
- "#elif THAT\n" +
- "} else {}\n"+
- "#endif\n"+
- "return 0;}");
+ initializeScanner("int foobar(int a) { if(a == 0) {\n" + "#ifdef THIS\n" + "} else {}\n" + "#elif THAT\n"
+ + "} else {}\n" + "#endif\n" + "return 0;}");
switch (i) {
case 0:
- addDefinition("THIS", "1");
- addDefinition("THAT", "1");
+ addDefinition("THIS", "1");
+ addDefinition("THAT", "1");
break;
case 1:
- addDefinition("THIS", "1");
- addDefinition("THAT", "0");
+ addDefinition("THIS", "1");
+ addDefinition("THAT", "0");
break;
case 2:
- addDefinition("THAT", "1");
+ addDefinition("THAT", "1");
break;
case 3:
- addDefinition("THAT", "0");
+ addDefinition("THAT", "0");
break;
}
validateToken(IToken.t_int);
- validateIdentifier("foobar");
+ validateIdentifier("foobar");
validateToken(IToken.tLPAREN);
validateToken(IToken.t_int);
- validateIdentifier("a");
+ validateIdentifier("a");
validateToken(IToken.tRPAREN);
validateToken(IToken.tLBRACE);
validateToken(IToken.t_if);
validateToken(IToken.tLPAREN);
- validateIdentifier("a");
+ validateIdentifier("a");
validateToken(IToken.tEQUAL);
- validateInteger("0");
+ validateInteger("0");
validateToken(IToken.tRPAREN);
validateToken(IToken.tLBRACE);
@@ -919,7 +880,7 @@ public class PortedScannerTests extends PreprocessorTestsBase {
}
validateToken(IToken.t_return);
- validateInteger("0");
+ validateInteger("0");
validateToken(IToken.tSEMI);
validateToken(IToken.tRBRACE);
validateEOF();
@@ -928,83 +889,83 @@ public class PortedScannerTests extends PreprocessorTestsBase {
}
public void testNestedRecursiveDefines() throws Exception {
- initializeScanner("#define C B A\n#define B C C\n#define A B\nA");
+ initializeScanner("#define C B A\n#define B C C\n#define A B\nA");
- validateIdentifier("B");
- validateDefinition("A", "B");
- validateDefinition("B", "C C");
- validateDefinition("C", "B A");
- validateIdentifier("A");
- validateIdentifier("B");
- validateIdentifier("A");
+ validateIdentifier("B");
+ validateDefinition("A", "B");
+ validateDefinition("B", "C C");
+ validateDefinition("C", "B A");
+ validateIdentifier("A");
+ validateIdentifier("B");
+ validateIdentifier("A");
validateEOF();
}
public void testBug36316() throws Exception {
- initializeScanner("#define A B->A\nA");
+ initializeScanner("#define A B->A\nA");
- validateIdentifier("B");
- validateDefinition("A", "B->A");
+ validateIdentifier("B");
+ validateDefinition("A", "B->A");
validateToken(IToken.tARROW);
- validateIdentifier("A");
+ validateIdentifier("A");
validateEOF();
}
public void testBug36434() throws Exception {
- initializeScanner("#define X(Y)\nX(55)");
+ initializeScanner("#define X(Y)\nX(55)");
validateEOF();
- /*IMacroDescriptor macro = fScanner.getDefinition( "X" );
- assertNotNull( macro );
+ /*IMacroDescriptor macro = fScanner.getDefinition( "X" );
+ assertNotNull( macro );
assertEquals( macro.getParameters().length, 1 );
- assertEquals( macro.getParameters()[0], "Y" );
+ assertEquals( macro.getParameters()[0], "Y" );
assertEquals( macro.getTokenizedExpansion().length, 0 );*/
}
public void testBug36047() throws Exception {
StringWriter writer = new StringWriter();
- writer.write("# define MAD_VERSION_STRINGIZE(str) #str\n");
- writer.write("# define MAD_VERSION_STRING(num) MAD_VERSION_STRINGIZE(num)\n");
- writer.write("# define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) \".\" \\\n");
- writer.write(" MAD_VERSION_STRING(MAD_VERSION_MINOR) \".\" \\\n");
- writer.write(" MAD_VERSION_STRING(MAD_VERSION_PATCH) \".\" \\\n");
- writer.write(" MAD_VERSION_STRING(MAD_VERSION_EXTRA)\n");
- writer.write("# define MAD_VERSION_MAJOR 2\n");
- writer.write("# define MAD_VERSION_MINOR 1\n");
- writer.write("# define MAD_VERSION_PATCH 3\n");
- writer.write("# define MAD_VERSION_EXTRA boo\n");
- writer.write("MAD_VERSION\n");
+ writer.write("# define MAD_VERSION_STRINGIZE(str) #str\n");
+ writer.write("# define MAD_VERSION_STRING(num) MAD_VERSION_STRINGIZE(num)\n");
+ writer.write("# define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) \".\" \\\n");
+ writer.write(" MAD_VERSION_STRING(MAD_VERSION_MINOR) \".\" \\\n");
+ writer.write(" MAD_VERSION_STRING(MAD_VERSION_PATCH) \".\" \\\n");
+ writer.write(" MAD_VERSION_STRING(MAD_VERSION_EXTRA)\n");
+ writer.write("# define MAD_VERSION_MAJOR 2\n");
+ writer.write("# define MAD_VERSION_MINOR 1\n");
+ writer.write("# define MAD_VERSION_PATCH 3\n");
+ writer.write("# define MAD_VERSION_EXTRA boo\n");
+ writer.write("MAD_VERSION\n");
initializeScanner(writer.toString());
- validateString("2.1.3.boo");
+ validateString("2.1.3.boo");
validateEOF();
}
public void testBug36475() throws Exception {
StringWriter writer = new StringWriter();
- writer.write(" \"A\" \"B\" \"C\" ");
+ writer.write(" \"A\" \"B\" \"C\" ");
initializeScanner(writer.toString());
- validateString("ABC");
+ validateString("ABC");
validateEOF();
}
public void testBug36509() throws Exception {
StringWriter writer = new StringWriter();
- writer.write("#define debug(s, t) printf(\"x\" # s \"= %d, x\" # t \"= %s\", \\\n");
- writer.write(" x ## s, x ## t) \n");
- writer.write("debug(1, 2);");
+ writer.write("#define debug(s, t) printf(\"x\" # s \"= %d, x\" # t \"= %s\", \\\n");
+ writer.write(" x ## s, x ## t) \n");
+ writer.write("debug(1, 2);");
initializeScanner(writer.toString());
- //printf("x1=%d, x2= %s", x1, x2);
- validateIdentifier("printf");
+ //printf("x1=%d, x2= %s", x1, x2);
+ validateIdentifier("printf");
validateToken(IToken.tLPAREN);
- validateString("x1= %d, x2= %s");
+ validateString("x1= %d, x2= %s");
validateToken(IToken.tCOMMA);
- validateIdentifier("x1");
+ validateIdentifier("x1");
validateToken(IToken.tCOMMA);
- validateIdentifier("x2");
+ validateIdentifier("x2");
validateToken(IToken.tRPAREN);
validateToken(IToken.tSEMI);
validateEOF();
@@ -1012,73 +973,73 @@ public class PortedScannerTests extends PreprocessorTestsBase {
public void testBug36695() throws Exception {
StringWriter writer = new StringWriter();
- writer.write("\'\\4\' \'\\n\'");
+ writer.write("\'\\4\' \'\\n\'");
initializeScanner(writer.toString());
- validateChar("\\4");
- validateChar("\\n");
+ validateChar("\\4");
+ validateChar("\\n");
validateEOF();
}
public void testBug36521() throws Exception {
StringWriter writer = new StringWriter();
- writer.write("#define str(s) # s\n");
- writer.write("fputs(str(strncmp(\"abc\\0d\", \"abc\", \'\\4\')\n");
- writer.write(" == 0), s);\n");
+ writer.write("#define str(s) # s\n");
+ writer.write("fputs(str(strncmp(\"abc\\0d\", \"abc\", \'\\4\')\n");
+ writer.write(" == 0), s);\n");
initializeScanner(writer.toString());
- validateIdentifier("fputs");
+ validateIdentifier("fputs");
validateToken(IToken.tLPAREN);
//TODO as in 36701B, whitespace is not properly replaced inside the string, ok for now.
- validateString("strncmp(\\\"abc\\\\0d\\\", \\\"abc\\\", '\\\\4') == 0");
- //validateString("strncmp(\\\"abc\\\\0d\\\", \\\"abc\\\", '\\\\4') == 0");
+ validateString("strncmp(\\\"abc\\\\0d\\\", \\\"abc\\\", '\\\\4') == 0");
+ //validateString("strncmp(\\\"abc\\\\0d\\\", \\\"abc\\\", '\\\\4') == 0");
validateToken(IToken.tCOMMA);
- validateIdentifier("s");
+ validateIdentifier("s");
validateToken(IToken.tRPAREN);
validateToken(IToken.tSEMI);
}
public void testBug36770() throws Exception {
StringWriter writer = new StringWriter();
- writer.write("#define A 0\n");
- writer.write("#if ( A == 1 )\n");
- writer.write("# define foo 1\n");
- writer.write("#else\n");
- writer.write("# define foo 2\n");
- writer.write("#endif\n");
- writer.write("foo\n");
+ writer.write("#define A 0\n");
+ writer.write("#if ( A == 1 )\n");
+ writer.write("# define foo 1\n");
+ writer.write("#else\n");
+ writer.write("# define foo 2\n");
+ writer.write("#endif\n");
+ writer.write("foo\n");
initializeScanner(writer.toString());
- validateInteger("2");
+ validateInteger("2");
validateEOF();
}
public void testBug36816() throws Exception {
- initializeScanner("#include \"foo.h", ParserMode.QUICK_PARSE);
+ initializeScanner("#include \"foo.h", ParserMode.QUICK_PARSE);
validateEOF();
validateProblemCount(2);
- initializeScanner("#include <foo.h", ParserMode.QUICK_PARSE);
+ initializeScanner("#include <foo.h", ParserMode.QUICK_PARSE);
validateEOF();
validateProblemCount(2);
- initializeScanner("#define FOO(A", ParserMode.QUICK_PARSE);
+ initializeScanner("#define FOO(A", ParserMode.QUICK_PARSE);
validateEOF();
validateProblemCount(1);
- initializeScanner("#define FOO(A \\ B", ParserMode.QUICK_PARSE);
+ initializeScanner("#define FOO(A \\ B", ParserMode.QUICK_PARSE);
validateEOF();
validateProblemCount(1);
}
public void testBug36255() throws Exception {
StringWriter writer = new StringWriter();
- writer.write("#if defined ( A ) \n");
- writer.write(" #if defined ( B ) && ( B != 0 ) \n");
- writer.write(" boo\n");
- writer.write(" #endif /*B*/\n");
- writer.write("#endif /*A*/");
+ writer.write("#if defined ( A ) \n");
+ writer.write(" #if defined ( B ) && ( B != 0 ) \n");
+ writer.write(" boo\n");
+ writer.write(" #endif /*B*/\n");
+ writer.write("#endif /*A*/");
initializeScanner(writer.toString());
validateEOF();
@@ -1086,141 +1047,141 @@ public class PortedScannerTests extends PreprocessorTestsBase {
public void testBug37011() throws Exception {
StringWriter writer = new StringWriter();
- writer.write("#define A \"//\"");
+ writer.write("#define A \"//\"");
initializeScanner(writer.toString());
validateEOF();
- validateDefinition("A", "\"//\"");
+ validateDefinition("A", "\"//\"");
}
public void testOtherPreprocessorDefines() throws Exception {
StringWriter writer = new StringWriter();
- writer.write("#define A a//boo\n");
- writer.write("#define B a /*boo*/ a\n");
- writer.write("#define C a \" //boo \"\n");
- writer.write("#define D a \\\"//boo\n");
- writer.write("#define E a \\n \"\\\"\"\n");
- writer.write("#define F a\\\n b\n");
- writer.write("#define G a '\"'//boo\n");
- writer.write("#define H a '\\'//b'\"/*bo\\o*/\" b\n");
+ writer.write("#define A a//boo\n");
+ writer.write("#define B a /*boo*/ a\n");
+ writer.write("#define C a \" //boo \"\n");
+ writer.write("#define D a \\\"//boo\n");
+ writer.write("#define E a \\n \"\\\"\"\n");
+ writer.write("#define F a\\\n b\n");
+ writer.write("#define G a '\"'//boo\n");
+ writer.write("#define H a '\\'//b'\"/*bo\\o*/\" b\n");
initializeScanner(writer.toString());
validateEOF();
- validateDefinition("A", "a");
- validateDefinition("B", "a a");
- validateDefinition("C", "a \" //boo \"");
- validateDefinition("D", "a \\\"//boo");
- validateDefinition("E", "a \\n \"\\\"\"");
- validateDefinition("F", "a b");
- validateDefinition("G", "a '\"'");
- validateDefinition("H", "a '\\'//b'\"/*bo\\o*/\" b");
+ validateDefinition("A", "a");
+ validateDefinition("B", "a a");
+ validateDefinition("C", "a \" //boo \"");
+ validateDefinition("D", "a \\\"//boo");
+ validateDefinition("E", "a \\n \"\\\"\"");
+ validateDefinition("F", "a b");
+ validateDefinition("G", "a '\"'");
+ validateDefinition("H", "a '\\'//b'\"/*bo\\o*/\" b");
}
public void testBug38065() throws Exception {
- initializeScanner("Foo\\\nBar");
+ initializeScanner("Foo\\\nBar");
- validateIdentifier("FooBar");
+ validateIdentifier("FooBar");
validateEOF();
}
public void testBug36701A() throws Exception {
StringWriter writer = new StringWriter();
- writer.write("#define str(s) # s\n");
- writer.write("str( @ \\n )\n");
+ writer.write("#define str(s) # s\n");
+ writer.write("str( @ \\n )\n");
initializeScanner(writer.toString());
- validateString("@ \\n");
+ validateString("@ \\n");
validateEOF();
}
public void testBug36701B() throws Exception {
StringWriter writer = new StringWriter();
- writer.write("#define str(s) # s\n");
- writer.write("str( @ /*ff*/ \\n hh \"aa\" )\n");
+ writer.write("#define str(s) # s\n");
+ writer.write("str( @ /*ff*/ \\n hh \"aa\" )\n");
initializeScanner(writer.toString());
- validateString("@ \\n hh \\\"aa\\\"");
+ validateString("@ \\n hh \\\"aa\\\"");
validateEOF();
}
public void testBug44305() throws Exception {
StringWriter writer = new StringWriter();
- writer.write("#define WCHAR_MAX 0 \n");
- writer.write("#if WCHAR_MAX <= 0xff\n");
- writer.write("bool\n");
- writer.write("#endif");
+ writer.write("#define WCHAR_MAX 0 \n");
+ writer.write("#if WCHAR_MAX <= 0xff\n");
+ writer.write("bool\n");
+ writer.write("#endif");
initializeScanner(writer.toString());
validateToken(IToken.t_bool);
validateEOF();
}
public void testBug45287() throws Exception {
- initializeScanner("'abcdefg' L'hijklmnop'");
- validateChar("abcdefg");
- validateWideChar("hijklmnop");
+ initializeScanner("'abcdefg' L'hijklmnop'");
+ validateChar("abcdefg");
+ validateWideChar("hijklmnop");
validateEOF();
}
public void testBug45476() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append("#define X 5\n");
- buffer.append("#if defined X\n");
- buffer.append("#define Y 10\n");
- buffer.append("#endif");
+ buffer.append("#define X 5\n");
+ buffer.append("#if defined X\n");
+ buffer.append("#define Y 10\n");
+ buffer.append("#endif");
initializeScanner(buffer.toString());
validateEOF();
- validateDefinition("Y", "10");
+ validateDefinition("Y", "10");
}
public void testBug45477() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append("#define D\n");
- buffer.append("#define D\n");
- buffer.append("#define sum(x,y) x+y\n");
- buffer.append("#define E 3\n");
- buffer.append("#define E 3\n");
- buffer.append("#define sum(x,y) x+y\n");
- buffer.append("#if defined(D)\n");
- buffer.append("printf\n");
- buffer.append("#endif\n");
- buffer.append("#if defined(sum)\n");
- buffer.append("scanf\n");
- buffer.append("#endif\n");
- buffer.append("#if defined(E)\n");
- buffer.append("sprintf\n");
- buffer.append("#endif\n");
+ buffer.append("#define D\n");
+ buffer.append("#define D\n");
+ buffer.append("#define sum(x,y) x+y\n");
+ buffer.append("#define E 3\n");
+ buffer.append("#define E 3\n");
+ buffer.append("#define sum(x,y) x+y\n");
+ buffer.append("#if defined(D)\n");
+ buffer.append("printf\n");
+ buffer.append("#endif\n");
+ buffer.append("#if defined(sum)\n");
+ buffer.append("scanf\n");
+ buffer.append("#endif\n");
+ buffer.append("#if defined(E)\n");
+ buffer.append("sprintf\n");
+ buffer.append("#endif\n");
initializeScanner(buffer.toString());
- validateIdentifier("printf");
- validateIdentifier("scanf");
- validateIdentifier("sprintf");
+ validateIdentifier("printf");
+ validateIdentifier("scanf");
+ validateIdentifier("sprintf");
validateEOF();
for (int i = 0; i < 5; ++i) {
buffer = new StringBuilder();
- buffer.append("#define D blah\n");
+ buffer.append("#define D blah\n");
switch (i) {
case 0:
- buffer.append("#define D\n");
+ buffer.append("#define D\n");
break;
case 1:
- buffer.append("#define D( x ) echo\n");
+ buffer.append("#define D( x ) echo\n");
break;
case 2:
- buffer.append("#define D ACDC\n");
+ buffer.append("#define D ACDC\n");
break;
case 3:
- buffer.append("#define D defined( D )\n");
+ buffer.append("#define D defined( D )\n");
break;
case 4:
- buffer.append("#define D blahh\n");
+ buffer.append("#define D blahh\n");
break;
}
@@ -1230,79 +1191,79 @@ public class PortedScannerTests extends PreprocessorTestsBase {
}
buffer = new StringBuilder();
- buffer.append("#define X 5\n");
- buffer.append("#define Y 7\n");
- buffer.append("#define SUMXY X _+ Y");
- buffer.append("#define SUMXY X + Y");
+ buffer.append("#define X 5\n");
+ buffer.append("#define Y 7\n");
+ buffer.append("#define SUMXY X _+ Y");
+ buffer.append("#define SUMXY X + Y");
initializeScanner(buffer.toString());
validateEOF();
}
public void testBug45551() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append("#define stdio someNonExistantIncludeFile\n");
- buffer.append("#include <stdio.h>\n");
+ buffer.append("#define stdio someNonExistantIncludeFile\n");
+ buffer.append("#include <stdio.h>\n");
initializeScanner(buffer.toString());
validateEOF();
validateProblemCount(1); // file does not exist
- IASTPreprocessorIncludeStatement[] includes= fLocationResolver.getIncludeDirectives();
+ IASTPreprocessorIncludeStatement[] includes = fLocationResolver.getIncludeDirectives();
assertEquals(1, includes.length);
- assertEquals("stdio.h", includes[0].getName().toString());
+ assertEquals("stdio.h", includes[0].getName().toString());
}
public void testBug46402() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append("#define X 5\n");
- buffer.append("#if defined( X )\n");
- buffer.append("// blah\n");
- buffer.append("#elif Y > 5 \n");
- buffer.append("// coo\n");
- buffer.append("#endif\n");
+ buffer.append("#define X 5\n");
+ buffer.append("#if defined( X )\n");
+ buffer.append("// blah\n");
+ buffer.append("#elif Y > 5 \n");
+ buffer.append("// coo\n");
+ buffer.append("#endif\n");
initializeScanner(buffer.toString(), ParserMode.COMPLETE_PARSE);
validateEOF();
}
public void testBug50821() throws Exception {
- initializeScanner("\'\n\n\n", ParserMode.QUICK_PARSE);
+ initializeScanner("\'\n\n\n", ParserMode.QUICK_PARSE);
fScanner.nextToken();
validateProblemCount(1);
}
public void test54778() throws Exception {
- initializeScanner("#if 1 || 0 < 3 \n printf \n #endif\n");
- validateIdentifier("printf");
+ initializeScanner("#if 1 || 0 < 3 \n printf \n #endif\n");
+ validateIdentifier("printf");
validateEOF();
- initializeScanner("#if !defined FOO || FOO > 3\nprintf\n#endif\n");
- validateIdentifier("printf");
+ initializeScanner("#if !defined FOO || FOO > 3\nprintf\n#endif\n");
+ validateIdentifier("printf");
validateEOF();
- initializeScanner("#if !defined FOO || FOO < 3\nprintf\n#endif\n");
- validateIdentifier("printf");
+ initializeScanner("#if !defined FOO || FOO < 3\nprintf\n#endif\n");
+ validateIdentifier("printf");
validateEOF();
}
public void test68229() throws Exception {
Writer writer = new StringWriter();
- writer.write("#define COUNT 0 \n");
- writer.write("1 \n");
- writer.write("#if COUNT \n");
- writer.write(" 2 \n");
- writer.write("#endif \n");
- writer.write("3 \n");
+ writer.write("#define COUNT 0 \n");
+ writer.write("1 \n");
+ writer.write("#if COUNT \n");
+ writer.write(" 2 \n");
+ writer.write("#endif \n");
+ writer.write("3 \n");
initializeScanner(writer.toString());
IToken t1 = fScanner.nextToken();
IToken t3 = fScanner.nextToken();
- assertEquals(t1.getImage(), "1");
- assertEquals(t3.getImage(), "3");
+ assertEquals(t1.getImage(), "1");
+ assertEquals(t3.getImage(), "3");
assertEquals(t1.getNext(), t3);
validateEOF();
writer = new StringWriter();
- writer.write("#define FOO( x ) x \n");
- writer.write("1 FOO( 2 ) 3 \n");
+ writer.write("#define FOO( x ) x \n");
+ writer.write("1 FOO( 2 ) 3 \n");
initializeScanner(writer.toString());
t1 = fScanner.nextToken();
@@ -1310,147 +1271,147 @@ public class PortedScannerTests extends PreprocessorTestsBase {
t3 = fScanner.nextToken();
validateEOF();
- assertEquals(t1.getImage(), "1");
- assertEquals(t2.getImage(), "2");
- assertEquals(t3.getImage(), "3");
+ assertEquals(t1.getImage(), "1");
+ assertEquals(t2.getImage(), "2");
+ assertEquals(t3.getImage(), "3");
assertEquals(t1.getNext(), t2);
}
public void testBug56517() throws Exception {
Writer writer = new StringWriter();
- writer.write("#if 0 \n");
- writer.write("char * x = \"#boo\";\n");
- writer.write("#endif\n");
+ writer.write("#if 0 \n");
+ writer.write("char * x = \"#boo\";\n");
+ writer.write("#endif\n");
initializeScanner(writer.toString());
validateEOF();
}
public void testBug36770B() throws Exception {
Writer writer = new StringWriter();
- writer.write("#define A 0\n");
- writer.write("#if ( A == 1 )\n");
- writer.write("# define foo\n");
- writer.write("#else\n");
- writer.write("# define bar\n");
- writer.write("#endif\n");
+ writer.write("#define A 0\n");
+ writer.write("#if ( A == 1 )\n");
+ writer.write("# define foo\n");
+ writer.write("#else\n");
+ writer.write("# define bar\n");
+ writer.write("#endif\n");
initializeScanner(writer.toString(), ParserMode.QUICK_PARSE);
validateEOF();
- validateDefinition("A", 0);
- validateDefinition("bar", "");
+ validateDefinition("A", 0);
+ validateDefinition("bar", "");
}
public void testBug47797() throws Exception {
- initializeScanner("\"\\uABCD\" \'\\uABCD\' \\uABCD_ident \\u001A01BC_ident ident\\U01AF ident\\u01bc00AF");
- validateString("\\uABCD");
- validateChar("\\uABCD");
- validateIdentifier("\\uABCD_ident");
- validateIdentifier("\\u001A01BC_ident");
- validateIdentifier("ident\\U01AF");
- validateIdentifier("ident\\u01bc00AF");
+ initializeScanner("\"\\uABCD\" \'\\uABCD\' \\uABCD_ident \\u001A01BC_ident ident\\U01AF ident\\u01bc00AF");
+ validateString("\\uABCD");
+ validateChar("\\uABCD");
+ validateIdentifier("\\uABCD_ident");
+ validateIdentifier("\\u001A01BC_ident");
+ validateIdentifier("ident\\U01AF");
+ validateIdentifier("ident\\u01bc00AF");
validateEOF();
}
public void testBug59768() throws Exception {
- initializeScanner("#define A A\nA");
- validateIdentifier("A");
+ initializeScanner("#define A A\nA");
+ validateIdentifier("A");
validateEOF();
- /*IMacroDescriptor d = fScanner.getDefinition( "A");
+ /*IMacroDescriptor d = fScanner.getDefinition( "A");
assertTrue( d.isCircular() );*/
}
public void testBug60764() throws Exception {
Writer writer = new StringWriter();
- writer.write("#define P a,b\n");
- writer.write("#define M(x) M1(x)\n");
- writer.write("#define M1(x,y) #x #y\n");
- writer.write("M(P)\n");
+ writer.write("#define P a,b\n");
+ writer.write("#define M(x) M1(x)\n");
+ writer.write("#define M1(x,y) #x #y\n");
+ writer.write("M(P)\n");
initializeScanner(writer.toString());
- validateString("ab");
+ validateString("ab");
validateEOF();
}
public void testBug62042() throws Exception {
- initializeScanner("0x", ParserMode.QUICK_PARSE);
- validateInteger("0x"); // to me this is a valid number
+ initializeScanner("0x", ParserMode.QUICK_PARSE);
+ validateInteger("0x"); // to me this is a valid number
validateEOF();
}
public void testBug61968() throws Exception {
Writer writer = new StringWriter();
- writer.write("unsigned int ui = 2172748163; //ok \n");
- writer.write("int big = 999999999999999;//ok \n");
- writer.write("void main() { \n");
- writer.write("caller(4); //ok\n");
- writer.write("caller(2172748163);//causes java.lang.NumberFormatException \n");
- writer.write("caller(999999999999999); //also causes NumberFormatException \n");
- writer.write("}\n");
+ writer.write("unsigned int ui = 2172748163; //ok \n");
+ writer.write("int big = 999999999999999;//ok \n");
+ writer.write("void main() { \n");
+ writer.write("caller(4); //ok\n");
+ writer.write("caller(2172748163);//causes java.lang.NumberFormatException \n");
+ writer.write("caller(999999999999999); //also causes NumberFormatException \n");
+ writer.write("}\n");
initializeScanner(writer.toString(), ParserMode.QUICK_PARSE);
fullyTokenize();
validateProblemCount(0);
}
public void testBug62378() throws Exception {
- initializeScanner("\"\\?\\?<\"");
- validateString("\\?\\?<");
+ initializeScanner("\"\\?\\?<\"");
+ validateString("\\?\\?<");
}
public void testBug62384() throws Exception {
- initializeScanner("18446744073709551615LL");
- validateInteger("18446744073709551615LL");
+ initializeScanner("18446744073709551615LL");
+ validateInteger("18446744073709551615LL");
}
public void testBug62390() throws Exception {
Writer writer = new StringWriter();
- writer.write("#define f(x) x\n");
- writer.write("#if f(\n");
- writer.write("5) == 5\n");
- writer.write("true1\n");
- writer.write("#endif\n");
- writer.write("#if A\n");
- writer.write("#elif f(\n");
- writer.write("5) == 5\n");
- writer.write("true2\n");
- writer.write("#endif\n");
- writer.write("#undef f\n");
- writer.write("#define f(x) \"A0I70_001.h\"\n");
- writer.write("#include f(\n");
- writer.write("5\n");
- writer.write(")\n");
- writer.write("#undef f\n");
- writer.write("#define f(x) 1467\n");
- writer.write("#line f(\n");
- writer.write("5\n");
- writer.write(")\n");
- writer.write("#pragma f(\n");
- writer.write("5\n");
- writer.write(")\n");
- writer.write("}\n");
+ writer.write("#define f(x) x\n");
+ writer.write("#if f(\n");
+ writer.write("5) == 5\n");
+ writer.write("true1\n");
+ writer.write("#endif\n");
+ writer.write("#if A\n");
+ writer.write("#elif f(\n");
+ writer.write("5) == 5\n");
+ writer.write("true2\n");
+ writer.write("#endif\n");
+ writer.write("#undef f\n");
+ writer.write("#define f(x) \"A0I70_001.h\"\n");
+ writer.write("#include f(\n");
+ writer.write("5\n");
+ writer.write(")\n");
+ writer.write("#undef f\n");
+ writer.write("#define f(x) 1467\n");
+ writer.write("#line f(\n");
+ writer.write("5\n");
+ writer.write(")\n");
+ writer.write("#pragma f(\n");
+ writer.write("5\n");
+ writer.write(")\n");
+ writer.write("}\n");
initializeScanner(writer.toString(), ParserMode.QUICK_PARSE);
fullyTokenize();
}
public void testBug62009() throws Exception {
- initializeScanner("#define def(x) (x#)\ndef(orange)\n", ParserMode.QUICK_PARSE);
+ initializeScanner("#define def(x) (x#)\ndef(orange)\n", ParserMode.QUICK_PARSE);
fullyTokenize();
- validateProblemCount(1);
+ validateProblemCount(1);
}
public void testBug61972() throws Exception {
- initializeScanner("#define DEF1(A1) A1\n#define DEF2 DEF1(DEF2)\nDEF2;");
- validateIdentifier("DEF2");
+ initializeScanner("#define DEF1(A1) A1\n#define DEF2 DEF1(DEF2)\nDEF2;");
+ validateIdentifier("DEF2");
validateToken(IToken.tSEMI);
validateEOF();
}
public void testBug64268() throws Exception {
Writer writer = new StringWriter();
- writer.write("#define BODY \\\n");
- writer.write(" { \\\n");
- writer.write(" /* this multi-line comment messes \\\n");
- writer.write(" up the parser. */ }\n");
- writer.write("BODY ");
+ writer.write("#define BODY \\\n");
+ writer.write(" { \\\n");
+ writer.write(" /* this multi-line comment messes \\\n");
+ writer.write(" up the parser. */ }\n");
+ writer.write("BODY ");
initializeScanner(writer.toString());
validateToken(IToken.tLBRACE);
validateToken(IToken.tRBRACE);
@@ -1458,46 +1419,44 @@ public class PortedScannerTests extends PreprocessorTestsBase {
}
public void testUndef() throws Exception {
- initializeScanner("#define A 5\n" +
- "#define B 10\n" +
- "#undef A\n" +
- "A B");
- validateIdentifier("A");
- validateInteger("10");
+ initializeScanner("#define A 5\n" + "#define B 10\n" + "#undef A\n" + "A B");
+ validateIdentifier("A");
+ validateInteger("10");
validateEOF();
}
public void testWackyFunctionMacros() throws Exception {
- initializeScanner("#define A(X) hi##X\n" +
- "#define B(Y) A(Y)\n" +
- "B(there)");
- validateIdentifier("hithere");
+ initializeScanner("#define A(X) hi##X\n" + "#define B(Y) A(Y)\n" + "B(there)");
+ validateIdentifier("hithere");
validateEOF();
}
public void testSlashes() throws Exception {
- initializeScanner("__q / __n");
- validateIdentifier("__q");
+ initializeScanner("__q / __n");
+ validateIdentifier("__q");
validateToken(IToken.tDIV);
- validateIdentifier("__n");
+ validateIdentifier("__n");
validateEOF();
}
public void testStringify() throws Exception {
- initializeScanner("#define xS(s) #s\n#define S(s) xS(s)\n#define X hi\nS(X)");
- validateString("hi");
+ initializeScanner("#define xS(s) #s\n#define S(s) xS(s)\n#define X hi\nS(X)");
+ validateString("hi");
validateEOF();
}
public void testWideToNarrowConcatenation() throws Exception {
- initializeScanner("\"ONE\" L\"TWO\"");
- validateLString("ONETWO");
+ initializeScanner("\"ONE\" L\"TWO\"");
+ validateLString("ONETWO");
validateEOF();
}
-
+
public void testUTFStringConcatenation() throws Exception {
IScannerExtensionConfiguration config = new GPPScannerExtensionConfiguration() {
- @Override public boolean supportUTFLiterals() { return true; }
+ @Override
+ public boolean supportUTFLiterals() {
+ return true;
+ }
};
initializeScanner("u\"a\" u\"b\"", ParserLanguage.CPP, config);
validateUTF16String("ab");
@@ -1508,7 +1467,7 @@ public class PortedScannerTests extends PreprocessorTestsBase {
initializeScanner("\"a\" u\"b\"", ParserLanguage.CPP, config);
validateUTF16String("ab");
validateEOF();
-
+
initializeScanner("U\"a\" U\"b\"", ParserLanguage.CPP, config);
validateUTF32String("ab");
validateEOF();
@@ -1521,64 +1480,63 @@ public class PortedScannerTests extends PreprocessorTestsBase {
}
public void testEmptyIncludeDirective() throws Exception {
- initializeScanner("#include \n#include <foo.h>\n");
+ initializeScanner("#include \n#include <foo.h>\n");
validateEOF();
- IASTPreprocessorIncludeStatement[] includes= fLocationResolver.getIncludeDirectives();
+ IASTPreprocessorIncludeStatement[] includes = fLocationResolver.getIncludeDirectives();
assertEquals(1, includes.length);
- assertEquals("foo.h", includes[0].getName().toString());
+ assertEquals("foo.h", includes[0].getName().toString());
}
public void testBug69412() throws Exception {
- initializeScanner("\'\\\\\'", ParserMode.COMPLETE_PARSE);
- validateChar("\\\\");
+ initializeScanner("\'\\\\\'", ParserMode.COMPLETE_PARSE);
+ validateChar("\\\\");
validateEOF();
validateProblemCount(0);
}
public void testBug70072() throws Exception {
- initializeScanner("#if 1/0\nint i;\n#elif 2/0\nint j;\n#endif\nint k;\n");
+ initializeScanner("#if 1/0\nint i;\n#elif 2/0\nint j;\n#endif\nint k;\n");
fullyTokenize();
}
public void testBug70261() throws Exception {
- initializeScanner("0X0");
- validateInteger("0X0");
+ initializeScanner("0X0");
+ validateInteger("0X0");
}
public void testBug62571() throws Exception {
- StringBuilder buffer = new StringBuilder("#define J(X,Y) X##Y\n");
- buffer.append("J(A,1Xxyz)\n");
- buffer.append("J(B,1X1X1Xxyz)\n");
- buffer.append("J(C,0Xxyz)\n");
- buffer.append("J(CC,0Xxyz)\n");
- buffer.append("J(D,0xxyz)\n");
- buffer.append("J(E,0x0x0xxyz)\n");
+ StringBuilder buffer = new StringBuilder("#define J(X,Y) X##Y\n");
+ buffer.append("J(A,1Xxyz)\n");
+ buffer.append("J(B,1X1X1Xxyz)\n");
+ buffer.append("J(C,0Xxyz)\n");
+ buffer.append("J(CC,0Xxyz)\n");
+ buffer.append("J(D,0xxyz)\n");
+ buffer.append("J(E,0x0x0xxyz)\n");
initializeScanner(buffer.toString());
- validateIdentifier("A1Xxyz");
- validateIdentifier("B1X1X1Xxyz");
- validateIdentifier("C0Xxyz");
- validateIdentifier("CC0Xxyz");
- validateIdentifier("D0xxyz");
- validateIdentifier("E0x0x0xxyz");
+ validateIdentifier("A1Xxyz");
+ validateIdentifier("B1X1X1Xxyz");
+ validateIdentifier("C0Xxyz");
+ validateIdentifier("CC0Xxyz");
+ validateIdentifier("D0xxyz");
+ validateIdentifier("E0x0x0xxyz");
}
public void testBug69134() throws Exception {
Writer writer = new StringWriter();
- writer.write("# ifdef YYDEBUG\n");
- writer.write("if (yyDebug) {\n");
- writer.write("(void) fprintf (yyTrace,\n");
- writer.write("\" # |Position|State|Mod|Lev|Action |Terminal and Lookahead or Rule\\n\");\n");
- writer.write("yyNl ();\n");
- writer.write("}\n");
- writer.write("# endif\n");
+ writer.write("# ifdef YYDEBUG\n");
+ writer.write("if (yyDebug) {\n");
+ writer.write("(void) fprintf (yyTrace,\n");
+ writer.write("\" # |Position|State|Mod|Lev|Action |Terminal and Lookahead or Rule\\n\");\n");
+ writer.write("yyNl ();\n");
+ writer.write("}\n");
+ writer.write("# endif\n");
initializeScanner(writer.toString());
fullyTokenize();
validateProblemCount(0);
}
public void testBug70073() throws Exception {
- StringBuilder buffer = new StringBuilder(
- "#if CONST \n #endif \n #elif CONST \n int");
+ StringBuilder buffer = new StringBuilder("#if CONST \n #endif \n #elif CONST \n int");
final List problems = new ArrayList();
initializeScanner(buffer.toString());
validateToken(IToken.t_int);
@@ -1587,21 +1545,21 @@ public class PortedScannerTests extends PreprocessorTestsBase {
public void testBug73652() throws Exception {
StringWriter writer = new StringWriter();
- writer.write("#define DoSuperMethodA IDoSuperMethodA\n");
- writer.write("#define IDoSuperMethodA(a,b,c) IIntuition->IDoSuperMethodA(a,b,c)\n");
- writer.write("DoSuperMethodA(0,0,0);\n");
+ writer.write("#define DoSuperMethodA IDoSuperMethodA\n");
+ writer.write("#define IDoSuperMethodA(a,b,c) IIntuition->IDoSuperMethodA(a,b,c)\n");
+ writer.write("DoSuperMethodA(0,0,0);\n");
initializeScanner(writer.toString());
- validateIdentifier("IIntuition");
+ validateIdentifier("IIntuition");
validateToken(IToken.tARROW);
- validateIdentifier("IDoSuperMethodA");
+ validateIdentifier("IDoSuperMethodA");
validateToken(IToken.tLPAREN);
- validateInteger("0");
+ validateInteger("0");
validateToken(IToken.tCOMMA);
- validateInteger("0");
+ validateInteger("0");
validateToken(IToken.tCOMMA);
- validateInteger("0");
+ validateInteger("0");
validateToken(IToken.tRPAREN);
validateToken(IToken.tSEMI);
validateEOF();
@@ -1609,23 +1567,23 @@ public class PortedScannerTests extends PreprocessorTestsBase {
public void testBug73652_2() throws Exception {
StringWriter writer = new StringWriter();
- writer.write("#define DoSuperMethodA DoSuperMethodB //doobalie\n");
- writer.write("#define DoSuperMethodB DoSuperMethodC /*oogalie*/ \n");
- writer.write("#define DoSuperMethodC IDoSuperMethodA \\\n\n");
- writer.write("#define IDoSuperMethodA(a,b,c) IIntuition->IDoSuperMethodA(a,b,c)\n");
- writer.write("DoSuperMethodA (0,0,0);\n");
+ writer.write("#define DoSuperMethodA DoSuperMethodB //doobalie\n");
+ writer.write("#define DoSuperMethodB DoSuperMethodC /*oogalie*/ \n");
+ writer.write("#define DoSuperMethodC IDoSuperMethodA \\\n\n");
+ writer.write("#define IDoSuperMethodA(a,b,c) IIntuition->IDoSuperMethodA(a,b,c)\n");
+ writer.write("DoSuperMethodA (0,0,0);\n");
initializeScanner(writer.toString());
- validateIdentifier("IIntuition");
+ validateIdentifier("IIntuition");
validateToken(IToken.tARROW);
- validateIdentifier("IDoSuperMethodA");
+ validateIdentifier("IDoSuperMethodA");
validateToken(IToken.tLPAREN);
- validateInteger("0");
+ validateInteger("0");
validateToken(IToken.tCOMMA);
- validateInteger("0");
+ validateInteger("0");
validateToken(IToken.tCOMMA);
- validateInteger("0");
+ validateInteger("0");
validateToken(IToken.tRPAREN);
validateToken(IToken.tSEMI);
validateEOF();
@@ -1633,22 +1591,22 @@ public class PortedScannerTests extends PreprocessorTestsBase {
}
public void testBug72997() throws Exception {
- initializeScanner("'\\\\'");
- validateChar("\\\\");
+ initializeScanner("'\\\\'");
+ validateChar("\\\\");
validateEOF();
}
public void testBug72725() throws Exception {
for (int i = 0; i < 2; ++i) {
StringBuilder buffer = new StringBuilder();
- buffer.append("#define a \\");
+ buffer.append("#define a \\");
if (i == 0)
- buffer.append("\r");
- buffer.append("\n");
- buffer.append("long macro stuff");
+ buffer.append("\r");
+ buffer.append("\n");
+ buffer.append("long macro stuff");
if (i == 0)
- buffer.append("\r");
- buffer.append("\n");
+ buffer.append("\r");
+ buffer.append("\n");
initializeScanner(buffer.toString());
validateEOF();
@@ -1658,32 +1616,32 @@ public class PortedScannerTests extends PreprocessorTestsBase {
public void testBug72506() throws Exception {
StringWriter writer = new StringWriter();
- writer.write("#define INCFILE(x) ver ## x\n");
- writer.write("#define xstr(x) str(x)\n");
- writer.write("#define str(x) #x\n");
- writer.write("xstr(INCFILE(2).h)\n");
+ writer.write("#define INCFILE(x) ver ## x\n");
+ writer.write("#define xstr(x) str(x)\n");
+ writer.write("#define str(x) #x\n");
+ writer.write("xstr(INCFILE(2).h)\n");
initializeScanner(writer.toString());
- validateString("ver2.h");
+ validateString("ver2.h");
validateEOF();
}
public void testBug72506_2() throws Exception {
StringWriter writer = new StringWriter();
- writer.write("#define str(x) #x\n");
- writer.write("#define A B\n");
- writer.write("#define B A\n");
- writer.write("str(B)\n");
+ writer.write("#define str(x) #x\n");
+ writer.write("#define A B\n");
+ writer.write("#define B A\n");
+ writer.write("str(B)\n");
initializeScanner(writer.toString());
- validateString("B");
+ validateString("B");
validateEOF();
}
public void testMacroPastingError() throws Exception {
StringWriter writer = new StringWriter();
- writer.write("#define m(expr) \\\r\n");
- writer.write(" foo( #expr ) \r\n");
+ writer.write("#define m(expr) \\\r\n");
+ writer.write(" foo( #expr ) \r\n");
initializeScanner(writer.toString());
validateEOF();
@@ -1691,31 +1649,30 @@ public class PortedScannerTests extends PreprocessorTestsBase {
}
public void testBug74176() throws Exception {
- initializeScanner("#define MYSTRING \"X Y Z ");
+ initializeScanner("#define MYSTRING \"X Y Z ");
validateEOF();
- initializeScanner("#define m(b) #");
+ initializeScanner("#define m(b) #");
validateEOF();
- initializeScanner("#define m(foo,b) #b");
+ initializeScanner("#define m(foo,b) #b");
validateEOF();
}
public void testBug74180() throws Exception {
- initializeScanner("true false", ParserLanguage.C);
- validateIdentifier("true");
- validateIdentifier("false");
+ initializeScanner("true false", ParserLanguage.C);
+ validateIdentifier("true");
+ validateIdentifier("false");
- initializeScanner("true false", ParserLanguage.CPP);
+ initializeScanner("true false", ParserLanguage.CPP);
validateToken(IToken.t_true);
validateToken(IToken.t_false);
}
public void testBug73492() throws Exception {
- String code = "#define PTR void *\n" +
- "PTR;\n";
+ String code = "#define PTR void *\n" + "PTR;\n";
- int offset = code.indexOf("PTR;") + 3;
+ int offset = code.indexOf("PTR;") + 3;
initializeScanner(code);
IToken t = fScanner.nextToken();
@@ -1732,27 +1689,27 @@ public class PortedScannerTests extends PreprocessorTestsBase {
}
public void testBug74328() throws Exception {
- initializeScanner("\"\";\n");
- validateString("");
+ initializeScanner("\"\";\n");
+ validateString("");
validateToken(IToken.tSEMI);
validateEOF();
}
public void testBug72537() throws Exception {
- initializeScanner("FOO BAR(boo)");
- fScanner.addMacroDefinition("FOO".toCharArray(), "foo".toCharArray());
- fScanner.addMacroDefinition("BAR(x)".toCharArray(), "x".toCharArray());
+ initializeScanner("FOO BAR(boo)");
+ fScanner.addMacroDefinition("FOO".toCharArray(), "foo".toCharArray());
+ fScanner.addMacroDefinition("BAR(x)".toCharArray(), "x".toCharArray());
- validateIdentifier("foo");
- validateIdentifier("boo");
+ validateIdentifier("foo");
+ validateIdentifier("boo");
validateEOF();
}
public void testBug75083() throws Exception {
- String code = "#define blah() { extern foo\n blah()\n";
+ String code = "#define blah() { extern foo\n blah()\n";
initializeScanner(code);
- int idx = code.indexOf("\n blah()") + 2 + 6;
+ int idx = code.indexOf("\n blah()") + 2 + 6;
IToken t = fScanner.nextToken();
assertEquals(IToken.tLBRACE, t.getType());
assertEquals(idx, t.getOffset());
@@ -1773,54 +1730,54 @@ public class PortedScannerTests extends PreprocessorTestsBase {
// the problems currently don't get reported when using the DOMScanner
public void testBug75532IProblems() throws Exception {
Writer writer = new StringWriter();
- writer.write("#if 09 == 9\n#endif\n"); // malformed octal
- writer.write("#if 1A == 0x1A\n#endif\n"); // malformed decimal
- writer.write("#if 0x == 0x0\n#endif\n"); // malformed hex
- writer.write("#if 0xAX == 0xA\n#endif\n"); // malformed hex
- writer.write("#if 1/0 == 1\n#endif\n"); // division by zero
- writer.write("#if defined ( sadf a\n#endif\n"); // missing ')' in defined
- writer.write("#if defined ( sadf\n#endif\n"); // missing ')' in defined
- writer.write("#if defined ( 2sadf )\n#endif\n"); // illegal identifier in defined
- writer.write("#if ( 1 == 1 ? 1\n#endif\n"); // bad conditional expression
- writer.write("#if ( \n#endif\n"); // expression syntax error
- writer.write("#if @\n#endif\n"); // expression syntax error
- writer.write("#if \n#endif\n"); // expression syntax error
- writer.write("#if -\n#endif\n"); // expression syntax error
- writer.write("#if ( 1 == 1\n#endif\n"); // missing ')'
- writer.write("#if 1 = 1\n#endif\n"); // assignment not allowed
-
- writer.write("int main(int argc, char **argv) {\n");
- writer.write("if ( 09 == 9 )\n"); // added while fixing this bug, IProblem on invalid octal number
- writer.write("return 1;\nreturn 0;\n}\n");
+ writer.write("#if 09 == 9\n#endif\n"); // malformed octal
+ writer.write("#if 1A == 0x1A\n#endif\n"); // malformed decimal
+ writer.write("#if 0x == 0x0\n#endif\n"); // malformed hex
+ writer.write("#if 0xAX == 0xA\n#endif\n"); // malformed hex
+ writer.write("#if 1/0 == 1\n#endif\n"); // division by zero
+ writer.write("#if defined ( sadf a\n#endif\n"); // missing ')' in defined
+ writer.write("#if defined ( sadf\n#endif\n"); // missing ')' in defined
+ writer.write("#if defined ( 2sadf )\n#endif\n"); // illegal identifier in defined
+ writer.write("#if ( 1 == 1 ? 1\n#endif\n"); // bad conditional expression
+ writer.write("#if ( \n#endif\n"); // expression syntax error
+ writer.write("#if @\n#endif\n"); // expression syntax error
+ writer.write("#if \n#endif\n"); // expression syntax error
+ writer.write("#if -\n#endif\n"); // expression syntax error
+ writer.write("#if ( 1 == 1\n#endif\n"); // missing ')'
+ writer.write("#if 1 = 1\n#endif\n"); // assignment not allowed
+
+ writer.write("int main(int argc, char **argv) {\n");
+ writer.write("if ( 09 == 9 )\n"); // added while fixing this bug, IProblem on invalid octal number
+ writer.write("return 1;\nreturn 0;\n}\n");
initializeScanner(writer.toString());
fullyTokenize();
- IASTProblem[] problems= fLocationResolver.getScannerProblems();
+ IASTProblem[] problems = fLocationResolver.getScannerProblems();
assertEquals(17, problems.length);
- int i= 0;
- assertEquals(IProblem.SCANNER_BAD_OCTAL_FORMAT, problems[i].getID());
- assertEquals(IProblem.SCANNER_CONSTANT_WITH_BAD_SUFFIX, problems[++i].getID());
- assertEquals(IProblem.SCANNER_CONSTANT_WITH_BAD_SUFFIX, problems[++i].getID());
- assertEquals(IProblem.SCANNER_CONSTANT_WITH_BAD_SUFFIX, problems[++i].getID());
- assertEquals(IProblem.SCANNER_DIVIDE_BY_ZERO, problems[++i].getID());
- assertEquals(IProblem.SCANNER_MISSING_R_PAREN, problems[++i].getID());
- assertEquals(IProblem.SCANNER_MISSING_R_PAREN, problems[++i].getID());
- assertEquals(IProblem.SCANNER_ILLEGAL_IDENTIFIER, problems[++i].getID());
- assertEquals(IProblem.SCANNER_BAD_CONDITIONAL_EXPRESSION,problems[++i].getID());
- assertEquals(IProblem.SCANNER_EXPRESSION_SYNTAX_ERROR, problems[++i].getID());
- assertEquals(IProblem.SCANNER_BAD_CHARACTER, problems[++i].getID());
- assertEquals(IProblem.SCANNER_EXPRESSION_SYNTAX_ERROR, problems[++i].getID());
- assertEquals(IProblem.SCANNER_EXPRESSION_SYNTAX_ERROR, problems[++i].getID());
- assertEquals(IProblem.SCANNER_EXPRESSION_SYNTAX_ERROR, problems[++i].getID());
- assertEquals(IProblem.SCANNER_MISSING_R_PAREN, problems[++i].getID());
- assertEquals(IProblem.SCANNER_ASSIGNMENT_NOT_ALLOWED, problems[++i].getID());
- assertEquals(IProblem.SCANNER_BAD_OCTAL_FORMAT, problems[++i].getID());
+ int i = 0;
+ assertEquals(IProblem.SCANNER_BAD_OCTAL_FORMAT, problems[i].getID());
+ assertEquals(IProblem.SCANNER_CONSTANT_WITH_BAD_SUFFIX, problems[++i].getID());
+ assertEquals(IProblem.SCANNER_CONSTANT_WITH_BAD_SUFFIX, problems[++i].getID());
+ assertEquals(IProblem.SCANNER_CONSTANT_WITH_BAD_SUFFIX, problems[++i].getID());
+ assertEquals(IProblem.SCANNER_DIVIDE_BY_ZERO, problems[++i].getID());
+ assertEquals(IProblem.SCANNER_MISSING_R_PAREN, problems[++i].getID());
+ assertEquals(IProblem.SCANNER_MISSING_R_PAREN, problems[++i].getID());
+ assertEquals(IProblem.SCANNER_ILLEGAL_IDENTIFIER, problems[++i].getID());
+ assertEquals(IProblem.SCANNER_BAD_CONDITIONAL_EXPRESSION, problems[++i].getID());
+ assertEquals(IProblem.SCANNER_EXPRESSION_SYNTAX_ERROR, problems[++i].getID());
+ assertEquals(IProblem.SCANNER_BAD_CHARACTER, problems[++i].getID());
+ assertEquals(IProblem.SCANNER_EXPRESSION_SYNTAX_ERROR, problems[++i].getID());
+ assertEquals(IProblem.SCANNER_EXPRESSION_SYNTAX_ERROR, problems[++i].getID());
+ assertEquals(IProblem.SCANNER_EXPRESSION_SYNTAX_ERROR, problems[++i].getID());
+ assertEquals(IProblem.SCANNER_MISSING_R_PAREN, problems[++i].getID());
+ assertEquals(IProblem.SCANNER_ASSIGNMENT_NOT_ALLOWED, problems[++i].getID());
+ assertEquals(IProblem.SCANNER_BAD_OCTAL_FORMAT, problems[++i].getID());
}
public void testExpressionEvalProblems() throws Exception {
Writer writer = new StringWriter();
- writer.write(" #if 1 == 1L \n");
- writer.write(" #endif \n");
+ writer.write(" #if 1 == 1L \n");
+ writer.write(" #endif \n");
initializeScanner(writer.toString());
validateEOF();
@@ -1829,48 +1786,48 @@ public class PortedScannerTests extends PreprocessorTestsBase {
public void testExpressionEvalProblems_2() throws Exception {
Writer writer = new StringWriter();
- writer.write("#define FOO( a, b ) a##b \n");
- writer.write("#if FOO ( 1, 0 ) == 10 \n");
- writer.write("1 \n");
- writer.write("#endif \n");
+ writer.write("#define FOO( a, b ) a##b \n");
+ writer.write("#if FOO ( 1, 0 ) == 10 \n");
+ writer.write("1 \n");
+ writer.write("#endif \n");
initializeScanner(writer.toString());
- validateInteger("1");
+ validateInteger("1");
validateEOF();
validateProblemCount(0);
}
public void testUnExpandedFunctionMacro() throws Exception {
Writer writer = new StringWriter();
- writer.write("#define foo( a ) #a \n");
- writer.write("foo( 1 ) foo \n");
+ writer.write("#define foo( a ) #a \n");
+ writer.write("foo( 1 ) foo \n");
initializeScanner(writer.toString());
- validateString("1");
- validateIdentifier("foo");
+ validateString("1");
+ validateIdentifier("foo");
validateEOF();
}
public void testBug39688A() throws Exception { // test valid IProblems
Writer writer = new StringWriter();
- writer.write("#define decl1(type, ... \\\n ) type var;\n");
- writer.write("decl1(int, x, y, z)\n");
- writer.write("#define decl2(type, args...) type args;");
- writer.write("decl2(int, a, b, c, x, y, z)\n");
- writer.write("#define decl3(type, args...) \\\n type args;");
- writer.write("decl3(int, a, b, c, x, y)\n");
- writer.write("#define decl4(type, args... \\\n ) type args;");
- writer.write("decl4(int, a, b, z)\n");
- writer.write("#define decl5(type, ...) type __VA_ARGS__;");
- writer.write("decl5(int, z)\n");
- writer.write("#define decl6(type, ... \\\n) type __VA_ARGS__;");
- writer.write("decl6(int, a, b, c, x)\n");
- writer.write("#define foo(a) a __VA_ARGS__;\n"); // C99: 6.10.3.5 this should produce an IProblem
- writer.write("#define foo2(a) a #__VA_ARGS__;\n"); // C99: 6.10.3.5 this should produce an IProblem
+ writer.write("#define decl1(type, ... \\\n ) type var;\n");
+ writer.write("decl1(int, x, y, z)\n");
+ writer.write("#define decl2(type, args...) type args;");
+ writer.write("decl2(int, a, b, c, x, y, z)\n");
+ writer.write("#define decl3(type, args...) \\\n type args;");
+ writer.write("decl3(int, a, b, c, x, y)\n");
+ writer.write("#define decl4(type, args... \\\n ) type args;");
+ writer.write("decl4(int, a, b, z)\n");
+ writer.write("#define decl5(type, ...) type __VA_ARGS__;");
+ writer.write("decl5(int, z)\n");
+ writer.write("#define decl6(type, ... \\\n) type __VA_ARGS__;");
+ writer.write("decl6(int, a, b, c, x)\n");
+ writer.write("#define foo(a) a __VA_ARGS__;\n"); // C99: 6.10.3.5 this should produce an IProblem
+ writer.write("#define foo2(a) a #__VA_ARGS__;\n"); // C99: 6.10.3.5 this should produce an IProblem
initializeScanner(writer.toString());
fullyTokenize();
- IASTProblem[] problems= fLocationResolver.getScannerProblems();
+ IASTProblem[] problems = fLocationResolver.getScannerProblems();
assertEquals(2, problems.length);
assertTrue(problems[0].getID() == IProblem.PREPROCESSOR_INVALID_VA_ARGS);
assertTrue(problems[1].getID() == IProblem.PREPROCESSOR_MACRO_PASTING_ERROR);
@@ -1878,69 +1835,69 @@ public class PortedScannerTests extends PreprocessorTestsBase {
public void testBug39688B() throws Exception { // test C99
Writer writer = new StringWriter();
- writer.write("#define debug(...) fprintf(stderr, __VA_ARGS__)\n");
- writer.write("#define showlist(...) puts(#__VA_ARGS__)\n");
- writer.write("#define report(test, ...) ((test)?puts(#test):\\\n printf(__VA_ARGS__))\n");
- writer.write("int main() {\n");
- writer.write("debug(\"Flag\");\n");
- writer.write("debug(\"X = %d\\n\", x);\n");
- writer.write("showlist(The first, second, and third items.);\n");
- writer.write("report(x>y, \"x is %d but y is %d\", x, y);\n");
- writer.write("return 0; }\n");
+ writer.write("#define debug(...) fprintf(stderr, __VA_ARGS__)\n");
+ writer.write("#define showlist(...) puts(#__VA_ARGS__)\n");
+ writer.write("#define report(test, ...) ((test)?puts(#test):\\\n printf(__VA_ARGS__))\n");
+ writer.write("int main() {\n");
+ writer.write("debug(\"Flag\");\n");
+ writer.write("debug(\"X = %d\\n\", x);\n");
+ writer.write("showlist(The first, second, and third items.);\n");
+ writer.write("report(x>y, \"x is %d but y is %d\", x, y);\n");
+ writer.write("return 0; }\n");
initializeScanner(writer.toString());
fullyTokenize();
validateProblemCount(0);
Map<String, IMacroBinding> defs = fScanner.getMacroDefinitions();
- assertTrue(defs.containsKey("debug"));
- assertTrue(defs.containsKey("showlist"));
- assertTrue(defs.containsKey("report"));
- IMacroBinding debug = defs.get("debug");
- assertTrue(new String(debug.getParameterPlaceholderList()[0]).equals("__VA_ARGS__"));
- assertEquals("fprintf(stderr, __VA_ARGS__)", new String(debug.getExpansion()));
-
- IMacroBinding showlist = defs.get("showlist");
- assertTrue(new String(showlist.getParameterPlaceholderList()[0]).equals("__VA_ARGS__"));
- assertTrue(new String(showlist.getExpansion()).equals("puts(#__VA_ARGS__)"));
- IMacroBinding report = defs.get("report");
- assertTrue(new String(report.getParameterPlaceholderList()[0]).equals("test"));
- assertTrue(new String(report.getParameterPlaceholderList()[1]).equals("__VA_ARGS__"));
- assertTrue(new String(report.getExpansion()).equals("((test)?puts(#test): printf(__VA_ARGS__))"));
+ assertTrue(defs.containsKey("debug"));
+ assertTrue(defs.containsKey("showlist"));
+ assertTrue(defs.containsKey("report"));
+ IMacroBinding debug = defs.get("debug");
+ assertTrue(new String(debug.getParameterPlaceholderList()[0]).equals("__VA_ARGS__"));
+ assertEquals("fprintf(stderr, __VA_ARGS__)", new String(debug.getExpansion()));
+
+ IMacroBinding showlist = defs.get("showlist");
+ assertTrue(new String(showlist.getParameterPlaceholderList()[0]).equals("__VA_ARGS__"));
+ assertTrue(new String(showlist.getExpansion()).equals("puts(#__VA_ARGS__)"));
+ IMacroBinding report = defs.get("report");
+ assertTrue(new String(report.getParameterPlaceholderList()[0]).equals("test"));
+ assertTrue(new String(report.getParameterPlaceholderList()[1]).equals("__VA_ARGS__"));
+ assertTrue(new String(report.getExpansion()).equals("((test)?puts(#test): printf(__VA_ARGS__))"));
check39688Tokens(writer);
}
public void testBug39688C() throws Exception { // test GCC
Writer writer = new StringWriter();
- writer.write("#define debug(vars...) fprintf(stderr, vars)\n");
- writer.write("#define showlist(vars...) puts(#vars)\n");
- writer.write("#define report(test, vars...) ((test)?puts(#test):\\\n printf(vars))\n");
- writer.write("int main() {\n");
- writer.write("debug(\"Flag\");\n");
- writer.write("debug(\"X = %d\\n\", x);\n");
- writer.write("showlist(The first, second, and third items.);\n");
- writer.write("report(x>y, \"x is %d but y is %d\", x, y);\n");
- writer.write("return 0; }\n");
+ writer.write("#define debug(vars...) fprintf(stderr, vars)\n");
+ writer.write("#define showlist(vars...) puts(#vars)\n");
+ writer.write("#define report(test, vars...) ((test)?puts(#test):\\\n printf(vars))\n");
+ writer.write("int main() {\n");
+ writer.write("debug(\"Flag\");\n");
+ writer.write("debug(\"X = %d\\n\", x);\n");
+ writer.write("showlist(The first, second, and third items.);\n");
+ writer.write("report(x>y, \"x is %d but y is %d\", x, y);\n");
+ writer.write("return 0; }\n");
initializeScanner(writer.toString());
fullyTokenize();
validateProblemCount(0);
Map defs = fScanner.getMacroDefinitions();
- assertTrue(defs.containsKey("debug"));
- assertTrue(defs.containsKey("showlist"));
- assertTrue(defs.containsKey("report"));
- IMacroBinding debug = (IMacroBinding) defs.get("debug");
- assertTrue(new String(debug.getParameterPlaceholderList()[0]).equals("vars"));
- assertTrue(new String(debug.getExpansion()).equals("fprintf(stderr, vars)"));
- IMacroBinding showlist = (IMacroBinding) defs.get("showlist");
- assertTrue(new String(showlist.getParameterPlaceholderList()[0]).equals("vars"));
- assertTrue(new String(showlist.getExpansion()).equals("puts(#vars)"));
- IMacroBinding report = (IMacroBinding) defs.get("report");
- assertTrue(new String(report.getParameterPlaceholderList()[0]).equals("test"));
- assertTrue(new String(report.getParameterPlaceholderList()[1]).equals("vars"));
- assertTrue(new String(report.getExpansion()).equals("((test)?puts(#test): printf(vars))"));
+ assertTrue(defs.containsKey("debug"));
+ assertTrue(defs.containsKey("showlist"));
+ assertTrue(defs.containsKey("report"));
+ IMacroBinding debug = (IMacroBinding) defs.get("debug");
+ assertTrue(new String(debug.getParameterPlaceholderList()[0]).equals("vars"));
+ assertTrue(new String(debug.getExpansion()).equals("fprintf(stderr, vars)"));
+ IMacroBinding showlist = (IMacroBinding) defs.get("showlist");
+ assertTrue(new String(showlist.getParameterPlaceholderList()[0]).equals("vars"));
+ assertTrue(new String(showlist.getExpansion()).equals("puts(#vars)"));
+ IMacroBinding report = (IMacroBinding) defs.get("report");
+ assertTrue(new String(report.getParameterPlaceholderList()[0]).equals("test"));
+ assertTrue(new String(report.getParameterPlaceholderList()[1]).equals("vars"));
+ assertTrue(new String(report.getExpansion()).equals("((test)?puts(#test): printf(vars))"));
check39688Tokens(writer);
}
@@ -1949,60 +1906,60 @@ public class PortedScannerTests extends PreprocessorTestsBase {
initializeScanner(writer.toString());
validateToken(IToken.t_int);
- validateIdentifier("main");
+ validateIdentifier("main");
validateToken(IToken.tLPAREN);
validateToken(IToken.tRPAREN);
validateToken(IToken.tLBRACE);
- validateIdentifier("fprintf");
+ validateIdentifier("fprintf");
validateToken(IToken.tLPAREN);
- validateIdentifier("stderr");
+ validateIdentifier("stderr");
validateToken(IToken.tCOMMA);
- validateString("Flag");
+ validateString("Flag");
validateToken(IToken.tRPAREN);
validateToken(IToken.tSEMI);
- validateIdentifier("fprintf");
+ validateIdentifier("fprintf");
validateToken(IToken.tLPAREN);
- validateIdentifier("stderr");
+ validateIdentifier("stderr");
validateToken(IToken.tCOMMA);
- validateString("X = %d\\n");
+ validateString("X = %d\\n");
validateToken(IToken.tCOMMA);
- validateIdentifier("x");
+ validateIdentifier("x");
validateToken(IToken.tRPAREN);
validateToken(IToken.tSEMI);
- validateIdentifier("puts");
+ validateIdentifier("puts");
validateToken(IToken.tLPAREN);
- validateString("The first, second, and third items.");
+ validateString("The first, second, and third items.");
validateToken(IToken.tRPAREN);
validateToken(IToken.tSEMI);
validateToken(IToken.tLPAREN);
validateToken(IToken.tLPAREN);
- validateIdentifier("x");
+ validateIdentifier("x");
validateToken(IToken.tGT);
- validateIdentifier("y");
+ validateIdentifier("y");
validateToken(IToken.tRPAREN);
validateToken(IToken.tQUESTION);
- validateIdentifier("puts");
+ validateIdentifier("puts");
validateToken(IToken.tLPAREN);
- validateString("x>y");
+ validateString("x>y");
validateToken(IToken.tRPAREN);
validateToken(IToken.tCOLON);
- validateIdentifier("printf");
+ validateIdentifier("printf");
validateToken(IToken.tLPAREN);
- validateString("x is %d but y is %d");
+ validateString("x is %d but y is %d");
validateToken(IToken.tCOMMA);
- validateIdentifier("x");
+ validateIdentifier("x");
validateToken(IToken.tCOMMA);
- validateIdentifier("y");
+ validateIdentifier("y");
validateToken(IToken.tRPAREN);
validateToken(IToken.tRPAREN);
validateToken(IToken.tSEMI);
validateToken(IToken.t_return);
- validateInteger("0");
+ validateInteger("0");
validateToken(IToken.tSEMI);
validateToken(IToken.tRBRACE);
@@ -2011,27 +1968,27 @@ public class PortedScannerTests extends PreprocessorTestsBase {
public void testMacroArgumentExpansion() throws Exception {
Writer writer = new StringWriter();
- writer.write("#define g_return( expr ) ( expr ) \n");
- writer.write("#define ETH( obj ) ( CHECK( (obj), boo ) ) \n");
- writer.write("#define CHECK CHECK_INSTANCE \n");
- writer.write("#define CHECK_INSTANCE( instance, type ) (foo((instance), (type))) \n");
- writer.write("g_return( ETH(ooga) ) \n");
+ writer.write("#define g_return( expr ) ( expr ) \n");
+ writer.write("#define ETH( obj ) ( CHECK( (obj), boo ) ) \n");
+ writer.write("#define CHECK CHECK_INSTANCE \n");
+ writer.write("#define CHECK_INSTANCE( instance, type ) (foo((instance), (type))) \n");
+ writer.write("g_return( ETH(ooga) ) \n");
initializeScanner(writer.toString());
validateToken(IToken.tLPAREN);
validateToken(IToken.tLPAREN);
validateToken(IToken.tLPAREN);
- validateIdentifier("foo");
+ validateIdentifier("foo");
validateToken(IToken.tLPAREN);
validateToken(IToken.tLPAREN);
validateToken(IToken.tLPAREN);
- validateIdentifier("ooga");
+ validateIdentifier("ooga");
validateToken(IToken.tRPAREN);
validateToken(IToken.tRPAREN);
validateToken(IToken.tCOMMA);
validateToken(IToken.tLPAREN);
- validateIdentifier("boo");
+ validateIdentifier("boo");
validateToken(IToken.tRPAREN);
validateToken(IToken.tRPAREN);
validateToken(IToken.tRPAREN);
@@ -2041,150 +1998,150 @@ public class PortedScannerTests extends PreprocessorTestsBase {
public void testBug75956() throws Exception {
Writer writer = new StringWriter();
- writer.write("#define ROPE( name ) name##Alloc\n");
- writer.write("#define _C 040 \n");
- writer.write("ROPE( _C ) \n");
+ writer.write("#define ROPE( name ) name##Alloc\n");
+ writer.write("#define _C 040 \n");
+ writer.write("ROPE( _C ) \n");
initializeScanner(writer.toString());
- validateIdentifier("_CAlloc");
+ validateIdentifier("_CAlloc");
validateEOF();
writer = new StringWriter();
- writer.write("#define ROPE( name ) Alloc ## name \n");
- writer.write("#define _C 040 \n");
- writer.write("ROPE( _C ) \n");
+ writer.write("#define ROPE( name ) Alloc ## name \n");
+ writer.write("#define _C 040 \n");
+ writer.write("ROPE( _C ) \n");
initializeScanner(writer.toString());
- validateIdentifier("Alloc_C");
+ validateIdentifier("Alloc_C");
validateEOF();
writer = new StringWriter();
- writer.write("#define ROPE( name ) name##Alloc\n");
- writer.write("#define _C 040 \n");
- writer.write("#define _CAlloc ooga \n");
- writer.write("ROPE( _C ) \n");
+ writer.write("#define ROPE( name ) name##Alloc\n");
+ writer.write("#define _C 040 \n");
+ writer.write("#define _CAlloc ooga \n");
+ writer.write("ROPE( _C ) \n");
initializeScanner(writer.toString());
- validateIdentifier("ooga");
+ validateIdentifier("ooga");
validateEOF();
}
public void testUnExpandedFunctionMacros() throws Exception {
Writer writer = new StringWriter();
- writer.write("#define ETH(x) x \n");
- writer.write("#define E ETH \n");
- writer.write("ETH( c ), ETH, E; \n");
+ writer.write("#define ETH(x) x \n");
+ writer.write("#define E ETH \n");
+ writer.write("ETH( c ), ETH, E; \n");
initializeScanner(writer.toString());
- validateIdentifier("c");
+ validateIdentifier("c");
validateToken(IToken.tCOMMA);
- validateIdentifier("ETH");
+ validateIdentifier("ETH");
validateToken(IToken.tCOMMA);
- validateIdentifier("ETH");
+ validateIdentifier("ETH");
validateToken(IToken.tSEMI);
validateEOF();
}
public void testBug79490A() throws Exception {
Writer writer = new StringWriter();
- writer.write("#define TEST 'n'\n");
- writer.write("#if TEST == 'y'\n");
- writer.write("#define TRUE 1\n");
- writer.write("#else\n");
- writer.write("#define FALSE 1\n");
- writer.write("#endif\n");
+ writer.write("#define TEST 'n'\n");
+ writer.write("#if TEST == 'y'\n");
+ writer.write("#define TRUE 1\n");
+ writer.write("#else\n");
+ writer.write("#define FALSE 1\n");
+ writer.write("#endif\n");
initializeScanner(writer.toString());
validateEOF();
- validateDefinition("TEST", "'n'");
- validateDefinition("FALSE", "1");
+ validateDefinition("TEST", "'n'");
+ validateDefinition("FALSE", "1");
}
public void testBug79490B() throws Exception {
Writer writer = new StringWriter();
- writer.write("#define TEST 'y'\n");
- writer.write("#if TEST == 'y'\n");
- writer.write("#define TRUE 1\n");
- writer.write("#else\n");
- writer.write("#define FALSE 1\n");
- writer.write("#endif\n");
+ writer.write("#define TEST 'y'\n");
+ writer.write("#if TEST == 'y'\n");
+ writer.write("#define TRUE 1\n");
+ writer.write("#else\n");
+ writer.write("#define FALSE 1\n");
+ writer.write("#endif\n");
initializeScanner(writer.toString());
validateEOF();
- validateDefinition("TEST", "'y'");
- validateDefinition("TRUE", "1");
+ validateDefinition("TEST", "'y'");
+ validateDefinition("TRUE", "1");
}
public void testBug102568A() throws Exception {
- initializeScanner("///*\r\nint x;\r\n");
+ initializeScanner("///*\r\nint x;\r\n");
validateToken(IToken.t_int);
- validateIdentifier("x");
+ validateIdentifier("x");
validateToken(IToken.tSEMI);
validateEOF();
}
public void testBug102568B() throws Exception {
- initializeScanner("// bla some thing /* ... \r\nint x;\r\n");
+ initializeScanner("// bla some thing /* ... \r\nint x;\r\n");
validateToken(IToken.t_int);
- validateIdentifier("x");
+ validateIdentifier("x");
validateToken(IToken.tSEMI);
validateEOF();
}
public void testbug84270() throws Exception {
Writer writer = new StringWriter();
- writer.write("#define h g( ~\n");
- writer.write("#define g f\n");
- writer.write("#define f(a) f(x * (a))\n");
- writer.write("h 5) \n");
+ writer.write("#define h g( ~\n");
+ writer.write("#define g f\n");
+ writer.write("#define f(a) f(x * (a))\n");
+ writer.write("h 5) \n");
initializeScanner(writer.toString());
fullyTokenize();
}
public void testBug107150() throws Exception {
Writer writer = new StringWriter();
- writer.write("#define FUNC_PROTOTYPE_PARAMS(list) list\r\n");
- writer.write("int func2 FUNC_PROTOTYPE_PARAMS\r\n");
- writer.write("((int arg1)){\r\n");
- writer.write(" return 0;\r\n");
- writer.write("}\r\n");
+ writer.write("#define FUNC_PROTOTYPE_PARAMS(list) list\r\n");
+ writer.write("int func2 FUNC_PROTOTYPE_PARAMS\r\n");
+ writer.write("((int arg1)){\r\n");
+ writer.write(" return 0;\r\n");
+ writer.write("}\r\n");
initializeScanner(writer.toString());
validateToken(IToken.t_int);
- validateIdentifier("func2");
+ validateIdentifier("func2");
validateToken(IToken.tLPAREN);
validateToken(IToken.t_int);
- validateIdentifier("arg1");
+ validateIdentifier("arg1");
validateToken(IToken.tRPAREN);
validateToken(IToken.tLBRACE);
validateToken(IToken.t_return);
- validateInteger("0");
+ validateInteger("0");
validateToken(IToken.tSEMI);
validateToken(IToken.tRBRACE);
validateEOF();
writer = new StringWriter();
- writer.write("#define FUNC_PROTOTYPE_PARAMS(list) list\n");
- writer.write("int func2 FUNC_PROTOTYPE_PARAMS\n");
- writer.write("((int arg1)){\n");
- writer.write(" return 0;\n");
- writer.write("}\n");
+ writer.write("#define FUNC_PROTOTYPE_PARAMS(list) list\n");
+ writer.write("int func2 FUNC_PROTOTYPE_PARAMS\n");
+ writer.write("((int arg1)){\n");
+ writer.write(" return 0;\n");
+ writer.write("}\n");
initializeScanner(writer.toString());
validateToken(IToken.t_int);
- validateIdentifier("func2");
+ validateIdentifier("func2");
validateToken(IToken.tLPAREN);
validateToken(IToken.t_int);
- validateIdentifier("arg1");
+ validateIdentifier("arg1");
validateToken(IToken.tRPAREN);
validateToken(IToken.tLBRACE);
validateToken(IToken.t_return);
- validateInteger("0");
+ validateInteger("0");
validateToken(IToken.tSEMI);
validateToken(IToken.tRBRACE);
validateEOF();
}
public void testBug126136() throws Exception {
- StringBuilder buffer = new StringBuilder("#define C C\n");
- buffer.append("#if !C\n");
- buffer.append("true\n");
- buffer.append("#endif\n");
+ StringBuilder buffer = new StringBuilder("#define C C\n");
+ buffer.append("#if !C\n");
+ buffer.append("true\n");
+ buffer.append("#endif\n");
initializeScanner(buffer.toString(), ParserLanguage.CPP);
fullyTokenize();
}
@@ -2289,8 +2246,7 @@ public class PortedScannerTests extends PreprocessorTestsBase {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=182180
public void testBug182180_1() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append("#ifdef _bug_182180_\n").append(
- "printf(\"Hello World /*.ap\\n\");\n").append("#endif\n")
+ buffer.append("#ifdef _bug_182180_\n").append("printf(\"Hello World /*.ap\\n\");\n").append("#endif\n")
.append("bug182180\n");
initializeScanner(buffer.toString());
validateIdentifier("bug182180");
@@ -2299,9 +2255,8 @@ public class PortedScannerTests extends PreprocessorTestsBase {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=182180
public void testBug182180_2() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append("#ifdef _bug_182180_\n").append(
- "char c='\"'; printf(\"Hello World /*.ap\\n\");\n").append(
- "#endif\n").append("bug182180\n");
+ buffer.append("#ifdef _bug_182180_\n").append("char c='\"'; printf(\"Hello World /*.ap\\n\");\n")
+ .append("#endif\n").append("bug182180\n");
initializeScanner(buffer.toString());
validateIdentifier("bug182180");
}
@@ -2309,8 +2264,7 @@ public class PortedScannerTests extends PreprocessorTestsBase {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=182180
public void testBug182180_3() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append("#ifdef _bug_182180_\n").append(
- "char c1='\\'',c2='\\\"'; printf(\"Hello World /*.ap\\n\");\n")
+ buffer.append("#ifdef _bug_182180_\n").append("char c1='\\'',c2='\\\"'; printf(\"Hello World /*.ap\\n\");\n")
.append("#endif\n").append("bug182180\n");
initializeScanner(buffer.toString());
validateIdentifier("bug182180");
@@ -2319,8 +2273,7 @@ public class PortedScannerTests extends PreprocessorTestsBase {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=182180
public void testBug182180_4() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append("#ifdef _bug_182180_\n").append(
- "printf(\"Hello '\"'World /*.ap\\n\");\n").append("#endif\n")
+ buffer.append("#ifdef _bug_182180_\n").append("printf(\"Hello '\"'World /*.ap\\n\");\n").append("#endif\n")
.append("bug182180\n");
initializeScanner(buffer.toString());
validateIdentifier("bug182180");
@@ -2329,8 +2282,7 @@ public class PortedScannerTests extends PreprocessorTestsBase {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=182180
public void testBug182180_5() throws Exception {
StringBuilder buffer = new StringBuilder();
- buffer.append("#ifdef _bug_182180_\n").append(
- "printf(\"Hello \\\"World /*.ap\\n\");\n").append("#endif\n")
+ buffer.append("#ifdef _bug_182180_\n").append("printf(\"Hello \\\"World /*.ap\\n\");\n").append("#endif\n")
.append("bug182180\n");
initializeScanner(buffer.toString());
validateIdentifier("bug182180");
@@ -2415,31 +2367,29 @@ public class PortedScannerTests extends PreprocessorTestsBase {
initializeScanner(buffer.toString());
validateToken(IToken.tPLUS);
}
-
- public void testBug39698() throws Exception {
- initializeScanner( "<? >?");
- validateToken( IGCCToken.tMIN );
- validateToken( IGCCToken.tMAX );
- validateEOF();
- }
-
- public void test__attribute__() throws Exception {
- initializeScanner(
- "#define __cdecl __attribute__((cdecl))\n" +
- "__cdecl;");
- validateToken(IGCCToken.t__attribute__);
- validateToken(IToken.tLPAREN);
- validateToken(IToken.tLPAREN);
- validateToken(IToken.tIDENTIFIER);
- validateToken(IToken.tRPAREN);
- validateToken(IToken.tRPAREN);
- validateToken(IToken.tSEMI);
- validateEOF();
- }
-
- public void testImaginary() throws Exception {
- initializeScanner("3i", ParserLanguage.C);
- validateInteger("3i");
- validateEOF();
- }
+
+ public void testBug39698() throws Exception {
+ initializeScanner("<? >?");
+ validateToken(IGCCToken.tMIN);
+ validateToken(IGCCToken.tMAX);
+ validateEOF();
+ }
+
+ public void test__attribute__() throws Exception {
+ initializeScanner("#define __cdecl __attribute__((cdecl))\n" + "__cdecl;");
+ validateToken(IGCCToken.t__attribute__);
+ validateToken(IToken.tLPAREN);
+ validateToken(IToken.tLPAREN);
+ validateToken(IToken.tIDENTIFIER);
+ validateToken(IToken.tRPAREN);
+ validateToken(IToken.tRPAREN);
+ validateToken(IToken.tSEMI);
+ validateEOF();
+ }
+
+ public void testImaginary() throws Exception {
+ initializeScanner("3i", ParserLanguage.C);
+ validateInteger("3i");
+ validateEOF();
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorBugsTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorBugsTests.java
index 3dcbd0a5399..d4e941348ba 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorBugsTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorBugsTests.java
@@ -20,13 +20,12 @@ import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
-
/**
- * Scanner2Tests ported to use the CPreprocessor plus additional bugs fixed in
+ * Scanner2Tests ported to use the CPreprocessor plus additional bugs fixed in
* the CPreprocessor, afterwards.
*/
public class PreprocessorBugsTests extends PreprocessorTestsBase {
-
+
public static TestSuite suite() {
return suite(PreprocessorBugsTests.class);
}
@@ -40,7 +39,7 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
validateProblem(0, IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND, "<regxag4.sfr>");
validateProblemCount(1);
}
-
+
// #define FUNKY(x) __##x##__
// #define __foo__ 127
//
@@ -56,7 +55,7 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
validateEOF();
validateProblemCount(0);
}
-
+
// #ifndef PREFIX
// #define PREFIX
// #endif
@@ -71,17 +70,17 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
validateProblem(0, IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND, "\"bar.h\"");
validateProblemCount(1);
}
-
+
// #define D
- // #if defined D
+ // #if defined D
// x;
- // #endif
- // #if defined(D)
+ // #endif
+ // #if defined(D)
// y;
- // #endif
+ // #endif
public void testBug186047() throws Exception {
initializeScanner();
-
+
validateIdentifier("x");
validateToken(IToken.tSEMI);
validateIdentifier("y");
@@ -89,7 +88,7 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
validateEOF();
validateProblemCount(0);
}
-
+
// __CDT_PARSER__
public void testPredefinedCDTMacro_Bug173848() throws Exception {
initializeScanner();
@@ -97,7 +96,7 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
validateEOF();
validateProblemCount(0);
}
-
+
// #define FOO(ARG) defined(ARG##_BAZ)
// #define BAR_BAZ UNDEFINED
// #if FOO(BAR)
@@ -109,11 +108,10 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
//
// #define PLATFORM(WTF_FEATURE) (defined( WTF_PLATFORM_##WTF_FEATURE ) && WTF_PLATFORM_##WTF_FEATURE)
// #define WTF_PLATFORM_FOO 1
- // #if PLATFORM(FOO)
+ // #if PLATFORM(FOO)
// ok
// #endif
-
public void testIndirectDefined_Bug225562() throws Exception {
initializeScanner();
validateIdentifier("juhuu");
@@ -121,12 +119,12 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
validateToken(IToken.tLPAREN);
validateIdentifier("UNDEFINED"); // here the expansion has to take place
validateToken(IToken.tRPAREN);
-
+
validateIdentifier("ok");
validateEOF();
validateProblemCount(0);
}
-
+
// "unintentionally unbounded
// "
//
@@ -136,7 +134,7 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
validateEOF();
validateProblemCount(2);
}
-
+
// #if true
// yes
// #else
@@ -170,10 +168,10 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
validateProblemCount(1);
validateProblem(0, IProblem.SCANNER_EXPRESSION_SYNTAX_ERROR, null);
}
-
+
// #define BAR1_RX_BLOCK_SIZE 1
// #define MAX(__x,__y) ((__x)>(__y)?(__x):(__y))
- // #define BAR_BLOCK_SIZE (MAX(BAR1_RX_BLOCK_SIZE,
+ // #define BAR_BLOCK_SIZE (MAX(BAR1_RX_BLOCK_SIZE,
// int main(void) {
// BAR_BLOCK_SIZE;
// }
@@ -236,11 +234,11 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
validateEOF();
validateProblemCount(0);
}
-
+
// #define ID(x) x
// ID(
// #include "bbb"
- // )
+ // )
// passed1
//
// ID(
@@ -264,9 +262,9 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
validateIdentifier("passed2");
validateIdentifier("passed3");
validateEOF();
- validateProblemCount(2); // the inclusions
+ validateProblemCount(2); // the inclusions
}
-
+
// #define UNFOLD(v,x) v:x
// UNFOLD("A",
// #ifdef X
@@ -280,7 +278,7 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
validateToken(IToken.tCOLON);
validateString("C");
validateEOF();
- validateProblemCount(0);
+ validateProblemCount(0);
}
// #if 0xe000
@@ -293,11 +291,11 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
validateFloatingPointLiteral("0x1p2");
validateInteger("0xe0");
validateEOF();
- validateProblemCount(0);
+ validateProblemCount(0);
}
-
- // #error //
- // #warning //
+
+ // #error //
+ // #warning //
// #pragma // not marked as problem
// #define //
// #include //
@@ -316,9 +314,9 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
initializeScanner();
validateIdentifier("a");
validateEOF();
- validateProblemCount(9);
+ validateProblemCount(9);
}
-
+
// #define str(x) #x
// #define xstr(x) str(x)
// #define MY_MACROS(Type) unsigned ##Type f();
@@ -328,7 +326,7 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
validateString("unsignedint f();");
validateEOF();
}
-
+
// #if '\0'
// no
// #else
@@ -346,7 +344,7 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
validateEOF();
validateProblemCount(0);
}
-
+
// #define foo(x) (## x)
// void test foo(void); // Valid for Microsoft's compiler, expands to (void)
public void testInvalidTokenPasting_Bug354553() throws Exception {
@@ -361,7 +359,7 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
validateProblem(0, IProblem.PREPROCESSOR_MACRO_PASTING_ERROR, "foo");
validateProblemCount(1);
}
-
+
// #define PR ""
// A
// #ifdef _DEBUG
@@ -374,7 +372,7 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
validateIdentifier("B");
validateProblemCount(0);
}
-
+
// __COUNTER__
// __COUNTER__
public void testCounter_Bug362148() throws Exception {
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorSpeedTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorSpeedTest.java
index d49f06141a9..4b82b3b4ee5 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorSpeedTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorSpeedTest.java
@@ -33,8 +33,8 @@ import org.eclipse.cdt.core.parser.ScannerInfo;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit;
import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
-public class PreprocessorSpeedTest {
-
+public class PreprocessorSpeedTest {
+
private PrintStream stream;
public static void main(String[] args) {
@@ -57,13 +57,10 @@ public class PreprocessorSpeedTest {
this.stream = stream;
runTest(n);
}
-
+
private void runTest(int n) throws Exception {
- String code =
- "#include <windows.h>\n" +
- "#include <stdio.h>\n" +
- "#include <iostream>\n";
-
+ String code = "#include <windows.h>\n" + "#include <stdio.h>\n" + "#include <iostream>\n";
+
FileContent reader = FileContent.create("<test-code>", code.toCharArray());
IScannerInfo info = getScannerInfo();
long totalTime = 0;
@@ -72,48 +69,47 @@ public class PreprocessorSpeedTest {
if (i > 0)
totalTime += time;
}
-
+
if (n > 1) {
System.out.println("Average Time: " + (totalTime / (n - 1)) + " millisecs");
}
}
- protected long testScan(FileContent reader, boolean quick, IScannerInfo info, ParserLanguage lang) throws Exception {
- FileCodeReaderFactory readerFactory= FileCodeReaderFactory.getInstance();
+ protected long testScan(FileContent reader, boolean quick, IScannerInfo info, ParserLanguage lang)
+ throws Exception {
+ FileCodeReaderFactory readerFactory = FileCodeReaderFactory.getInstance();
IScannerExtensionConfiguration scannerConfig;
- if (lang == ParserLanguage.C) {
- scannerConfig= GCCScannerExtensionConfiguration.getInstance();
- }
- else {
- scannerConfig= GPPScannerExtensionConfiguration.getInstance(info);
- }
+ if (lang == ParserLanguage.C) {
+ scannerConfig = GCCScannerExtensionConfiguration.getInstance();
+ } else {
+ scannerConfig = GPPScannerExtensionConfiguration.getInstance(info);
+ }
ParserMode mode = ParserMode.COMPLETE_PARSE;
- CPreprocessor cpp= new CPreprocessor(reader, info, lang, new NullLogService(), scannerConfig, readerFactory);
+ CPreprocessor cpp = new CPreprocessor(reader, info, lang, new NullLogService(), scannerConfig, readerFactory);
cpp.getLocationMap().setRootNode(new CPPASTTranslationUnit());
long startTime = System.currentTimeMillis();
int count = 0;
try {
while (true) {
- IToken t = cpp.nextToken();
-
- if (stream != null)
- stream.println(t.getImage());
-
- if (t == null)
- break;
- ++count;
-
+ IToken t = cpp.nextToken();
+
+ if (stream != null)
+ stream.println(t.getImage());
+
+ if (t == null)
+ break;
+ ++count;
+
}
} catch (EndOfFileException e2) {
}
long totalTime = System.currentTimeMillis() - startTime;
- System.out.println( "Resulting scan took " + totalTime + " millisecs " +
- count + " tokens");
+ System.out.println("Resulting scan took " + totalTime + " millisecs " + count + " tokens");
return totalTime;
}
-
+
protected IScannerInfo getScannerInfo() {
- String config = System.getProperty("speedTest.config");
+ String config = System.getProperty("speedTest.config");
if (config == null)
return mingwScannerInfo();
@@ -231,21 +227,17 @@ public class PreprocessorSpeedTest {
Map definitions = new Hashtable();
//definitions.put( "__GNUC__", "3" ); //$NON-NLS-1$ //$NON-NLS-2$
- String [] includePaths = new String[] {
- "C:\\Program Files\\Microsoft SDK\\Include",
- "C:\\Program Files\\Microsoft Visual C++ Toolkit 2003\\include"
- };
- return new ScannerInfo( definitions, includePaths );
+ String[] includePaths = new String[] { "C:\\Program Files\\Microsoft SDK\\Include",
+ "C:\\Program Files\\Microsoft Visual C++ Toolkit 2003\\include" };
+ return new ScannerInfo(definitions, includePaths);
}
protected IScannerInfo msvc98ScannerInfo() {
Map definitions = new Hashtable();
- String [] includePaths = new String[] {
- "C:\\Program Files\\Microsoft Visual Studio\\VC98\\Include"
- };
- return new ScannerInfo( definitions, includePaths );
+ String[] includePaths = new String[] { "C:\\Program Files\\Microsoft Visual Studio\\VC98\\Include" };
+ return new ScannerInfo(definitions, includePaths);
}
-
+
protected IScannerInfo mingwScannerInfo() {
// TODO It would be easier and more flexible if we used discovery for this
Map definitions = new Hashtable();
@@ -278,16 +270,12 @@ public class PreprocessorSpeedTest {
definitions.put("__declspec(x)", "__attribute__((x))");
definitions.put("__DEPRECATED", "");
definitions.put("__EXCEPTIONS", "");
-
- String [] includePaths = new String[] {
- "c:/mingw/include/c++/3.2.3",
- "c:/mingw/include/c++/3.2.3/mingw32",
- "c:/mingw/include/c++/3.2.3/backward",
- "c:/mingw/include",
- "c:/mingw/lib/gcc-lib/mingw32/3.2.3/include"
- };
- return new ScannerInfo( definitions, includePaths );
+ String[] includePaths = new String[] { "c:/mingw/include/c++/3.2.3", "c:/mingw/include/c++/3.2.3/mingw32",
+ "c:/mingw/include/c++/3.2.3/backward", "c:/mingw/include",
+ "c:/mingw/lib/gcc-lib/mingw32/3.2.3/include" };
+
+ return new ScannerInfo(definitions, includePaths);
}
protected IScannerInfo ydlScannerInfo() {
@@ -305,17 +293,12 @@ public class PreprocessorSpeedTest {
definitions.put("linux", "");
definitions.put("__linux", "");
definitions.put("__GNUG__", "3");
-
- String [] includePaths = new String[] {
- "/usr/include/g++",
- "/usr/include/g++/powerpc-yellowdog-linux",
- "/usr/include/g++/backward",
- "/usr/local/include",
- "/usr/lib/gcc-lib/powerpc-yellowdog-linux/3.3.3/include",
- "/usr/include"
- };
- return new ScannerInfo( definitions, includePaths );
+ String[] includePaths = new String[] { "/usr/include/g++", "/usr/include/g++/powerpc-yellowdog-linux",
+ "/usr/include/g++/backward", "/usr/local/include",
+ "/usr/lib/gcc-lib/powerpc-yellowdog-linux/3.3.3/include", "/usr/include" };
+
+ return new ScannerInfo(definitions, includePaths);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTests.java
index 71255c6b75b..c7cb3b143ce 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTests.java
@@ -487,11 +487,11 @@ public class PreprocessorTests extends PreprocessorTestsBase {
validateProblemCount(0);
}
- // #define ONE(a, ...) int x
- // #define TWO(b, args...) int y
- // ONE("string");
- // TWO("string");
- public void testSkippingVarags() throws Exception {
+ // #define ONE(a, ...) int x
+ // #define TWO(b, args...) int y
+ // ONE("string");
+ // TWO("string");
+ public void testSkippingVarags() throws Exception {
initializeScanner();
validateToken(IToken.t_int);
validateIdentifier("x");
@@ -503,12 +503,12 @@ public class PreprocessorTests extends PreprocessorTestsBase {
validateEOF();
validateProblemCount(0);
- }
+ }
- // #define eval(f,x) f(x)
- // #define m(x) m[x]
- // eval(m,y);
- public void testReconsiderArgsForExpansion() throws Exception {
+ // #define eval(f,x) f(x)
+ // #define m(x) m[x]
+ // eval(m,y);
+ public void testReconsiderArgsForExpansion() throws Exception {
initializeScanner();
validateIdentifier("m");
validateToken(IToken.tLBRACKET);
@@ -518,38 +518,38 @@ public class PreprocessorTests extends PreprocessorTestsBase {
validateEOF();
validateProblemCount(0);
- }
+ }
- //#define f\
- //(x) ok
- // f(x)
- public void testLineSpliceInMacroDefinition() throws Exception {
+ //#define f\
+ //(x) ok
+ // f(x)
+ public void testLineSpliceInMacroDefinition() throws Exception {
initializeScanner();
validateIdentifier("ok");
validateEOF();
validateProblemCount(0);
- }
-
- // #define f() fval
- // #define nospace f()f()
- // #define space f() f()
- // #define str(x) #x
- // #define xstr(x) str(x)
- // #define tp1(x,y,z) [x ## y ## z]
- // #define tp2(x,y,z) [ x ## y ## z ]
- // #define tstr1(x,y) [#x#y]
- // #define tstr2(x,y) [ #x #y ]
- // #define spaceBeforeStr(x) a #x b
- // xstr(nospace);
- // xstr(space);
- // xstr(tp1(a b, c d , e f));
- // xstr(tp2(a b, c d , e f));
- // xstr(tp1(a-b, c-d , e-f));
- // xstr(tp2(a-b, c-d , e-f));
- // xstr(tstr1(a b, c d));
- // xstr(tstr2(a b, c d));
- // xstr(spaceBeforeStr(c));
- public void testSpaceInStringify() throws Exception {
+ }
+
+ // #define f() fval
+ // #define nospace f()f()
+ // #define space f() f()
+ // #define str(x) #x
+ // #define xstr(x) str(x)
+ // #define tp1(x,y,z) [x ## y ## z]
+ // #define tp2(x,y,z) [ x ## y ## z ]
+ // #define tstr1(x,y) [#x#y]
+ // #define tstr2(x,y) [ #x #y ]
+ // #define spaceBeforeStr(x) a #x b
+ // xstr(nospace);
+ // xstr(space);
+ // xstr(tp1(a b, c d , e f));
+ // xstr(tp2(a b, c d , e f));
+ // xstr(tp1(a-b, c-d , e-f));
+ // xstr(tp2(a-b, c-d , e-f));
+ // xstr(tstr1(a b, c d));
+ // xstr(tstr2(a b, c d));
+ // xstr(spaceBeforeStr(c));
+ public void testSpaceInStringify() throws Exception {
initializeScanner();
validateString("fvalfval");
validateToken(IToken.tSEMI);
@@ -580,17 +580,17 @@ public class PreprocessorTests extends PreprocessorTestsBase {
validateEOF();
validateProblemCount(0);
- }
-
- // #define empty
- // #define paste1(y) x##y z
- // #define paste2(x) x##empty z
- // paste1();
- // paste1(empty);
- // paste2();
- // paste2(empty);
- // paste2(a);
- public void testTokenPasteWithEmptyParam() throws Exception {
+ }
+
+ // #define empty
+ // #define paste1(y) x##y z
+ // #define paste2(x) x##empty z
+ // paste1();
+ // paste1(empty);
+ // paste2();
+ // paste2(empty);
+ // paste2(a);
+ public void testTokenPasteWithEmptyParam() throws Exception {
initializeScanner();
validateIdentifier("x");
validateIdentifier("z");
@@ -613,17 +613,17 @@ public class PreprocessorTests extends PreprocessorTestsBase {
validateEOF();
validateProblemCount(0);
- }
-
- // #define empty
- // #define paste1(y) x##y z
- // #define paste2(x) x##empty z
- // paste1();
- // paste1(empty);
- // paste2();
- // paste2(empty);
- // paste2(a);
- public void testSpacesBeforeStringify() throws Exception {
+ }
+
+ // #define empty
+ // #define paste1(y) x##y z
+ // #define paste2(x) x##empty z
+ // paste1();
+ // paste1(empty);
+ // paste2();
+ // paste2(empty);
+ // paste2(a);
+ public void testSpacesBeforeStringify() throws Exception {
initializeScanner();
validateIdentifier("x");
validateIdentifier("z");
@@ -646,13 +646,13 @@ public class PreprocessorTests extends PreprocessorTestsBase {
validateEOF();
validateProblemCount(0);
- }
+ }
- // #define paste(x,y,z) x##y##z
- // paste(a,b,c);
- // paste(1,2,3);
- public void testTokenPasteChain() throws Exception {
- initializeScanner();
+ // #define paste(x,y,z) x##y##z
+ // paste(a,b,c);
+ // paste(1,2,3);
+ public void testTokenPasteChain() throws Exception {
+ initializeScanner();
validateIdentifier("abc");
validateToken(IToken.tSEMI);
@@ -661,38 +661,38 @@ public class PreprocessorTests extends PreprocessorTestsBase {
validateEOF();
validateProblemCount(0);
- }
+ }
// #define A(x,y,z) x + y + z
// #define _t t
// A ( _t , , _t )
- public void testEmptyToken() throws Exception {
- initializeScanner();
- validateIdentifier("t");
+ public void testEmptyToken() throws Exception {
+ initializeScanner();
+ validateIdentifier("t");
validateToken(IToken.tPLUS);
validateToken(IToken.tPLUS);
- validateIdentifier("t");
- }
-
- // #define FOO 5
- // # define BAR 10
- // int x = FOO + BAR;
- public void testSimpleObjectLike1() throws Exception {
- initializeScanner();
- validateToken(IToken.t_int);
- validateIdentifier("x");
- validateToken(IToken.tASSIGN);
- validateInteger("5");
- validateToken(IToken.tPLUS);
- validateInteger("10");
- validateToken(IToken.tSEMI);
- validateEOF();
+ validateIdentifier("t");
+ }
+
+ // #define FOO 5
+ // # define BAR 10
+ // int x = FOO + BAR;
+ public void testSimpleObjectLike1() throws Exception {
+ initializeScanner();
+ validateToken(IToken.t_int);
+ validateIdentifier("x");
+ validateToken(IToken.tASSIGN);
+ validateInteger("5");
+ validateToken(IToken.tPLUS);
+ validateInteger("10");
+ validateToken(IToken.tSEMI);
+ validateEOF();
validateProblemCount(0);
}
- // #define FOO BAR
- // # define BAR 10
- // int x = BAR;
+ // #define FOO BAR
+ // # define BAR 10
+ // int x = BAR;
public void testSimpleObjectLike2() throws Exception {
initializeScanner();
validateToken(IToken.t_int);
@@ -829,24 +829,13 @@ public class PreprocessorTests extends PreprocessorTestsBase {
}
private static StringBuffer getExample3Defines() {
- return new StringBuffer()
- .append("#define x 3 \n")
- .append("#define f(a) f(x * (a)) \n")
- .append("#undef x \n")
- .append("#define x 2 \n")
- .append("#define g f \n")
- .append("#define z z[0] \n")
- .append("#define h g(~ \n")
- .append("#define m(a) a(w) \n")
- .append("#define w 0,1 \n")
- .append("#define t(a) a \n")
- .append("#define p() int \n")
- .append("#define q(x) x \n")
- .append("#define r(x,y) x ## y \n")
- .append("#define str(x) # x \n");
+ return new StringBuffer().append("#define x 3 \n").append("#define f(a) f(x * (a)) \n").append("#undef x \n")
+ .append("#define x 2 \n").append("#define g f \n").append("#define z z[0] \n")
+ .append("#define h g(~ \n").append("#define m(a) a(w) \n").append("#define w 0,1 \n")
+ .append("#define t(a) a \n").append("#define p() int \n").append("#define q(x) x \n")
+ .append("#define r(x,y) x ## y \n").append("#define str(x) # x \n");
}
-
public void testSpecExample3_1() throws Exception {
StringBuffer sb = getExample3Defines();
sb.append("f(y+1) + f(f(z)) % t(t(g)(0) + t)(1); \n");
@@ -960,7 +949,6 @@ public class PreprocessorTests extends PreprocessorTestsBase {
validateProblemCount(0);
}
-
public void testSpecExample3_3() throws Exception {
StringBuffer sb = getExample3Defines();
sb.append("p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) }; \n");
@@ -990,7 +978,7 @@ public class PreprocessorTests extends PreprocessorTestsBase {
public void testSpecExample3_4() throws Exception {
StringBuffer sb = getExample3Defines();
- sb.append("char c[2][6] = { str(hello), str() }; \n"); //31
+ sb.append("char c[2][6] = { str(hello), str() }; \n"); //31
// char c[2][6] = { "hello", "" }; //15
initializeScanner(sb.toString());
@@ -1015,21 +1003,16 @@ public class PreprocessorTests extends PreprocessorTestsBase {
}
private static StringBuffer getExample4Defines() {
- return new StringBuffer()
- .append("#define str(s) # s \n")
- .append("#define xstr(s) str(s) \n")
- .append("#define debug(s, t) printf(\"x\" # s \"= %d, x\" # t \"= %s\", \\ \n")
- .append("x ## s, x ## t) \n")
- .append("#define INCFILE(n) vers ## n \n")
- .append("#define glue(a, b) a ## b \n")
- .append("#define xglue(a, b) glue(a, b) \n")
- .append("#define HIGHLOW \"hello\" \n")
- .append("#define LOW LOW \", world\" \n");
+ return new StringBuffer().append("#define str(s) # s \n").append("#define xstr(s) str(s) \n")
+ .append("#define debug(s, t) printf(\"x\" # s \"= %d, x\" # t \"= %s\", \\ \n")
+ .append("x ## s, x ## t) \n").append("#define INCFILE(n) vers ## n \n")
+ .append("#define glue(a, b) a ## b \n").append("#define xglue(a, b) glue(a, b) \n")
+ .append("#define HIGHLOW \"hello\" \n").append("#define LOW LOW \", world\" \n");
}
public void testSpecExample4_1() throws Exception {
StringBuffer sb = getExample4Defines();
- sb.append("debug(1, 2); \n"); //31
+ sb.append("debug(1, 2); \n"); //31
// printf("x1= %d, x2= %s", x1, x2); // 9
initializeScanner(sb.toString());
@@ -1124,11 +1107,9 @@ public class PreprocessorTests extends PreprocessorTestsBase {
}
public StringBuffer getExample7Defines() {
- return new StringBuffer()
- .append("#define debug(...) fprintf(stderr, __VA_ARGS__) \n ")
- .append("#define showlist(...) puts(#__VA_ARGS__)\n ")
- .append("#define report(test, ...) ((test)?puts(#test):\\ \n ")
- .append("printf(__VA_ARGS__)) \n ");
+ return new StringBuffer().append("#define debug(...) fprintf(stderr, __VA_ARGS__) \n ")
+ .append("#define showlist(...) puts(#__VA_ARGS__)\n ")
+ .append("#define report(test, ...) ((test)?puts(#test):\\ \n ").append("printf(__VA_ARGS__)) \n ");
}
public void testSpecExample7_1() throws Exception {
@@ -1185,7 +1166,6 @@ public class PreprocessorTests extends PreprocessorTestsBase {
validateProblemCount(0);
}
-
public void testSpecExample7_4() throws Exception {
StringBuffer sb = getExample7Defines();
sb.append("report(x>y, \"x is %d but y is %d\", x, y); \n");
@@ -1206,7 +1186,7 @@ public class PreprocessorTests extends PreprocessorTestsBase {
validateToken(IToken.tRPAREN);
validateToken(IToken.tCOLON);
validateIdentifier("printf");
- validateToken(IToken.tLPAREN );
+ validateToken(IToken.tLPAREN);
validateString("x is %d but y is %d");
validateToken(IToken.tCOMMA);
validateIdentifier("x");
@@ -1219,7 +1199,6 @@ public class PreprocessorTests extends PreprocessorTestsBase {
validateProblemCount(0);
}
-
// #define foo g g g
// #define g f##oo
// foo
@@ -1304,15 +1283,15 @@ public class PreprocessorTests extends PreprocessorTestsBase {
public void testC99_6_7_5_3_5_Bug104869() throws Exception {
initializeScanner();
// read in expected tokens
- List<IToken> expect= new ArrayList<IToken>();
- IToken t= fScanner.nextToken();
- while(t.getType() != IToken.tDECR) {
+ List<IToken> expect = new ArrayList<IToken>();
+ IToken t = fScanner.nextToken();
+ while (t.getType() != IToken.tDECR) {
expect.add(t);
- t= fScanner.nextToken();
+ t = fScanner.nextToken();
}
for (IToken et : expect) {
- t= fScanner.nextToken();
+ t = fScanner.nextToken();
assertEquals(et.getImage(), t.getImage());
assertEquals(et.getType(), t.getType());
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTestsBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTestsBase.java
index 937a688da9e..243a46882c5 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTestsBase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTestsBase.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.core.parser.tests.scanner;
import java.io.IOException;
@@ -69,8 +69,9 @@ public abstract class PreprocessorTestsBase extends BaseTestCase {
protected void initializeScanner(String input, ParserLanguage lang) throws IOException {
initializeScanner(getContent(input), lang, ParserMode.COMPLETE_PARSE, new ScannerInfo());
}
-
- protected void initializeScanner(String input, ParserLanguage lang, IScannerExtensionConfiguration scannerConfig) throws IOException {
+
+ protected void initializeScanner(String input, ParserLanguage lang, IScannerExtensionConfiguration scannerConfig)
+ throws IOException {
initializeScanner(getContent(input), lang, ParserMode.COMPLETE_PARSE, new ScannerInfo(), scannerConfig);
}
@@ -79,24 +80,26 @@ public abstract class PreprocessorTestsBase extends BaseTestCase {
return FileContent.create("<test-code>", input.toCharArray());
}
- protected void initializeScanner(FileContent input, ParserLanguage lang, ParserMode mode, IScannerInfo scannerInfo) throws IOException {
+ protected void initializeScanner(FileContent input, ParserLanguage lang, ParserMode mode, IScannerInfo scannerInfo)
+ throws IOException {
initializeScanner(input, lang, mode, scannerInfo, null);
}
-
- protected void initializeScanner(FileContent input, ParserLanguage lang, ParserMode mode, IScannerInfo scannerInfo, IScannerExtensionConfiguration scannerConfig) throws IOException {
- IncludeFileContentProvider readerFactory= FileCodeReaderFactory.getInstance();
+
+ protected void initializeScanner(FileContent input, ParserLanguage lang, ParserMode mode, IScannerInfo scannerInfo,
+ IScannerExtensionConfiguration scannerConfig) throws IOException {
+ IncludeFileContentProvider readerFactory = FileCodeReaderFactory.getInstance();
//IScannerExtensionConfiguration scannerConfig;
-
+
if (scannerConfig == null) {
- if (lang == ParserLanguage.C) {
- scannerConfig= GCCScannerExtensionConfiguration.getInstance();
- } else {
- scannerConfig= GPPScannerExtensionConfiguration.getInstance(scannerInfo);
- }
+ if (lang == ParserLanguage.C) {
+ scannerConfig = GCCScannerExtensionConfiguration.getInstance();
+ } else {
+ scannerConfig = GPPScannerExtensionConfiguration.getInstance(scannerInfo);
+ }
}
-
- fScanner= new CPreprocessor(input, scannerInfo, lang, NULL_LOG, scannerConfig, readerFactory);
- fLocationResolver= fScanner.getLocationMap();
+
+ fScanner = new CPreprocessor(input, scannerInfo, lang, NULL_LOG, scannerConfig, readerFactory);
+ fLocationResolver = fScanner.getLocationMap();
}
protected void initializeScanner() throws Exception {
@@ -109,15 +112,17 @@ public abstract class PreprocessorTestsBase extends BaseTestCase {
protected IASTTranslationUnit parse(ParserLanguage lang) {
assertNotNull("The scanner needs to be initialized before parsing the code.", fScanner);
- if (lang == ParserLanguage.C) {
- return new GNUCSourceParser(fScanner, ParserMode.COMPLETE_PARSE, NULL_LOG, GCCParserExtensionConfiguration.getInstance()).parse();
+ if (lang == ParserLanguage.C) {
+ return new GNUCSourceParser(fScanner, ParserMode.COMPLETE_PARSE, NULL_LOG,
+ GCCParserExtensionConfiguration.getInstance()).parse();
}
- return new GNUCPPSourceParser(fScanner, ParserMode.COMPLETE_PARSE, NULL_LOG, GPPParserExtensionConfiguration.getInstance()).parse();
+ return new GNUCPPSourceParser(fScanner, ParserMode.COMPLETE_PARSE, NULL_LOG,
+ GPPParserExtensionConfiguration.getInstance()).parse();
}
protected StringBuilder[] getTestContent(int sections) throws IOException {
- return TestSourceReader.getContentsForTest(
- CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), sections);
+ return TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "parser", getClass(),
+ getName(), sections);
}
protected String getAboveComment() throws IOException {
@@ -125,22 +130,22 @@ public abstract class PreprocessorTestsBase extends BaseTestCase {
}
protected void fullyTokenize() throws Exception {
- try {
+ try {
for (;;) {
- IToken t= fScanner.nextToken();
+ IToken t = fScanner.nextToken();
}
} catch (EndOfFileException e) {
}
}
protected void validateToken(int tokenType) throws Exception {
- IToken t= fScanner.nextToken();
+ IToken t = fScanner.nextToken();
assertEquals(tokenType, t.getType());
}
protected void validateToken(int tokenType, String image) throws Exception {
try {
- IToken t= fScanner.nextToken();
+ IToken t = fScanner.nextToken();
assertEquals(tokenType, t.getType());
assertEquals(image, t.getImage());
} catch (EndOfFileException e) {
@@ -163,19 +168,19 @@ public abstract class PreprocessorTestsBase extends BaseTestCase {
protected void validateLString(String expectedImage) throws Exception {
validateToken(IToken.tLSTRING, "L\"" + expectedImage + "\"");
}
-
+
protected void validateUTF16String(String expectedImage) throws Exception {
validateToken(IToken.tUTF16STRING, "u\"" + expectedImage + "\"");
}
-
+
protected void validateUTF32String(String expectedImage) throws Exception {
validateToken(IToken.tUTF32STRING, "U\"" + expectedImage + "\"");
}
-
+
protected void validateUserDefinedLiteralString(String expectedImage, String expectedSuffix) throws Exception {
validateToken(IToken.tUSER_DEFINED_STRING_LITERAL, "\"" + expectedImage + "\"" + expectedSuffix);
}
-
+
protected void validateChar(String expectedImage) throws Exception {
validateToken(IToken.tCHAR, "'" + expectedImage + "'");
}
@@ -183,24 +188,24 @@ public abstract class PreprocessorTestsBase extends BaseTestCase {
protected void validateWideChar(String expectedImage) throws Exception {
validateToken(IToken.tLCHAR, "L'" + expectedImage + "'");
}
-
+
protected void validateUTF16Char(String expectedImage) throws Exception {
validateToken(IToken.tUTF16CHAR, "u'" + expectedImage + "'");
}
-
+
protected void validateUTF32Char(String expectedImage) throws Exception {
validateToken(IToken.tUTF32CHAR, "U'" + expectedImage + "'");
}
-
+
protected void validateFloatingPointLiteral(String expectedImage) throws Exception {
validateToken(IToken.tFLOATINGPT, expectedImage);
}
protected void validateEOF() throws Exception {
try {
- IToken t= fScanner.nextToken();
+ IToken t = fScanner.nextToken();
fail("superfluous token " + t);
- } catch(EndOfFileException e) {
+ } catch (EndOfFileException e) {
}
}
@@ -226,9 +231,9 @@ public abstract class PreprocessorTestsBase extends BaseTestCase {
protected void validateProblemCount(int count) throws Exception {
assertEquals(count, fLocationResolver.getScannerProblems().length);
}
-
+
protected void validateProblem(int idx, int problemID, String detail) throws Exception {
- IASTProblem problem= fLocationResolver.getScannerProblems()[idx];
+ IASTProblem problem = fLocationResolver.getScannerProblems()[idx];
assertEquals(problemID, problem.getID());
if (detail != null) {
assertEquals(detail, problem.getArguments()[0]);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/ScannerTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/ScannerTestSuite.java
index 60ce7e3d8bb..66430a1d156 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/ScannerTestSuite.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/ScannerTestSuite.java
@@ -18,8 +18,8 @@ import junit.framework.TestSuite;
public class ScannerTestSuite extends TestSuite {
- public static Test suite() {
- TestSuite suite= new ScannerTestSuite();
+ public static Test suite() {
+ TestSuite suite = new ScannerTestSuite();
suite.addTest(LexerTests.suite());
suite.addTest(LocationMapTests.suite());
suite.addTest(PortedScannerTests.suite());
@@ -31,5 +31,5 @@ public class ScannerTestSuite extends TestSuite {
suite.addTest(StreamHasherTests.suite());
suite.addTest(FileCharArrayTests.suite());
return suite;
- }
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/StreamHasherTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/StreamHasherTests.java
index 4bc4b853c49..f31602849c8 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/StreamHasherTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/StreamHasherTests.java
@@ -22,42 +22,22 @@ import org.eclipse.cdt.internal.core.parser.scanner.StreamHasher;
* Unit test for StreamHasher class.
*/
public class StreamHasherTests extends BaseTestCase {
-
- private static final String TEXT =
- "'Twas brillig, and the slithy toves\r\n" +
- "Did gyre and gimble in the wabe;\r\n" +
- "All mimsy were the borogoves,\r\n" +
- "And the mome raths outgrabe.\r\n" +
- "\r\n" +
- "\"Beware the Jabberwock, my son!\r\n" +
- "The jaws that bite, the claws that catch!\r\n" +
- "Beware the Jubjub bird, and shun\r\n" +
- "The frumious Bandersnatch!\"\r\n" +
- "\r\n" +
- "He took his vorpal sword in hand:\r\n" +
- "Long time the manxome foe he sought—\r\n" +
- "So rested he by the Tumtum tree,\r\n" +
- "And stood awhile in thought.\r\n" +
- "\r\n" +
- "And as in uffish thought he stood,\r\n" +
- "The Jabberwock, with eyes of flame,\r\n" +
- "Came whiffling through the tulgey wood,\r\n" +
- "And burbled as it came!\r\n" +
- "\r\n" +
- "One, two! One, two! and through and through\r\n" +
- "The vorpal blade went snicker-snack!\r\n" +
- "He left it dead, and with its head\r\n" +
- "He went galumphing back.\r\n" +
- "\r\n" +
- "\"And hast thou slain the Jabberwock?\r\n" +
- "Come to my arms, my beamish boy!\r\n" +
- "O frabjous day! Callooh! Callay!\"\r\n" +
- "He chortled in his joy.\r\n" +
- "\r\n" +
- "'Twas brillig, and the slithy toves\r\n" +
- "Did gyre and gimble in the wabe;\r\n" +
- "All mimsy were the borogoves,\r\n" +
- "And the mome raths outgrabe.\r\n";
+
+ private static final String TEXT = "'Twas brillig, and the slithy toves\r\n"
+ + "Did gyre and gimble in the wabe;\r\n" + "All mimsy were the borogoves,\r\n"
+ + "And the mome raths outgrabe.\r\n" + "\r\n" + "\"Beware the Jabberwock, my son!\r\n"
+ + "The jaws that bite, the claws that catch!\r\n" + "Beware the Jubjub bird, and shun\r\n"
+ + "The frumious Bandersnatch!\"\r\n" + "\r\n" + "He took his vorpal sword in hand:\r\n"
+ + "Long time the manxome foe he sought—\r\n" + "So rested he by the Tumtum tree,\r\n"
+ + "And stood awhile in thought.\r\n" + "\r\n" + "And as in uffish thought he stood,\r\n"
+ + "The Jabberwock, with eyes of flame,\r\n" + "Came whiffling through the tulgey wood,\r\n"
+ + "And burbled as it came!\r\n" + "\r\n" + "One, two! One, two! and through and through\r\n"
+ + "The vorpal blade went snicker-snack!\r\n" + "He left it dead, and with its head\r\n"
+ + "He went galumphing back.\r\n" + "\r\n" + "\"And hast thou slain the Jabberwock?\r\n"
+ + "Come to my arms, my beamish boy!\r\n" + "O frabjous day! Callooh! Callay!\"\r\n"
+ + "He chortled in his joy.\r\n" + "\r\n" + "'Twas brillig, and the slithy toves\r\n"
+ + "Did gyre and gimble in the wabe;\r\n" + "All mimsy were the borogoves,\r\n"
+ + "And the mome raths outgrabe.\r\n";
public static TestSuite suite() {
return suite(StreamHasherTests.class);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/TestMacro.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/TestMacro.java
index 5393b5030ef..09007e31c76 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/TestMacro.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/TestMacro.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.cdt.core.parser.tests.scanner;
import org.eclipse.cdt.core.dom.ILinkage;
@@ -25,9 +25,9 @@ final class TestMacro implements IMacroBinding {
private String[] fParams;
public TestMacro(String name, String expansion, String[] params) {
- fName= name;
- fExpansion= expansion;
- fParams= params;
+ fName = name;
+ fExpansion = expansion;
+ fParams = params;
}
@Override
@@ -70,9 +70,9 @@ final class TestMacro implements IMacroBinding {
if (fParams == null) {
return null;
}
- char[][] result= new char[fParams.length][];
+ char[][] result = new char[fParams.length][];
for (int i = 0; i < result.length; i++) {
- result[i]= fParams[i].toCharArray();
+ result[i] = fParams[i].toCharArray();
}
return result;
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/Bug246129.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/Bug246129.java
index 0b4ed3e655a..09cbafbb0c1 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/Bug246129.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/Bug246129.java
@@ -114,20 +114,18 @@ public class Bug246129 extends IndexTestBase {
// source files if index-all-files is turned off.
IPathEntry[] entries = new IPathEntry[] {
CoreModel.newIncludeEntry(fProject.getPath(), null, fWrapperIncludeFolder.getLocation()),
- CoreModel.newIncludeEntry(fProject.getPath(), null, fIncludeFolder.getLocation()) };
+ CoreModel.newIncludeEntry(fProject.getPath(), null, fIncludeFolder.getLocation()) };
fProject.setRawPathEntries(entries, npm());
// However, the scanner info provider used by the unit tests
// needs separate setup, and this one must be complete.
- TestScannerProvider.sIncludes = new String[] {
- fWrapperIncludeFolder.getLocation().toOSString(),
- fIncludeFolder.getLocation().toOSString(),
- fExternalWrapperIncludeFolder.getAbsolutePath(),
+ TestScannerProvider.sIncludes = new String[] { fWrapperIncludeFolder.getLocation().toOSString(),
+ fIncludeFolder.getLocation().toOSString(), fExternalWrapperIncludeFolder.getAbsolutePath(),
fExternalIncludeFolder.getAbsolutePath() };
- IndexerPreferences.set(fProject.getProject(),
- IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "false");
+ IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG,
+ "false");
File falseFriendDirectory = new File(fWrapperIncludeFolder.getLocation().toOSString() + "/ext/..");
@@ -210,8 +208,7 @@ public class Bug246129 extends IndexTestBase {
}
public void testAst() throws Exception {
- ITranslationUnit tu =
- CoreModel.getDefault().createTranslationUnitFrom(fProject, fSource.getLocation());
+ ITranslationUnit tu = CoreModel.getDefault().createTranslationUnitFrom(fProject, fSource.getLocation());
IASTTranslationUnit ast = tu.getAST();
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/EmptyIndexFragment.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/EmptyIndexFragment.java
index 451b51cabed..1a53b06f6a7 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/EmptyIndexFragment.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/EmptyIndexFragment.java
@@ -41,7 +41,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
*/
public class EmptyIndexFragment implements IIndexFragment {
@Override
- public void acquireReadLock() throws InterruptedException {}
+ public void acquireReadLock() throws InterruptedException {
+ }
@Override
public IIndexFragmentBinding adaptBinding(IBinding binding) {
@@ -54,52 +55,48 @@ public class EmptyIndexFragment implements IIndexFragment {
}
@Override
- public IIndexFragmentBinding[] findBindings(Pattern[] patterns,
- boolean isFullyQualified, IndexFilter filter,
+ public IIndexFragmentBinding[] findBindings(Pattern[] patterns, boolean isFullyQualified, IndexFilter filter,
IProgressMonitor monitor) throws CoreException {
return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
}
@Override
- public IIndexFragmentBinding[] findBindings(char[][] names,
- IndexFilter filter, IProgressMonitor monitor) throws CoreException {
+ public IIndexFragmentBinding[] findBindings(char[][] names, IndexFilter filter, IProgressMonitor monitor)
+ throws CoreException {
return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
}
@Override
- public IIndexFragmentBinding[] findBindings(char[] name,
- boolean filescope, IndexFilter filter, IProgressMonitor monitor)
- throws CoreException {
+ public IIndexFragmentBinding[] findBindings(char[] name, boolean filescope, IndexFilter filter,
+ IProgressMonitor monitor) throws CoreException {
return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
}
@Override
- public IIndexFragmentBinding[] findBindingsForPrefix(char[] prefix,
- boolean filescope, IndexFilter filter, IProgressMonitor monitor)
- throws CoreException {
+ public IIndexFragmentBinding[] findBindingsForPrefix(char[] prefix, boolean filescope, IndexFilter filter,
+ IProgressMonitor monitor) throws CoreException {
return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
}
@Override
- public IIndexFragmentBinding[] findBindingsForContentAssist(char[] prefix,
- boolean filescope, IndexFilter filter, IProgressMonitor monitor)
- throws CoreException {
+ public IIndexFragmentBinding[] findBindingsForContentAssist(char[] prefix, boolean filescope, IndexFilter filter,
+ IProgressMonitor monitor) throws CoreException {
return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
}
@Override
- public IIndexMacro[] findMacros(char[] name, boolean isPrefix, boolean caseSensitive, IndexFilter filter, IProgressMonitor monitor) {
+ public IIndexMacro[] findMacros(char[] name, boolean isPrefix, boolean caseSensitive, IndexFilter filter,
+ IProgressMonitor monitor) {
return IIndexMacro.EMPTY_INDEX_MACRO_ARRAY;
}
@Override
- public IIndexFragmentInclude[] findIncludedBy(IIndexFragmentFile file)
- throws CoreException {
+ public IIndexFragmentInclude[] findIncludedBy(IIndexFragmentFile file) throws CoreException {
return IIndexFragmentInclude.EMPTY_FRAGMENT_INCLUDES_ARRAY;
}
@Override
- public IIndexFragmentName[] findNames(IBinding binding, int flags) {
+ public IIndexFragmentName[] findNames(IBinding binding, int flags) {
return IIndexFragmentName.EMPTY_NAME_ARRAY;
}
@@ -120,20 +117,18 @@ public class EmptyIndexFragment implements IIndexFragment {
@Override
@Deprecated
- public IIndexFragmentFile getFile(int linkageID, IIndexFileLocation location)
- throws CoreException {
+ public IIndexFragmentFile getFile(int linkageID, IIndexFileLocation location) throws CoreException {
return null;
}
@Override
- public IIndexFragmentFile getFile(int linkageID, IIndexFileLocation location,
- ISignificantMacros sigMacros) throws CoreException {
+ public IIndexFragmentFile getFile(int linkageID, IIndexFileLocation location, ISignificantMacros sigMacros)
+ throws CoreException {
return null;
}
@Override
- public IIndexFragmentFile[] getFiles(int linkageID, IIndexFileLocation location)
- throws CoreException {
+ public IIndexFragmentFile[] getFiles(int linkageID, IIndexFileLocation location) throws CoreException {
return IIndexFragmentFile.EMPTY_ARRAY;
}
@@ -154,20 +149,21 @@ public class EmptyIndexFragment implements IIndexFragment {
@Override
public String getProperty(String key) throws CoreException {
- if(IIndexFragment.PROPERTY_FRAGMENT_ID.equals(key)) {
+ if (IIndexFragment.PROPERTY_FRAGMENT_ID.equals(key)) {
return "org.eclipse.cdt.internal.core.index.EmptyIndexFragment"; //$NON-NLS-1$
}
- if(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_ID.equals(key)) {
+ if (IIndexFragment.PROPERTY_FRAGMENT_FORMAT_ID.equals(key)) {
return "org.eclipse.cdt.internal.core.index.EmptyIndexFragmentFormat"; //$NON-NLS-1$
}
- if(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_VERSION.equals(key)) {
+ if (IIndexFragment.PROPERTY_FRAGMENT_FORMAT_VERSION.equals(key)) {
return "0"; //$NON-NLS-1$
}
return null;
}
@Override
- public void releaseReadLock() {}
+ public void releaseReadLock() {
+ }
@Override
public boolean hasWaitingReaders() {
@@ -175,7 +171,8 @@ public class EmptyIndexFragment implements IIndexFragment {
}
@Override
- public void resetCacheCounters() {}
+ public void resetCacheCounters() {
+ }
@Override
public IIndexFragmentFileSet createFileSet() {
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java
index 4d84441889e..f0b037c9283 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java
@@ -71,7 +71,7 @@ import org.osgi.framework.Bundle;
* the PDOM purely from AST information (i.e. without a real binding from the DOM).
*/
public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
- private static final boolean DEBUG= false;
+ private static final boolean DEBUG = false;
private static final String END_OF_ADDED_CODE_MARKER = "/*END_OF_ADDED_CODE*/";
protected ITestStrategy strategy;
@@ -91,8 +91,7 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
super.tearDown();
}
- protected IASTName findName(String section, int offset, int len,
- boolean preferImplicitName) {
+ protected IASTName findName(String section, int offset, int len, boolean preferImplicitName) {
if (len <= 0)
len += section.length();
@@ -111,11 +110,11 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
}
sectionOffset = source.indexOf(section, sectionOffset);
if (sectionOffset >= 0) {
- IASTName name= null;
+ IASTName name = null;
if (!preferImplicitName)
- name= nodeSelector.findName(sectionOffset + offset, len);
+ name = nodeSelector.findName(sectionOffset + offset, len);
if (name == null)
- name= nodeSelector.findImplicitName(sectionOffset + offset, len);
+ name = nodeSelector.findImplicitName(sectionOffset + offset, len);
return name;
}
}
@@ -145,7 +144,7 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
* <ul>
* <li> There is not a unique name with the specified criteria
* <li> The binding associated with the name is null or a problem binding
- * <li> The binding is not an instance of the specified class
+ * <li> The binding is not an instance of the specified class
* </ul>
* @param section the code fragment to search for in the AST. The first occurrence of an identical
* section is used.
@@ -159,13 +158,14 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
if (len <= 0)
len += section.length() - offset;
- IASTName name= findName(section, offset, len);
+ IASTName name = findName(section, offset, len);
assertNotNull("Name not found for \"" + section + "\"", name);
assertEquals(section.substring(0, len), name.getRawSignature());
IBinding binding = name.resolveBinding();
assertNotNull("No binding for " + name.getRawSignature(), binding);
- assertFalse("Binding is a ProblemBinding for name \"" + name.getRawSignature() + "\"", IProblemBinding.class.isAssignableFrom(name.resolveBinding().getClass()));
+ assertFalse("Binding is a ProblemBinding for name \"" + name.getRawSignature() + "\"",
+ IProblemBinding.class.isAssignableFrom(name.resolveBinding().getClass()));
assertInstance(binding, clazz, cs);
return clazz.cast(binding);
}
@@ -180,7 +180,7 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
* <ul>
* <li> There is not a unique implicit name with the specified criteria
* <li> The binding associated with the implicit name is null or a problem binding
- * <li> The binding is not an instance of the specified class
+ * <li> The binding is not an instance of the specified class
* </ul>
* @param section the code fragment to search for in the AST. The first occurrence of an identical
* section is used.
@@ -193,13 +193,14 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
if (len <= 0)
len += section.length() - offset;
- IASTName name= findImplicitName(section, offset, len);
+ IASTName name = findImplicitName(section, offset, len);
assertNotNull("Name not found for \"" + section + "\"", name);
assertEquals(section.substring(offset, offset + len), name.getRawSignature());
IBinding binding = name.resolveBinding();
assertNotNull("No binding for " + name.getRawSignature(), binding);
- assertFalse("Binding is a ProblemBinding for name \"" + name.getRawSignature() + "\"", IProblemBinding.class.isAssignableFrom(name.resolveBinding().getClass()));
+ assertFalse("Binding is a ProblemBinding for name \"" + name.getRawSignature() + "\"",
+ IProblemBinding.class.isAssignableFrom(name.resolveBinding().getClass()));
assertInstance(binding, clazz, cs);
return clazz.cast(binding);
}
@@ -222,13 +223,14 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
if (len <= 0)
len += section.length() - offset;
- IASTName name= findName(section, offset, len);
+ IASTName name = findName(section, offset, len);
assertNotNull("Name not found for \"" + section + "\"", name);
assertEquals(section.substring(offset, offset + len), name.getRawSignature());
IBinding binding = name.resolveBinding();
assertNotNull("No binding for " + name.getRawSignature(), binding);
- assertFalse("Binding is a ProblemBinding for name \"" + name.getRawSignature() + "\"", IProblemBinding.class.isAssignableFrom(name.resolveBinding().getClass()));
+ assertFalse("Binding is a ProblemBinding for name \"" + name.getRawSignature() + "\"",
+ IProblemBinding.class.isAssignableFrom(name.resolveBinding().getClass()));
return (T) binding;
}
@@ -249,7 +251,7 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
if (len <= 0)
len += section.length();
- IASTName name= findImplicitName(section, 0, len);
+ IASTName name = findImplicitName(section, 0, len);
assertNotNull("Name not found for \"" + section + "\"", name);
assertEquals(section.substring(0, len), name.getRawSignature());
@@ -267,7 +269,7 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
* @return the associated name's binding
*/
protected IBinding getProblemFromASTName(String section, int len) {
- IASTName name= findName(section, 0, len);
+ IASTName name = findName(section, 0, len);
assertNotNull("Name not found for \"" + section + "\"", name);
assertEquals(section.substring(0, len), name.getRawSignature());
@@ -310,7 +312,8 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
assertTrue(type.isInstance((ft.getParameterTypes()[index])));
}
- protected void assertCompositeTypeParam(int index, int compositeTypeKey, IType function, String qn) throws DOMException {
+ protected void assertCompositeTypeParam(int index, int compositeTypeKey, IType function, String qn)
+ throws DOMException {
// assert function is IFunctionType
IFunctionType ft = (IFunctionType) function;
assertTrue(ICPPClassType.class.isInstance((ft.getParameterTypes()[index])));
@@ -318,7 +321,7 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
assertEquals(qn, ASTTypeUtil.getQualifiedName((ICPPClassType) ft.getParameterTypes()[index]));
}
- protected static <T> T assertInstance(Object o, Class<T> clazz, Class ... cs) {
+ protected static <T> T assertInstance(Object o, Class<T> clazz, Class... cs) {
assertNotNull("Expected " + clazz.getName() + " but got null", o);
assertTrue("Expected " + clazz.getName() + " but got " + o.getClass().getName(), clazz.isInstance(o));
for (Class c : cs) {
@@ -341,16 +344,17 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
assertQNEquals(qn, variable);
assertInstance(variable.getType(), expType);
if (expTypeQN != null) {
- IType type= variable.getType();
+ IType type = variable.getType();
assertInstance(type, IBinding.class);
assertQNEquals(expTypeQN, (IBinding) type);
}
}
- protected static void assertTypeContainer(IType conType, String expQN, Class containerType, Class expContainedType, String expContainedTypeQN) {
+ protected static void assertTypeContainer(IType conType, String expQN, Class containerType, Class expContainedType,
+ String expContainedTypeQN) {
assertInstance(conType, ITypeContainer.class);
assertInstance(conType, containerType);
- IType containedType= ((ITypeContainer) conType).getType();
+ IType containedType = ((ITypeContainer) conType).getType();
assertInstance(containedType, expContainedType);
if (expContainedTypeQN != null) {
assertInstance(containedType, IBinding.class);
@@ -388,7 +392,7 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
}
return i - offset;
}
-
+
// Get a BindingAssertionHelper for the last AST.
protected BindingAssertionHelper getAssertionHelper() {
int index = strategy.getAstCount() - 1;
@@ -396,38 +400,46 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
}
static protected class NameCollector extends ASTVisitor {
- {
- shouldVisitNames = true;
+ {
+ shouldVisitNames = true;
shouldVisitImplicitNames = true;
- }
- public List<IASTName> nameList = new ArrayList<>();
+ }
+ public List<IASTName> nameList = new ArrayList<>();
- @Override
+ @Override
public int visit(IASTName name) {
- nameList.add(name);
- return PROCESS_CONTINUE;
- }
+ nameList.add(name);
+ return PROCESS_CONTINUE;
+ }
- public IASTName getName(int idx) {
- if (idx < 0 || idx >= nameList.size())
- return null;
- return nameList.get(idx);
- }
+ public IASTName getName(int idx) {
+ if (idx < 0 || idx >= nameList.size())
+ return null;
+ return nameList.get(idx);
+ }
- public int size() {
- return nameList.size();
- }
- }
+ public int size() {
+ return nameList.size();
+ }
+ }
protected interface ITestStrategy {
IIndex getIndex();
+
void setUp() throws Exception;
+
void tearDown() throws Exception;
+
public int getAstCount();
+
public IASTTranslationUnit getAst(int index);
+
public StringBuilder getAstSource(int index);
+
public StringBuilder[] getTestData();
+
public ICProject getCProject();
+
public boolean isCompositeIndex();
}
@@ -488,11 +500,14 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
@Override
public void setUp() throws Exception {
- cproject = cpp ?
- CProjectHelper.createCCProject(getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER) :
- CProjectHelper.createCProject(getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
+ cproject = cpp
+ ? CProjectHelper.createCCProject(getName() + System.currentTimeMillis(), "bin",
+ IPDOMManager.ID_NO_INDEXER)
+ : CProjectHelper.createCProject(getName() + System.currentTimeMillis(), "bin",
+ IPDOMManager.ID_NO_INDEXER);
Bundle b = CTestPlugin.getDefault().getBundle();
- testData = TestSourceReader.getContentsForTest(b, "parser", IndexBindingResolutionTestBase.this.getClass(), getName(), 2);
+ testData = TestSourceReader.getContentsForTest(b, "parser", IndexBindingResolutionTestBase.this.getClass(),
+ getName(), 2);
if (testData.length < 2)
fail("Insufficient test data");
@@ -505,17 +520,18 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), headerContents);
CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
- waitForIndexer(cproject);
+ waitForIndexer(cproject);
if (DEBUG) {
System.out.println("Project PDOM: " + getName());
((PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject)).accept(new PDOMPrettyPrinter());
}
- index= CCorePlugin.getIndexManager().getIndex(cproject);
+ index = CCorePlugin.getIndexManager().getIndex(cproject);
index.acquireReadLock();
- IFile cppfile= TestSourceReader.createFile(cproject.getProject(), new Path("references.c" + (cpp ? "pp" : "")), sourceContents);
+ IFile cppfile = TestSourceReader.createFile(cproject.getProject(),
+ new Path("references.c" + (cpp ? "pp" : "")), sourceContents);
ast = TestSourceReader.createIndexBasedAST(index, cproject, cppfile);
}
@@ -525,7 +541,8 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
index.releaseReadLock();
}
if (cproject != null) {
- cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
@@ -551,7 +568,7 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
public SinglePDOMTestStrategy(boolean cpp) {
this(cpp, true);
}
-
+
public SinglePDOMTestStrategy(boolean cpp, boolean shouldRequireHeaderFile) {
this.cpp = cpp;
this.shouldRequireHeaderFile = shouldRequireHeaderFile;
@@ -588,17 +605,20 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
@Override
public void setUp() throws Exception {
- cproject = cpp ?
- CProjectHelper.createCCProject(getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER) :
- CProjectHelper.createCProject(getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
+ cproject = cpp
+ ? CProjectHelper.createCCProject(getName() + System.currentTimeMillis(), "bin",
+ IPDOMManager.ID_NO_INDEXER)
+ : CProjectHelper.createCProject(getName() + System.currentTimeMillis(), "bin",
+ IPDOMManager.ID_NO_INDEXER);
Bundle b = CTestPlugin.getDefault().getBundle();
- testData = TestSourceReader.getContentsForTest(b, "parser", IndexBindingResolutionTestBase.this.getClass(), getName(), 2);
+ testData = TestSourceReader.getContentsForTest(b, "parser", IndexBindingResolutionTestBase.this.getClass(),
+ getName(), 2);
- if(testData.length < 1) {
+ if (testData.length < 1) {
fail("Insufficient test data");
- } else if(shouldRequireHeaderFile && testData.length == 1) {
+ } else if (shouldRequireHeaderFile && testData.length == 1) {
fail("Insufficient test data");
- } else if(testData.length == 1) {
+ } else if (testData.length == 1) {
StringBuilder newTestData[] = new StringBuilder[2];
newTestData[0] = new StringBuilder();
newTestData[1] = testData[0];
@@ -613,17 +633,18 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), headerContents);
CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
- waitForIndexer(cproject);
+ waitForIndexer(cproject);
- IFile cppfile= TestSourceReader.createFile(cproject.getProject(), new Path("references.c" + (cpp ? "pp" : "")), sourceContents);
- waitForIndexer(cproject);
+ IFile cppfile = TestSourceReader.createFile(cproject.getProject(),
+ new Path("references.c" + (cpp ? "pp" : "")), sourceContents);
+ waitForIndexer(cproject);
if (DEBUG) {
System.out.println("Project PDOM: " + getName());
((PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject)).accept(new PDOMPrettyPrinter());
}
- index= CCorePlugin.getIndexManager().getIndex(cproject);
+ index = CCorePlugin.getIndexManager().getIndex(cproject);
index.acquireReadLock();
ast = TestSourceReader.createIndexBasedAST(index, cproject, cppfile);
@@ -635,7 +656,8 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
index.releaseReadLock();
}
if (cproject != null) {
- cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
@@ -703,11 +725,14 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
@Override
public void setUp() throws Exception {
- cproject = cpp ?
- CProjectHelper.createCCProject(getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER) :
- CProjectHelper.createCProject(getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
+ cproject = cpp
+ ? CProjectHelper.createCCProject(getName() + System.currentTimeMillis(), "bin",
+ IPDOMManager.ID_NO_INDEXER)
+ : CProjectHelper.createCProject(getName() + System.currentTimeMillis(), "bin",
+ IPDOMManager.ID_NO_INDEXER);
Bundle b = CTestPlugin.getDefault().getBundle();
- testData = TestSourceReader.getContentsForTest(b, "parser", IndexBindingResolutionTestBase.this.getClass(), getName(), 0);
+ testData = TestSourceReader.getContentsForTest(b, "parser", IndexBindingResolutionTestBase.this.getClass(),
+ getName(), 0);
List<IFile> astFiles = new ArrayList<>();
for (int i = 0; i < testData.length;) {
@@ -730,8 +755,9 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
// Wait for the indexer before updating the file.
break;
}
- contents.delete(0, endOfLine); // Remove first line from the file contents.
- IFile file = TestSourceReader.createFile(cproject.getProject(), new Path(filename), contents.toString());
+ contents.delete(0, endOfLine); // Remove first line from the file contents.
+ IFile file = TestSourceReader.createFile(cproject.getProject(), new Path(filename),
+ contents.toString());
if (astRequested || (j == testData.length - 1 && astFiles.isEmpty())) {
int pos = astFiles.indexOf(file);
if (pos < 0) {
@@ -743,7 +769,7 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
}
}
CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
- waitForIndexer(cproject);
+ waitForIndexer(cproject);
}
if (DEBUG) {
@@ -751,7 +777,7 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
((PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject)).accept(new PDOMPrettyPrinter());
}
- index= CCorePlugin.getIndexManager().getIndex(cproject);
+ index = CCorePlugin.getIndexManager().getIndex(cproject);
index.acquireReadLock();
for (IFile file : astFiles) {
@@ -765,7 +791,8 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
index.releaseReadLock();
}
if (cproject != null) {
- cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
@@ -802,20 +829,25 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
index.releaseReadLock();
}
if (cproject != null) {
- cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
if (referenced != null) {
- referenced.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ referenced.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
@Override
public void setUp() throws Exception {
- cproject= cpp ?
- CProjectHelper.createCCProject("OnlineContent"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER) :
- CProjectHelper.createCProject("OnlineContent"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
- Bundle b= CTestPlugin.getDefault().getBundle();
- testData= TestSourceReader.getContentsForTest(b, "parser", IndexBindingResolutionTestBase.this.getClass(), getName(), 2);
+ cproject = cpp
+ ? CProjectHelper.createCCProject("OnlineContent" + System.currentTimeMillis(), "bin",
+ IPDOMManager.ID_NO_INDEXER)
+ : CProjectHelper.createCProject("OnlineContent" + System.currentTimeMillis(), "bin",
+ IPDOMManager.ID_NO_INDEXER);
+ Bundle b = CTestPlugin.getDefault().getBundle();
+ testData = TestSourceReader.getContentsForTest(b, "parser", IndexBindingResolutionTestBase.this.getClass(),
+ getName(), 2);
if (testData.length < 2)
fail("Insufficient test data");
testData[1].insert(0, "#include \"header.h\" " + END_OF_ADDED_CODE_MARKER + "\n");
@@ -826,36 +858,41 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
referenced = createReferencedContent();
- TestScannerProvider.sIncludes= new String[] {referenced.getProject().getLocation().toOSString()};
- IFile references= TestSourceReader.createFile(cproject.getProject(), new Path("refs.c" + (cpp ? "pp" : "")), sourceContents);
+ TestScannerProvider.sIncludes = new String[] { referenced.getProject().getLocation().toOSString() };
+ IFile references = TestSourceReader.createFile(cproject.getProject(),
+ new Path("refs.c" + (cpp ? "pp" : "")), sourceContents);
- IProject[] refs = new IProject[] {referenced.getProject()};
+ IProject[] refs = new IProject[] { referenced.getProject() };
IProjectDescription pd = cproject.getProject().getDescription();
pd.setReferencedProjects(refs);
cproject.getProject().setDescription(pd, new NullProgressMonitor());
- IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
+ IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEXER_ID,
+ IPDOMManager.ID_FAST_INDEXER);
CCorePlugin.getIndexManager().reindex(cproject);
waitForIndexer(cproject);
if (DEBUG) {
System.out.println("Online: " + getName());
- ((PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject)).accept(new PDOMPrettyPrinter());
+ ((PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject)).accept(new PDOMPrettyPrinter());
}
- index= CCorePlugin.getIndexManager().getIndex(cproject, IIndexManager.ADD_DEPENDENCIES);
+ index = CCorePlugin.getIndexManager().getIndex(cproject, IIndexManager.ADD_DEPENDENCIES);
index.acquireReadLock();
- ast= TestSourceReader.createIndexBasedAST(index, cproject, references);
+ ast = TestSourceReader.createIndexBasedAST(index, cproject, references);
}
private ICProject createReferencedContent() throws Exception {
- ICProject referenced = cpp ?
- CProjectHelper.createCCProject("ReferencedContent" + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER) :
- CProjectHelper.createCProject("ReferencedContent" + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
+ ICProject referenced = cpp
+ ? CProjectHelper.createCCProject("ReferencedContent" + System.currentTimeMillis(), "bin",
+ IPDOMManager.ID_NO_INDEXER)
+ : CProjectHelper.createCProject("ReferencedContent" + System.currentTimeMillis(), "bin",
+ IPDOMManager.ID_NO_INDEXER);
String content = testData[0].toString();
IFile file = TestSourceReader.createFile(referenced.getProject(), new Path("header.h"), content);
- IndexerPreferences.set(referenced.getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
+ IndexerPreferences.set(referenced.getProject(), IndexerPreferences.KEY_INDEXER_ID,
+ IPDOMManager.ID_FAST_INDEXER);
CCorePlugin.getIndexManager().reindex(referenced);
waitForIndexer(referenced);
@@ -927,9 +964,10 @@ public abstract class IndexBindingResolutionTestBase extends SemanticTestBase {
}
}
- protected static void assertSameType(IType first, IType second){
+ protected static void assertSameType(IType first, IType second) {
assertNotNull(first);
assertNotNull(second);
- assertTrue("Expected types to be the same, but first was: '" + first.toString() + "' and second was: '" + second + "'", first.isSameType(second));
+ assertTrue("Expected types to be the same, but first was: '" + first.toString() + "' and second was: '" + second
+ + "'", first.isSameType(second));
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java
index 07464be7ba7..a4578fdf5e9 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java
@@ -123,50 +123,50 @@ public class IndexBugsTests extends BaseTestCase {
protected IASTTranslationUnit tu;
protected String contents;
- public BindingAssertionHelper(IFile file, String contents, IIndex index) throws CModelException, CoreException {
- this.contents= contents;
- this.tu= TestSourceReader.createIndexBasedAST(index, fCProject, file);
- }
-
- public IASTTranslationUnit getTranslationUnit() {
- return tu;
- }
-
- public IBinding assertProblem(String section, int len) {
- IBinding binding= binding(section, len);
- assertTrue("Non-ProblemBinding for name: " + section.substring(0, len),
- binding instanceof IProblemBinding);
- return binding;
- }
-
- public <T extends IBinding> T assertNonProblem(String section, int len) {
- IBinding binding= binding(section, len);
- if (binding instanceof IProblemBinding) {
- IProblemBinding problem= (IProblemBinding) binding;
- fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID())+")");
- }
- if (binding == null) {
- fail("Null binding resolved for name: " + section.substring(0, len));
- }
- return (T) binding;
- }
-
- public void assertNoName(String section, int len) {
- IASTName name= findName(section, len, false);
+ public BindingAssertionHelper(IFile file, String contents, IIndex index) throws CModelException, CoreException {
+ this.contents = contents;
+ this.tu = TestSourceReader.createIndexBasedAST(index, fCProject, file);
+ }
+
+ public IASTTranslationUnit getTranslationUnit() {
+ return tu;
+ }
+
+ public IBinding assertProblem(String section, int len) {
+ IBinding binding = binding(section, len);
+ assertTrue("Non-ProblemBinding for name: " + section.substring(0, len), binding instanceof IProblemBinding);
+ return binding;
+ }
+
+ public <T extends IBinding> T assertNonProblem(String section, int len) {
+ IBinding binding = binding(section, len);
+ if (binding instanceof IProblemBinding) {
+ IProblemBinding problem = (IProblemBinding) binding;
+ fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID())
+ + ")");
+ }
+ if (binding == null) {
+ fail("Null binding resolved for name: " + section.substring(0, len));
+ }
+ return (T) binding;
+ }
+
+ public void assertNoName(String section, int len) {
+ IASTName name = findName(section, len, false);
if (name != null) {
String selection = section.substring(0, len);
fail("Found unexpected \"" + selection + "\": " + name.resolveBinding());
}
- }
+ }
- /**
- * Asserts that there is exactly one name at the given location and that
- * it resolves to the given type of binding.
- */
- public IASTImplicitName assertImplicitName(String section, int len, Class<?> bindingClass) {
- IASTName name = findName(section, len, true);
- final String selection = section.substring(0, len);
- assertNotNull("did not find \""+selection+"\"", name);
+ /**
+ * Asserts that there is exactly one name at the given location and that
+ * it resolves to the given type of binding.
+ */
+ public IASTImplicitName assertImplicitName(String section, int len, Class<?> bindingClass) {
+ IASTName name = findName(section, len, true);
+ final String selection = section.substring(0, len);
+ assertNotNull("did not find \"" + selection + "\"", name);
assertInstance(name, IASTImplicitName.class);
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
@@ -176,7 +176,7 @@ public class IndexBugsTests extends BaseTestCase {
if (implicits.length > 1) {
boolean found = false;
for (IASTImplicitName n : implicits) {
- if (((ASTNode)n).getOffset() == ((ASTNode)name).getOffset()) {
+ if (((ASTNode) n).getOffset() == ((ASTNode) name).getOffset()) {
assertFalse(found);
found = true;
}
@@ -184,74 +184,73 @@ public class IndexBugsTests extends BaseTestCase {
assertTrue(found);
}
- assertEquals(selection, name.getRawSignature());
- IBinding binding = name.resolveBinding();
- assertNotNull(binding);
- assertInstance(binding, bindingClass);
- return (IASTImplicitName) name;
- }
-
- public void assertNoImplicitName(String section, int len) {
- IASTName name = findName(section, len, true);
- final String selection = section.substring(0, len);
- assertNull("found name \""+selection+"\"", name);
- }
-
- public IASTImplicitName[] getImplicitNames(String section, int len) {
- IASTName name = findName(section, len, true);
- IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
+ assertEquals(selection, name.getRawSignature());
+ IBinding binding = name.resolveBinding();
+ assertNotNull(binding);
+ assertInstance(binding, bindingClass);
+ return (IASTImplicitName) name;
+ }
+
+ public void assertNoImplicitName(String section, int len) {
+ IASTName name = findName(section, len, true);
+ final String selection = section.substring(0, len);
+ assertNull("found name \"" + selection + "\"", name);
+ }
+
+ public IASTImplicitName[] getImplicitNames(String section, int len) {
+ IASTName name = findName(section, len, true);
+ IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
IASTImplicitName[] implicits = owner.getImplicitNames();
return implicits;
- }
-
- private IASTName findName(String section, int len, boolean implicit) {
- final int offset = contents.indexOf(section);
- assertTrue(offset >= 0);
- IASTNodeSelector selector = tu.getNodeSelector(null);
- return implicit ? selector.findImplicitName(offset, len) : selector.findName(offset, len);
- }
-
- private String renderProblemID(int i) {
- try {
- for (Field field : IProblemBinding.class.getDeclaredFields()) {
- if (field.getName().startsWith("SEMANTIC_")) {
- if (field.getType() == int.class) {
- Integer ci= (Integer) field.get(null);
- if (ci.intValue() == i) {
- return field.getName();
- }
- }
- }
- }
- } catch(IllegalAccessException iae) {
- throw new RuntimeException(iae);
- }
- return "Unknown problem ID";
- }
-
- public <T extends IBinding> T assertNonProblem(String section, int len, Class<T> type, Class... cs) {
- IBinding binding= binding(section, len);
- assertTrue("ProblemBinding for name: " + section.substring(0, len),
- !(binding instanceof IProblemBinding));
- assertInstance(binding, type);
- for (Class c : cs) {
- assertInstance(binding, c);
- }
- return type.cast(binding);
- }
-
- private IBinding binding(String section, int len) {
- IASTName name = findName(section, len, false);
- final String selection = section.substring(0, len);
+ }
+
+ private IASTName findName(String section, int len, boolean implicit) {
+ final int offset = contents.indexOf(section);
+ assertTrue(offset >= 0);
+ IASTNodeSelector selector = tu.getNodeSelector(null);
+ return implicit ? selector.findImplicitName(offset, len) : selector.findName(offset, len);
+ }
+
+ private String renderProblemID(int i) {
+ try {
+ for (Field field : IProblemBinding.class.getDeclaredFields()) {
+ if (field.getName().startsWith("SEMANTIC_")) {
+ if (field.getType() == int.class) {
+ Integer ci = (Integer) field.get(null);
+ if (ci.intValue() == i) {
+ return field.getName();
+ }
+ }
+ }
+ }
+ } catch (IllegalAccessException iae) {
+ throw new RuntimeException(iae);
+ }
+ return "Unknown problem ID";
+ }
+
+ public <T extends IBinding> T assertNonProblem(String section, int len, Class<T> type, Class... cs) {
+ IBinding binding = binding(section, len);
+ assertTrue("ProblemBinding for name: " + section.substring(0, len), !(binding instanceof IProblemBinding));
+ assertInstance(binding, type);
+ for (Class c : cs) {
+ assertInstance(binding, c);
+ }
+ return type.cast(binding);
+ }
+
+ private IBinding binding(String section, int len) {
+ IASTName name = findName(section, len, false);
+ final String selection = section.substring(0, len);
assertNotNull("Did not find \"" + selection + "\"", name);
- assertEquals(selection, name.getRawSignature());
+ assertEquals(selection, name.getRawSignature());
- IBinding binding = name.resolveBinding();
- assertNotNull("No binding for " + name.getRawSignature(), binding);
+ IBinding binding = name.resolveBinding();
+ assertNotNull("No binding for " + name.getRawSignature(), binding);
- return name.resolveBinding();
- }
- }
+ return name.resolveBinding();
+ }
+ }
public static TestSuite suite() {
final TestSuite ts = suite(IndexBugsTests.class);
@@ -262,10 +261,10 @@ public class IndexBugsTests extends BaseTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- fCProject= CProjectHelper.createCCProject("__bugsTest__", "bin", IPDOMManager.ID_FAST_INDEXER);
+ fCProject = CProjectHelper.createCCProject("__bugsTest__", "bin", IPDOMManager.ID_FAST_INDEXER);
CCorePlugin.getIndexManager().reindex(fCProject);
waitForIndexer();
- fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
+ fIndex = CCorePlugin.getIndexManager().getIndex(fCProject);
}
@Override
@@ -280,20 +279,20 @@ public class IndexBugsTests extends BaseTestCase {
return fCProject.getProject();
}
- protected String[] getContentsForTest(int blocks) throws IOException {
- CharSequence[] help= TestSourceReader.getContentsForTest(
- CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), blocks);
- String[] result= new String[help.length];
- int i= 0;
- for (CharSequence buf : help) {
- result[i++]= buf.toString();
+ protected String[] getContentsForTest(int blocks) throws IOException {
+ CharSequence[] help = TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "parser",
+ getClass(), getName(), blocks);
+ String[] result = new String[help.length];
+ int i = 0;
+ for (CharSequence buf : help) {
+ result[i++] = buf.toString();
}
- return result;
- }
+ return result;
+ }
- protected IFile createFile(IContainer container, String fileName, String contents) throws Exception {
- return TestSourceReader.createFile(container, new Path(fileName), contents);
- }
+ protected IFile createFile(IContainer container, String fileName, String contents) throws Exception {
+ return TestSourceReader.createFile(container, new Path(fileName), contents);
+ }
private IIndexFile getIndexFile(IFile file) throws CoreException {
return getIndexFile(fIndex, file);
@@ -311,10 +310,10 @@ public class IndexBugsTests extends BaseTestCase {
}
protected Pattern[] getPattern(String qname) {
- String[] parts= qname.split("::");
- Pattern[] result= new Pattern[parts.length];
+ String[] parts = qname.split("::");
+ Pattern[] result = new Pattern[parts.length];
for (int i = 0; i < result.length; i++) {
- result[i]= Pattern.compile(parts[i]);
+ result[i] = Pattern.compile(parts[i]);
}
return result;
}
@@ -329,7 +328,7 @@ public class IndexBugsTests extends BaseTestCase {
* <ul>
* <li> There is not a unique name with the specified criteria
* <li> The binding associated with the name is null or a problem binding
- * <li> The binding is not an instance of the specified class
+ * <li> The binding is not an instance of the specified class
* </ul>
* @param ast the AST to test.
* @param source the source code corresponding to the AST.
@@ -342,19 +341,18 @@ public class IndexBugsTests extends BaseTestCase {
*/
protected <T> T getBindingFromASTName(IASTTranslationUnit ast, String source, String section, int len,
Class<T> clazz, Class... cs) {
- IASTName name= ast.getNodeSelector(null).findName(source.indexOf(section), len);
+ IASTName name = ast.getNodeSelector(null).findName(source.indexOf(section), len);
assertNotNull("Name not found for \"" + section + "\"", name);
assertEquals(section.substring(0, len), name.getRawSignature());
IBinding binding = name.resolveBinding();
assertNotNull("No binding for " + section.substring(0, len), binding);
- assertTrue("ProblemBinding for name: " + section.substring(0, len),
- !(binding instanceof IProblemBinding));
+ assertTrue("ProblemBinding for name: " + section.substring(0, len), !(binding instanceof IProblemBinding));
assertInstance(binding, clazz, cs);
return clazz.cast(binding);
}
- protected static <T> T assertInstance(Object o, Class<T> clazz, Class ... cs) {
+ protected static <T> T assertInstance(Object o, Class<T> clazz, Class... cs) {
assertNotNull("Expected " + clazz.getName() + " but got null", o);
assertTrue("Expected " + clazz.getName() + " but got " + o.getClass().getName(), clazz.isInstance(o));
for (Class c : cs) {
@@ -378,80 +376,81 @@ public class IndexBugsTests extends BaseTestCase {
public void test154563() throws Exception {
// Because of fix for http://bugs.eclipse.org/193779 this test case passes.
// However http://bugs.eclipse.org/154563 remains to be fixed.
- String[] content= getContentsForTest(2);
+ String[] content = getContentsForTest(2);
- IFile file= createFile(getProject(), "header.h", content[0]);
+ IFile file = createFile(getProject(), "header.h", content[0]);
waitUntilFileIsIndexed(file, INDEXER_TIMEOUT_SEC * 1000);
- IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
+ IIndex index = CCorePlugin.getIndexManager().getIndex(fCProject);
index.acquireReadLock();
try {
- IBinding[] bs= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
+ IBinding[] bs = index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bs.length);
assertTrue(bs[0] instanceof ICPPClassType);
- assertEquals(2, ((ICPPClassType)bs[0]).getDeclaredMethods().length);
+ assertEquals(2, ((ICPPClassType) bs[0]).getDeclaredMethods().length);
} finally {
index.releaseReadLock();
}
- file= createFile(getProject(), "header.h", content[1]);
+ file = createFile(getProject(), "header.h", content[1]);
waitUntilFileIsIndexed(file, INDEXER_TIMEOUT_SEC * 1000);
- index= CCorePlugin.getIndexManager().getIndex(fCProject);
+ index = CCorePlugin.getIndexManager().getIndex(fCProject);
index.acquireReadLock();
try {
- IBinding[] bs= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
+ IBinding[] bs = index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bs.length);
assertTrue(bs[0] instanceof ICPPClassType);
- assertEquals(3, ((ICPPClassType)bs[0]).getDeclaredMethods().length);
+ assertEquals(3, ((ICPPClassType) bs[0]).getDeclaredMethods().length);
} finally {
index.releaseReadLock();
}
}
- public void test150906() throws Exception {
- String fileName= "bug150906.c";
- String varName= "arrayDataSize";
- StringBuilder content= new StringBuilder();
- content.append("unsigned char arrayData[] = {\n");
- for (int i= 0; i < 1024 * 250 - 1; i++) {
- content.append("0x00,");
- }
- content.append("0x00};\n");
- content.append("unsigned int arrayDataSize = sizeof(arrayData);\n");
+ public void test150906() throws Exception {
+ String fileName = "bug150906.c";
+ String varName = "arrayDataSize";
+ StringBuilder content = new StringBuilder();
+ content.append("unsigned char arrayData[] = {\n");
+ for (int i = 0; i < 1024 * 250 - 1; i++) {
+ content.append("0x00,");
+ }
+ content.append("0x00};\n");
+ content.append("unsigned int arrayDataSize = sizeof(arrayData);\n");
int indexOfDecl = content.indexOf(varName);
waitForIndexer();
- IFile file= createFile(getProject(), fileName, content.toString());
+ IFile file = createFile(getProject(), fileName, content.toString());
// must be done in a reasonable amount of time
waitUntilFileIsIndexed(file, INDEXER_TIMEOUT_SEC * 1000);
fIndex.acquireReadLock();
try {
- IIndexBinding[] bindings= fIndex.findBindings(getPattern("arrayDataSize"), true, IndexFilter.ALL, npm());
+ IIndexBinding[] bindings = fIndex.findBindings(getPattern("arrayDataSize"), true, IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
- IIndexBinding binding= bindings[0];
+ IIndexBinding binding = bindings[0];
// check if we have the definition
- IIndexName[] decls= fIndex.findNames(binding, IIndex.FIND_DEFINITIONS);
+ IIndexName[] decls = fIndex.findNames(binding, IIndex.FIND_DEFINITIONS);
assertEquals(1, decls.length);
assertEquals(indexOfDecl, decls[0].getNodeOffset());
} finally {
fIndex.releaseReadLock();
}
- }
+ }
// enum {e20070206};
public void test156671() throws Exception {
waitForIndexer();
- String content= getContentsForTest(1)[0];
+ String content = getContentsForTest(1)[0];
- IFile file= TestSourceReader.createFile(fCProject.getProject(), "test156671.cpp", content);
+ IFile file = TestSourceReader.createFile(fCProject.getProject(), "test156671.cpp", content);
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEXER_TIMEOUT_SEC * 1000);
fIndex.acquireReadLock();
try {
- IBinding[] bindings= fIndex.findBindings("e20070206".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
+ IBinding[] bindings = fIndex.findBindings("e20070206".toCharArray(),
+ IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
assertEquals(1, bindings.length);
assertTrue(bindings[0] instanceof IEnumerator);
} finally {
@@ -462,26 +461,27 @@ public class IndexBugsTests extends BaseTestCase {
public void test160281_1() throws Exception {
waitForIndexer();
IProject project = fCProject.getProject();
- IFile include= TestSourceReader.createFile(project, "inc/test160281_1.h", "");
- TestScannerProvider.sIncludes= new String[]{include.getLocation().removeLastSegments(1).toString()};
- TestScannerProvider.sIncludeFiles= new String[]{include.getName()};
- IFile file= TestSourceReader.createFile(project, "test160281_1.cpp", "");
+ IFile include = TestSourceReader.createFile(project, "inc/test160281_1.h", "");
+ TestScannerProvider.sIncludes = new String[] { include.getLocation().removeLastSegments(1).toString() };
+ TestScannerProvider.sIncludeFiles = new String[] { include.getName() };
+ IFile file = TestSourceReader.createFile(project, "test160281_1.cpp", "");
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEXER_TIMEOUT_SEC * 1000);
fIndex.acquireReadLock();
try {
- IIndexFile ifile= getIndexFile(file);
- IIndexInclude[] includes= ifile.getIncludes();
+ IIndexFile ifile = getIndexFile(file);
+ IIndexInclude[] includes = ifile.getIncludes();
// the first directory searched for file is the preprocessor's working directory (build directory), see gcc manual -include option
- IIndexInclude i1= includes[0];
+ IIndexInclude i1 = includes[0];
assertEquals(file.getLocationURI(), i1.getIncludedByLocation().getURI());
- assertEquals(project.getFile(TestScannerProvider.sIncludeFiles[0]).getLocation(), new Path(i1.getFullName()));
+ assertEquals(project.getFile(TestScannerProvider.sIncludeFiles[0]).getLocation(),
+ new Path(i1.getFullName()));
// the include file is not in the working directory
assertEquals(null, i1.getIncludesLocation());
// the second directory is the directory containing the main source file
- IIndexInclude i2= includes[1];
+ IIndexInclude i2 = includes[1];
assertEquals(file.getLocationURI(), i2.getIncludedByLocation().getURI());
assertEquals(include.getLocationURI(), i2.getIncludesLocation().getURI());
assertEquals(true, i2.isSystemInclude());
@@ -497,32 +497,32 @@ public class IndexBugsTests extends BaseTestCase {
public void test160281_2() throws Exception {
waitForIndexer();
IProject project = fCProject.getProject();
- IFile include= TestSourceReader.createFile(project, "inc/test160281_2.h", "#define X y\n");
- TestScannerProvider.sIncludes= new String[]{include.getLocation().removeLastSegments(1).toString()};
- TestScannerProvider.sMacroFiles= new String[]{include.getName()};
- IFile file= TestSourceReader.createFile(project, "test160281_2.cpp", "int X;");
+ IFile include = TestSourceReader.createFile(project, "inc/test160281_2.h", "#define X y\n");
+ TestScannerProvider.sIncludes = new String[] { include.getLocation().removeLastSegments(1).toString() };
+ TestScannerProvider.sMacroFiles = new String[] { include.getName() };
+ IFile file = TestSourceReader.createFile(project, "test160281_2.cpp", "int X;");
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEXER_TIMEOUT_SEC * 1000);
fIndex.acquireReadLock();
try {
- IIndexFile ifile= getIndexFile(file);
- IIndexInclude[] includes= ifile.getIncludes();
+ IIndexFile ifile = getIndexFile(file);
+ IIndexInclude[] includes = ifile.getIncludes();
// the first directory searched for file is the preprocessor's working directory (build directory), see gcc manual -imacros option
- IIndexInclude i1= includes[0];
+ IIndexInclude i1 = includes[0];
assertEquals(file.getLocationURI(), i1.getIncludedByLocation().getURI());
assertEquals(project.getFile(TestScannerProvider.sMacroFiles[0]).getLocation(), new Path(i1.getFullName()));
// the include file is not in the working directory
assertEquals(null, i1.getIncludesLocation());
// the second directory is the directory containing the main source file
- IIndexInclude i2= includes[1];
+ IIndexInclude i2 = includes[1];
assertEquals(file.getLocationURI(), i2.getIncludedByLocation().getURI());
assertEquals(include.getLocationURI(), i2.getIncludesLocation().getURI());
assertEquals(true, i2.isSystemInclude());
assertEquals(0, i2.getNameOffset());
assertEquals(0, i2.getNameLength());
- IIndexBinding[] bindings= fIndex.findBindings("y".toCharArray(), IndexFilter.ALL, npm());
+ IIndexBinding[] bindings = fIndex.findBindings("y".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
assertTrue(bindings[0] instanceof IVariable);
@@ -532,69 +532,70 @@ public class IndexBugsTests extends BaseTestCase {
}
}
- // namespace ns162011 {
- // class Class162011 {
- // friend void function162011(Class162011);
- // };
- // void function162011(Class162011 x){};
- // }
- public void test162011() throws Exception {
+ // namespace ns162011 {
+ // class Class162011 {
+ // friend void function162011(Class162011);
+ // };
+ // void function162011(Class162011 x){};
+ // }
+ public void test162011() throws Exception {
String content = getContentsForTest(1)[0];
String fileName = "bug162011.cpp";
String funcName = "function162011";
int indexOfDecl = content.indexOf(funcName);
- int indexOfDef = content.indexOf(funcName, indexOfDecl+1);
- IFile file= createFile(getProject(), fileName, content);
+ int indexOfDef = content.indexOf(funcName, indexOfDecl + 1);
+ IFile file = createFile(getProject(), fileName, content);
waitUntilFileIsIndexed(file, INDEXER_TIMEOUT_SEC * 1000);
// make sure the ast is correct
- ITranslationUnit tu= (ITranslationUnit) fCProject.findElement(new Path(fileName));
- IASTTranslationUnit ast= tu.getAST();
- IASTName name= (IASTName) ast.getNodeSelector(null).findNode(indexOfDecl, funcName.length());
- IBinding astBinding= name.resolveBinding();
+ ITranslationUnit tu = (ITranslationUnit) fCProject.findElement(new Path(fileName));
+ IASTTranslationUnit ast = tu.getAST();
+ IASTName name = (IASTName) ast.getNodeSelector(null).findNode(indexOfDecl, funcName.length());
+ IBinding astBinding = name.resolveBinding();
- IName[] astDecls= ast.getDeclarations(astBinding);
+ IName[] astDecls = ast.getDeclarations(astBinding);
assertEquals(2, astDecls.length);
- int i1= astDecls[0].getFileLocation().getNodeOffset();
- int i2= astDecls[1].getFileLocation().getNodeOffset();
+ int i1 = astDecls[0].getFileLocation().getNodeOffset();
+ int i2 = astDecls[1].getFileLocation().getNodeOffset();
assertEquals(indexOfDecl, Math.min(i1, i2));
assertEquals(indexOfDef, Math.max(i1, i2));
fIndex.acquireReadLock();
try {
- IIndexBinding[] bindings= fIndex.findBindings(getPattern("ns162011::function162011"), true, IndexFilter.ALL, npm());
+ IIndexBinding[] bindings = fIndex.findBindings(getPattern("ns162011::function162011"), true,
+ IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
- IIndexBinding binding= bindings[0];
+ IIndexBinding binding = bindings[0];
// check if we have the declaration
- IIndexName[] decls= fIndex.findNames(binding, IIndex.FIND_DECLARATIONS);
+ IIndexName[] decls = fIndex.findNames(binding, IIndex.FIND_DECLARATIONS);
assertEquals(1, decls.length);
assertEquals(indexOfDecl, decls[0].getNodeOffset());
// check if we have the definition
- decls= fIndex.findNames(binding, IIndex.FIND_DEFINITIONS);
+ decls = fIndex.findNames(binding, IIndex.FIND_DEFINITIONS);
assertEquals(1, decls.length);
assertEquals(indexOfDef, decls[0].getNodeOffset());
} finally {
fIndex.releaseReadLock();
}
- }
+ }
public void test164360_1() throws Exception {
waitForIndexer();
- IFile include= TestSourceReader.createFile(fCProject.getProject(), "test164360.h", "");
- TestScannerProvider.sIncludeFiles= new String[] { include.getLocation().toOSString() };
- IFile file= TestSourceReader.createFile(fCProject.getProject(), "test164360.cpp", "");
+ IFile include = TestSourceReader.createFile(fCProject.getProject(), "test164360.h", "");
+ TestScannerProvider.sIncludeFiles = new String[] { include.getLocation().toOSString() };
+ IFile file = TestSourceReader.createFile(fCProject.getProject(), "test164360.cpp", "");
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEXER_TIMEOUT_SEC * 1000);
fIndex.acquireReadLock();
try {
- IIndexFile ifile= getIndexFile(file);
- IIndexInclude[] includes= ifile.getIncludes();
+ IIndexFile ifile = getIndexFile(file);
+ IIndexInclude[] includes = ifile.getIncludes();
assertEquals(1, includes.length);
- IIndexInclude i= includes[0];
+ IIndexInclude i = includes[0];
assertEquals(file.getLocationURI(), i.getIncludedByLocation().getURI());
assertEquals(include.getLocationURI(), i.getIncludesLocation().getURI());
assertEquals(true, i.isSystemInclude());
@@ -607,17 +608,17 @@ public class IndexBugsTests extends BaseTestCase {
public void test164360_2() throws Exception {
waitForIndexer();
- IFile include= TestSourceReader.createFile(fCProject.getProject(), "test164360.h", "");
- TestScannerProvider.sMacroFiles= new String[]{include.getLocation().toOSString()};
- IFile file= TestSourceReader.createFile(fCProject.getProject(), "test164360.cpp", "");
+ IFile include = TestSourceReader.createFile(fCProject.getProject(), "test164360.h", "");
+ TestScannerProvider.sMacroFiles = new String[] { include.getLocation().toOSString() };
+ IFile file = TestSourceReader.createFile(fCProject.getProject(), "test164360.cpp", "");
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEXER_TIMEOUT_SEC * 1000);
fIndex.acquireReadLock();
try {
- IIndexFile ifile= getIndexFile(file);
- IIndexInclude[] includes= ifile.getIncludes();
+ IIndexFile ifile = getIndexFile(file);
+ IIndexInclude[] includes = ifile.getIncludes();
assertEquals(1, includes.length);
- IIndexInclude i= includes[0];
+ IIndexInclude i = includes[0];
assertEquals(file.getLocationURI(), i.getIncludedByLocation().getURI());
assertEquals(include.getLocationURI(), i.getIncludesLocation().getURI());
assertEquals(true, i.isSystemInclude());
@@ -633,21 +634,21 @@ public class IndexBugsTests extends BaseTestCase {
// #define macro164500 2
public void test164500() throws Exception {
waitForIndexer();
- String content= getContentsForTest(1)[0];
+ String content = getContentsForTest(1)[0];
- IFile file= TestSourceReader.createFile(fCProject.getProject(), "test164500.cpp", content);
+ IFile file = TestSourceReader.createFile(fCProject.getProject(), "test164500.cpp", content);
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEXER_TIMEOUT_SEC * 1000);
fIndex.acquireReadLock();
try {
- IIndexFile ifile= getIndexFile(file);
- IIndexMacro[] macros= ifile.getMacros();
+ IIndexFile ifile = getIndexFile(file);
+ IIndexMacro[] macros = ifile.getMacros();
assertEquals(3, macros.length);
- IIndexMacro m= macros[0];
+ IIndexMacro m = macros[0];
assertEquals("1", new String(m.getExpansionImage()));
assertEquals("macro164500", new String(m.getName()));
- m= macros[2];
+ m = macros[2];
assertEquals("2", new String(m.getExpansionImage()));
assertEquals("macro164500", new String(m.getName()));
} finally {
@@ -664,24 +665,25 @@ public class IndexBugsTests extends BaseTestCase {
// // header.h
// enum E {A,B,C};
public void test171834() throws Exception {
- CModelListener.sSuppressUpdateOfLastRecentlyUsed= false;
+ CModelListener.sSuppressUpdateOfLastRecentlyUsed = false;
waitForIndexer();
ICProject cproject = CProjectHelper.createCCProject("seq1", "bin", IPDOMManager.ID_FAST_INDEXER);
try {
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
String[] testData = getContentsForTest(3);
- IFile header= TestSourceReader.createFile(cproject.getProject(), "header.h", testData[0]);
- IFile referer= TestSourceReader.createFile(cproject.getProject(), "content.cpp", testData[1]);
+ IFile header = TestSourceReader.createFile(cproject.getProject(), "header.h", testData[0]);
+ IFile referer = TestSourceReader.createFile(cproject.getProject(), "content.cpp", testData[1]);
TestSourceReader.waitUntilFileIsIndexed(index, referer, INDEXER_TIMEOUT_SEC * 1000);
index.acquireReadLock();
try {
- IBinding[] bindings = index.findBindings(Pattern.compile("var"), true, IndexFilter.ALL, new NullProgressMonitor());
+ IBinding[] bindings = index.findBindings(Pattern.compile("var"), true, IndexFilter.ALL,
+ new NullProgressMonitor());
assertEquals(1, bindings.length);
- IType type = ((ICPPVariable)bindings[0]).getType();
+ IType type = ((ICPPVariable) bindings[0]).getType();
assertTrue(type instanceof ICPPClassType);
- assertEquals("var is not of type class", ICPPClassType.k_class, ((ICPPClassType)type).getKey());
+ assertEquals("var is not of type class", ICPPClassType.k_class, ((ICPPClassType) type).getKey());
} finally {
index.releaseReadLock();
}
@@ -692,10 +694,11 @@ public class IndexBugsTests extends BaseTestCase {
index.acquireReadLock();
try {
- IBinding[] bindings = index.findBindings(Pattern.compile("var"), true, IndexFilter.ALL, new NullProgressMonitor());
+ IBinding[] bindings = index.findBindings(Pattern.compile("var"), true, IndexFilter.ALL,
+ new NullProgressMonitor());
assertEquals(1, bindings.length);
- IType type = ((ICPPVariable)bindings[0]).getType();
+ IType type = ((ICPPVariable) bindings[0]).getType();
assertTrue(type instanceof IEnumeration);
} finally {
index.releaseReadLock();
@@ -710,23 +713,24 @@ public class IndexBugsTests extends BaseTestCase {
// } S20070201;
public void test172454_1() throws Exception {
waitForIndexer();
- String content= getContentsForTest(1)[0];
+ String content = getContentsForTest(1)[0];
- IFile file= TestSourceReader.createFile(fCProject.getProject(), "test172454.c", content);
+ IFile file = TestSourceReader.createFile(fCProject.getProject(), "test172454.c", content);
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEXER_TIMEOUT_SEC * 1000);
fIndex.acquireReadLock();
try {
- IBinding[] bindings= fIndex.findBindings("S20070201".toCharArray(), IndexFilter.getFilter(ILinkage.C_LINKAGE_ID), npm());
+ IBinding[] bindings = fIndex.findBindings("S20070201".toCharArray(),
+ IndexFilter.getFilter(ILinkage.C_LINKAGE_ID), npm());
assertEquals(2, bindings.length);
IBinding struct, typedef;
if (bindings[0] instanceof ICompositeType) {
- struct= bindings[0];
- typedef= bindings[1];
+ struct = bindings[0];
+ typedef = bindings[1];
} else {
- struct= bindings[1];
- typedef= bindings[0];
+ struct = bindings[1];
+ typedef = bindings[0];
}
assertTrue(struct instanceof ICompositeType);
@@ -743,31 +747,32 @@ public class IndexBugsTests extends BaseTestCase {
// } S20070201;
public void test172454_2() throws Exception {
waitForIndexer();
- String content= getContentsForTest(1)[0];
+ String content = getContentsForTest(1)[0];
- IFile file= TestSourceReader.createFile(fCProject.getProject(), "test172454.cpp", content);
+ IFile file = TestSourceReader.createFile(fCProject.getProject(), "test172454.cpp", content);
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEXER_TIMEOUT_SEC * 1000);
fIndex.acquireReadLock();
try {
- IBinding[] bindings= fIndex.findBindings("S20070201".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
+ IBinding[] bindings = fIndex.findBindings("S20070201".toCharArray(),
+ IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
assertEquals(2, bindings.length);
IBinding struct, typedef;
if (bindings[0] instanceof ICPPClassType) {
- struct= bindings[0];
- typedef= bindings[1];
+ struct = bindings[0];
+ typedef = bindings[1];
} else {
- struct= bindings[1];
- typedef= bindings[0];
+ struct = bindings[1];
+ typedef = bindings[0];
}
assertTrue(struct instanceof ICPPClassType);
- assertTrue(((ICPPClassType)struct).getKey()==ICompositeType.k_struct);
+ assertTrue(((ICPPClassType) struct).getKey() == ICompositeType.k_struct);
assertTrue(typedef instanceof ITypedef);
IType aliased = ((ITypedef) typedef).getType();
assertTrue(aliased instanceof ICPPClassType);
- assertTrue(((ICPPClassType)aliased).getKey()==ICompositeType.k_struct);
+ assertTrue(((ICPPClassType) aliased).getKey() == ICompositeType.k_struct);
assertTrue(((ITypedef) typedef).isSameType((ICompositeType) struct));
} finally {
fIndex.releaseReadLock();
@@ -777,43 +782,46 @@ public class IndexBugsTests extends BaseTestCase {
// typedef int T20070213;
public void test173997() throws Exception {
waitForIndexer();
- String content= getContentsForTest(1)[0];
+ String content = getContentsForTest(1)[0];
- IFile file= TestSourceReader.createFile(fCProject.getProject(), "test173997.cpp", content);
+ IFile file = TestSourceReader.createFile(fCProject.getProject(), "test173997.cpp", content);
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEXER_TIMEOUT_SEC * 1000);
fIndex.acquireReadLock();
try {
- IBinding[] bindings= fIndex.findBindings("T20070213".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
+ IBinding[] bindings = fIndex.findBindings("T20070213".toCharArray(),
+ IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
assertEquals(1, bindings.length);
assertTrue(bindings[0] instanceof ITypedef);
- ITypedef td= (ITypedef) bindings[0];
- IType type= td.getType();
+ ITypedef td = (ITypedef) bindings[0];
+ IType type = td.getType();
assertTrue(type instanceof IBasicType);
- IBasicType btype= (IBasicType) type;
+ IBasicType btype = (IBasicType) type;
assertEquals(IBasicType.t_int, btype.getType());
} finally {
fIndex.releaseReadLock();
}
- long timestamp= file.getLocalTimeStamp();
- content= "int UPDATED20070213;\n" + content.replaceFirst("int", "float");
- file= TestSourceReader.createFile(fCProject.getProject(), "test173997.cpp", content);
+ long timestamp = file.getLocalTimeStamp();
+ content = "int UPDATED20070213;\n" + content.replaceFirst("int", "float");
+ file = TestSourceReader.createFile(fCProject.getProject(), "test173997.cpp", content);
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEXER_TIMEOUT_SEC * 1000);
fIndex.acquireReadLock();
try {
// double check if file was indexed
- IBinding[] bindings= fIndex.findBindings("UPDATED20070213".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
+ IBinding[] bindings = fIndex.findBindings("UPDATED20070213".toCharArray(),
+ IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
assertEquals(1, bindings.length);
- bindings= fIndex.findBindings("T20070213".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
+ bindings = fIndex.findBindings("T20070213".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID),
+ npm());
assertEquals(1, bindings.length);
assertTrue(bindings[0] instanceof ITypedef);
- ITypedef td= (ITypedef) bindings[0];
- IType type= td.getType();
+ ITypedef td = (ITypedef) bindings[0];
+ IType type = td.getType();
assertTrue(type instanceof IBasicType);
- IBasicType btype= (IBasicType) type;
+ IBasicType btype = (IBasicType) type;
assertTrue(IBasicType.t_int != btype.getType());
assertEquals(IBasicType.t_float, btype.getType());
} finally {
@@ -829,34 +837,34 @@ public class IndexBugsTests extends BaseTestCase {
// class B {};
// B var;
public void test173997_2() throws Exception {
- String[] content= getContentsForTest(2);
+ String[] content = getContentsForTest(2);
- IFile file= createFile(getProject(), "header.h", content[0]);
+ IFile file = createFile(getProject(), "header.h", content[0]);
waitUntilFileIsIndexed(file, INDEXER_TIMEOUT_SEC * 1000);
- IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
+ IIndex index = CCorePlugin.getIndexManager().getIndex(fCProject);
index.acquireReadLock();
try {
- IBinding[] bs= index.findBindings("var".toCharArray(), IndexFilter.ALL, npm());
+ IBinding[] bs = index.findBindings("var".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bs.length);
assertTrue(bs[0] instanceof ICPPVariable);
- assertTrue(((ICPPVariable)bs[0]).getType() instanceof ICPPClassType);
- assertEquals("A", ((ICPPClassType)(((ICPPVariable)bs[0]).getType())).getName());
+ assertTrue(((ICPPVariable) bs[0]).getType() instanceof ICPPClassType);
+ assertEquals("A", ((ICPPClassType) (((ICPPVariable) bs[0]).getType())).getName());
} finally {
index.releaseReadLock();
}
- file= createFile(getProject(), "header.h", content[1]);
+ file = createFile(getProject(), "header.h", content[1]);
waitUntilFileIsIndexed(file, INDEXER_TIMEOUT_SEC * 1000);
- index= CCorePlugin.getIndexManager().getIndex(fCProject);
+ index = CCorePlugin.getIndexManager().getIndex(fCProject);
index.acquireReadLock();
try {
- IBinding[] bs= index.findBindings("var".toCharArray(), IndexFilter.ALL, npm());
+ IBinding[] bs = index.findBindings("var".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bs.length);
assertTrue(bs[0] instanceof ICPPVariable);
- assertTrue(((ICPPVariable)bs[0]).getType() instanceof ICPPClassType);
- assertEquals("B", ((ICPPClassType)(((ICPPVariable)bs[0]).getType())).getName());
+ assertTrue(((ICPPVariable) bs[0]).getType() instanceof ICPPClassType);
+ assertEquals("B", ((ICPPClassType) (((ICPPVariable) bs[0]).getType())).getName());
} finally {
index.releaseReadLock();
}
@@ -880,12 +888,12 @@ public class IndexBugsTests extends BaseTestCase {
String[] testData = getContentsForTest(3);
TestSourceReader.createFile(fCProject.getProject(), "header.h", testData[0]);
- IFile test= TestSourceReader.createFile(fCProject.getProject(), "test.cpp", testData[1]);
+ IFile test = TestSourceReader.createFile(fCProject.getProject(), "test.cpp", testData[1]);
TestSourceReader.createFile(fCProject.getProject(), "unrelated.cpp", testData[2]);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
indexManager.reindex(fCProject);
waitForIndexer();
- IIndex index= indexManager.getIndex(fCProject);
+ IIndex index = indexManager.getIndex(fCProject);
index.acquireReadLock();
try {
IASTTranslationUnit ast = TestSourceReader.createIndexBasedAST(index, fCProject, test);
@@ -922,11 +930,11 @@ public class IndexBugsTests extends BaseTestCase {
TestSourceReader.createFile(fCProject.getProject(), "test1.h", testData[0]);
TestSourceReader.createFile(fCProject.getProject(), "test2.h", testData[1]);
TestSourceReader.createFile(fCProject.getProject(), "test1.cpp", testData[2]);
- IFile test2= TestSourceReader.createFile(fCProject.getProject(), "test2.cpp", testData[3]);
+ IFile test2 = TestSourceReader.createFile(fCProject.getProject(), "test2.cpp", testData[3]);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
indexManager.reindex(fCProject);
waitForIndexer();
- IIndex index= indexManager.getIndex(fCProject);
+ IIndex index = indexManager.getIndex(fCProject);
index.acquireReadLock();
try {
IASTTranslationUnit ast = TestSourceReader.createIndexBasedAST(index, fCProject, test2);
@@ -963,11 +971,11 @@ public class IndexBugsTests extends BaseTestCase {
TestSourceReader.createFile(fCProject.getProject(), "test1.h", testData[0]);
TestSourceReader.createFile(fCProject.getProject(), "test2.h", testData[1]);
TestSourceReader.createFile(fCProject.getProject(), "test1.cpp", testData[2]);
- IFile test2= TestSourceReader.createFile(fCProject.getProject(), "test2.cpp", testData[3]);
+ IFile test2 = TestSourceReader.createFile(fCProject.getProject(), "test2.cpp", testData[3]);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
indexManager.reindex(fCProject);
waitForIndexer();
- IIndex index= indexManager.getIndex(fCProject);
+ IIndex index = indexManager.getIndex(fCProject);
index.acquireReadLock();
try {
IASTTranslationUnit ast = TestSourceReader.createIndexBasedAST(index, fCProject, test2);
@@ -982,13 +990,13 @@ public class IndexBugsTests extends BaseTestCase {
waitForIndexer();
/* Check that when a project is deleted, its index contents do not
- * appear in the initial index of a newly created project of the same name */
+ * appear in the initial index of a newly created project of the same name */
- String pname = "deleteTest"+System.currentTimeMillis();
+ String pname = "deleteTest" + System.currentTimeMillis();
ICProject cproject = CProjectHelper.createCCProject(pname, "bin", IPDOMManager.ID_FAST_INDEXER);
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
- String content= getContentsForTest(1)[0];
- IFile file= TestSourceReader.createFile(cproject.getProject(), "content.cpp", content);
+ String content = getContentsForTest(1)[0];
+ IFile file = TestSourceReader.createFile(cproject.getProject(), "content.cpp", content);
TestSourceReader.waitUntilFileIsIndexed(index, file, INDEXER_TIMEOUT_SEC * 1000);
CProjectHelper.delete(cproject);
@@ -996,7 +1004,8 @@ public class IndexBugsTests extends BaseTestCase {
index = CCorePlugin.getIndexManager().getIndex(cproject);
index.acquireReadLock();
try {
- IBinding[] bindings = index.findBindings(Pattern.compile(".*"), false, IndexFilter.ALL, new NullProgressMonitor());
+ IBinding[] bindings = index.findBindings(Pattern.compile(".*"), false, IndexFilter.ALL,
+ new NullProgressMonitor());
assertEquals(0, bindings.length);
} finally {
index.releaseReadLock();
@@ -1009,12 +1018,12 @@ public class IndexBugsTests extends BaseTestCase {
waitForIndexer();
/* Check that the contents of an index is preserved over a project
- * move operation */
+ * move operation */
ICProject cproject = CProjectHelper.createCCProject("moveTest", "bin", IPDOMManager.ID_FAST_INDEXER);
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
- String content= getContentsForTest(1)[0];
- IFile file= TestSourceReader.createFile(cproject.getProject(), "content.cpp", content);
+ String content = getContentsForTest(1)[0];
+ IFile file = TestSourceReader.createFile(cproject.getProject(), "content.cpp", content);
TestSourceReader.waitUntilFileIsIndexed(index, file, INDEXER_TIMEOUT_SEC * 1000);
// move the project to a random new location
@@ -1026,7 +1035,8 @@ public class IndexBugsTests extends BaseTestCase {
index = CCorePlugin.getIndexManager().getIndex(cproject);
index.acquireReadLock();
try {
- IBinding[] bindings = index.findBindings(Pattern.compile(".*"), false, IndexFilter.ALL_DECLARED, new NullProgressMonitor());
+ IBinding[] bindings = index.findBindings(Pattern.compile(".*"), false, IndexFilter.ALL_DECLARED,
+ new NullProgressMonitor());
assertEquals(4, bindings.length);
} finally {
index.releaseReadLock();
@@ -1045,9 +1055,9 @@ public class IndexBugsTests extends BaseTestCase {
// };
public void testFindBindingsWithPrefix() throws Exception {
waitForIndexer();
- String content= getContentsForTest(1)[0];
+ String content = getContentsForTest(1)[0];
- IFile file= TestSourceReader.createFile(fCProject.getProject(), "testFBWP.cpp", content);
+ IFile file = TestSourceReader.createFile(fCProject.getProject(), "testFBWP.cpp", content);
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEXER_TIMEOUT_SEC * 1000);
fIndex.acquireReadLock();
@@ -1059,16 +1069,16 @@ public class IndexBugsTests extends BaseTestCase {
}
};
- IBinding[] bindings= fIndex.findBindingsForPrefix(new char[] {'a'}, true, NON_FUNCTIONS, null);
+ IBinding[] bindings = fIndex.findBindingsForPrefix(new char[] { 'a' }, true, NON_FUNCTIONS, null);
assertEquals(3, bindings.length);
- bindings= fIndex.findBindingsForPrefix(new char[] {'a'}, false, NON_FUNCTIONS, null);
+ bindings = fIndex.findBindingsForPrefix(new char[] { 'a' }, false, NON_FUNCTIONS, null);
assertEquals(6, bindings.length);
- bindings= fIndex.findBindingsForPrefix(new char[] {'a','A'}, true, NON_FUNCTIONS, null);
+ bindings = fIndex.findBindingsForPrefix(new char[] { 'a', 'A' }, true, NON_FUNCTIONS, null);
assertEquals(1, bindings.length);
- bindings= fIndex.findBindingsForPrefix(new char[] {'a','A'}, false, NON_FUNCTIONS, null);
+ bindings = fIndex.findBindingsForPrefix(new char[] { 'a', 'A' }, false, NON_FUNCTIONS, null);
assertEquals(2, bindings.length);
} finally {
fIndex.releaseReadLock();
@@ -1078,9 +1088,10 @@ public class IndexBugsTests extends BaseTestCase {
// class a { class b { class c { void f(); }; }; };
public void testFilterFindBindingsFQCharArray() throws Exception {
waitForIndexer();
- String content= getContentsForTest(1)[0];
+ String content = getContentsForTest(1)[0];
- IFile file= TestSourceReader.createFile(fCProject.getProject(), "testFilterFindBindingsFQCharArray.cpp", content);
+ IFile file = TestSourceReader.createFile(fCProject.getProject(), "testFilterFindBindingsFQCharArray.cpp",
+ content);
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEXER_TIMEOUT_SEC * 1000);
fIndex.acquireReadLock();
@@ -1092,17 +1103,18 @@ public class IndexBugsTests extends BaseTestCase {
}
};
- IBinding[] bindings= fIndex.findBindings(new char[][]{{'a'},{'b'},{'c'},{'f'}}, NON_CLASS, npm());
+ IBinding[] bindings = fIndex.findBindings(new char[][] { { 'a' }, { 'b' }, { 'c' }, { 'f' } }, NON_CLASS,
+ npm());
assertEquals(1, bindings.length);
} finally {
fIndex.releaseReadLock();
}
}
- // typedef struct {
- // float fNumber;
- // int iIdx;
- // } StructA_T;
+ // typedef struct {
+ // float fNumber;
+ // int iIdx;
+ // } StructA_T;
// #include "../__bugsTest__/common.h"
// StructA_T gvar1;
@@ -1110,24 +1122,24 @@ public class IndexBugsTests extends BaseTestCase {
// #include "../__bugsTest__/common.h"
// StructA_T gvar2;
public void testFileInMultipleFragments_bug192352() throws Exception {
- String[] contents= getContentsForTest(3);
+ String[] contents = getContentsForTest(3);
ICProject p2 = CProjectHelper.createCCProject("__bugsTest_2_", "bin", IPDOMManager.ID_FAST_INDEXER);
try {
- IFile f1= TestSourceReader.createFile(fCProject.getProject(), "common.h", contents[0]);
- IFile f2= TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[1]);
- IFile f3= TestSourceReader.createFile(p2.getProject(), "src.cpp", contents[2]);
+ IFile f1 = TestSourceReader.createFile(fCProject.getProject(), "common.h", contents[0]);
+ IFile f2 = TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[1]);
+ IFile f3 = TestSourceReader.createFile(p2.getProject(), "src.cpp", contents[2]);
waitForIndexer();
- IIndex index= CCorePlugin.getIndexManager().getIndex(new ICProject[]{fCProject, p2});
+ IIndex index = CCorePlugin.getIndexManager().getIndex(new ICProject[] { fCProject, p2 });
index.acquireReadLock();
try {
- IIndexBinding[] bindings= index.findBindings("StructA_T".toCharArray(), IndexFilter.ALL, npm());
+ IIndexBinding[] bindings = index.findBindings("StructA_T".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
- IIndexBinding binding= bindings[0];
- IIndexName[] names= index.findReferences(binding);
+ IIndexBinding binding = bindings[0];
+ IIndexName[] names = index.findReferences(binding);
assertEquals(2, names.length);
- names= index.findDeclarations(binding);
+ names = index.findDeclarations(binding);
assertEquals(1, names.length);
} finally {
index.releaseReadLock();
@@ -1158,17 +1170,17 @@ public class IndexBugsTests extends BaseTestCase {
// #endif
public void testIncludeGuardsOutsideOfHeader_Bug167100() throws Exception {
final IIndexManager indexManager = CCorePlugin.getIndexManager();
- String[] contents= getContentsForTest(5);
- IFile f1= TestSourceReader.createFile(fCProject.getProject(), "header1.h", contents[0]);
- IFile f2= TestSourceReader.createFile(fCProject.getProject(), "header2.h", contents[1]);
- IFile f3= TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[2]);
+ String[] contents = getContentsForTest(5);
+ IFile f1 = TestSourceReader.createFile(fCProject.getProject(), "header1.h", contents[0]);
+ IFile f2 = TestSourceReader.createFile(fCProject.getProject(), "header2.h", contents[1]);
+ IFile f3 = TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[2]);
indexManager.reindex(fCProject);
waitForIndexer();
- IFile f4= TestSourceReader.createFile(fCProject.getProject(), "src2.cpp", contents[3]);
- IFile f5= TestSourceReader.createFile(fCProject.getProject(), "src3.cpp", contents[4]);
+ IFile f4 = TestSourceReader.createFile(fCProject.getProject(), "src2.cpp", contents[3]);
+ IFile f5 = TestSourceReader.createFile(fCProject.getProject(), "src3.cpp", contents[4]);
waitForIndexer();
- IIndex index= indexManager.getIndex(fCProject);
+ IIndex index = indexManager.getIndex(fCProject);
index.acquireReadLock();
try {
IIndexBinding[] bindings = index.findBindings("v".toCharArray(), IndexFilter.ALL, npm());
@@ -1179,10 +1191,10 @@ public class IndexBugsTests extends BaseTestCase {
assertEquals(1, names.length);
assertEquals(f4.getFullPath().toString(), names[0].getFile().getLocation().getFullPath());
- IIndexFile[] idxFiles= index.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(f5));
+ IIndexFile[] idxFiles = index.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(f5));
assertEquals(1, idxFiles.length);
- IIndexFile idxFile= idxFiles[0];
- IIndexInclude[] includes= idxFile.getIncludes();
+ IIndexFile idxFile = idxFiles[0];
+ IIndexInclude[] includes = idxFile.getIncludes();
assertEquals(2, includes.length);
assertTrue(includes[0].isActive());
assertTrue(includes[0].isResolved());
@@ -1201,18 +1213,18 @@ public class IndexBugsTests extends BaseTestCase {
// MAC()= MAC(1) + MAC(1,2);
// }
public void testVariadicMacros_Bug200239_1() throws Exception {
- String[] contents= getContentsForTest(2);
+ String[] contents = getContentsForTest(2);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
- IFile f1= TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0]);
+ IFile f1 = TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0]);
waitUntilFileIsIndexed(f1, INDEXER_TIMEOUT_SEC * 1000);
- IFile f2= TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[1]);
+ IFile f2 = TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[1]);
waitForIndexer();
fIndex.acquireReadLock();
try {
- IIndexBinding[] bindings= fIndex.findBindings("Bug200239".toCharArray(), IndexFilter.ALL, npm());
+ IIndexBinding[] bindings = fIndex.findBindings("Bug200239".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
- IIndexName[] refs= fIndex.findReferences(bindings[0]);
+ IIndexName[] refs = fIndex.findReferences(bindings[0]);
assertEquals(3, refs.length);
} finally {
fIndex.releaseReadLock();
@@ -1227,18 +1239,18 @@ public class IndexBugsTests extends BaseTestCase {
// GMAC()= GMAC(1) + GMAC(1,2);
// }
public void testVariadicMacros_Bug200239_2() throws Exception {
- String[] contents= getContentsForTest(2);
+ String[] contents = getContentsForTest(2);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
- IFile f1= TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0]);
+ IFile f1 = TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0]);
waitUntilFileIsIndexed(f1, INDEXER_TIMEOUT_SEC * 1000);
- IFile f2= TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[1]);
+ IFile f2 = TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[1]);
waitForIndexer();
fIndex.acquireReadLock();
try {
- IIndexBinding[] bindings= fIndex.findBindings("Bug200239".toCharArray(), IndexFilter.ALL, npm());
+ IIndexBinding[] bindings = fIndex.findBindings("Bug200239".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
- IIndexName[] refs= fIndex.findReferences(bindings[0]);
+ IIndexName[] refs = fIndex.findReferences(bindings[0]);
assertEquals(3, refs.length);
} finally {
fIndex.releaseReadLock();
@@ -1248,18 +1260,18 @@ public class IndexBugsTests extends BaseTestCase {
// typedef bug200553_A bug200553_B;
// typedef bug200553_B bug200553_A;
public void testTypedefRecursionCpp_Bug200553() throws Exception {
- String[] contents= getContentsForTest(1);
+ String[] contents = getContentsForTest(1);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
- IFile f1= TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[0]);
+ IFile f1 = TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[0]);
waitForIndexer();
fIndex.acquireReadLock();
try {
- IIndexBinding[] bindings= fIndex.findBindings("bug200553_A".toCharArray(), IndexFilter.ALL, npm());
+ IIndexBinding[] bindings = fIndex.findBindings("bug200553_A".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
assertTrue(bindings[0] instanceof ITypedef);
checkTypedefDepth((ITypedef) bindings[0]);
- bindings= fIndex.findBindings("bug200553_B".toCharArray(), IndexFilter.ALL, npm());
+ bindings = fIndex.findBindings("bug200553_B".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
assertTrue(bindings[0] instanceof ITypedef);
checkTypedefDepth((ITypedef) bindings[0]);
@@ -1267,16 +1279,16 @@ public class IndexBugsTests extends BaseTestCase {
fIndex.releaseReadLock();
}
- indexManager.update(new ICElement[] {fCProject}, IIndexManager.UPDATE_ALL);
+ indexManager.update(new ICElement[] { fCProject }, IIndexManager.UPDATE_ALL);
waitForIndexer();
fIndex.acquireReadLock();
try {
- IIndexBinding[] bindings= fIndex.findBindings("bug200553_A".toCharArray(), IndexFilter.ALL, npm());
+ IIndexBinding[] bindings = fIndex.findBindings("bug200553_A".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
assertTrue(bindings[0] instanceof ITypedef);
checkTypedefDepth((ITypedef) bindings[0]);
- bindings= fIndex.findBindings("bug200553_B".toCharArray(), IndexFilter.ALL, npm());
+ bindings = fIndex.findBindings("bug200553_B".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
assertTrue(bindings[0] instanceof ITypedef);
checkTypedefDepth((ITypedef) bindings[0]);
@@ -1286,10 +1298,10 @@ public class IndexBugsTests extends BaseTestCase {
}
private void checkTypedefDepth(ITypedef td) throws DOMException {
- int maxDepth= 20;
- IType type= td;
+ int maxDepth = 20;
+ IType type = td;
while (--maxDepth > 0 && type instanceof ITypedef) {
- type= ((ITypedef) type).getType();
+ type = ((ITypedef) type).getType();
}
assertTrue(maxDepth > 0);
}
@@ -1297,18 +1309,18 @@ public class IndexBugsTests extends BaseTestCase {
// typedef bug200553_A bug200553_B;
// typedef bug200553_B bug200553_A;
public void testTypedefRecursionC_Bug200553() throws Exception {
- String[] contents= getContentsForTest(1);
+ String[] contents = getContentsForTest(1);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
- IFile f1= TestSourceReader.createFile(fCProject.getProject(), "src.c", contents[0]);
+ IFile f1 = TestSourceReader.createFile(fCProject.getProject(), "src.c", contents[0]);
waitForIndexer();
fIndex.acquireReadLock();
try {
- IIndexBinding[] bindings= fIndex.findBindings("bug200553_A".toCharArray(), IndexFilter.ALL, npm());
+ IIndexBinding[] bindings = fIndex.findBindings("bug200553_A".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
assertTrue(bindings[0] instanceof ITypedef);
checkTypedefDepth((ITypedef) bindings[0]);
- bindings= fIndex.findBindings("bug200553_B".toCharArray(), IndexFilter.ALL, npm());
+ bindings = fIndex.findBindings("bug200553_B".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
assertTrue(bindings[0] instanceof ITypedef);
checkTypedefDepth((ITypedef) bindings[0]);
@@ -1316,16 +1328,16 @@ public class IndexBugsTests extends BaseTestCase {
fIndex.releaseReadLock();
}
- indexManager.update(new ICElement[] {fCProject}, IIndexManager.UPDATE_ALL);
+ indexManager.update(new ICElement[] { fCProject }, IIndexManager.UPDATE_ALL);
waitForIndexer();
fIndex.acquireReadLock();
try {
- IIndexBinding[] bindings= fIndex.findBindings("bug200553_A".toCharArray(), IndexFilter.ALL, npm());
+ IIndexBinding[] bindings = fIndex.findBindings("bug200553_A".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
assertTrue(bindings[0] instanceof ITypedef);
checkTypedefDepth((ITypedef) bindings[0]);
- bindings= fIndex.findBindings("bug200553_B".toCharArray(), IndexFilter.ALL, npm());
+ bindings = fIndex.findBindings("bug200553_B".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
assertTrue(bindings[0] instanceof ITypedef);
checkTypedefDepth((ITypedef) bindings[0]);
@@ -1338,13 +1350,13 @@ public class IndexBugsTests extends BaseTestCase {
// #include "source.cpp"
// #endif
public void testIncludeSource_Bug199412() throws Exception {
- String[] contents= getContentsForTest(1);
+ String[] contents = getContentsForTest(1);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
- IFile f1= TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[0]);
+ IFile f1 = TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[0]);
waitForIndexer();
- final ITranslationUnit tu= (ITranslationUnit) fCProject.findElement(new Path("source.cpp"));
- Thread th= new Thread() {
+ final ITranslationUnit tu = (ITranslationUnit) fCProject.findElement(new Path("source.cpp"));
+ Thread th = new Thread() {
@Override
public void run() {
try {
@@ -1370,14 +1382,13 @@ public class IndexBugsTests extends BaseTestCase {
// void func_209049(long long x);
public void testGPPTypes_Bug209049() throws Exception {
- String[] contents= getContentsForTest(1);
+ String[] contents = getContentsForTest(1);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
- IFile f1= TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[0]);
+ IFile f1 = TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[0]);
waitForIndexer();
fIndex.acquireReadLock();
try {
- IIndexBinding[] bindings = fIndex.findBindings("func_209049".toCharArray(),
- IndexFilter.ALL, npm());
+ IIndexBinding[] bindings = fIndex.findBindings("func_209049".toCharArray(), IndexFilter.ALL, npm());
IFunctionType ft = ((IFunction) bindings[0]).getType();
assertEquals("void (long long int)", ASTTypeUtil.getType(ft));
} finally {
@@ -1392,7 +1403,7 @@ public class IndexBugsTests extends BaseTestCase {
// staticInHeader();
// }
public void testStaticFunctionsInHeader_Bug180305() throws Exception {
- String[] contents= getContentsForTest(2);
+ String[] contents = getContentsForTest(2);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0]);
TestSourceReader.createFile(fCProject.getProject(), "source1.cpp", contents[1]);
@@ -1401,8 +1412,7 @@ public class IndexBugsTests extends BaseTestCase {
waitForIndexer();
fIndex.acquireReadLock();
try {
- IIndexBinding[] bindings = fIndex.findBindings("staticInHeader".toCharArray(),
- IndexFilter.ALL, npm());
+ IIndexBinding[] bindings = fIndex.findBindings("staticInHeader".toCharArray(), IndexFilter.ALL, npm());
IFunction func = (IFunction) bindings[0];
assertTrue(func.isStatic());
IIndexName[] refs = fIndex.findReferences(func);
@@ -1419,7 +1429,7 @@ public class IndexBugsTests extends BaseTestCase {
// int a= staticConstInHeader;
// }
public void testStaticVariableInHeader_Bug180305() throws Exception {
- String[] contents= getContentsForTest(2);
+ String[] contents = getContentsForTest(2);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0]);
TestSourceReader.createFile(fCProject.getProject(), "source1.cpp", contents[1]);
@@ -1428,8 +1438,7 @@ public class IndexBugsTests extends BaseTestCase {
waitForIndexer();
fIndex.acquireReadLock();
try {
- IIndexBinding[] bindings = fIndex.findBindings("staticConstInHeader".toCharArray(),
- IndexFilter.ALL, npm());
+ IIndexBinding[] bindings = fIndex.findBindings("staticConstInHeader".toCharArray(), IndexFilter.ALL, npm());
IVariable var = (IVariable) bindings[0];
assertTrue(var.isStatic());
IIndexName[] refs = fIndex.findReferences(var);
@@ -1446,7 +1455,7 @@ public class IndexBugsTests extends BaseTestCase {
// staticInHeader();
// }
public void testStaticFunctionsInHeaderC_Bug180305() throws Exception {
- String[] contents= getContentsForTest(2);
+ String[] contents = getContentsForTest(2);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0]);
TestSourceReader.createFile(fCProject.getProject(), "source1.c", contents[1]);
@@ -1473,7 +1482,7 @@ public class IndexBugsTests extends BaseTestCase {
// int a= staticConstInHeader;
// }
public void testStaticVariableInHeaderC_Bug180305() throws Exception {
- String[] contents= getContentsForTest(2);
+ String[] contents = getContentsForTest(2);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0]);
TestSourceReader.createFile(fCProject.getProject(), "source1.c", contents[1]);
@@ -1497,7 +1506,7 @@ public class IndexBugsTests extends BaseTestCase {
// #include "header.x"
public void testNonStandardSuffix_Bug205778() throws Exception {
- String[] contents= getContentsForTest(2);
+ String[] contents = getContentsForTest(2);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
TestSourceReader.createFile(fCProject.getProject(), "header.x", contents[0]);
TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[1]);
@@ -1521,7 +1530,7 @@ public class IndexBugsTests extends BaseTestCase {
// #include "MyClass.h"
public void testAddingMemberBeforeContainer_Bug203170() throws Exception {
- String[] contents= getContentsForTest(3);
+ String[] contents = getContentsForTest(3);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
TestSourceReader.createFile(fCProject.getProject(), "MyClass_inline.h", contents[0]);
TestSourceReader.createFile(fCProject.getProject(), "MyClass.h", contents[1]);
@@ -1530,8 +1539,8 @@ public class IndexBugsTests extends BaseTestCase {
waitForIndexer();
fIndex.acquireReadLock();
try {
- IIndexBinding[] bindings = fIndex.findBindings(new char[][] { "MyClass".toCharArray(),
- "method".toCharArray() }, IndexFilter.ALL, npm());
+ IIndexBinding[] bindings = fIndex.findBindings(
+ new char[][] { "MyClass".toCharArray(), "method".toCharArray() }, IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
IIndexName[] decls = fIndex.findDeclarations(bindings[0]);
assertEquals(2, decls.length);
@@ -1552,7 +1561,7 @@ public class IndexBugsTests extends BaseTestCase {
// a.b;
// }
public void testUnrelatedTypedef_Bug214146() throws Exception {
- String[] contents= getContentsForTest(3);
+ String[] contents = getContentsForTest(3);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
TestSourceReader.createFile(fCProject.getProject(), "s1.cpp", contents[0]);
TestSourceReader.createFile(fCProject.getProject(), "h1.h", contents[1]);
@@ -1561,8 +1570,8 @@ public class IndexBugsTests extends BaseTestCase {
waitForIndexer();
fIndex.acquireReadLock();
try {
- IIndexBinding[] bindings = fIndex.findBindings(new char[][] { "unrelated".toCharArray(),
- "b".toCharArray() }, IndexFilter.ALL, npm());
+ IIndexBinding[] bindings = fIndex.findBindings(
+ new char[][] { "unrelated".toCharArray(), "b".toCharArray() }, IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
IIndexName[] decls = fIndex.findNames(bindings[0], IIndex.FIND_ALL_OCCURRENCES);
assertEquals(2, decls.length);
@@ -1581,7 +1590,7 @@ public class IndexBugsTests extends BaseTestCase {
// int ok;
// #endif
public void testUndefInHeader_Bug227088() throws Exception {
- String[] contents= getContentsForTest(2);
+ String[] contents = getContentsForTest(2);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0]);
TestSourceReader.createFile(fCProject.getProject(), "s1.cpp", contents[1]);
@@ -1608,18 +1617,19 @@ public class IndexBugsTests extends BaseTestCase {
// #include "common.h"
// #include "header.h"
public void testCommonHeader_Bug228012() throws Exception {
- String[] contents= getContentsForTest(3);
+ String[] contents = getContentsForTest(3);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
TestSourceReader.createFile(fCProject.getProject(), "common.h", contents[0]);
- IFile hfile= TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[1]);
+ IFile hfile = TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[1]);
TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[2]);
indexManager.reindex(fCProject);
waitForIndexer();
- ITranslationUnit tu= (ITranslationUnit) CoreModel.getDefault().create(hfile);
+ ITranslationUnit tu = (ITranslationUnit) CoreModel.getDefault().create(hfile);
fIndex.acquireReadLock();
try {
- IASTTranslationUnit ast= tu.getAST(fIndex, ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT | ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
- IASTSimpleDeclaration decl= (IASTSimpleDeclaration) ast.getDeclarations()[0];
+ IASTTranslationUnit ast = tu.getAST(fIndex,
+ ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT | ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
+ IASTSimpleDeclaration decl = (IASTSimpleDeclaration) ast.getDeclarations()[0];
assertEquals("ok", decl.getDeclarators()[0].getName().toString());
} finally {
fIndex.releaseReadLock();
@@ -1633,18 +1643,19 @@ public class IndexBugsTests extends BaseTestCase {
// #define BUG ok
// #include "h1.h"
public void testIndirectContext_Bug267907() throws Exception {
- String[] contents= getContentsForTest(3);
+ String[] contents = getContentsForTest(3);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
TestSourceReader.createFile(fCProject.getProject(), "h1.h", contents[0]);
- IFile hfile= TestSourceReader.createFile(fCProject.getProject(), "h2.h", contents[1]);
+ IFile hfile = TestSourceReader.createFile(fCProject.getProject(), "h2.h", contents[1]);
TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[2]);
indexManager.reindex(fCProject);
waitForIndexer();
- ITranslationUnit tu= (ITranslationUnit) CoreModel.getDefault().create(hfile);
+ ITranslationUnit tu = (ITranslationUnit) CoreModel.getDefault().create(hfile);
fIndex.acquireReadLock();
try {
- IASTTranslationUnit ast= tu.getAST(fIndex, ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT | ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
- IASTSimpleDeclaration decl= (IASTSimpleDeclaration) ast.getDeclarations()[0];
+ IASTTranslationUnit ast = tu.getAST(fIndex,
+ ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT | ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
+ IASTSimpleDeclaration decl = (IASTSimpleDeclaration) ast.getDeclarations()[0];
assertEquals("ok", decl.getDeclarators()[0].getName().toString());
} finally {
fIndex.releaseReadLock();
@@ -1655,10 +1666,10 @@ public class IndexBugsTests extends BaseTestCase {
// #define _CONCAT(x,y) x##y
// #define CONCAT(x,y) _CONCAT(x,y)
public void testIncludeHeuristics_Bug213562() throws Exception {
- String contents= getContentsForTest(1)[0];
+ String contents = getContentsForTest(1)[0];
final IIndexManager indexManager = CCorePlugin.getIndexManager();
TestSourceReader.createFile(fCProject.getProject(), "f1/g/header.h", "#define ID one\n");
- TestSourceReader.createFile(fCProject.getProject(), "f2/header.h", "#define ID two\n");
+ TestSourceReader.createFile(fCProject.getProject(), "f2/header.h", "#define ID two\n");
TestSourceReader.createFile(fCProject.getProject(), "f1/g/h/header.h", "#define ID three\n");
TestSourceReader.createFile(fCProject.getProject(), "f1/g/source.cpp", contents + "int CONCAT(one, ID);\n");
TestSourceReader.createFile(fCProject.getProject(), "f2/g/source.cpp", contents + "int CONCAT(two, ID);\n");
@@ -1667,11 +1678,13 @@ public class IndexBugsTests extends BaseTestCase {
waitForIndexer();
fIndex.acquireReadLock();
try {
- IIndexBinding[] bindings= fIndex.findBindings("oneone".toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor());
+ IIndexBinding[] bindings = fIndex.findBindings("oneone".toCharArray(), IndexFilter.ALL_DECLARED,
+ new NullProgressMonitor());
assertEquals(1, bindings.length);
- bindings= fIndex.findBindings("twotwo".toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor());
+ bindings = fIndex.findBindings("twotwo".toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor());
assertEquals(1, bindings.length);
- bindings= fIndex.findBindings("threethree".toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor());
+ bindings = fIndex.findBindings("threethree".toCharArray(), IndexFilter.ALL_DECLARED,
+ new NullProgressMonitor());
assertEquals(1, bindings.length);
} finally {
fIndex.releaseReadLock();
@@ -1681,18 +1694,18 @@ public class IndexBugsTests extends BaseTestCase {
public void testIncludeHeuristicsFlag_Bug213562() throws Exception {
final IIndexManager indexManager = CCorePlugin.getIndexManager();
TestSourceReader.createFile(fCProject.getProject(), "f1/header.h", "");
- IFile f1= TestSourceReader.createFile(fCProject.getProject(), "source1.cpp", "#include \"header.h\"\n");
- IFile f2= TestSourceReader.createFile(fCProject.getProject(), "source2.cpp", "#include \"f1/header.h\"\n");
+ IFile f1 = TestSourceReader.createFile(fCProject.getProject(), "source1.cpp", "#include \"header.h\"\n");
+ IFile f2 = TestSourceReader.createFile(fCProject.getProject(), "source2.cpp", "#include \"f1/header.h\"\n");
indexManager.reindex(fCProject);
waitForIndexer();
fIndex.acquireReadLock();
try {
- IIndexFile f= getIndexFile(f1);
- IIndexInclude i= f.getIncludes()[0];
+ IIndexFile f = getIndexFile(f1);
+ IIndexInclude i = f.getIncludes()[0];
assertTrue(i.isResolvedByHeuristics());
- f= getIndexFile(f2);
- i= f.getIncludes()[0];
+ f = getIndexFile(f2);
+ i = f.getIncludes()[0];
assertFalse(i.isResolvedByHeuristics());
} finally {
fIndex.releaseReadLock();
@@ -1702,18 +1715,18 @@ public class IndexBugsTests extends BaseTestCase {
// #include "dir"
// #include "header.h"
public void testInclusionOfFolders_Bug243682() throws Exception {
- String contents= getContentsForTest(1)[0];
+ String contents = getContentsForTest(1)[0];
final IIndexManager indexManager = CCorePlugin.getIndexManager();
- IFile sol= TestSourceReader.createFile(fCProject.getProject(), "f1/header.h", "");
+ IFile sol = TestSourceReader.createFile(fCProject.getProject(), "f1/header.h", "");
TestSourceReader.createFile(fCProject.getProject(), "dir/dummy.h", "");
TestSourceReader.createFile(fCProject.getProject(), "header.h/dummy.h", "");
- IFile f1= TestSourceReader.createFile(fCProject.getProject(), "source1.cpp", contents);
+ IFile f1 = TestSourceReader.createFile(fCProject.getProject(), "source1.cpp", contents);
indexManager.reindex(fCProject);
waitForIndexer();
fIndex.acquireReadLock();
try {
- IIndexFile f= getIndexFile(f1);
- IIndexInclude[] is= f.getIncludes();
+ IIndexFile f = getIndexFile(f1);
+ IIndexInclude[] is = f.getIncludes();
assertFalse(is[0].isResolved());
assertTrue(is[1].isResolvedByHeuristics());
assertEquals(sol.getFullPath().toString(), is[1].getIncludesLocation().getFullPath());
@@ -1742,24 +1755,26 @@ public class IndexBugsTests extends BaseTestCase {
// #include "a.h"
public void testStrangeIncludeStrategy_Bug249884() throws Exception {
- String[] contents= getContentsForTest(3);
+ String[] contents = getContentsForTest(3);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
- IFile ah= TestSourceReader.createFile(fCProject.getProject(), "a.h", contents[0]);
+ IFile ah = TestSourceReader.createFile(fCProject.getProject(), "a.h", contents[0]);
TestSourceReader.createFile(fCProject.getProject(), "b.h", contents[1]);
TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[2]);
indexManager.reindex(fCProject);
waitForIndexer();
- ITranslationUnit tu= (ITranslationUnit) CoreModel.getDefault().create(ah);
+ ITranslationUnit tu = (ITranslationUnit) CoreModel.getDefault().create(ah);
fIndex.acquireReadLock();
try {
- IIndexBinding[] bindings= fIndex.findBindings("aOK".toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor());
+ IIndexBinding[] bindings = fIndex.findBindings("aOK".toCharArray(), IndexFilter.ALL_DECLARED,
+ new NullProgressMonitor());
assertEquals(1, bindings.length);
fIndex.findBindings("bOK".toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor());
assertEquals(1, bindings.length);
- IASTTranslationUnit ast= tu.getAST(fIndex, ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT | ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
+ IASTTranslationUnit ast = tu.getAST(fIndex,
+ ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT | ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
final IASTDeclaration[] decls = ast.getDeclarations();
assertEquals(1, decls.length);
- IASTSimpleDeclaration decl= (IASTSimpleDeclaration) decls[0];
+ IASTSimpleDeclaration decl = (IASTSimpleDeclaration) decls[0];
assertEquals("aOK", decl.getDeclarators()[0].getName().toString());
} finally {
fIndex.releaseReadLock();
@@ -1769,9 +1784,9 @@ public class IndexBugsTests extends BaseTestCase {
// struct s {int a;};
// struct s x[]= {{.a=1,},{.a=2}};
public void testReferencesInDesignators_Bug253690() throws Exception {
- String code= getContentsForTest(1)[0];
+ String code = getContentsForTest(1)[0];
final IIndexManager indexManager = CCorePlugin.getIndexManager();
- IFile file= TestSourceReader.createFile(fCProject.getProject(), "test.c", code);
+ IFile file = TestSourceReader.createFile(fCProject.getProject(), "test.c", code);
waitUntilFileIsIndexed(file, 4000);
fIndex.acquireReadLock();
try {
@@ -1790,15 +1805,15 @@ public class IndexBugsTests extends BaseTestCase {
// class Y : public ns::X<int> {
// };
public void testInstanceInheritance_258745() throws Exception {
- String code= getContentsForTest(1)[0];
+ String code = getContentsForTest(1)[0];
final IIndexManager indexManager = CCorePlugin.getIndexManager();
- IFile file= TestSourceReader.createFile(fCProject.getProject(), "test.cpp", code);
+ IFile file = TestSourceReader.createFile(fCProject.getProject(), "test.cpp", code);
waitUntilFileIsIndexed(file, 4000);
fIndex.acquireReadLock();
try {
IIndexBinding[] bindings = fIndex.findBindings("Y".toCharArray(), false, IndexFilter.ALL_DECLARED, npm());
assertEquals(1, bindings.length);
- ICPPClassType ct= (ICPPClassType) bindings[0];
+ ICPPClassType ct = (ICPPClassType) bindings[0];
final ICPPBase[] bases = ct.getBases();
assertEquals(1, bases.length);
IBinding inst = bases[0].getBaseClass();
@@ -1813,17 +1828,19 @@ public class IndexBugsTests extends BaseTestCase {
// static int STATIC;
// void ref() {STATIC=1;}
public void testStaticVarInSourceIncluded_Bug265821() throws Exception {
- String[] contents= getContentsForTest(2);
+ String[] contents = getContentsForTest(2);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
- IFile a= TestSourceReader.createFile(fCProject.getProject(), "A.cpp", contents[0]);
- IFile b= TestSourceReader.createFile(fCProject.getProject(), "B.cpp", contents[1]);
+ IFile a = TestSourceReader.createFile(fCProject.getProject(), "A.cpp", contents[0]);
+ IFile b = TestSourceReader.createFile(fCProject.getProject(), "B.cpp", contents[1]);
indexManager.reindex(fCProject);
waitForIndexer();
- ITranslationUnit tu= (ITranslationUnit) CoreModel.getDefault().create(b);
+ ITranslationUnit tu = (ITranslationUnit) CoreModel.getDefault().create(b);
fIndex.acquireReadLock();
try {
- IASTTranslationUnit ast= tu.getAST(fIndex, ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT | ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
- IBinding var= ((IASTSimpleDeclaration) ast.getDeclarations()[0]).getDeclarators()[0].getName().resolveBinding();
+ IASTTranslationUnit ast = tu.getAST(fIndex,
+ ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT | ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
+ IBinding var = ((IASTSimpleDeclaration) ast.getDeclarations()[0]).getDeclarators()[0].getName()
+ .resolveBinding();
IIndexBinding adapted = fIndex.adaptBinding(var);
assertNotNull(adapted);
} finally {
@@ -1836,25 +1853,25 @@ public class IndexBugsTests extends BaseTestCase {
// #include "a.h"
// void test() {a=0;}
public void testDeclarationForBinding_Bug254844() throws Exception {
- String[] contents= getContentsForTest(2);
+ String[] contents = getContentsForTest(2);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
- IFile a= TestSourceReader.createFile(fCProject.getProject(), "a.h", contents[0]);
- IFile b= TestSourceReader.createFile(fCProject.getProject(), "b.h", contents[0]);
- IFile source= TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[1]);
+ IFile a = TestSourceReader.createFile(fCProject.getProject(), "a.h", contents[0]);
+ IFile b = TestSourceReader.createFile(fCProject.getProject(), "b.h", contents[0]);
+ IFile source = TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[1]);
indexManager.reindex(fCProject);
waitForIndexer();
- ITranslationUnit tu= (ITranslationUnit) CoreModel.getDefault().create(source);
+ ITranslationUnit tu = (ITranslationUnit) CoreModel.getDefault().create(source);
fIndex.acquireReadLock();
try {
- IASTTranslationUnit ast= tu.getAST(fIndex, ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
- IIndexFileSet fileset= ast.getIndexFileSet();
- IBinding var= getBindingFromASTName(ast, contents[1], "a=", 1, IBinding.class);
- IName[] decls= ast.getDeclarations(var);
+ IASTTranslationUnit ast = tu.getAST(fIndex, ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
+ IIndexFileSet fileset = ast.getIndexFileSet();
+ IBinding var = getBindingFromASTName(ast, contents[1], "a=", 1, IBinding.class);
+ IName[] decls = ast.getDeclarations(var);
assertEquals(2, decls.length);
- int check= 0;
+ int check = 0;
for (IName name : decls) {
assert name instanceof IIndexName;
- IIndexName iName= (IIndexName) name;
+ IIndexName iName = (IIndexName) name;
if (iName.getFileLocation().getFileName().endsWith("a.h")) {
check |= 1;
assertTrue(fileset.contains(iName.getFile()));
@@ -1906,7 +1923,7 @@ public class IndexBugsTests extends BaseTestCase {
final IIndexManager indexManager = CCorePlugin.getIndexManager();
indexManager.reindex(fCProject);
waitForIndexer();
- IIndex index= indexManager.getIndex(fCProject);
+ IIndex index = indexManager.getIndex(fCProject);
index.acquireReadLock();
try {
BindingAssertionHelper aHelper = new BindingAssertionHelper(a, testData[1], index);
@@ -1947,7 +1964,7 @@ public class IndexBugsTests extends BaseTestCase {
final IIndexManager indexManager = CCorePlugin.getIndexManager();
indexManager.reindex(fCProject);
waitForIndexer();
- IIndex index= indexManager.getIndex(fCProject);
+ IIndex index = indexManager.getIndex(fCProject);
index.acquireReadLock();
try {
BindingAssertionHelper aHelper = new BindingAssertionHelper(a, testData[1], index);
@@ -1983,7 +2000,7 @@ public class IndexBugsTests extends BaseTestCase {
final IIndexManager indexManager = CCorePlugin.getIndexManager();
indexManager.reindex(fCProject);
waitForIndexer();
- IIndex index= indexManager.getIndex(fCProject);
+ IIndex index = indexManager.getIndex(fCProject);
index.acquireReadLock();
try {
BindingAssertionHelper aHelper = new BindingAssertionHelper(a, testData[1], index);
@@ -2017,12 +2034,12 @@ public class IndexBugsTests extends BaseTestCase {
String[] testData = getContentsForTest(3);
TestSourceReader.createFile(fCProject.getProject(), "header.h", testData[0]);
- IFile test= TestSourceReader.createFile(fCProject.getProject(), "test.cpp", testData[1]);
+ IFile test = TestSourceReader.createFile(fCProject.getProject(), "test.cpp", testData[1]);
TestSourceReader.createFile(fCProject.getProject(), "unrelated.cpp", testData[2]);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
indexManager.reindex(fCProject);
waitForIndexer();
- IIndex index= indexManager.getIndex(fCProject);
+ IIndex index = indexManager.getIndex(fCProject);
index.acquireReadLock();
try {
IASTTranslationUnit ast = TestSourceReader.createIndexBasedAST(index, fCProject, test);
@@ -2050,12 +2067,12 @@ public class IndexBugsTests extends BaseTestCase {
String[] testData = getContentsForTest(3);
TestSourceReader.createFile(fCProject.getProject(), "header.h", testData[0]);
- IFile test= TestSourceReader.createFile(fCProject.getProject(), "test.cpp", testData[1]);
+ IFile test = TestSourceReader.createFile(fCProject.getProject(), "test.cpp", testData[1]);
TestSourceReader.createFile(fCProject.getProject(), "unrelated.cpp", testData[2]);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
indexManager.reindex(fCProject);
waitForIndexer();
- IIndex index= indexManager.getIndex(fCProject);
+ IIndex index = indexManager.getIndex(fCProject);
index.acquireReadLock();
try {
BindingAssertionHelper helper = new BindingAssertionHelper(test, testData[1], index);
@@ -2082,16 +2099,16 @@ public class IndexBugsTests extends BaseTestCase {
String[] testData = getContentsForTest(3);
TestSourceReader.createFile(fCProject.getProject(), "a.h", testData[0]);
TestSourceReader.createFile(fCProject.getProject(), "b.h", testData[1]);
- IFile s= TestSourceReader.createFile(fCProject.getProject(), "s1.c", testData[2]);
+ IFile s = TestSourceReader.createFile(fCProject.getProject(), "s1.c", testData[2]);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
indexManager.reindex(fCProject);
waitForIndexer();
- IIndex index= indexManager.getIndex(fCProject);
+ IIndex index = indexManager.getIndex(fCProject);
index.acquireReadLock();
try {
IASTTranslationUnit tu = TestSourceReader.createIndexBasedAST(index, fCProject, s);
- IASTPreprocessorStatement[] pstmts= tu.getAllPreprocessorStatements();
- IASTPreprocessorStatement ifndef= pstmts[1];
+ IASTPreprocessorStatement[] pstmts = tu.getAllPreprocessorStatements();
+ IASTPreprocessorStatement ifndef = pstmts[1];
assertInstance(ifndef, IASTPreprocessorIfdefStatement.class);
assertTrue(((IASTPreprocessorIfdefStatement) ifndef).taken());
} finally {
@@ -2116,16 +2133,16 @@ public class IndexBugsTests extends BaseTestCase {
String[] testData = getContentsForTest(3);
TestSourceReader.createFile(fCProject.getProject(), "a.h", testData[0]);
TestSourceReader.createFile(fCProject.getProject(), "b.h", testData[1]);
- IFile s= TestSourceReader.createFile(fCProject.getProject(), "s1.c", testData[2]);
+ IFile s = TestSourceReader.createFile(fCProject.getProject(), "s1.c", testData[2]);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
indexManager.reindex(fCProject);
waitForIndexer();
- IIndex index= indexManager.getIndex(fCProject);
+ IIndex index = indexManager.getIndex(fCProject);
index.acquireReadLock();
try {
IASTTranslationUnit tu = TestSourceReader.createIndexBasedAST(index, fCProject, s);
- IASTPreprocessorStatement[] pstmts= tu.getAllPreprocessorStatements();
- IASTPreprocessorStatement ifndef= pstmts[1];
+ IASTPreprocessorStatement[] pstmts = tu.getAllPreprocessorStatements();
+ IASTPreprocessorStatement ifndef = pstmts[1];
assertInstance(ifndef, IASTPreprocessorIfdefStatement.class);
assertFalse(((IASTPreprocessorIfdefStatement) ifndef).taken());
} finally {
@@ -2144,13 +2161,13 @@ public class IndexBugsTests extends BaseTestCase {
public void testPreprocessingStatementOrder_270806_3() throws Exception {
waitForIndexer();
String[] testData = getContentsForTest(1);
- IFile f= TestSourceReader.createFile(fCProject.getProject(), "a.cpp", testData[0]);
+ IFile f = TestSourceReader.createFile(fCProject.getProject(), "a.cpp", testData[0]);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
waitUntilFileIsIndexed(f, 4000);
- IIndex index= indexManager.getIndex(fCProject);
+ IIndex index = indexManager.getIndex(fCProject);
index.acquireReadLock();
try {
- IIndexFile file= getIndexFile(index, f);
+ IIndexFile file = getIndexFile(index, f);
// check order of includes
IIndexInclude[] incs = file.getIncludes();
assertEquals(2, incs.length);
@@ -2176,19 +2193,20 @@ public class IndexBugsTests extends BaseTestCase {
public void testFunctionTemplateWithThrowsException_293021() throws Exception {
waitForIndexer();
String testData = getContentsForTest(1)[0].toString();
- IFile f= TestSourceReader.createFile(fCProject.getProject(), "testFunctionTemplateWithThrowsException_293021.cpp", testData);
+ IFile f = TestSourceReader.createFile(fCProject.getProject(),
+ "testFunctionTemplateWithThrowsException_293021.cpp", testData);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
waitUntilFileIsIndexed(f, 4000);
- IIndex index= indexManager.getIndex(fCProject);
+ IIndex index = indexManager.getIndex(fCProject);
index.acquireReadLock();
try {
- IIndexFile file= getIndexFile(index, f);
- int idx= testData.indexOf("f(");
- IIndexName[] names = file.findNames(idx, idx+1);
+ IIndexFile file = getIndexFile(index, f);
+ int idx = testData.indexOf("f(");
+ IIndexName[] names = file.findNames(idx, idx + 1);
assertEquals(1, names.length);
- ICPPFunctionTemplate ft= (ICPPFunctionTemplate) index.findBinding(names[0]);
+ ICPPFunctionTemplate ft = (ICPPFunctionTemplate) index.findBinding(names[0]);
final IType[] espec = ft.getExceptionSpecification();
- ICPPTemplateParameter par= (ICPPTemplateParameter) espec[0];
+ ICPPTemplateParameter par = (ICPPTemplateParameter) espec[0];
assertEquals(ft, par.getOwner());
} finally {
index.releaseReadLock();
@@ -2213,23 +2231,23 @@ public class IndexBugsTests extends BaseTestCase {
String[] testData = getContentsForTest(4);
TestSourceReader.createFile(fCProject.getProject(), "a.h", testData[0]);
TestSourceReader.createFile(fCProject.getProject(), "b.h", testData[1]);
- IFile s1= TestSourceReader.createFile(fCProject.getProject(), "s1.cpp", testData[2]);
- IFile s2= TestSourceReader.createFile(fCProject.getProject(), "s2.cpp", testData[3]);
+ IFile s1 = TestSourceReader.createFile(fCProject.getProject(), "s1.cpp", testData[2]);
+ IFile s2 = TestSourceReader.createFile(fCProject.getProject(), "s2.cpp", testData[3]);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
indexManager.reindex(fCProject);
waitForIndexer();
- IIndex index= indexManager.getIndex(fCProject);
+ IIndex index = indexManager.getIndex(fCProject);
index.acquireReadLock();
try {
IASTTranslationUnit tu = TestSourceReader.createIndexBasedAST(index, fCProject, s1);
- IASTSimpleDeclaration sdecl= (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IVariable var= (IVariable) sdecl.getDeclarators()[0].getName().resolveBinding();
+ IASTSimpleDeclaration sdecl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IVariable var = (IVariable) sdecl.getDeclarators()[0].getName().resolveBinding();
assertFalse(var.getType() instanceof IProblemBinding);
assertTrue(var.getType() instanceof ICPPClassType);
tu = TestSourceReader.createIndexBasedAST(index, fCProject, s2);
- sdecl= (IASTSimpleDeclaration) tu.getDeclarations()[0];
- var= (IVariable) sdecl.getDeclarators()[0].getName().resolveBinding();
+ sdecl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ var = (IVariable) sdecl.getDeclarators()[0].getName().resolveBinding();
assertFalse(var.getType() instanceof IProblemBinding);
assertTrue(var.getType() instanceof ICPPClassType);
} finally {
@@ -2254,23 +2272,23 @@ public class IndexBugsTests extends BaseTestCase {
String[] testData = getContentsForTest(4);
TestSourceReader.createFile(fCProject.getProject(), "a.h", testData[0]);
TestSourceReader.createFile(fCProject.getProject(), "b.h", testData[1]);
- IFile s1= TestSourceReader.createFile(fCProject.getProject(), "s1.cpp", testData[2]);
- IFile s2= TestSourceReader.createFile(fCProject.getProject(), "s2.cpp", testData[3]);
+ IFile s1 = TestSourceReader.createFile(fCProject.getProject(), "s1.cpp", testData[2]);
+ IFile s2 = TestSourceReader.createFile(fCProject.getProject(), "s2.cpp", testData[3]);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
indexManager.reindex(fCProject);
waitForIndexer();
- IIndex index= indexManager.getIndex(fCProject);
+ IIndex index = indexManager.getIndex(fCProject);
index.acquireReadLock();
try {
IASTTranslationUnit tu = TestSourceReader.createIndexBasedAST(index, fCProject, s1);
- IASTSimpleDeclaration sdecl= (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IVariable var= (IVariable) sdecl.getDeclarators()[0].getName().resolveBinding();
+ IASTSimpleDeclaration sdecl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ IVariable var = (IVariable) sdecl.getDeclarators()[0].getName().resolveBinding();
assertFalse(var.getType() instanceof IProblemBinding);
assertTrue(var.getType() instanceof ICPPClassType);
tu = TestSourceReader.createIndexBasedAST(index, fCProject, s2);
- sdecl= (IASTSimpleDeclaration) tu.getDeclarations()[0];
- var= (IVariable) sdecl.getDeclarators()[0].getName().resolveBinding();
+ sdecl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
+ var = (IVariable) sdecl.getDeclarators()[0].getName().resolveBinding();
assertTrue(var.getType() instanceof ISemanticProblem);
} finally {
index.releaseReadLock();
@@ -2281,23 +2299,22 @@ public class IndexBugsTests extends BaseTestCase {
IIndexBinding[] r;
final IProject prj = fCProject.getProject();
- final IFolder src= prj.getFolder("src");
- final IFolder h= prj.getFolder("h");
+ final IFolder src = prj.getFolder("src");
+ final IFolder h = prj.getFolder("h");
src.create(true, false, null);
h.create(true, false, null);
assertTrue(src.exists());
assertTrue(h.exists());
- ICProjectDescription desc= CCorePlugin.getDefault().getProjectDescription(prj);
+ ICProjectDescription desc = CCorePlugin.getDefault().getProjectDescription(prj);
assertNotNull(desc);
- desc.getActiveConfiguration().setSourceEntries(new ICSourceEntry[] {
- new CSourceEntry(src, new IPath[0], ICSettingEntry.SOURCE_PATH)
- });
+ desc.getActiveConfiguration().setSourceEntries(
+ new ICSourceEntry[] { new CSourceEntry(src, new IPath[0], ICSettingEntry.SOURCE_PATH) });
CCorePlugin.getDefault().setProjectDescription(prj, desc);
TestSourceReader.createFile(h, "a.h", "int version1;");
waitForIndexer(fCProject);
- final IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
+ final IIndex index = CCorePlugin.getIndexManager().getIndex(fCProject);
index.acquireReadLock();
try {
r = index.findBindings("version1".toCharArray(), IndexFilter.ALL_DECLARED, null);
@@ -2306,7 +2323,7 @@ public class IndexBugsTests extends BaseTestCase {
index.releaseReadLock();
}
- IFile s= TestSourceReader.createFile(h, "a.h", "int version2;");
+ IFile s = TestSourceReader.createFile(h, "a.h", "int version2;");
waitForIndexer(fCProject);
index.acquireReadLock();
try {
@@ -2316,7 +2333,7 @@ public class IndexBugsTests extends BaseTestCase {
index.releaseReadLock();
}
- s= TestSourceReader.createFile(src, "source.cpp", "#include \"../h/a.h\"");
+ s = TestSourceReader.createFile(src, "source.cpp", "#include \"../h/a.h\"");
waitUntilFileIsIndexed(s, INDEXER_TIMEOUT_SEC * 1000);
index.acquireReadLock();
try {
@@ -2326,7 +2343,7 @@ public class IndexBugsTests extends BaseTestCase {
index.releaseReadLock();
}
- s= TestSourceReader.createFile(h, "a.h", "int version3;");
+ s = TestSourceReader.createFile(h, "a.h", "int version3;");
waitUntilFileIsIndexed(s, INDEXER_TIMEOUT_SEC * 1000);
index.acquireReadLock();
try {
@@ -2343,33 +2360,33 @@ public class IndexBugsTests extends BaseTestCase {
IIndexBinding[] r;
final IProject prj = fCProject.getProject();
- IFile file= TestSourceReader.createFile(prj, "a.cpp", "// \u0110 \n int a;");
+ IFile file = TestSourceReader.createFile(prj, "a.cpp", "// \u0110 \n int a;");
file.setCharset("US-ASCII", new NullProgressMonitor());
waitForIndexer(fCProject);
- final IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
- int offset1= 0;
+ final IIndex index = CCorePlugin.getIndexManager().getIndex(fCProject);
+ int offset1 = 0;
index.acquireReadLock();
try {
r = index.findBindings("a".toCharArray(), IndexFilter.ALL_DECLARED, null);
assertEquals(1, r.length);
IIndexName[] defs = index.findDefinitions(r[0]);
assertEquals(1, defs.length);
- offset1= defs[0].getNodeOffset();
+ offset1 = defs[0].getNodeOffset();
} finally {
index.releaseReadLock();
}
file.setCharset("UTF-8", new NullProgressMonitor());
waitForIndexer(fCProject);
- int offset2= 0;
+ int offset2 = 0;
index.acquireReadLock();
try {
r = index.findBindings("a".toCharArray(), IndexFilter.ALL_DECLARED, null);
assertEquals(1, r.length);
IIndexName[] defs = index.findDefinitions(r[0]);
assertEquals(1, defs.length);
- offset1= defs[0].getNodeOffset();
+ offset1 = defs[0].getNodeOffset();
} finally {
index.releaseReadLock();
}
@@ -2381,7 +2398,7 @@ public class IndexBugsTests extends BaseTestCase {
IIndexBinding[] r;
final IProject prj = fCProject.getProject();
- final IFolder root= prj.getFolder("root");
+ final IFolder root = prj.getFolder("root");
root.create(true, false, null);
assertTrue(root.exists());
IFolder child1 = root.getFolder("child1");
@@ -2395,7 +2412,7 @@ public class IndexBugsTests extends BaseTestCase {
TestSourceReader.createFile(child2, "b.c", "void bug343538();");
waitForIndexer(fCProject);
- final IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
+ final IIndex index = CCorePlugin.getIndexManager().getIndex(fCProject);
index.acquireReadLock();
try {
r = index.findBindings("bug343538".toCharArray(), IndexFilter.ALL, null);
@@ -2406,32 +2423,32 @@ public class IndexBugsTests extends BaseTestCase {
index.releaseReadLock();
}
- // Collect files and folders
- final Set<IFile> files = new HashSet<IFile>();
- final Set<IFolder> folders = new HashSet<IFolder>();
- folders.add(root);
- root.accept(new IResourceVisitor() {
- @Override
+ // Collect files and folders
+ final Set<IFile> files = new HashSet<IFile>();
+ final Set<IFolder> folders = new HashSet<IFolder>();
+ folders.add(root);
+ root.accept(new IResourceVisitor() {
+ @Override
public boolean visit(final IResource resource) throws CoreException {
- if (resource instanceof IFile) {
- files.add((IFile) resource);
- } else if (resource instanceof IFolder) {
- folders.add((IFolder) resource);
- }
- return true;
- }
- });
-
- Job job = new WorkspaceJob("Delete folder") {
- @Override
- public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {
- IWorkspace ws = ResourcesPlugin.getWorkspace();
- ws.delete(files.toArray(new IResource[files.size()]), IResource.FORCE, null);
- ws.delete(folders.toArray(new IResource[folders.size()]), IResource.FORCE, null);
- return Status.OK_STATUS;
- }
- };
- job.schedule();
+ if (resource instanceof IFile) {
+ files.add((IFile) resource);
+ } else if (resource instanceof IFolder) {
+ folders.add((IFolder) resource);
+ }
+ return true;
+ }
+ });
+
+ Job job = new WorkspaceJob("Delete folder") {
+ @Override
+ public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {
+ IWorkspace ws = ResourcesPlugin.getWorkspace();
+ ws.delete(files.toArray(new IResource[files.size()]), IResource.FORCE, null);
+ ws.delete(folders.toArray(new IResource[folders.size()]), IResource.FORCE, null);
+ return Status.OK_STATUS;
+ }
+ };
+ job.schedule();
job.join();
Thread.sleep(100);
waitForIndexer(fCProject);
@@ -2458,16 +2475,17 @@ public class IndexBugsTests extends BaseTestCase {
// // a.h and b.h
// int A;
public void testUpdatingHeaderInContext_367315() throws Exception {
- String[] contents= getContentsForTest(2);
+ String[] contents = getContentsForTest(2);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
TestSourceReader.createFile(fCProject.getProject(), "context.c", contents[0]);
- IFile ah= TestSourceReader.createFile(fCProject.getProject(), "a.h", contents[1]);
- IFile bh= TestSourceReader.createFile(fCProject.getProject(), "b.h", contents[1]);
+ IFile ah = TestSourceReader.createFile(fCProject.getProject(), "a.h", contents[1]);
+ IFile bh = TestSourceReader.createFile(fCProject.getProject(), "b.h", contents[1]);
indexManager.reindex(fCProject);
waitForIndexer();
fIndex.acquireReadLock();
try {
- IIndexBinding[] vars = fIndex.findBindings("B".toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor());
+ IIndexBinding[] vars = fIndex.findBindings("B".toCharArray(), IndexFilter.ALL_DECLARED,
+ new NullProgressMonitor());
assertEquals(1, vars.length);
assertEquals(2, fIndex.findDefinitions(vars[0]).length);
} finally {
@@ -2475,12 +2493,13 @@ public class IndexBugsTests extends BaseTestCase {
}
final CoreModel coreModel = CCorePlugin.getDefault().getCoreModel();
- ICElement[] selection = new ICElement[] {coreModel.create(ah), coreModel.create(bh)};
+ ICElement[] selection = new ICElement[] { coreModel.create(ah), coreModel.create(bh) };
indexManager.update(selection, IIndexManager.UPDATE_ALL);
waitForIndexer();
fIndex.acquireReadLock();
try {
- IIndexBinding[] vars = fIndex.findBindings("B".toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor());
+ IIndexBinding[] vars = fIndex.findBindings("B".toCharArray(), IndexFilter.ALL_DECLARED,
+ new NullProgressMonitor());
assertEquals(1, vars.length);
assertEquals(2, fIndex.findDefinitions(vars[0]).length);
} finally {
@@ -2499,15 +2518,16 @@ public class IndexBugsTests extends BaseTestCase {
// namespace ns { typedef int INT; }
public void testUpdateUnresolvedIncludes_378317() throws Exception {
// Turn off indexing of unused headers.
- IndexerPreferences.set(fCProject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "false");
+ IndexerPreferences.set(fCProject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG,
+ "false");
// Turn off automatic index update.
IndexerPreferences.setUpdatePolicy(fCProject.getProject(), IndexerPreferences.UPDATE_POLICY_MANUAL);
try {
- String[] contents= getContentsForTest(3);
+ String[] contents = getContentsForTest(3);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
TestSourceReader.createFile(fCProject.getProject(), "test.c", contents[0]);
- IFile ah= TestSourceReader.createFile(fCProject.getProject(), "a.h", contents[1]);
+ IFile ah = TestSourceReader.createFile(fCProject.getProject(), "a.h", contents[1]);
// b.h is not created yet, so #include "b.h" in a.h is unresolved.
indexManager.reindex(fCProject);
waitForIndexer();
@@ -2520,7 +2540,7 @@ public class IndexBugsTests extends BaseTestCase {
fIndex.releaseReadLock();
}
- IFile bh= TestSourceReader.createFile(fCProject.getProject(), "b.h", contents[2]);
+ IFile bh = TestSourceReader.createFile(fCProject.getProject(), "b.h", contents[2]);
indexManager.update(new ICElement[] { fCProject }, IIndexManager.UPDATE_UNRESOLVED_INCLUDES);
waitForIndexer();
fIndex.acquireReadLock();
@@ -2536,7 +2556,8 @@ public class IndexBugsTests extends BaseTestCase {
} finally {
// Restore default indexer preferences.
Properties defaults = IndexerPreferences.getDefaultIndexerProperties();
- IndexerPreferences.set(fCProject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG,
+ IndexerPreferences.set(fCProject.getProject(),
+ IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG,
defaults.getProperty(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG));
IndexerPreferences.setUpdatePolicy(fCProject.getProject(), IndexerPreferences.getDefaultUpdatePolicy());
}
@@ -2561,7 +2582,7 @@ public class IndexBugsTests extends BaseTestCase {
try {
IProjectDescription desc = fCProject.getProject().getDescription();
desc.setReferencedProjects(new IProject[] { p1.getProject() });
- fCProject.getProject().setDescription(desc, npm());
+ fCProject.getProject().setDescription(desc, npm());
// make sure the header is read from the other pdom when the ast is created
IFile head1 = TestSourceReader.createFile(p1.getProject(), "h1.hh", contents[0]);
@@ -2579,20 +2600,18 @@ public class IndexBugsTests extends BaseTestCase {
index.acquireReadLock();
locked = true;
- IASTTranslationUnit ast = tu.getAST(
- index,
- ITranslationUnit.AST_SKIP_ALL_HEADERS
- | ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT
- | ITranslationUnit.AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS
- | ITranslationUnit.AST_PARSE_INACTIVE_CODE);
+ IASTTranslationUnit ast = tu.getAST(index,
+ ITranslationUnit.AST_SKIP_ALL_HEADERS | ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT
+ | ITranslationUnit.AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS
+ | ITranslationUnit.AST_PARSE_INACTIVE_CODE);
assertNotNull(ast);
IASTDeclaration[] decls = ast.getDeclarations();
assertNotNull(decls);
- assertEquals(1, decls.length);
+ assertEquals(1, decls.length);
assertTrue(decls[0] instanceof IASTSimpleDeclaration);
- IASTDeclarator[] decltors = ((IASTSimpleDeclaration)decls[0]).getDeclarators();
+ IASTDeclarator[] decltors = ((IASTSimpleDeclaration) decls[0]).getDeclarators();
assertNotNull(decltors);
assertEquals(1, decltors.length);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionBugs.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionBugs.java
index 7e2e9cdaed7..25ecfe783ea 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionBugs.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionBugs.java
@@ -39,12 +39,23 @@ import org.eclipse.cdt.core.index.IIndexBinding;
public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase {
public static class SingleProject extends IndexCBindingResolutionBugs {
- public SingleProject() { setStrategy(new SinglePDOMTestStrategy(false)); }
- public static TestSuite suite() { return suite(SingleProject.class); }
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
+
public static class ProjectWithDepProj extends IndexCBindingResolutionBugs {
- public ProjectWithDepProj() { setStrategy(new ReferencedProject(false)); }
- public static TestSuite suite() { return suite(ProjectWithDepProj.class); }
+ public ProjectWithDepProj() {
+ setStrategy(new ReferencedProject(false));
+ }
+
+ public static TestSuite suite() {
+ return suite(ProjectWithDepProj.class);
+ }
}
public static void addTests(TestSuite suite) {
@@ -72,9 +83,9 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
IBinding b0 = getBindingFromASTName("func1()", 5);
assertTrue(b0 instanceof IFunction);
IFunction f0 = (IFunction) b0;
- IParameter[] params= f0.getParameters();
+ IParameter[] params = f0.getParameters();
assertEquals(0, params.length);
- IType returnType= f0.getType().getReturnType();
+ IType returnType = f0.getType().getReturnType();
assertTrue(returnType instanceof IBasicType);
assertEquals(IBasicType.Kind.eVoid, ((IBasicType) returnType).getKind());
}
@@ -91,210 +102,212 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
assertTrue(b0 instanceof IFunction);
}
- // typedef struct {
- // int utm;
- // } usertype;
- // void func(usertype t);
+ // typedef struct {
+ // int utm;
+ // } usertype;
+ // void func(usertype t);
// #include "header.h"
- // void test() {
+ // void test() {
// usertype ut;
// func(ut);
- // }
- public void testFuncWithTypedefForAnonymousStruct_190730() throws Exception {
+ // }
+ public void testFuncWithTypedefForAnonymousStruct_190730() throws Exception {
IBinding b0 = getBindingFromASTName("func(", 4);
assertTrue(b0 instanceof IFunction);
- IFunction f= (IFunction) b0;
- IParameter[] pars= f.getParameters();
+ IFunction f = (IFunction) b0;
+ IParameter[] pars = f.getParameters();
assertEquals(1, pars.length);
- IType type= pars[0].getType();
+ IType type = pars[0].getType();
assertInstance(type, ITypedef.class);
- type= ((ITypedef) type).getType();
+ type = ((ITypedef) type).getType();
assertInstance(type, ICompositeType.class);
- }
+ }
- // typedef enum {
- // eItem
- // } userEnum;
- // void func(userEnum t);
+ // typedef enum {
+ // eItem
+ // } userEnum;
+ // void func(userEnum t);
// #include "header.h"
- // void test() {
+ // void test() {
// userEnum ut;
// func(ut);
- // }
- public void testFuncWithTypedefForAnonymousEnum_190730() throws Exception {
+ // }
+ public void testFuncWithTypedefForAnonymousEnum_190730() throws Exception {
IBinding b0 = getBindingFromASTName("func(", 4);
assertTrue(b0 instanceof IFunction);
- IFunction f= (IFunction) b0;
- IParameter[] pars= f.getParameters();
+ IFunction f = (IFunction) b0;
+ IParameter[] pars = f.getParameters();
assertEquals(1, pars.length);
- IType type= pars[0].getType();
+ IType type = pars[0].getType();
assertInstance(type, ITypedef.class);
- type= ((ITypedef) type).getType();
+ type = ((ITypedef) type).getType();
assertInstance(type, IEnumeration.class);
assertTrue(type instanceof IEnumeration);
- }
+ }
- // int globalVar;
+ // int globalVar;
// // don't include header
- // char globalVar;
- public void testAstIndexConflictVariable_Bug195127() throws Exception {
- fakeFailForMultiProject();
+ // char globalVar;
+ public void testAstIndexConflictVariable_Bug195127() throws Exception {
+ fakeFailForMultiProject();
IBinding b0 = getBindingFromASTName("globalVar;", 9);
assertTrue(b0 instanceof IVariable);
- IVariable v= (IVariable) b0;
- IType type= v.getType();
+ IVariable v = (IVariable) b0;
+ IType type = v.getType();
assertTrue(type instanceof IBasicType);
assertTrue(((IBasicType) type).getKind() == IBasicType.Kind.eChar);
- }
+ }
- // int globalFunc();
+ // int globalFunc();
// // don't include header
- // char globalFunc();
- public void testAstIndexConflictFunction_Bug195127() throws Exception {
- fakeFailForMultiProject();
+ // char globalFunc();
+ public void testAstIndexConflictFunction_Bug195127() throws Exception {
+ fakeFailForMultiProject();
IBinding b0 = getBindingFromASTName("globalFunc(", 10);
assertTrue(b0 instanceof IFunction);
- IFunction f= (IFunction) b0;
- IType type= f.getType().getReturnType();
+ IFunction f = (IFunction) b0;
+ IType type = f.getType().getReturnType();
assertTrue(type instanceof IBasicType);
assertTrue(((IBasicType) type).getKind() == IBasicType.Kind.eChar);
- }
+ }
- // struct astruct {
- // int member;
- // };
+ // struct astruct {
+ // int member;
+ // };
// // don't include header
- // struct astruct {
- // char member;
- // int additionalMember;
- // };
- public void testAstIndexConflictStruct_Bug195127() throws Exception {
- fakeFailForMultiProject();
+ // struct astruct {
+ // char member;
+ // int additionalMember;
+ // };
+ public void testAstIndexConflictStruct_Bug195127() throws Exception {
+ fakeFailForMultiProject();
IBinding b0 = getBindingFromASTName("astruct", 7);
assertTrue(b0 instanceof ICompositeType);
- ICompositeType ct= (ICompositeType) b0;
- IField[] fields= ct.getFields();
+ ICompositeType ct = (ICompositeType) b0;
+ IField[] fields = ct.getFields();
assertEquals(2, fields.length);
- IField member= fields[0];
- IField additionalMember= fields[1];
+ IField member = fields[0];
+ IField additionalMember = fields[1];
if (member.getName().equals("additionalMember")) {
- IField h= member; member= additionalMember; additionalMember= h;
+ IField h = member;
+ member = additionalMember;
+ additionalMember = h;
}
assertEquals("member", member.getName());
assertEquals("additionalMember", additionalMember.getName());
- IType type= member.getType();
+ IType type = member.getType();
assertTrue(type instanceof IBasicType);
assertTrue(((IBasicType) type).getKind() == IBasicType.Kind.eChar);
- }
+ }
- // enum anenum {
- // eItem0
- // };
+ // enum anenum {
+ // eItem0
+ // };
// // don't include header
- // enum anenum {
- // eItem0, eItem1
- // };
- public void testAstIndexConflictEnumerator_Bug195127() throws Exception {
- fakeFailForMultiProject();
+ // enum anenum {
+ // eItem0, eItem1
+ // };
+ public void testAstIndexConflictEnumerator_Bug195127() throws Exception {
+ fakeFailForMultiProject();
IBinding b0 = getBindingFromASTName("anenum", 6);
assertTrue(b0 instanceof IEnumeration);
- IEnumeration enumeration= (IEnumeration) b0;
- IEnumerator[] enumerators= enumeration.getEnumerators();
+ IEnumeration enumeration = (IEnumeration) b0;
+ IEnumerator[] enumerators = enumeration.getEnumerators();
assertEquals(2, enumerators.length);
- }
+ }
- // typedef int atypedef;
+ // typedef int atypedef;
// // don't include header
- // typedef char atypedef;
- public void testAstIndexConflictTypedef_Bug195127() throws Exception {
- fakeFailForMultiProject();
+ // typedef char atypedef;
+ public void testAstIndexConflictTypedef_Bug195127() throws Exception {
+ fakeFailForMultiProject();
IBinding b0 = getBindingFromASTName("atypedef;", 8);
assertTrue(b0 instanceof ITypedef);
- ITypedef t= (ITypedef) b0;
- IType type= t.getType();
+ ITypedef t = (ITypedef) b0;
+ IType type = t.getType();
assertTrue(type instanceof IBasicType);
assertTrue(((IBasicType) type).getKind() == IBasicType.Kind.eChar);
- }
+ }
- // struct st_20070703 {
- // int member;
- // };
+ // struct st_20070703 {
+ // int member;
+ // };
// #include "header.h"
- // struct st_20070703;
- // void func(struct st_20070703* x) {
- // x->member= 0;
- // }
- public void testAstIndexStructFwdDecl_Bug195227() throws Exception {
+ // struct st_20070703;
+ // void func(struct st_20070703* x) {
+ // x->member= 0;
+ // }
+ public void testAstIndexStructFwdDecl_Bug195227() throws Exception {
IBinding b0 = getBindingFromASTName("member=", 6);
assertTrue(b0 instanceof IField);
- }
+ }
- // struct astruct {
- // int member;
- // };
- // enum anenum {
- // eItem0
- // };
+ // struct astruct {
+ // int member;
+ // };
+ // enum anenum {
+ // eItem0
+ // };
// #include "header.h"
- // struct astruct;
- // enum anenum;
- // void func(struct astruct a, enum anenum b) {
- // }
- public void testAstIndexFwdDecl_Bug195227() throws Exception {
+ // struct astruct;
+ // enum anenum;
+ // void func(struct astruct a, enum anenum b) {
+ // }
+ public void testAstIndexFwdDecl_Bug195227() throws Exception {
IBinding b0 = getBindingFromASTName("astruct;", 7);
IBinding b1 = getBindingFromASTName("anenum;", 6);
assertTrue(b0 instanceof ICompositeType);
- ICompositeType t= (ICompositeType) b0;
- IField[] f= t.getFields();
+ ICompositeType t = (ICompositeType) b0;
+ IField[] f = t.getFields();
assertEquals(1, f.length);
assertTrue(b1 instanceof IEnumeration);
- IEnumeration e= (IEnumeration) b1;
- IEnumerator[] ei= e.getEnumerators();
+ IEnumeration e = (IEnumeration) b1;
+ IEnumerator[] ei = e.getEnumerators();
assertEquals(1, ei.length);
b0 = getBindingFromASTName("astruct a", 7);
b1 = getBindingFromASTName("anenum b", 6);
assertTrue(b0 instanceof ICompositeType);
- t= (ICompositeType) b0;
- f= t.getFields();
+ t = (ICompositeType) b0;
+ f = t.getFields();
assertEquals(1, f.length);
assertTrue(b1 instanceof IEnumeration);
- e= (IEnumeration) b1;
- ei= e.getEnumerators();
+ e = (IEnumeration) b1;
+ ei = e.getEnumerators();
assertEquals(1, ei.length);
- }
-
- // // no header needed
-
- // typedef struct {
- // int member;
- // } t_struct;
- // typedef union {
- // int member;
- // } t_union;
- // typedef enum {
- // ei
- // } t_enum;
+ }
+
+ // // no header needed
+
+ // typedef struct {
+ // int member;
+ // } t_struct;
+ // typedef union {
+ // int member;
+ // } t_union;
+ // typedef enum {
+ // ei
+ // } t_enum;
public void testIsSameAnonymousType_Bug193962() throws DOMException {
// struct
IBinding tdAST = getBindingFromASTName("t_struct;", 8);
assertFalse(tdAST instanceof IIndexBinding);
- IBinding tdIndex= strategy.getIndex().adaptBinding(tdAST);
+ IBinding tdIndex = strategy.getIndex().adaptBinding(tdAST);
assertTrue(tdIndex instanceof IIndexBinding);
assertTrue(tdAST instanceof ITypedef);
assertTrue(tdIndex instanceof ITypedef);
- IType tAST= ((ITypedef) tdAST).getType();
- IType tIndex= ((ITypedef) tdIndex).getType();
+ IType tAST = ((ITypedef) tdAST).getType();
+ IType tIndex = ((ITypedef) tdIndex).getType();
assertTrue(tAST instanceof ICompositeType);
assertTrue(tIndex instanceof ICompositeType);
assertTrue(tAST.isSameType(tIndex));
@@ -303,13 +316,13 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
// union
tdAST = getBindingFromASTName("t_union;", 7);
assertFalse(tdAST instanceof IIndexBinding);
- tdIndex= strategy.getIndex().adaptBinding(tdAST);
+ tdIndex = strategy.getIndex().adaptBinding(tdAST);
assertTrue(tdIndex instanceof IIndexBinding);
assertTrue(tdAST instanceof ITypedef);
assertTrue(tdIndex instanceof ITypedef);
- tAST= ((ITypedef) tdAST).getType();
- tIndex= ((ITypedef) tdIndex).getType();
+ tAST = ((ITypedef) tdAST).getType();
+ tIndex = ((ITypedef) tdIndex).getType();
assertTrue(tAST instanceof ICompositeType);
assertTrue(tIndex instanceof ICompositeType);
assertTrue(tAST.isSameType(tIndex));
@@ -318,13 +331,13 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
// enum
tdAST = getBindingFromASTName("t_enum;", 6);
assertFalse(tdAST instanceof IIndexBinding);
- tdIndex= strategy.getIndex().adaptBinding(tdAST);
+ tdIndex = strategy.getIndex().adaptBinding(tdAST);
assertTrue(tdIndex instanceof IIndexBinding);
assertTrue(tdAST instanceof ITypedef);
assertTrue(tdIndex instanceof ITypedef);
- tAST= ((ITypedef) tdAST).getType();
- tIndex= ((ITypedef) tdIndex).getType();
+ tAST = ((ITypedef) tdAST).getType();
+ tIndex = ((ITypedef) tdIndex).getType();
assertTrue(tAST instanceof IEnumeration);
assertTrue(tIndex instanceof IEnumeration);
assertTrue(tAST.isSameType(tIndex));
@@ -346,8 +359,8 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
// struct
IBinding b = getBindingFromASTName("var1=", 4);
assertTrue(b instanceof IField);
- IField f= (IField) b;
- IScope outer= f.getCompositeTypeOwner().getScope();
+ IField f = (IField) b;
+ IScope outer = f.getCompositeTypeOwner().getScope();
assertTrue(outer instanceof ICCompositeTypeScope);
assertEquals("outer", outer.getScopeName().toString());
}
@@ -367,8 +380,8 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
// struct
IBinding b = getBindingFromASTName("var1=", 4);
assertTrue(b instanceof IField);
- IField f= (IField) b;
- IScope outer= f.getCompositeTypeOwner().getScope();
+ IField f = (IField) b;
+ IScope outer = f.getCompositeTypeOwner().getScope();
assertTrue(outer instanceof ICCompositeTypeScope);
assertEquals("outer", outer.getScopeName().toString());
}
@@ -387,8 +400,8 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
// struct
IBinding b = getBindingFromASTName("myFunc(", 6);
assertTrue(b instanceof IFunction);
- IFunction f= (IFunction) b;
- IParameter[] params= f.getParameters();
+ IFunction f = (IFunction) b;
+ IParameter[] params = f.getParameters();
assertEquals(1, params.length);
assertTrue(params[0].getType() instanceof IBasicType);
assertEquals(IBasicType.Kind.eInt, ((IBasicType) params[0].getType()).getKind());
@@ -476,7 +489,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
// .f = 3.1
// };
public void testDesignatedInitializer_Bug210019() throws Exception {
- IField f= getBindingFromASTName("f", 0);
+ IField f = getBindingFromASTName("f", 0);
}
// struct S {
@@ -488,6 +501,6 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
// f(&i->data);
// }
public void testBug394151() throws Exception {
- IParameter f= getBindingFromASTName("f(", 1);
+ IParameter f = getBindingFromASTName("f(", 1);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionTest.java
index 08793d58c03..75812e04f7a 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionTest.java
@@ -41,12 +41,23 @@ import junit.framework.TestSuite;
public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase {
public static class SingleProject extends IndexCBindingResolutionTest {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(false));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(false));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
+
public static class ProjectWithDepProj extends IndexCBindingResolutionTest {
- public ProjectWithDepProj() {setStrategy(new ReferencedProject(false));}
- public static TestSuite suite() {return suite(ProjectWithDepProj.class);}
+ public ProjectWithDepProj() {
+ setStrategy(new ReferencedProject(false));
+ }
+
+ public static TestSuite suite() {
+ return suite(ProjectWithDepProj.class);
+ }
}
public static void addTests(TestSuite suite) {
@@ -69,17 +80,17 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
IBinding b1 = getBindingFromASTName("g;", 1);
assertInstance(b0, IVariable.class);
- IVariable v0= (IVariable) b0;
+ IVariable v0 = (IVariable) b0;
assertInstance(v0.getType(), IPointerType.class);
- IPointerType p0= (IPointerType) v0.getType();
+ IPointerType p0 = (IPointerType) v0.getType();
assertInstance(p0.getType(), IFunctionType.class);
- IFunctionType f0= (IFunctionType) p0.getType();
+ IFunctionType f0 = (IFunctionType) p0.getType();
assertInstance(f0.getReturnType(), IBasicType.class);
assertEquals(1, f0.getParameterTypes().length);
assertInstance(f0.getParameterTypes()[0], IBasicType.class);
assertInstance(b1, IFunction.class);
- IFunctionType f1= ((IFunction)b1).getType();
+ IFunctionType f1 = ((IFunction) b1).getType();
assertInstance(f1.getReturnType(), IBasicType.class);
assertEquals(1, f1.getParameterTypes().length);
assertInstance(f1.getParameterTypes()[0], IBasicType.class);
@@ -163,16 +174,15 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
assertInstance(b4, ITypedef.class);
assertInstance(b5, ITypedef.class);
- ITypedef t5= (ITypedef) b5;
+ ITypedef t5 = (ITypedef) b5;
assertInstance(t5.getType(), ICompositeType.class);
- assertEquals(ICompositeType.k_struct, ((ICompositeType)t5.getType()).getKey());
+ assertEquals(ICompositeType.k_struct, ((ICompositeType) t5.getType()).getKey());
assertInstance(b6, ITypedef.class);
- ITypedef t6= (ITypedef) b6;
+ ITypedef t6 = (ITypedef) b6;
assertInstance(t6.getType(), IEnumeration.class);
}
-
// typedef struct S {int a;} S;
// typedef enum E {A,B} E;
@@ -185,12 +195,12 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
IBinding b2 = getBindingFromASTName("E *e", 1);
assertInstance(b1, ITypedef.class);
- ITypedef t1= (ITypedef) b1;
+ ITypedef t1 = (ITypedef) b1;
assertInstance(t1.getType(), ICompositeType.class);
- assertEquals(ICompositeType.k_struct, ((ICompositeType)t1.getType()).getKey());
+ assertEquals(ICompositeType.k_struct, ((ICompositeType) t1.getType()).getKey());
assertInstance(b2, ITypedef.class);
- ITypedef t2= (ITypedef) b2;
+ ITypedef t2 = (ITypedef) b2;
assertInstance(t2.getType(), IEnumeration.class);
}
@@ -228,66 +238,67 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
// b6->z = 13;
// }
public void testFieldReference() throws Exception {
- IBinding b01 = getBindingFromASTName("b1;",2);
+ IBinding b01 = getBindingFromASTName("b1;", 2);
assertVariable(b01, "b1", ICompositeType.class, "U");
- IBinding b02 = getBindingFromASTName("b2;",2);
+ IBinding b02 = getBindingFromASTName("b2;", 2);
assertVariable(b02, "b2", ICompositeType.class, "S");
- IBinding b03 = getBindingFromASTName("b3 =",2);
+ IBinding b03 = getBindingFromASTName("b3 =", 2);
assertVariable(b03, "b3", IPointerType.class, null);
- assertTypeContainer(((IVariable)b03).getType(), null, IPointerType.class, ICompositeType.class, "U");
- IBinding b04 = getBindingFromASTName("b4 =",2);
+ assertTypeContainer(((IVariable) b03).getType(), null, IPointerType.class, ICompositeType.class, "U");
+ IBinding b04 = getBindingFromASTName("b4 =", 2);
assertVariable(b04, "b4", IPointerType.class, null);
- assertTypeContainer(((IVariable)b04).getType(), null, IPointerType.class, ICompositeType.class, "S");
- IBinding b05 = getBindingFromASTName("b5;",2);
+ assertTypeContainer(((IVariable) b04).getType(), null, IPointerType.class, ICompositeType.class, "S");
+ IBinding b05 = getBindingFromASTName("b5;", 2);
assertVariable(b05, "b5", ITypedef.class, null);
- assertTypeContainer(((IVariable)b05).getType(), null, ITypedef.class, ICompositeType.class, "S");
- IBinding b06 = getBindingFromASTName("b6 =",2);
+ assertTypeContainer(((IVariable) b05).getType(), null, ITypedef.class, ICompositeType.class, "S");
+ IBinding b06 = getBindingFromASTName("b6 =", 2);
assertVariable(b06, "b6", IPointerType.class, null);
- assertTypeContainer(((IVariable)b06).getType(), null, IPointerType.class, ITypedef.class, "TS");
- assertTypeContainer(((IPointerType)((IVariable)b06).getType()).getType(), null, ITypedef.class, ICompositeType.class, "S");
- IBinding b07 = getBindingFromASTName("x = 0",1);
+ assertTypeContainer(((IVariable) b06).getType(), null, IPointerType.class, ITypedef.class, "TS");
+ assertTypeContainer(((IPointerType) ((IVariable) b06).getType()).getType(), null, ITypedef.class,
+ ICompositeType.class, "S");
+ IBinding b07 = getBindingFromASTName("x = 0", 1);
assertVariable(b07, "x", IBasicType.class, null);
- IBinding b08 = getBindingFromASTName("y = 1",1);
+ IBinding b08 = getBindingFromASTName("y = 1", 1);
assertVariable(b08, "y", IBasicType.class, null);
- IBinding b09 = getBindingFromASTName("x = 0",1);
+ IBinding b09 = getBindingFromASTName("x = 0", 1);
assertVariable(b09, "x", IBasicType.class, null);
- IBinding b10 = getBindingFromASTName("y = 1",1);
+ IBinding b10 = getBindingFromASTName("y = 1", 1);
assertVariable(b08, "y", IBasicType.class, null);
- IBinding b11 = getBindingFromASTName("u.x = 2",1);
+ IBinding b11 = getBindingFromASTName("u.x = 2", 1);
assertVariable(b11, "u", ICompositeType.class, "U");
- IBinding b12 = getBindingFromASTName("x = 2",1);
+ IBinding b12 = getBindingFromASTName("x = 2", 1);
assertVariable(b12, "x", IBasicType.class, null);
- IBinding b13 = getBindingFromASTName("u.y = 3",1);
+ IBinding b13 = getBindingFromASTName("u.y = 3", 1);
assertVariable(b13, "u", ICompositeType.class, "U");
- IBinding b14 = getBindingFromASTName("y = 3",1);
+ IBinding b14 = getBindingFromASTName("y = 3", 1);
assertVariable(b08, "y", IBasicType.class, null);
- IBinding b15 = getBindingFromASTName("x = 4",1);
+ IBinding b15 = getBindingFromASTName("x = 4", 1);
assertVariable(b15, "x", IBasicType.class, null);
- IBinding b16 = getBindingFromASTName("y = 5",1);
+ IBinding b16 = getBindingFromASTName("y = 5", 1);
assertVariable(b16, "y", IBasicType.class, null);
- IBinding b17 = getBindingFromASTName("u.x = 6",1);
+ IBinding b17 = getBindingFromASTName("u.x = 6", 1);
assertVariable(b17, "u", ICompositeType.class, "U");
- IBinding b18 = getBindingFromASTName("x = 6",1);
+ IBinding b18 = getBindingFromASTName("x = 6", 1);
assertVariable(b18, "x", IBasicType.class, null);
- IBinding b19 = getBindingFromASTName("u.y = 7",1);
+ IBinding b19 = getBindingFromASTName("u.y = 7", 1);
assertVariable(b19, "u", ICompositeType.class, "U");
- IBinding b20 = getBindingFromASTName("y = 7",1);
+ IBinding b20 = getBindingFromASTName("y = 7", 1);
assertVariable(b20, "y", IBasicType.class, null);
- IBinding b21 = getBindingFromASTName("z = 8",1);
+ IBinding b21 = getBindingFromASTName("z = 8", 1);
assertVariable(b21, "z", IBasicType.class, null);
- IBinding b22 = getBindingFromASTName("x = 9",1);
+ IBinding b22 = getBindingFromASTName("x = 9", 1);
assertVariable(b22, "x", IBasicType.class, null);
- IBinding b23 = getBindingFromASTName("y = 10",1);
+ IBinding b23 = getBindingFromASTName("y = 10", 1);
assertVariable(b23, "y", IBasicType.class, null);
- IBinding b24 = getBindingFromASTName("u.x = 11",1);
+ IBinding b24 = getBindingFromASTName("u.x = 11", 1);
assertVariable(b24, "u", ICompositeType.class, "U");
- IBinding b25 = getBindingFromASTName("x = 11",1);
+ IBinding b25 = getBindingFromASTName("x = 11", 1);
assertVariable(b25, "x", IBasicType.class, null);
- IBinding b26 = getBindingFromASTName("u.y = 12",1);
+ IBinding b26 = getBindingFromASTName("u.y = 12", 1);
assertVariable(b26, "u", ICompositeType.class, "U");
- IBinding b27 = getBindingFromASTName("y = 12",1);
+ IBinding b27 = getBindingFromASTName("y = 12", 1);
assertVariable(b27, "y", IBasicType.class, null);
- IBinding b28 = getBindingFromASTName("z = 13",1);
+ IBinding b28 = getBindingFromASTName("z = 13", 1);
assertVariable(b28, "z", IBasicType.class, null);
}
@@ -379,26 +390,26 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
// int* c= &b;
// enum X {e0, e4=4, e5, e2=2, e3};
- // void ref() {
- // a; b; c; e0; e2; e3; e4; e5;
- // }
+ // void ref() {
+ // a; b; c; e0; e2; e3; e4; e5;
+ // }
public void testValues() throws Exception {
- IVariable v= (IVariable) getBindingFromASTName("a;", 1);
+ IVariable v = (IVariable) getBindingFromASTName("a;", 1);
checkValue(v.getInitialValue(), -4);
- v= (IVariable) getBindingFromASTName("b;", 1);
+ v = (IVariable) getBindingFromASTName("b;", 1);
checkValue(v.getInitialValue(), 0);
- v= (IVariable) getBindingFromASTName("c;", 1);
+ v = (IVariable) getBindingFromASTName("c;", 1);
assertNull(v.getInitialValue().numberValue());
- IEnumerator e= (IEnumerator) getBindingFromASTName("e0", 2);
+ IEnumerator e = (IEnumerator) getBindingFromASTName("e0", 2);
checkValue(e.getValue(), 0);
- e= (IEnumerator) getBindingFromASTName("e2", 2);
+ e = (IEnumerator) getBindingFromASTName("e2", 2);
checkValue(e.getValue(), 2);
- e= (IEnumerator) getBindingFromASTName("e3", 2);
+ e = (IEnumerator) getBindingFromASTName("e3", 2);
checkValue(e.getValue(), 3);
- e= (IEnumerator) getBindingFromASTName("e4", 2);
+ e = (IEnumerator) getBindingFromASTName("e4", 2);
checkValue(e.getValue(), 4);
- e= (IEnumerator) getBindingFromASTName("e5", 2);
+ e = (IEnumerator) getBindingFromASTName("e5", 2);
checkValue(e.getValue(), 5);
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugs.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugs.java
index 1674ec9ba30..d1f4f6c6239 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugs.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugs.java
@@ -73,13 +73,23 @@ import junit.framework.TestSuite;
public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBase {
public static class SingleProject extends IndexCPPBindingResolutionBugs {
- public SingleProject() { setStrategy(new SinglePDOMTestStrategy(true)); }
- public static TestSuite suite() { return suite(SingleProject.class); }
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
public static class ProjectWithDepProj extends IndexCPPBindingResolutionBugs {
- public ProjectWithDepProj() { setStrategy(new ReferencedProject(true)); }
- public static TestSuite suite() { return suite(ProjectWithDepProj.class); }
+ public ProjectWithDepProj() {
+ setStrategy(new ReferencedProject(true));
+ }
+
+ public static TestSuite suite() {
+ return suite(ProjectWithDepProj.class);
+ }
}
public static void addTests(TestSuite suite) {
@@ -104,18 +114,18 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// FUNC() {}
// FUNC2(1) {}
public void test_208558() throws Exception {
- IIndex index= getIndex();
+ IIndex index = getIndex();
- IIndexMacro[] macrosA= index.findMacros("OBJ".toCharArray(), IndexFilter.ALL, npm());
- IIndexMacro[] macrosB= index.findMacros("FUNC".toCharArray(), IndexFilter.ALL, npm());
- IIndexMacro[] macrosC= index.findMacros("FUNC2".toCharArray(), IndexFilter.ALL, npm());
+ IIndexMacro[] macrosA = index.findMacros("OBJ".toCharArray(), IndexFilter.ALL, npm());
+ IIndexMacro[] macrosB = index.findMacros("FUNC".toCharArray(), IndexFilter.ALL, npm());
+ IIndexMacro[] macrosC = index.findMacros("FUNC2".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, macrosA.length);
assertEquals(1, macrosB.length);
assertEquals(1, macrosC.length);
- IIndexMacro obj= macrosA[0];
- IIndexMacro func= macrosB[0];
- IIndexMacro func2= macrosC[0];
+ IIndexMacro obj = macrosA[0];
+ IIndexMacro func = macrosB[0];
+ IIndexMacro func2 = macrosC[0];
assertEquals("OBJ", new String(obj.getName()));
assertEquals("FUNC", new String(func.getName()));
@@ -135,12 +145,12 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
assertEquals(1, func2.getParameterList().length);
assertEquals("A", new String(func2.getParameterList()[0]));
- IIndexBinding[] bindings= index.findBindings(Pattern.compile(".*"), false, IndexFilter.ALL, npm());
+ IIndexBinding[] bindings = index.findBindings(Pattern.compile(".*"), false, IndexFilter.ALL, npm());
assertEquals(3, bindings.length);
- IIndexBinding foo= index.findBindings("foo".toCharArray(), IndexFilter.ALL, npm())[0];
- IIndexBinding bar= index.findBindings("bar".toCharArray(), IndexFilter.ALL, npm())[0];
- IIndexBinding baz= index.findBindings("baz".toCharArray(), IndexFilter.ALL, npm())[0];
+ IIndexBinding foo = index.findBindings("foo".toCharArray(), IndexFilter.ALL, npm())[0];
+ IIndexBinding bar = index.findBindings("bar".toCharArray(), IndexFilter.ALL, npm())[0];
+ IIndexBinding baz = index.findBindings("baz".toCharArray(), IndexFilter.ALL, npm())[0];
assertEquals("foo", foo.getName());
assertEquals("bar", bar.getName());
@@ -161,7 +171,7 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// testTemplate(testFile);
// }
public void test_207320() {
- IBinding b0= getBindingFromASTName("testTemplate(", 12);
+ IBinding b0 = getBindingFromASTName("testTemplate(", 12);
assertInstance(b0, ICPPFunction.class);
assertInstance(b0, ICPPTemplateInstance.class);
}
@@ -197,53 +207,54 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// testCall( /*8*/ global_cBaseRef);
// }
public void test_206187() throws Exception {
- IBinding b1= getBindingFromASTName("testCall( /*1*/", 8);
- IBinding b2= getBindingFromASTName("testCall( /*2*/", 8);
- IBinding b3= getBindingFromASTName("testCall( /*3*/", 8);
- IBinding b4= getBindingFromASTName("testCall( /*4*/", 8);
- IBinding b5= getBindingFromASTName("testCall( /*5*/", 8);
- IBinding b6= getBindingFromASTName("testCall( /*6*/", 8);
- IBinding b7= getBindingFromASTName("testCall( /*7*/", 8);
- IBinding b8= getBindingFromASTName("testCall( /*8*/", 8);
+ IBinding b1 = getBindingFromASTName("testCall( /*1*/", 8);
+ IBinding b2 = getBindingFromASTName("testCall( /*2*/", 8);
+ IBinding b3 = getBindingFromASTName("testCall( /*3*/", 8);
+ IBinding b4 = getBindingFromASTName("testCall( /*4*/", 8);
+ IBinding b5 = getBindingFromASTName("testCall( /*5*/", 8);
+ IBinding b6 = getBindingFromASTName("testCall( /*6*/", 8);
+ IBinding b7 = getBindingFromASTName("testCall( /*7*/", 8);
+ IBinding b8 = getBindingFromASTName("testCall( /*8*/", 8);
}
// template<typename T1>
- // class A {};
- //
- // template<typename T2>
- // class B : public A<T2> {};
- //
- // class C {};
- //
- // B<C> b;
-
- // void foo() {C c; B<int> b;}
- public void test_188274() throws Exception {
- IBinding b0= getBindingFromASTName("C", 1);
- IBinding b1= getBindingFromASTName("B", 1);
- assertInstance(b0, ICPPClassType.class);
- assertInstance(b1, ICPPClassType.class);
- assertInstance(b1, ICPPClassTemplate.class);
- assertInstance(b1, ICPPInstanceCache.class);
-
- ICPPInstanceCache ct= (ICPPInstanceCache) b1;
- ICPPSpecialization inst= ct.getInstance(new ICPPTemplateArgument[]{new CPPTemplateTypeArgument((IType)b0)});
- assertInstance(inst, ICPPClassType.class);
- ICPPClassType c2t= (ICPPClassType) inst;
- ICPPBase[] bases= c2t.getBases();
- assertEquals(1, bases.length);
- assertInstance(bases[0].getBaseClass(), ICPPClassType.class);
- }
+ // class A {};
+ //
+ // template<typename T2>
+ // class B : public A<T2> {};
+ //
+ // class C {};
+ //
+ // B<C> b;
+
+ // void foo() {C c; B<int> b;}
+ public void test_188274() throws Exception {
+ IBinding b0 = getBindingFromASTName("C", 1);
+ IBinding b1 = getBindingFromASTName("B", 1);
+ assertInstance(b0, ICPPClassType.class);
+ assertInstance(b1, ICPPClassType.class);
+ assertInstance(b1, ICPPClassTemplate.class);
+ assertInstance(b1, ICPPInstanceCache.class);
+
+ ICPPInstanceCache ct = (ICPPInstanceCache) b1;
+ ICPPSpecialization inst = ct
+ .getInstance(new ICPPTemplateArgument[] { new CPPTemplateTypeArgument((IType) b0) });
+ assertInstance(inst, ICPPClassType.class);
+ ICPPClassType c2t = (ICPPClassType) inst;
+ ICPPBase[] bases = c2t.getBases();
+ assertEquals(1, bases.length);
+ assertInstance(bases[0].getBaseClass(), ICPPClassType.class);
+ }
// namespace ns {class A{};}
// ns::A a;
// class B {};
public void test_188324() throws Exception {
- IASTName name= findName("B", 1);
- IBinding b0= getBindingFromASTName("ns::A", 2);
+ IASTName name = findName("B", 1);
+ IBinding b0 = getBindingFromASTName("ns::A", 2);
assertInstance(b0, ICPPNamespace.class);
- ICPPNamespace ns= (ICPPNamespace) b0;
+ ICPPNamespace ns = (ICPPNamespace) b0;
assertEquals(0, ns.getNamespaceScope().getBindings(name, false, false).length);
}
@@ -257,9 +268,9 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// Bug 185828 reports a StackOverflowException is thrown before we get here.
// That the SOE is thrown is detected in BaseTestCase via an Error IStatus
- IBinding b0= getBindingFromASTName("C<int>", 1);
- IBinding b1= getBindingFromASTName("C<int>", 6);
- IBinding b2= getProblemFromASTName("unresolvable", 12);
+ IBinding b0 = getBindingFromASTName("C<int>", 1);
+ IBinding b1 = getBindingFromASTName("C<int>", 6);
+ IBinding b2 = getProblemFromASTName("unresolvable", 12);
assertInstance(b0, ICPPClassType.class);
assertInstance(b0, ICPPClassTemplate.class);
@@ -285,10 +296,10 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// MyClass* cls= new MyClass();
// }
public void test_184216() throws Exception {
- IBinding b0= getBindingFromASTName("MyClass*", 7);
+ IBinding b0 = getBindingFromASTName("MyClass*", 7);
assertInstance(b0, ICPPClassType.class);
- ICPPClassType ct= (ICPPClassType) b0;
- ICPPMethod[] ms= ct.getDeclaredMethods(); // 184216 reports CCE thrown
+ ICPPClassType ct = (ICPPClassType) b0;
+ ICPPMethod[] ms = ct.getDeclaredMethods(); // 184216 reports CCE thrown
assertEquals(2, ms.length);
assertInstance(ms[0], ICPPTemplateDefinition.class);
assertInstance(ms[1], ICPPTemplateDefinition.class);
@@ -383,21 +394,21 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// }
// }
public void test_176708_CCE() throws Exception {
- IBinding binding= getBindingFromASTName("Y {", 1);
+ IBinding binding = getBindingFromASTName("Y {", 1);
assertTrue(binding instanceof ICPPNamespace);
- ICPPNamespace adapted= (ICPPNamespace) strategy.getIndex().adaptBinding(binding);
- IASTName name= findName("Ambiguity problem", 9);
+ ICPPNamespace adapted = (ICPPNamespace) strategy.getIndex().adaptBinding(binding);
+ IASTName name = findName("Ambiguity problem", 9);
assertNotNull(name);
- IBinding binding2= adapted.getNamespaceScope().getBinding(name, true);
+ IBinding binding2 = adapted.getNamespaceScope().getBinding(name, true);
}
// namespace X {int i;}
// int a= X::i;
public void test_176708_NPE() throws Exception {
- IBinding binding= getBindingFromASTName("i;", 1);
+ IBinding binding = getBindingFromASTName("i;", 1);
assertTrue(binding instanceof ICPPVariable);
- IScope scope= binding.getScope();
+ IScope scope = binding.getScope();
}
// template<class T, class U, class V>
@@ -406,12 +417,12 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// template<>
// class A<int, bool, double> {};
public void test_180784() throws Exception {
- IBinding b0= getBindingFromASTName("A<int, bool, double> {};", 20);
+ IBinding b0 = getBindingFromASTName("A<int, bool, double> {};", 20);
assertInstance(b0, ICPPSpecialization.class);
- ICPPSpecialization s= (ICPPSpecialization) b0;
- IBinding b1= s.getSpecializedBinding();
+ ICPPSpecialization s = (ICPPSpecialization) b0;
+ IBinding b1 = s.getSpecializedBinding();
assertInstance(b1, ICPPClassTemplate.class);
- ICPPClassTemplate t= (ICPPClassTemplate) b1;
+ ICPPClassTemplate t = (ICPPClassTemplate) b1;
ICPPTemplateParameter[] ps = t.getTemplateParameters();
assertNotNull(ps);
assertEquals(3, ps.length);
@@ -438,8 +449,8 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
public void test_180948() throws Exception {
// Main check occurs in BaseTestCase - that no ClassCastException
// is thrown during indexing
- IBinding b0= getBindingFromASTName("id(*", 2);
- IBinding b1= getBindingFromASTName("id(6", 2);
+ IBinding b0 = getBindingFromASTName("id(*", 2);
+ IBinding b1 = getBindingFromASTName("id(6", 2);
}
// void func1(void);
@@ -471,73 +482,73 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
assertTrue(b0 instanceof ICPPField);
}
- // typedef struct {
- // int utm;
- // } usertype;
- // void func(usertype t);
+ // typedef struct {
+ // int utm;
+ // } usertype;
+ // void func(usertype t);
- // void test() {
+ // void test() {
// usertype ut;
// func(ut);
- // }
- public void testFuncWithTypedefForAnonymousStruct_190730() throws Exception {
+ // }
+ public void testFuncWithTypedefForAnonymousStruct_190730() throws Exception {
IBinding b0 = getBindingFromASTName("func(", 4);
assertTrue(b0 instanceof IFunction);
- IFunction f= (IFunction) b0;
- IParameter[] pars= f.getParameters();
+ IFunction f = (IFunction) b0;
+ IParameter[] pars = f.getParameters();
assertEquals(1, pars.length);
- IType type= pars[0].getType();
+ IType type = pars[0].getType();
assertTrue(type instanceof ITypedef);
- type= ((ITypedef) type).getType();
+ type = ((ITypedef) type).getType();
assertTrue(type instanceof ICPPClassType);
- }
+ }
- // typedef enum {
- // eItem
- // } userEnum;
- // void func(userEnum t);
+ // typedef enum {
+ // eItem
+ // } userEnum;
+ // void func(userEnum t);
- // void test() {
+ // void test() {
// userEnum ut;
// func(ut);
- // }
- public void testFuncWithTypedefForAnonymousEnum_190730() throws Exception {
+ // }
+ public void testFuncWithTypedefForAnonymousEnum_190730() throws Exception {
IBinding b0 = getBindingFromASTName("func(", 4);
assertTrue(b0 instanceof IFunction);
- IFunction f= (IFunction) b0;
- IParameter[] pars= f.getParameters();
+ IFunction f = (IFunction) b0;
+ IParameter[] pars = f.getParameters();
assertEquals(1, pars.length);
- IType type= pars[0].getType();
+ IType type = pars[0].getType();
assertTrue(type instanceof ITypedef);
- type= ((ITypedef) type).getType();
+ type = ((ITypedef) type).getType();
assertTrue(type instanceof IEnumeration);
- }
-
- // // no header needed
-
- // typedef class {
- // int member;
- // } t_class;
- // typedef struct {
- // int member;
- // } t_struct;
- // typedef union {
- // int member;
- // } t_union;
- // typedef enum {
- // ei
- // } t_enum;
+ }
+
+ // // no header needed
+
+ // typedef class {
+ // int member;
+ // } t_class;
+ // typedef struct {
+ // int member;
+ // } t_struct;
+ // typedef union {
+ // int member;
+ // } t_union;
+ // typedef enum {
+ // ei
+ // } t_enum;
public void testIsSameAnonymousType_193962() throws DOMException {
// class
IBinding tdAST = getBindingFromASTName("t_class;", 7);
assertFalse(tdAST instanceof IIndexBinding);
- IBinding tdIndex= strategy.getIndex().adaptBinding(tdAST);
+ IBinding tdIndex = strategy.getIndex().adaptBinding(tdAST);
assertTrue(tdIndex instanceof IIndexBinding);
assertTrue(tdAST instanceof ITypedef);
assertTrue(tdIndex instanceof ITypedef);
- IType tAST= ((ITypedef) tdAST).getType();
- IType tIndex= ((ITypedef) tdIndex).getType();
+ IType tAST = ((ITypedef) tdAST).getType();
+ IType tIndex = ((ITypedef) tdIndex).getType();
assertTrue(tAST instanceof ICompositeType);
assertTrue(tIndex instanceof ICompositeType);
assertTrue(tAST.isSameType(tIndex));
@@ -546,13 +557,13 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// struct
tdAST = getBindingFromASTName("t_struct;", 8);
assertFalse(tdAST instanceof IIndexBinding);
- tdIndex= strategy.getIndex().adaptBinding(tdAST);
+ tdIndex = strategy.getIndex().adaptBinding(tdAST);
assertTrue(tdIndex instanceof IIndexBinding);
assertTrue(tdAST instanceof ITypedef);
assertTrue(tdIndex instanceof ITypedef);
- tAST= ((ITypedef) tdAST).getType();
- tIndex= ((ITypedef) tdIndex).getType();
+ tAST = ((ITypedef) tdAST).getType();
+ tIndex = ((ITypedef) tdIndex).getType();
assertTrue(tAST instanceof ICompositeType);
assertTrue(tIndex instanceof ICompositeType);
assertTrue(tAST.isSameType(tIndex));
@@ -561,13 +572,13 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// union
tdAST = getBindingFromASTName("t_union;", 7);
assertFalse(tdAST instanceof IIndexBinding);
- tdIndex= strategy.getIndex().adaptBinding(tdAST);
+ tdIndex = strategy.getIndex().adaptBinding(tdAST);
assertTrue(tdIndex instanceof IIndexBinding);
assertTrue(tdAST instanceof ITypedef);
assertTrue(tdIndex instanceof ITypedef);
- tAST= ((ITypedef) tdAST).getType();
- tIndex= ((ITypedef) tdIndex).getType();
+ tAST = ((ITypedef) tdAST).getType();
+ tIndex = ((ITypedef) tdIndex).getType();
assertTrue(tAST instanceof ICompositeType);
assertTrue(tIndex instanceof ICompositeType);
assertTrue(tAST.isSameType(tIndex));
@@ -576,46 +587,46 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// enum
tdAST = getBindingFromASTName("t_enum;", 6);
assertFalse(tdAST instanceof IIndexBinding);
- tdIndex= strategy.getIndex().adaptBinding(tdAST);
+ tdIndex = strategy.getIndex().adaptBinding(tdAST);
assertTrue(tdIndex instanceof IIndexBinding);
assertTrue(tdAST instanceof ITypedef);
assertTrue(tdIndex instanceof ITypedef);
- tAST= ((ITypedef) tdAST).getType();
- tIndex= ((ITypedef) tdIndex).getType();
+ tAST = ((ITypedef) tdAST).getType();
+ tIndex = ((ITypedef) tdIndex).getType();
assertTrue(tAST instanceof IEnumeration);
assertTrue(tIndex instanceof IEnumeration);
assertTrue(tAST.isSameType(tIndex));
assertTrue(tIndex.isSameType(tAST));
}
- // // no header needed
+ // // no header needed
// namespace ns {
- // typedef class {
- // int member;
- // } t_class;
- // typedef struct {
- // int member;
- // } t_struct;
- // typedef union {
- // int member;
- // } t_union;
- // typedef enum {
- // ei
- // } t_enum;
+ // typedef class {
+ // int member;
+ // } t_class;
+ // typedef struct {
+ // int member;
+ // } t_struct;
+ // typedef union {
+ // int member;
+ // } t_union;
+ // typedef enum {
+ // ei
+ // } t_enum;
// };
public void testIsSameNestedAnonymousType_193962() throws DOMException {
// class
IBinding tdAST = getBindingFromASTName("t_class;", 7);
assertFalse(tdAST instanceof IIndexBinding);
- IBinding tdIndex= strategy.getIndex().adaptBinding(tdAST);
+ IBinding tdIndex = strategy.getIndex().adaptBinding(tdAST);
assertTrue(tdIndex instanceof IIndexBinding);
assertTrue(tdAST instanceof ITypedef);
assertTrue(tdIndex instanceof ITypedef);
- IType tAST= ((ITypedef) tdAST).getType();
- IType tIndex= ((ITypedef) tdIndex).getType();
+ IType tAST = ((ITypedef) tdAST).getType();
+ IType tIndex = ((ITypedef) tdIndex).getType();
assertTrue(tAST instanceof ICompositeType);
assertTrue(tIndex instanceof ICompositeType);
assertTrue(tAST.isSameType(tIndex));
@@ -624,13 +635,13 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// struct
tdAST = getBindingFromASTName("t_struct;", 8);
assertFalse(tdAST instanceof IIndexBinding);
- tdIndex= strategy.getIndex().adaptBinding(tdAST);
+ tdIndex = strategy.getIndex().adaptBinding(tdAST);
assertTrue(tdIndex instanceof IIndexBinding);
assertTrue(tdAST instanceof ITypedef);
assertTrue(tdIndex instanceof ITypedef);
- tAST= ((ITypedef) tdAST).getType();
- tIndex= ((ITypedef) tdIndex).getType();
+ tAST = ((ITypedef) tdAST).getType();
+ tIndex = ((ITypedef) tdIndex).getType();
assertTrue(tAST instanceof ICompositeType);
assertTrue(tIndex instanceof ICompositeType);
assertTrue(tAST.isSameType(tIndex));
@@ -639,13 +650,13 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// union
tdAST = getBindingFromASTName("t_union;", 7);
assertFalse(tdAST instanceof IIndexBinding);
- tdIndex= strategy.getIndex().adaptBinding(tdAST);
+ tdIndex = strategy.getIndex().adaptBinding(tdAST);
assertTrue(tdIndex instanceof IIndexBinding);
assertTrue(tdAST instanceof ITypedef);
assertTrue(tdIndex instanceof ITypedef);
- tAST= ((ITypedef) tdAST).getType();
- tIndex= ((ITypedef) tdIndex).getType();
+ tAST = ((ITypedef) tdAST).getType();
+ tIndex = ((ITypedef) tdIndex).getType();
assertTrue(tAST instanceof ICompositeType);
assertTrue(tIndex instanceof ICompositeType);
assertTrue(tAST.isSameType(tIndex));
@@ -654,13 +665,13 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// enum
tdAST = getBindingFromASTName("t_enum;", 6);
assertFalse(tdAST instanceof IIndexBinding);
- tdIndex= strategy.getIndex().adaptBinding(tdAST);
+ tdIndex = strategy.getIndex().adaptBinding(tdAST);
assertTrue(tdIndex instanceof IIndexBinding);
assertTrue(tdAST instanceof ITypedef);
assertTrue(tdIndex instanceof ITypedef);
- tAST= ((ITypedef) tdAST).getType();
- tIndex= ((ITypedef) tdIndex).getType();
+ tAST = ((ITypedef) tdAST).getType();
+ tIndex = ((ITypedef) tdIndex).getType();
assertTrue(tAST instanceof IEnumeration);
assertTrue(tIndex instanceof IEnumeration);
assertTrue(tAST.isSameType(tIndex));
@@ -710,8 +721,8 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// struct
IBinding b = getBindingFromASTName("var1=", 4);
assertTrue(b instanceof IField);
- IField f= (IField) b;
- IScope outer= f.getCompositeTypeOwner().getScope();
+ IField f = (IField) b;
+ IScope outer = f.getCompositeTypeOwner().getScope();
assertTrue(outer instanceof ICPPClassScope);
assertEquals("outer", outer.getScopeName().toString());
}
@@ -734,8 +745,8 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// struct
IBinding b = getBindingFromASTName("var1=", 4);
assertTrue(b instanceof IField);
- IField f= (IField) b;
- IScope outer= f.getCompositeTypeOwner().getScope();
+ IField f = (IField) b;
+ IScope outer = f.getCompositeTypeOwner().getScope();
assertTrue(outer instanceof ICPPClassScope);
assertEquals("outer", outer.getScopeName().toString());
@@ -753,8 +764,8 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
public void testUsingDirective_216527() throws Exception {
IBinding b = getBindingFromASTName("v=", 1);
assertTrue(b instanceof IVariable);
- IVariable v= (IVariable) b;
- IScope scope= v.getScope();
+ IVariable v = (IVariable) b;
+ IScope scope = v.getScope();
assertTrue(scope instanceof ICPPNamespaceScope);
assertEquals("ns", scope.getScopeName().toString());
}
@@ -776,15 +787,15 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
public void testNamespaceComposition_200673() throws Exception {
IBinding a = getBindingFromASTName("a=", 1);
assertTrue(a instanceof IVariable);
- IVariable v= (IVariable) a;
- IScope scope= v.getScope();
+ IVariable v = (IVariable) a;
+ IScope scope = v.getScope();
assertTrue(scope instanceof ICPPNamespaceScope);
assertEquals("NSA", scope.getScopeName().toString());
IBinding b = getBindingFromASTName("b;", 1);
assertTrue(b instanceof IVariable);
- v= (IVariable) b;
- scope= v.getScope();
+ v = (IVariable) b;
+ scope = v.getScope();
assertTrue(scope instanceof ICPPNamespaceScope);
assertEquals("NSB", scope.getScopeName().toString());
}
@@ -793,7 +804,7 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// namespace N {using namespace N::M;}
// using namespace N;
- // void test() {x;}
+ // void test() {x;}
public void testEndlessLoopWithUsingDeclaration_209813() throws DOMException {
getProblemFromASTName("x;", 1);
}
@@ -803,70 +814,78 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// void test(MyClass* ptr);
// class MyClass;
public void testClassRedeclarationAfterReference_229571() throws Exception {
- IBinding cl= getBindingFromASTName("MyClass;", 7);
- IFunction fn= getBindingFromASTName("test(", 4, IFunction.class);
- IType type= fn.getType().getParameterTypes()[0];
+ IBinding cl = getBindingFromASTName("MyClass;", 7);
+ IFunction fn = getBindingFromASTName("test(", 4, IFunction.class);
+ IType type = fn.getType().getParameterTypes()[0];
assertInstance(type, IPointerType.class);
- type= ((IPointerType) type).getType();
+ type = ((IPointerType) type).getType();
assertInstance(cl, IType.class);
assertSameType(type, (IType) cl);
}
- // class A {
- // public:
- // void foo() const volatile;
- // void foo() volatile;
- // void foo() const;
- // void foo();
- // void bar() const volatile;
- // void bar() volatile;
- // void bar() const;
- // void bar();
- // };
-
- // void A::foo() const volatile { bar();/*1*/ }
- // void A::foo() volatile { bar();/*2*/ }
- // void A::foo() const { bar();/*3*/ }
- // void A::foo() { bar();/*4*/ }
- // void test() {
- // A a;
- // const A ca;
- // volatile A va;
- // const volatile A cva;
- // cva.bar();/*5*/
- // va.bar();/*6*/
- // ca.bar();/*7*/
- // a.bar();/*8*/
- // }
- public void testMemberFunctionDisambiguationByCVness_238409() throws Exception {
- ICPPMethod bar_cv= getBindingFromASTName("bar();/*1*/", 3, ICPPMethod.class);
- ICPPMethod bar_v= getBindingFromASTName("bar();/*2*/", 3, ICPPMethod.class);
- ICPPMethod bar_c= getBindingFromASTName("bar();/*3*/", 3, ICPPMethod.class);
- ICPPMethod bar= getBindingFromASTName("bar();/*4*/", 3, ICPPMethod.class);
- ICPPFunctionType bar_cv_ft= bar_cv.getType();
- ICPPFunctionType bar_v_ft= bar_v.getType();
- ICPPFunctionType bar_c_ft= bar_c.getType();
- ICPPFunctionType bar_ft= bar.getType();
-
- assertTrue(bar_cv_ft.isConst()); assertTrue(bar_cv_ft.isVolatile());
- assertTrue(!bar_v_ft.isConst()); assertTrue(bar_v_ft.isVolatile());
- assertTrue(bar_c_ft.isConst()); assertTrue(!bar_c_ft.isVolatile());
- assertTrue(!bar_ft.isConst()); assertTrue(!bar_ft.isVolatile());
-
- bar_cv= getBindingFromASTName("bar();/*5*/", 3, ICPPMethod.class);
- bar_v= getBindingFromASTName("bar();/*6*/", 3, ICPPMethod.class);
- bar_c= getBindingFromASTName("bar();/*7*/", 3, ICPPMethod.class);
- bar= getBindingFromASTName("bar();/*8*/", 3, ICPPMethod.class);
- bar_cv_ft= bar_cv.getType();
- bar_v_ft= bar_v.getType();
- bar_c_ft= bar_c.getType();
- bar_ft= bar.getType();
-
- assertTrue(bar_cv_ft.isConst()); assertTrue(bar_cv_ft.isVolatile());
- assertTrue(!bar_v_ft.isConst()); assertTrue(bar_v_ft.isVolatile());
- assertTrue(bar_c_ft.isConst()); assertTrue(!bar_c_ft.isVolatile());
- assertTrue(!bar_ft.isConst()); assertTrue(!bar_ft.isVolatile());
- }
+ // class A {
+ // public:
+ // void foo() const volatile;
+ // void foo() volatile;
+ // void foo() const;
+ // void foo();
+ // void bar() const volatile;
+ // void bar() volatile;
+ // void bar() const;
+ // void bar();
+ // };
+
+ // void A::foo() const volatile { bar();/*1*/ }
+ // void A::foo() volatile { bar();/*2*/ }
+ // void A::foo() const { bar();/*3*/ }
+ // void A::foo() { bar();/*4*/ }
+ // void test() {
+ // A a;
+ // const A ca;
+ // volatile A va;
+ // const volatile A cva;
+ // cva.bar();/*5*/
+ // va.bar();/*6*/
+ // ca.bar();/*7*/
+ // a.bar();/*8*/
+ // }
+ public void testMemberFunctionDisambiguationByCVness_238409() throws Exception {
+ ICPPMethod bar_cv = getBindingFromASTName("bar();/*1*/", 3, ICPPMethod.class);
+ ICPPMethod bar_v = getBindingFromASTName("bar();/*2*/", 3, ICPPMethod.class);
+ ICPPMethod bar_c = getBindingFromASTName("bar();/*3*/", 3, ICPPMethod.class);
+ ICPPMethod bar = getBindingFromASTName("bar();/*4*/", 3, ICPPMethod.class);
+ ICPPFunctionType bar_cv_ft = bar_cv.getType();
+ ICPPFunctionType bar_v_ft = bar_v.getType();
+ ICPPFunctionType bar_c_ft = bar_c.getType();
+ ICPPFunctionType bar_ft = bar.getType();
+
+ assertTrue(bar_cv_ft.isConst());
+ assertTrue(bar_cv_ft.isVolatile());
+ assertTrue(!bar_v_ft.isConst());
+ assertTrue(bar_v_ft.isVolatile());
+ assertTrue(bar_c_ft.isConst());
+ assertTrue(!bar_c_ft.isVolatile());
+ assertTrue(!bar_ft.isConst());
+ assertTrue(!bar_ft.isVolatile());
+
+ bar_cv = getBindingFromASTName("bar();/*5*/", 3, ICPPMethod.class);
+ bar_v = getBindingFromASTName("bar();/*6*/", 3, ICPPMethod.class);
+ bar_c = getBindingFromASTName("bar();/*7*/", 3, ICPPMethod.class);
+ bar = getBindingFromASTName("bar();/*8*/", 3, ICPPMethod.class);
+ bar_cv_ft = bar_cv.getType();
+ bar_v_ft = bar_v.getType();
+ bar_c_ft = bar_c.getType();
+ bar_ft = bar.getType();
+
+ assertTrue(bar_cv_ft.isConst());
+ assertTrue(bar_cv_ft.isVolatile());
+ assertTrue(!bar_v_ft.isConst());
+ assertTrue(bar_v_ft.isVolatile());
+ assertTrue(bar_c_ft.isConst());
+ assertTrue(!bar_c_ft.isVolatile());
+ assertTrue(!bar_ft.isConst());
+ assertTrue(!bar_ft.isVolatile());
+ }
// typedef char t[12];
// void test1(char *);
@@ -880,9 +899,9 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// test3(x); // problem binding here
// }
public void testAdjustmentOfParameterTypes_239975() throws Exception {
- getBindingFromASTName("test1(x)", 5, ICPPFunction.class);
- getBindingFromASTName("test2(x)", 5, ICPPFunction.class);
- getBindingFromASTName("test3(x)", 5, ICPPFunction.class);
+ getBindingFromASTName("test1(x)", 5, ICPPFunction.class);
+ getBindingFromASTName("test2(x)", 5, ICPPFunction.class);
+ getBindingFromASTName("test3(x)", 5, ICPPFunction.class);
}
// class A {
@@ -951,99 +970,107 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// Container<char>::CT<int> espect;
public void testClassTypes_98171() throws Exception {
// regular class
- ICPPClassType ct= getBindingFromASTName("C", 1);
- assertBindings(new String[] {"B"}, ct.getBases());
- assertBindings(new String[] {"n", "m", "B", "C"}, ct.getAllDeclaredMethods());
- assertBindings(new String[] {"C", "C"}, ct.getConstructors());
- assertBindings(new String[] {"g"}, ct.getDeclaredFields());
- assertBindings(new String[] {"n", "C"}, ct.getDeclaredMethods());
- assertBindings(new String[] {"f", "g"}, ct.getFields());
- assertBindings(new String[] {"m", "n", "C", "C", "~C", "B", "B", "~B", "operator =", "operator ="}, ct.getMethods());
- assertBindings(new String[] {"O"}, ct.getNestedClasses());
+ ICPPClassType ct = getBindingFromASTName("C", 1);
+ assertBindings(new String[] { "B" }, ct.getBases());
+ assertBindings(new String[] { "n", "m", "B", "C" }, ct.getAllDeclaredMethods());
+ assertBindings(new String[] { "C", "C" }, ct.getConstructors());
+ assertBindings(new String[] { "g" }, ct.getDeclaredFields());
+ assertBindings(new String[] { "n", "C" }, ct.getDeclaredMethods());
+ assertBindings(new String[] { "f", "g" }, ct.getFields());
+ assertBindings(new String[] { "m", "n", "C", "C", "~C", "B", "B", "~B", "operator =", "operator =" },
+ ct.getMethods());
+ assertBindings(new String[] { "O" }, ct.getNestedClasses());
// class template
- ct= getBindingFromASTName("CT<int>", 2);
+ ct = getBindingFromASTName("CT<int>", 2);
assertInstance(ct, ICPPClassTemplate.class);
- assertBindings(new String[] {"B"}, ct.getBases());
- assertBindings(new String[] {"n", "m", "B", "CT"}, ct.getAllDeclaredMethods());
- assertBindings(new String[] {"CT", "CT"}, ct.getConstructors());
- assertBindings(new String[] {"g"}, ct.getDeclaredFields());
- assertBindings(new String[] {"n", "CT"}, ct.getDeclaredMethods());
- assertBindings(new String[] {"f", "g"}, ct.getFields());
- assertBindings(new String[] {"m", "n", "CT", "CT", "~CT", "B", "B", "~B", "operator =", "operator ="}, ct.getMethods());
- assertBindings(new String[] {"O"}, ct.getNestedClasses());
+ assertBindings(new String[] { "B" }, ct.getBases());
+ assertBindings(new String[] { "n", "m", "B", "CT" }, ct.getAllDeclaredMethods());
+ assertBindings(new String[] { "CT", "CT" }, ct.getConstructors());
+ assertBindings(new String[] { "g" }, ct.getDeclaredFields());
+ assertBindings(new String[] { "n", "CT" }, ct.getDeclaredMethods());
+ assertBindings(new String[] { "f", "g" }, ct.getFields());
+ assertBindings(new String[] { "m", "n", "CT", "CT", "~CT", "B", "B", "~B", "operator =", "operator =" },
+ ct.getMethods());
+ assertBindings(new String[] { "O" }, ct.getNestedClasses());
// class template instance
- ct= getBindingFromASTName("CT<int>", 7);
+ ct = getBindingFromASTName("CT<int>", 7);
assertInstance(ct, ICPPTemplateInstance.class);
- assertBindings(new String[] {"B"}, ct.getBases());
- assertBindings(new String[] {"n", "m", "B", "CT"}, ClassTypeHelper.getAllDeclaredMethods(ct));
- assertBindings(new String[] {"CT", "CT"}, ct.getConstructors());
- assertBindings(new String[] {"g"}, ct.getDeclaredFields());
- assertBindings(new String[] {"n", "CT"}, ct.getDeclaredMethods());
- assertBindings(new String[] {"f", "g"}, ClassTypeHelper.getFields(ct));
- assertBindings(new String[] {"m", "n", "CT", "CT", "~CT", "B", "B", "~B", "operator =", "operator ="}, ClassTypeHelper.getMethods(ct));
- assertBindings(new String[] {"O"}, ct.getNestedClasses());
+ assertBindings(new String[] { "B" }, ct.getBases());
+ assertBindings(new String[] { "n", "m", "B", "CT" }, ClassTypeHelper.getAllDeclaredMethods(ct));
+ assertBindings(new String[] { "CT", "CT" }, ct.getConstructors());
+ assertBindings(new String[] { "g" }, ct.getDeclaredFields());
+ assertBindings(new String[] { "n", "CT" }, ct.getDeclaredMethods());
+ assertBindings(new String[] { "f", "g" }, ClassTypeHelper.getFields(ct));
+ assertBindings(new String[] { "m", "n", "CT", "CT", "~CT", "B", "B", "~B", "operator =", "operator =" },
+ ClassTypeHelper.getMethods(ct));
+ assertBindings(new String[] { "O" }, ct.getNestedClasses());
// explicit class template instance
- ct= getBindingFromASTName("CT<char>", 8);
+ ct = getBindingFromASTName("CT<char>", 8);
assertInstance(ct, ICPPTemplateInstance.class);
- assertBindings(new String[] {"A"}, ct.getBases());
- assertBindings(new String[] {"o", "l", "A", "CT", "CT"}, ClassTypeHelper.getAllDeclaredMethods(ct));
- assertBindings(new String[] {"CT", "CT", "CT"}, ct.getConstructors());
- assertBindings(new String[] {"h"}, ct.getDeclaredFields());
- assertBindings(new String[] {"o", "CT", "CT"}, ct.getDeclaredMethods());
- assertBindings(new String[] {"e", "h"}, ClassTypeHelper.getFields(ct));
- assertBindings(new String[] {"l", "o", "CT", "CT", "CT", "~CT", "A", "A", "~A", "operator =", "operator ="}, ClassTypeHelper.getMethods(ct));
- assertBindings(new String[] {"P"}, ct.getNestedClasses());
+ assertBindings(new String[] { "A" }, ct.getBases());
+ assertBindings(new String[] { "o", "l", "A", "CT", "CT" }, ClassTypeHelper.getAllDeclaredMethods(ct));
+ assertBindings(new String[] { "CT", "CT", "CT" }, ct.getConstructors());
+ assertBindings(new String[] { "h" }, ct.getDeclaredFields());
+ assertBindings(new String[] { "o", "CT", "CT" }, ct.getDeclaredMethods());
+ assertBindings(new String[] { "e", "h" }, ClassTypeHelper.getFields(ct));
+ assertBindings(new String[] { "l", "o", "CT", "CT", "CT", "~CT", "A", "A", "~A", "operator =", "operator =" },
+ ClassTypeHelper.getMethods(ct));
+ assertBindings(new String[] { "P" }, ct.getNestedClasses());
// class specialization
- ct= getBindingFromASTName("C spec", 1);
+ ct = getBindingFromASTName("C spec", 1);
assertInstance(ct, ICPPClassSpecialization.class);
- assertBindings(new String[] {"B"}, ct.getBases());
- assertBindings(new String[] {"n", "m", "B", "C"}, ClassTypeHelper.getAllDeclaredMethods(ct));
- assertBindings(new String[] {"C", "C"}, ct.getConstructors());
- assertBindings(new String[] {"g"}, ct.getDeclaredFields());
- assertBindings(new String[] {"n", "C"}, ct.getDeclaredMethods());
- assertBindings(new String[] {"f", "g"}, ClassTypeHelper.getFields(ct));
- assertBindings(new String[] {"m", "n", "C", "C", "~C", "B", "B", "~B", "operator =", "operator ="}, ClassTypeHelper.getMethods(ct));
- assertBindings(new String[] {"O"}, ct.getNestedClasses());
+ assertBindings(new String[] { "B" }, ct.getBases());
+ assertBindings(new String[] { "n", "m", "B", "C" }, ClassTypeHelper.getAllDeclaredMethods(ct));
+ assertBindings(new String[] { "C", "C" }, ct.getConstructors());
+ assertBindings(new String[] { "g" }, ct.getDeclaredFields());
+ assertBindings(new String[] { "n", "C" }, ct.getDeclaredMethods());
+ assertBindings(new String[] { "f", "g" }, ClassTypeHelper.getFields(ct));
+ assertBindings(new String[] { "m", "n", "C", "C", "~C", "B", "B", "~B", "operator =", "operator =" },
+ ClassTypeHelper.getMethods(ct));
+ assertBindings(new String[] { "O" }, ct.getNestedClasses());
// class template specialization
- ct= getBindingFromASTName("CT<int> spect", 2);
+ ct = getBindingFromASTName("CT<int> spect", 2);
assertInstance(ct, ICPPClassTemplate.class, ICPPClassSpecialization.class);
- assertBindings(new String[] {"B"}, ct.getBases());
- assertBindings(new String[] {"n", "m", "B", "CT"}, ClassTypeHelper.getAllDeclaredMethods(ct));
- assertBindings(new String[] {"CT", "CT"}, ct.getConstructors());
- assertBindings(new String[] {"g"}, ct.getDeclaredFields());
- assertBindings(new String[] {"n", "CT"}, ct.getDeclaredMethods());
- assertBindings(new String[] {"f", "g"}, ClassTypeHelper.getFields(ct));
- assertBindings(new String[] {"m", "n", "CT", "CT", "~CT", "B", "B", "~B", "operator =", "operator ="}, ClassTypeHelper.getMethods(ct));
- assertBindings(new String[] {"O"}, ct.getNestedClasses());
+ assertBindings(new String[] { "B" }, ct.getBases());
+ assertBindings(new String[] { "n", "m", "B", "CT" }, ClassTypeHelper.getAllDeclaredMethods(ct));
+ assertBindings(new String[] { "CT", "CT" }, ct.getConstructors());
+ assertBindings(new String[] { "g" }, ct.getDeclaredFields());
+ assertBindings(new String[] { "n", "CT" }, ct.getDeclaredMethods());
+ assertBindings(new String[] { "f", "g" }, ClassTypeHelper.getFields(ct));
+ assertBindings(new String[] { "m", "n", "CT", "CT", "~CT", "B", "B", "~B", "operator =", "operator =" },
+ ClassTypeHelper.getMethods(ct));
+ assertBindings(new String[] { "O" }, ct.getNestedClasses());
// explicit class specialization
- ct= getBindingFromASTName("C espec", 1);
+ ct = getBindingFromASTName("C espec", 1);
assertInstance(ct, ICPPClassSpecialization.class);
- assertBindings(new String[] {"A"}, ct.getBases());
- assertBindings(new String[] {"o", "l", "A", "C", "C"}, ClassTypeHelper.getAllDeclaredMethods(ct));
- assertBindings(new String[] {"C", "C", "C"}, ct.getConstructors());
- assertBindings(new String[] {"h"}, ct.getDeclaredFields());
- assertBindings(new String[] {"o", "C", "C"}, ct.getDeclaredMethods());
- assertBindings(new String[] {"e", "h"}, ClassTypeHelper.getFields(ct));
- assertBindings(new String[] {"l", "o", "C", "C", "C", "~C", "A", "A", "~A", "operator =", "operator ="}, ClassTypeHelper.getMethods(ct));
- assertBindings(new String[] {"P"}, ct.getNestedClasses());
+ assertBindings(new String[] { "A" }, ct.getBases());
+ assertBindings(new String[] { "o", "l", "A", "C", "C" }, ClassTypeHelper.getAllDeclaredMethods(ct));
+ assertBindings(new String[] { "C", "C", "C" }, ct.getConstructors());
+ assertBindings(new String[] { "h" }, ct.getDeclaredFields());
+ assertBindings(new String[] { "o", "C", "C" }, ct.getDeclaredMethods());
+ assertBindings(new String[] { "e", "h" }, ClassTypeHelper.getFields(ct));
+ assertBindings(new String[] { "l", "o", "C", "C", "C", "~C", "A", "A", "~A", "operator =", "operator =" },
+ ClassTypeHelper.getMethods(ct));
+ assertBindings(new String[] { "P" }, ct.getNestedClasses());
// explicit class template specialization
- ct= getBindingFromASTName("CT<int> espect", 7);
+ ct = getBindingFromASTName("CT<int> espect", 7);
assertInstance(ct, ICPPTemplateInstance.class);
- assertBindings(new String[] {"A"}, ct.getBases());
- assertBindings(new String[] {"o", "l", "A", "CT", "CT"}, ClassTypeHelper.getAllDeclaredMethods(ct));
- assertBindings(new String[] {"CT", "CT", "CT"}, ct.getConstructors());
- assertBindings(new String[] {"h"}, ct.getDeclaredFields());
- assertBindings(new String[] {"o", "CT", "CT"}, ct.getDeclaredMethods());
- assertBindings(new String[] {"e", "h"}, ClassTypeHelper.getFields(ct));
- assertBindings(new String[] {"l", "o", "CT", "CT", "CT", "~CT", "A", "A", "~A", "operator =", "operator ="}, ClassTypeHelper.getMethods(ct));
- assertBindings(new String[] {"P"}, ct.getNestedClasses());
+ assertBindings(new String[] { "A" }, ct.getBases());
+ assertBindings(new String[] { "o", "l", "A", "CT", "CT" }, ClassTypeHelper.getAllDeclaredMethods(ct));
+ assertBindings(new String[] { "CT", "CT", "CT" }, ct.getConstructors());
+ assertBindings(new String[] { "h" }, ct.getDeclaredFields());
+ assertBindings(new String[] { "o", "CT", "CT" }, ct.getDeclaredMethods());
+ assertBindings(new String[] { "e", "h" }, ClassTypeHelper.getFields(ct));
+ assertBindings(new String[] { "l", "o", "CT", "CT", "CT", "~CT", "A", "A", "~A", "operator =", "operator =" },
+ ClassTypeHelper.getMethods(ct));
+ assertBindings(new String[] { "P" }, ct.getNestedClasses());
}
// void func(const int* x) {}
@@ -1053,7 +1080,7 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// func(q);
// }
public void testOverloadedFunctionFromIndex_256240() throws Exception {
- getBindingFromASTName("func(q", 4, ICPPFunction.class);
+ getBindingFromASTName("func(q", 4, ICPPFunction.class);
}
// class A {
@@ -1065,7 +1092,7 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// void A::B::m() {}
public void testNestedClasses_259683() throws Exception {
- getBindingFromASTName("A::B::m", 7, ICPPMethod.class);
+ getBindingFromASTName("A::B::m", 7, ICPPMethod.class);
}
// namespace ns {
@@ -1085,21 +1112,21 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// }
// }
public void testLookupScopeForConversionNames_267221() throws Exception {
- getBindingFromASTName("operator S *", 12, ICPPMethod.class);
+ getBindingFromASTName("operator S *", 12, ICPPMethod.class);
}
private void assertBindings(String[] expected, ICPPBase[] bases) throws DOMException {
- IBinding[] bindings= new IBinding[bases.length];
+ IBinding[] bindings = new IBinding[bases.length];
for (int i = 0; i < bindings.length; i++) {
- bindings[i]= bases[i].getBaseClass();
+ bindings[i] = bases[i].getBaseClass();
}
assertBindings(expected, bindings);
}
private void assertBindings(String[] expected, IBinding[] binding) {
- String[] actual= new String[binding.length];
+ String[] actual = new String[binding.length];
for (int i = 0; i < actual.length; i++) {
- actual[i]= binding[i].getName();
+ actual[i] = binding[i].getName();
}
Arrays.sort(actual);
Arrays.sort(expected);
@@ -1107,15 +1134,15 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
}
private String toString(String[] actual) {
- StringBuilder buf= new StringBuilder();
+ StringBuilder buf = new StringBuilder();
buf.append('{');
- boolean isFirst= true;
+ boolean isFirst = true;
for (String val : actual) {
if (!isFirst) {
buf.append(',');
}
buf.append(val);
- isFirst= false;
+ isFirst = false;
}
buf.append('}');
return buf.toString();
@@ -1134,7 +1161,7 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// useBase(x.d);
// }
public void testLateDefinitionOfInheritance_292749() throws Exception {
- getBindingFromFirstIdentifier("useBase(x.d)", ICPPFunction.class);
+ getBindingFromFirstIdentifier("useBase(x.d)", ICPPFunction.class);
}
// namespace one {
@@ -1144,7 +1171,7 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// }
// namespace two {
// using one::fx;
- // }
+ // }
// void test() {
// two::fx();
@@ -1152,9 +1179,9 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// two::fx(1,1);
// }
public void testUsingDeclaration_300019() throws Exception {
- getBindingFromASTName("fx();", 2, ICPPFunction.class);
- getBindingFromASTName("fx(1);", 2, ICPPFunction.class);
- getBindingFromASTName("fx(1,1);", 2, ICPPFunction.class);
+ getBindingFromASTName("fx();", 2, ICPPFunction.class);
+ getBindingFromASTName("fx(1);", 2, ICPPFunction.class);
+ getBindingFromASTName("fx(1,1);", 2, ICPPFunction.class);
}
// struct YetAnotherTest {
@@ -1173,7 +1200,7 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// arr[0].member=0;
// }
public void testElaboratedTypeSpecifier_303739() throws Exception {
- getBindingFromASTName("member=0", -2, ICPPField.class);
+ getBindingFromASTName("member=0", -2, ICPPField.class);
}
// typedef int xxx::* MBR_PTR;
@@ -1182,10 +1209,10 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// MBR_PTR x;
// }
public void testProblemInIndexBinding_317146() throws Exception {
- ITypedef td= getBindingFromASTName("MBR_PTR", 0, ITypedef.class);
- ICPPPointerToMemberType ptrMbr= (ICPPPointerToMemberType) td.getType();
- IType t= ptrMbr.getMemberOfClass();
- assertInstance(t, ISemanticProblem.class);
+ ITypedef td = getBindingFromASTName("MBR_PTR", 0, ITypedef.class);
+ ICPPPointerToMemberType ptrMbr = (ICPPPointerToMemberType) td.getType();
+ IType t = ptrMbr.getMemberOfClass();
+ assertInstance(t, ISemanticProblem.class);
}
// void f255(
@@ -1257,10 +1284,10 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// f(c16); f(c32);
// }
public void testChar16_319186() throws Exception {
- IFunction f= getBindingFromASTName("f(c16)", 1);
+ IFunction f = getBindingFromASTName("f(c16)", 1);
assertEquals("char16_t", ASTTypeUtil.getType(f.getType().getParameterTypes()[0]));
- f= getBindingFromASTName("f(c32)", 1);
+ f = getBindingFromASTName("f(c32)", 1);
assertEquals("char32_t", ASTTypeUtil.getType(f.getType().getParameterTypes()[0]));
}
@@ -1280,9 +1307,9 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// Type x;
// }
public void test_326778() throws Exception {
- IVariable v= getBindingFromASTName("var", 0);
- IFunction f= getBindingFromASTName("fun", 0);
- ITypedef t= getBindingFromASTName("Type", 0);
+ IVariable v = getBindingFromASTName("var", 0);
+ IFunction f = getBindingFromASTName("fun", 0);
+ ITypedef t = getBindingFromASTName("Type", 0);
}
// struct base {
@@ -1302,11 +1329,11 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// }
// };
public void test_356982() throws Exception {
- IASTName name= findName("+ ", 1);
+ IASTName name = findName("+ ", 1);
assertTrue(name instanceof IASTImplicitName);
assertEquals("base", name.resolveBinding().getOwner().getName());
- name= findName("- ", 1);
+ name = findName("- ", 1);
assertTrue(name instanceof IASTImplicitName);
assertEquals("base", name.resolveBinding().getOwner().getName());
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugsSingleProjectFirstAST.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugsSingleProjectFirstAST.java
index 9e1873f16fa..dc8a280a747 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugsSingleProjectFirstAST.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugsSingleProjectFirstAST.java
@@ -25,10 +25,24 @@ public class IndexCPPBindingResolutionBugsSingleProjectFirstAST extends IndexCPP
}
/* Invalid tests for this strategy, they assume that the second file is already indexed. */
- @Override public void test_208558() {}
- @Override public void test_176708_CCE() {}
- @Override public void testIsSameAnonymousType_193962() {}
- @Override public void testIsSameNestedAnonymousType_193962() {}
+ @Override
+ public void test_208558() {
+ }
+
+ @Override
+ public void test_176708_CCE() {
+ }
+
+ @Override
+ public void testIsSameAnonymousType_193962() {
+ }
+
+ @Override
+ public void testIsSameNestedAnonymousType_193962() {
+ }
+
/* For some unknown reason this test is flaky for this strategy. */
- @Override public void testTemplateArgumentResolution_450888() {}
+ @Override
+ public void testTemplateArgumentResolution_450888() {
+ }
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java
index 7d83b29454e..c90605a1739 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java
@@ -68,73 +68,63 @@ import junit.framework.TestSuite;
public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBase {
public static class SingleProject extends IndexCPPBindingResolutionTest {
- public SingleProject() { setStrategy(new SinglePDOMTestStrategy(true)); }
- public static TestSuite suite() { return suite(SingleProject.class); }
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
public static class ProjectWithDepProj extends IndexCPPBindingResolutionTest {
- public ProjectWithDepProj() { setStrategy(new ReferencedProject(true)); }
- public static TestSuite suite() { return suite(ProjectWithDepProj.class); }
+ public ProjectWithDepProj() {
+ setStrategy(new ReferencedProject(true));
+ }
+
+ public static TestSuite suite() {
+ return suite(ProjectWithDepProj.class);
+ }
}
public static void addTests(TestSuite suite) {
suite.addTest(SingleProject.suite());
suite.addTest(ProjectWithDepProj.suite());
}
-
+
public IndexCPPBindingResolutionTest() {
setStrategy(new SinglePDOMTestStrategy(true));
}
- public static TestSuite suite() { return suite(SingleProject.class); }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
/* Assertion helpers */
/* ##################################################################### */
- static protected void assertField(
- IBinding binding,
- String qn,
- Class expType,
- String expTypeQN) {
+ static protected void assertField(IBinding binding, String qn, Class expType, String expTypeQN) {
assertTrue(binding instanceof ICPPField);
ICPPField field = (ICPPField) binding;
assertQNEquals(qn, field);
assertTrue(expType.isInstance(field.getType()));
if (expTypeQN != null) {
- assert(field.getType() instanceof ICPPBinding);
+ assert (field.getType() instanceof ICPPBinding);
ICPPBinding tyBinding = (ICPPBinding) field.getType();
assertQNEquals(expTypeQN, tyBinding);
}
}
- static protected void assertClassTypeBinding(IBinding binding,
- String qn,
- int key,
- int bases,
- int fields,
- int declaredFields,
- int methods,
- int declaredMethods,
- int allDeclaredMethods,
- int friends,
- int constructors,
+ static protected void assertClassTypeBinding(IBinding binding, String qn, int key, int bases, int fields,
+ int declaredFields, int methods, int declaredMethods, int allDeclaredMethods, int friends, int constructors,
int nestedClasses) {
assertTrue(binding instanceof ICPPClassType);
- assertClassType((ICPPClassType) binding, qn, key, bases, fields, declaredFields, methods,
- declaredMethods, allDeclaredMethods, friends, constructors, nestedClasses);
- }
-
- static protected void assertClassType(
- IType type,
- String qn,
- int key,
- int bases,
- int fields,
- int declaredFields,
- int methods,
- int declaredMethods,
- int allDeclaredMethods,
- int friends,
- int constructors,
+ assertClassType((ICPPClassType) binding, qn, key, bases, fields, declaredFields, methods, declaredMethods,
+ allDeclaredMethods, friends, constructors, nestedClasses);
+ }
+
+ static protected void assertClassType(IType type, String qn, int key, int bases, int fields, int declaredFields,
+ int methods, int declaredMethods, int allDeclaredMethods, int friends, int constructors,
int nestedClasses) {
assertTrue(type instanceof ICPPClassType);
ICPPClassType classType = (ICPPClassType) type;
@@ -154,28 +144,28 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
public void assertEnumeration(IBinding binding, String name, String[] enumerators) throws DOMException {
assertTrue(binding instanceof IEnumeration);
assertEquals(name, binding.getName());
- IEnumerator[] aEnumerators = ((IEnumeration)binding).getEnumerators();
+ IEnumerator[] aEnumerators = ((IEnumeration) binding).getEnumerators();
Set expectedEnumerators = new HashSet();
expectedEnumerators.addAll(Arrays.asList(enumerators));
Set actualEnumerators = new HashSet();
for (IEnumerator enumerator : aEnumerators) {
actualEnumerators.add(enumerator.getName());
- }
- assertEquals(expectedEnumerators, actualEnumerators);
- }
+ }
+ assertEquals(expectedEnumerators, actualEnumerators);
+ }
/**
- * @param type
- * @param cqn
- * @param qn may be null
- */
+ * @param type
+ * @param cqn
+ * @param qn may be null
+ */
static protected void assertPTM(IType type, String cqn, String qn) {
assertTrue(type instanceof ICPPPointerToMemberType);
ICPPPointerToMemberType ptmt = (ICPPPointerToMemberType) type;
ICPPClassType classType = (ICPPClassType) ptmt.getMemberOfClass();
assertQNEquals(cqn, classType);
if (qn != null) {
- assert(ptmt.getType() instanceof ICPPBinding);
+ assert (ptmt.getType() instanceof ICPPBinding);
ICPPBinding tyBinding = (ICPPBinding) ptmt.getType();
assertQNEquals(qn, tyBinding);
}
@@ -189,7 +179,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
}
private void assertUserDefinedLiteralType(String retName) {
- ICPPVariable v= getBindingFromFirstIdentifier("test =");
+ ICPPVariable v = getBindingFromFirstIdentifier("test =");
assertEquals(retName, ASTTypeUtil.getType(v.getType()));
}
@@ -216,17 +206,17 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// void B::m(A* a) {}
// void B::n(E* a) {}
// void B::o(T* a) {}
- // void B::p(E a) {}
+ // void B::p(E a) {}
//
// void usage() {
// B b;
// b.p(E1);
// }
public void testUsingTypeDeclaration_201177() {
- IBinding b0= getBindingFromASTName("B::m", 4);
- IBinding b1= getBindingFromASTName("B::n", 4);
- IBinding b2= getBindingFromASTName("B::o", 4);
- IBinding b3= getBindingFromASTName("p(E1)", 1);
+ IBinding b0 = getBindingFromASTName("B::m", 4);
+ IBinding b1 = getBindingFromASTName("B::n", 4);
+ IBinding b2 = getBindingFromASTName("B::o", 4);
+ IBinding b3 = getBindingFromASTName("p(E1)", 1);
assertInstance(b0, ICPPMethod.class);
assertInstance(b1, ICPPMethod.class);
assertInstance(b2, ICPPMethod.class);
@@ -241,8 +231,8 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// m::C c;
// m::D d;
public void testUsingNamingDirective_177917_1a() {
- IBinding b0= getBindingFromASTName("C c", 1);
- IBinding b1= getBindingFromASTName("D d", 1);
+ IBinding b0 = getBindingFromASTName("C c", 1);
+ IBinding b1 = getBindingFromASTName("D d", 1);
}
// namespace n { class A{}; }
@@ -254,7 +244,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// namespace n { class C{}; }
// m::C c;
public void testUsingNamingDirective_177917_1b() {
- IBinding b0= getBindingFromFirstIdentifier("C c");
+ IBinding b0 = getBindingFromFirstIdentifier("C c");
}
// int ff(int x) { return x; }
@@ -272,11 +262,11 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// int g(char x) {return 2;}
// int nn= g(f(2));
public void testUsingTypeDeclaration_177917_1() {
- IBinding b1= getBindingFromASTName("A a", 1);
- IBinding b2= getBindingFromASTName("B b", 1);
- IBinding b3= getBindingFromASTName("C c", 1);
- IBinding b4= getBindingFromASTName("CE1", 3);
- IBinding b5= getBindingFromASTName("f(2", 1);
+ IBinding b1 = getBindingFromASTName("A a", 1);
+ IBinding b2 = getBindingFromASTName("B b", 1);
+ IBinding b3 = getBindingFromASTName("C c", 1);
+ IBinding b4 = getBindingFromASTName("CE1", 3);
+ IBinding b5 = getBindingFromASTName("f(2", 1);
}
// namespace a { class A {}; }
@@ -288,8 +278,8 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// b::A aa;
// b::B bb;
public void testUsingTypeDeclaration_177917_2() {
- IBinding b0= getBindingFromASTName("A aa", 1);
- IBinding b1= getBindingFromASTName("B bb", 1);
+ IBinding b0 = getBindingFromASTName("A aa", 1);
+ IBinding b1 = getBindingFromASTName("B bb", 1);
}
// namespace header {
@@ -336,18 +326,17 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// }
public void testUsingOverloadedFunctionDeclaration() {
IBinding b;
- b= getBindingFromASTName("fh()", 2);
- b= getBindingFromASTName("fh(1)", 2);
- b= getBindingFromASTName("clh c", 3);
- b= getBindingFromASTName("f()", 1);
- b= getBindingFromASTName("f(1)", 1);
- b= getBindingFromASTName("cl c1", 2);
- b= getBindingFromASTName("fs()", 2);
- b= getBindingFromASTName("fs(1)", 2);
- b= getBindingFromASTName("cls c2", 3);
+ b = getBindingFromASTName("fh()", 2);
+ b = getBindingFromASTName("fh(1)", 2);
+ b = getBindingFromASTName("clh c", 3);
+ b = getBindingFromASTName("f()", 1);
+ b = getBindingFromASTName("f(1)", 1);
+ b = getBindingFromASTName("cl c1", 2);
+ b = getBindingFromASTName("fs()", 2);
+ b = getBindingFromASTName("fs(1)", 2);
+ b = getBindingFromASTName("cls c2", 3);
}
-
// int (*f)(int);
// int g(int n){return n;}
// int g(int n, int m){ return n+m; }
@@ -360,17 +349,17 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
IBinding b1 = getBindingFromASTName("g;", 1);
assertInstance(b0, ICPPVariable.class);
- ICPPVariable v0= (ICPPVariable) b0;
+ ICPPVariable v0 = (ICPPVariable) b0;
assertInstance(v0.getType(), IPointerType.class);
- IPointerType p0= (IPointerType) v0.getType();
+ IPointerType p0 = (IPointerType) v0.getType();
assertInstance(p0.getType(), ICPPFunctionType.class);
- ICPPFunctionType f0= (ICPPFunctionType) p0.getType();
+ ICPPFunctionType f0 = (ICPPFunctionType) p0.getType();
assertInstance(f0.getReturnType(), ICPPBasicType.class);
assertEquals(1, f0.getParameterTypes().length);
assertInstance(f0.getParameterTypes()[0], ICPPBasicType.class);
assertInstance(b1, ICPPFunction.class);
- ICPPFunctionType f1= ((ICPPFunction)b1).getType();
+ ICPPFunctionType f1 = ((ICPPFunction) b1).getType();
assertInstance(f1.getReturnType(), ICPPBasicType.class);
assertEquals(1, f1.getParameterTypes().length);
assertInstance(f1.getParameterTypes()[0], ICPPBasicType.class);
@@ -399,11 +388,11 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// }
public void testPointerToMemberFields() throws IOException, DOMException {
IBinding b0 = getBindingFromASTName("C *cp", 1);
- assertClassType((ICPPClassType)b0, "C", ICPPClassType.k_class, 1, 6, 5, 9, 0, 1, 0, 2, 1);
+ assertClassType((ICPPClassType) b0, "C", ICPPClassType.k_class, 1, 6, 5, 9, 0, 1, 0, 2, 1);
IBinding b1 = getBindingFromASTName("cp = new C()", 2);
assertVariable(b1, "cp", IPointerType.class, null);
- IPointerType b1type = (IPointerType) ((ICPPVariable)b1).getType();
+ IPointerType b1type = (IPointerType) ((ICPPVariable) b1).getType();
assertClassType(b1type.getType(), "C", ICPPClassType.k_class, 1, 6, 5, 9, 0, 1, 0, 2, 1);
IBinding b2 = getBindingFromASTName("cs.*cp->o", 2);
@@ -412,23 +401,23 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
IBinding b3 = getBindingFromASTName("ouch = lp", 4);
assertField(b3, "C::ouch", ICPPPointerToMemberType.class, null);
- assertPTM(((ICPPField)b3).getType(), "C::CS", null);
+ assertPTM(((ICPPField) b3).getType(), "C::CS", null);
IBinding b4 = getBindingFromASTName("autsch;", 6);
assertField(b4, "C::autsch", ICPPPointerToMemberType.class, null);
- assertPTM(((ICPPField)b4).getType(), "C::CS", null);
+ assertPTM(((ICPPField) b4).getType(), "C::CS", null);
IBinding b5 = getBindingFromASTName("cs)->*cp->a", 2);
assertField(b5, "C::cs", ICPPClassType.class, "C::CS");
- assertClassType(((ICPPField)b5).getType(), "C::CS", ICompositeType.k_struct, 0, 1, 1, 5, 1, 1, 0, 2, 0);
+ assertClassType(((ICPPField) b5).getType(), "C::CS", ICompositeType.k_struct, 0, 1, 1, 5, 1, 1, 0, 2, 0);
IBinding b6 = getBindingFromASTName("autsch = lp", 6);
assertField(b4, "C::autsch", ICPPPointerToMemberType.class, null);
- assertPTM(((ICPPField)b4).getType(), "C::CS", null);
+ assertPTM(((ICPPField) b4).getType(), "C::CS", null);
IBinding b7 = getBindingFromASTName("ouch;", 4);
assertField(b3, "C::ouch", ICPPPointerToMemberType.class, null);
- assertPTM(((ICPPField)b3).getType(), "C::CS", null);
+ assertPTM(((ICPPField) b3).getType(), "C::CS", null);
}
// class C {}; struct S {}; union U {}; enum E {ER1,ER2,ER3};
@@ -449,7 +438,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// struct S2 : public S {}; /*base*/
public void testSimpleGlobalBindings() throws IOException, DOMException {
{
- IBinding b0 = getBindingFromASTName("C c; ", 1);
+ IBinding b0 = getBindingFromASTName("C c; ", 1);
assertClassTypeBinding(b0, "C", ICPPClassType.k_class, 0, 0, 0, 4, 0, 0, 0, 2, 0);
IBinding b1 = getBindingFromASTName("c; ", 1);
@@ -458,7 +447,8 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
assertClassTypeBinding(b1type, "C", ICPPClassType.k_class, 0, 0, 0, 4, 0, 0, 0, 2, 0);
assertEquals(EScopeKind.eGlobal, b1type.getScope().getKind());
assertTrue(b1type.getCompositeScope() instanceof ICPPClassScope);
- assertClassTypeBinding(((ICPPClassScope) b1type.getCompositeScope()).getClassType(), "C", ICPPClassType.k_class, 0, 0, 0, 4, 0, 0, 0, 2, 0);
+ assertClassTypeBinding(((ICPPClassScope) b1type.getCompositeScope()).getClassType(), "C",
+ ICPPClassType.k_class, 0, 0, 0, 4, 0, 0, 0, 2, 0);
}
{
IBinding b2 = getBindingFromASTName("S s;", 1);
@@ -480,12 +470,12 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
}
{
IBinding b6 = getBindingFromASTName("E e; ", 1);
- assertEnumeration(b6, "E", new String[] {"ER1","ER2","ER3"});
+ assertEnumeration(b6, "E", new String[] { "ER1", "ER2", "ER3" });
IBinding b7 = getBindingFromASTName("e; ", 1);
assertVariable(b7, "e", IEnumeration.class, "E");
IEnumeration b5type = (IEnumeration) ((ICPPVariable) b7).getType();
- assertEnumeration(b5type, "E", new String[] {"ER1","ER2","ER3"});
+ assertEnumeration(b5type, "E", new String[] { "ER1", "ER2", "ER3" });
assertEquals(EScopeKind.eGlobal, b5type.getScope().getKind());
}
{
@@ -502,7 +492,8 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
IBinding b10 = getBindingFromASTName("var3 = &s;", 4);
assertVariable(b10, "var3", IPointerType.class, null);
IPointerType b10type = (IPointerType) ((ICPPVariable) b10).getType();
- assertClassTypeBinding((ICPPClassType) b10type.getType(), "S", ICompositeType.k_struct, 0, 0, 0, 4, 0, 0, 0, 2, 0);
+ assertClassTypeBinding((ICPPClassType) b10type.getType(), "S", ICompositeType.k_struct, 0, 0, 0, 4, 0, 0, 0,
+ 2, 0);
}
{
IBinding b11 = getBindingFromASTName("func(e);", 4);
@@ -692,22 +683,22 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// a.p();//6 // calls A::p()&
// }
public void testRankingOfReferenceBindings() throws Exception {
- ICPPMethod m= getBindingFromImplicitASTName("<< 1;//1", 2);
+ ICPPMethod m = getBindingFromImplicitASTName("<< 1;//1", 2);
assertNotNull(m);
assertEquals(1, m.getType().getParameterTypes().length);
- ICPPFunction f= getBindingFromImplicitASTName("<< 'c';//2", 2);
+ ICPPFunction f = getBindingFromImplicitASTName("<< 'c';//2", 2);
assertNotNull(f);
assertEquals(2, f.getType().getParameterTypes().length);
- m= getBindingFromImplicitASTName("<< 1;//3", 2);
+ m = getBindingFromImplicitASTName("<< 1;//3", 2);
assertNotNull(m);
assertEquals(1, m.getType().getParameterTypes().length);
- m= getBindingFromImplicitASTName("<< 'c';//4", 2);
+ m = getBindingFromImplicitASTName("<< 'c';//4", 2);
assertNotNull(m);
assertEquals(1, m.getType().getParameterTypes().length);
- m= getBindingFromFirstIdentifier("p();//5");
+ m = getBindingFromFirstIdentifier("p();//5");
assertNotNull(m);
assertTrue(m.getType().isRValueReference());
- m= getBindingFromFirstIdentifier("p();//6");
+ m = getBindingFromFirstIdentifier("p();//6");
assertNotNull(m);
assertFalse(m.getType().isRValueReference());
}
@@ -782,7 +773,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
public void testQualifiedNamesForTypedef() throws DOMException {
IBinding b0 = getBindingFromASTName("Int i0;", 3);
assertQNEquals("n1::n2::Int", b0);
- IBinding b1= getBindingFromASTName("Int i1;", 3);
+ IBinding b1 = getBindingFromASTName("Int i1;", 3);
assertQNEquals("n1::n2::Int", b1);
IBinding b2 = getBindingFromASTName("Int i2;", 3);
@@ -823,7 +814,6 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
checkBindings();
}
-
// // header content
// enum E { ER1, ER2 };
@@ -1134,7 +1124,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
IBinding b7 = getBindingFromASTName("f;/*7*/", 1);
IBinding b8 = getBindingFromASTName("f;/*8*/", 1);
IBinding b9 = getBindingFromASTName("f;/*9*/", 1);
- IBinding b10= getBindingFromASTName("f;/*10*/", 1);
+ IBinding b10 = getBindingFromASTName("f;/*10*/", 1);
IBinding b11 = getBindingFromASTName("f;/*11*/", 1);
IBinding b12 = getBindingFromASTName("f;/*12*/", 1);
IBinding b13 = getBindingFromASTName("f;/*13*/", 1);
@@ -1163,11 +1153,11 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// func(&C::m1);
// func(&C::m2);
// }
- public void testAddressOfConstMethod_233889() {
- IBinding fn1= getBindingFromASTName("func(&C::m1", 4, ICPPFunction.class);
- IBinding fn2= getBindingFromASTName("func(&C::m2", 4, ICPPFunction.class);
+ public void testAddressOfConstMethod_233889() {
+ IBinding fn1 = getBindingFromASTName("func(&C::m1", 4, ICPPFunction.class);
+ IBinding fn2 = getBindingFromASTName("func(&C::m2", 4, ICPPFunction.class);
assertNotSame(fn1, fn2);
- }
+ }
// void f_int(int);
// void f_const_int(const int);
@@ -1252,46 +1242,46 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// f_int_const_ptr_const(int_const_ptr_const); // ok
// }
public void testConstIntPtrParameter() {
- getBindingFromASTName("f_int_ptr(int_ptr)", 9);
- getProblemFromASTName("f_int_ptr(const_int_ptr)", 9);
- getProblemFromASTName("f_int_ptr(int_const_ptr)", 9);
- getBindingFromASTName("f_int_ptr(int_ptr_const)", 9);
+ getBindingFromASTName("f_int_ptr(int_ptr)", 9);
+ getProblemFromASTName("f_int_ptr(const_int_ptr)", 9);
+ getProblemFromASTName("f_int_ptr(int_const_ptr)", 9);
+ getBindingFromASTName("f_int_ptr(int_ptr_const)", 9);
getProblemFromASTName("f_int_ptr(const_int_ptr_const)", 9);
getProblemFromASTName("f_int_ptr(int_const_ptr_const)", 9);
- getBindingFromASTName("f_const_int_ptr(int_ptr)", 15);
- getBindingFromASTName("f_const_int_ptr(const_int_ptr)", 15);
- getBindingFromASTName("f_const_int_ptr(int_const_ptr)", 15);
- getBindingFromASTName("f_const_int_ptr(int_ptr_const)", 15);
- getBindingFromASTName("f_const_int_ptr(const_int_ptr_const)", 15);
- getBindingFromASTName("f_const_int_ptr(int_const_ptr_const)", 15);
-
- getBindingFromASTName("f_int_const_ptr(int_ptr)", 15);
- getBindingFromASTName("f_int_const_ptr(const_int_ptr)", 15);
- getBindingFromASTName("f_int_const_ptr(int_const_ptr)", 15);
- getBindingFromASTName("f_int_const_ptr(int_ptr_const)", 15);
- getBindingFromASTName("f_int_const_ptr(const_int_ptr_const)", 15);
- getBindingFromASTName("f_int_const_ptr(int_const_ptr_const)", 15);
-
- getBindingFromASTName("f_int_ptr_const(int_ptr)", 15);
- getProblemFromASTName("f_int_ptr_const(const_int_ptr)", 15);
- getProblemFromASTName("f_int_ptr_const(int_const_ptr)", 15);
- getBindingFromASTName("f_int_ptr_const(int_ptr_const)", 15);
- getProblemFromASTName("f_int_ptr_const(const_int_ptr_const)", 15);
- getProblemFromASTName("f_int_ptr_const(int_const_ptr_const)", 15);
-
- getBindingFromASTName("f_const_int_ptr_const(int_ptr)", 21);
- getBindingFromASTName("f_const_int_ptr_const(const_int_ptr)", 21);
- getBindingFromASTName("f_const_int_ptr_const(int_const_ptr)", 21);
- getBindingFromASTName("f_const_int_ptr_const(int_ptr_const)", 21);
- getBindingFromASTName("f_const_int_ptr_const(const_int_ptr_const)", 21);
+ getBindingFromASTName("f_const_int_ptr(int_ptr)", 15);
+ getBindingFromASTName("f_const_int_ptr(const_int_ptr)", 15);
+ getBindingFromASTName("f_const_int_ptr(int_const_ptr)", 15);
+ getBindingFromASTName("f_const_int_ptr(int_ptr_const)", 15);
+ getBindingFromASTName("f_const_int_ptr(const_int_ptr_const)", 15);
+ getBindingFromASTName("f_const_int_ptr(int_const_ptr_const)", 15);
+
+ getBindingFromASTName("f_int_const_ptr(int_ptr)", 15);
+ getBindingFromASTName("f_int_const_ptr(const_int_ptr)", 15);
+ getBindingFromASTName("f_int_const_ptr(int_const_ptr)", 15);
+ getBindingFromASTName("f_int_const_ptr(int_ptr_const)", 15);
+ getBindingFromASTName("f_int_const_ptr(const_int_ptr_const)", 15);
+ getBindingFromASTName("f_int_const_ptr(int_const_ptr_const)", 15);
+
+ getBindingFromASTName("f_int_ptr_const(int_ptr)", 15);
+ getProblemFromASTName("f_int_ptr_const(const_int_ptr)", 15);
+ getProblemFromASTName("f_int_ptr_const(int_const_ptr)", 15);
+ getBindingFromASTName("f_int_ptr_const(int_ptr_const)", 15);
+ getProblemFromASTName("f_int_ptr_const(const_int_ptr_const)", 15);
+ getProblemFromASTName("f_int_ptr_const(int_const_ptr_const)", 15);
+
+ getBindingFromASTName("f_const_int_ptr_const(int_ptr)", 21);
+ getBindingFromASTName("f_const_int_ptr_const(const_int_ptr)", 21);
+ getBindingFromASTName("f_const_int_ptr_const(int_const_ptr)", 21);
+ getBindingFromASTName("f_const_int_ptr_const(int_ptr_const)", 21);
+ getBindingFromASTName("f_const_int_ptr_const(const_int_ptr_const)", 21);
getBindingFromASTName("f_const_int_ptr_const(int_const_ptr_const)", 21);
- getBindingFromASTName("f_int_const_ptr_const(int_ptr)", 21);
- getBindingFromASTName("f_int_const_ptr_const(const_int_ptr)", 21);
- getBindingFromASTName("f_int_const_ptr_const(int_const_ptr)", 21);
- getBindingFromASTName("f_int_const_ptr_const(int_ptr_const)", 21);
- getBindingFromASTName("f_int_const_ptr_const(const_int_ptr_const)", 21);
+ getBindingFromASTName("f_int_const_ptr_const(int_ptr)", 21);
+ getBindingFromASTName("f_int_const_ptr_const(const_int_ptr)", 21);
+ getBindingFromASTName("f_int_const_ptr_const(int_const_ptr)", 21);
+ getBindingFromASTName("f_int_const_ptr_const(int_ptr_const)", 21);
+ getBindingFromASTName("f_int_const_ptr_const(const_int_ptr_const)", 21);
getBindingFromASTName("f_int_const_ptr_const(int_const_ptr_const)", 21);
}
@@ -1304,8 +1294,8 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// void f(const int*const){} // b2, redef
// void f(int const*const){} // b2, redef
public void testConstIntPtrParameterInDefinitionAST() throws CoreException {
- IBinding binding1= getBindingFromASTName("f(int*){}", 1);
- IBinding binding2= getBindingFromASTName("f(const int*){}", 1);
+ IBinding binding1 = getBindingFromASTName("f(int*){}", 1);
+ IBinding binding2 = getBindingFromASTName("f(const int*){}", 1);
getProblemFromASTName("f(int const*){}", 1);
getProblemFromASTName("f(int *const){}", 1);
getProblemFromASTName("f(const int*const){}", 1);
@@ -1318,8 +1308,8 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// void f(const int&){} // b2
// void f(int const&){} // b2, redef
public void testConstIntRefParameterInDefinitionAST() throws CoreException {
- IBinding binding1= getBindingFromASTName("f(int&){}", 1);
- IBinding binding2= getBindingFromASTName("f(const int&){}", 1);
+ IBinding binding1 = getBindingFromASTName("f(int&){}", 1);
+ IBinding binding2 = getBindingFromASTName("f(const int&){}", 1);
getProblemFromASTName("f(int const&){}", 1);
}
@@ -1351,8 +1341,8 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// f(int_const_ptr_const); // b2
// }
public void testConstIntPtrParameterInDefinitionAST2() throws CoreException {
- IBinding binding1= getBindingFromASTName("f(int*){}", 1);
- IBinding binding2= getBindingFromASTName("f(const int*){}", 1);
+ IBinding binding1 = getBindingFromASTName("f(int*){}", 1);
+ IBinding binding2 = getBindingFromASTName("f(const int*){}", 1);
assertEquals(binding1, getBindingFromASTName("f(int_ptr)", 1));
assertEquals(binding2, getBindingFromASTName("f(const_int_ptr)", 1));
@@ -1388,8 +1378,8 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// f(int_const_ptr_const); // b2
// }
public void testConstIntPtrParameterInDefinition() throws CoreException {
- IBinding binding1= getBindingFromASTName("f(int*){}", 1);
- IBinding binding2= getBindingFromASTName("f(const int*){}", 1);
+ IBinding binding1 = getBindingFromASTName("f(int*){}", 1);
+ IBinding binding2 = getBindingFromASTName("f(const int*){}", 1);
assertEquals(binding1, getBindingFromASTName("f(int_ptr)", 1));
assertEquals(binding2, getBindingFromASTName("f(const_int_ptr)", 1));
@@ -1429,15 +1419,15 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// namespace x {
// int a(int);
// }
- // using namespace x;
+ // using namespace x;
// using x::a;
// void test() {
// a(1);
// }
- public void testLegalConflictWithUsingDeclaration() {
+ public void testLegalConflictWithUsingDeclaration() {
getBindingFromASTName("a(1)", 1);
- }
+ }
// class A {};
// class B {};
@@ -1448,7 +1438,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// class D : public C {};
// void foo(B b) {}
- // class E : public C {};
+ // class E : public C {};
// void refs() {
// C c;
// foo(c);
@@ -1457,44 +1447,44 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// E e;
// foo(e);
// }
- public void testUserDefinedConversionOperator_224364() {
- IBinding ca= getBindingFromASTName("C c;", 1);
- assertInstance(ca, ICPPClassType.class);
+ public void testUserDefinedConversionOperator_224364() {
+ IBinding ca = getBindingFromASTName("C c;", 1);
+ assertInstance(ca, ICPPClassType.class);
- IBinding foo1= getBindingFromASTName("foo(c)", 3);
+ IBinding foo1 = getBindingFromASTName("foo(c)", 3);
- IBinding da= getBindingFromASTName("D d", 1);
- assertInstance(da, ICPPClassType.class);
+ IBinding da = getBindingFromASTName("D d", 1);
+ assertInstance(da, ICPPClassType.class);
- IBinding foo2= getBindingFromASTName("foo(d)", 3);
- IBinding foo3= getBindingFromASTName("foo(e)", 3);
- }
+ IBinding foo2 = getBindingFromASTName("foo(d)", 3);
+ IBinding foo3 = getBindingFromASTName("foo(e)", 3);
+ }
// int a= 1+2-3*4+10/2; // -4
// int b= a+4;
// int* c= &b;
// enum X {e0, e4=4, e5, e2=2, e3};
- // void ref() {
- // a; b; c; e0; e2; e3; e4; e5;
- // }
+ // void ref() {
+ // a; b; c; e0; e2; e3; e4; e5;
+ // }
public void testValues() {
- IVariable v= (IVariable) getBindingFromASTName("a;", 1);
+ IVariable v = (IVariable) getBindingFromASTName("a;", 1);
asserValueEquals(v.getInitialValue(), -4);
- v= (IVariable) getBindingFromASTName("b;", 1);
+ v = (IVariable) getBindingFromASTName("b;", 1);
asserValueEquals(v.getInitialValue(), 0);
- v= (IVariable) getBindingFromASTName("c;", 1);
+ v = (IVariable) getBindingFromASTName("c;", 1);
assertNull(v.getInitialValue().numberValue());
- IEnumerator e= (IEnumerator) getBindingFromASTName("e0", 2);
+ IEnumerator e = (IEnumerator) getBindingFromASTName("e0", 2);
asserValueEquals(e.getValue(), 0);
- e= (IEnumerator) getBindingFromASTName("e2", 2);
+ e = (IEnumerator) getBindingFromASTName("e2", 2);
asserValueEquals(e.getValue(), 2);
- e= (IEnumerator) getBindingFromASTName("e3", 2);
+ e = (IEnumerator) getBindingFromASTName("e3", 2);
asserValueEquals(e.getValue(), 3);
- e= (IEnumerator) getBindingFromASTName("e4", 2);
+ e = (IEnumerator) getBindingFromASTName("e4", 2);
asserValueEquals(e.getValue(), 4);
- e= (IEnumerator) getBindingFromASTName("e5", 2);
+ e = (IEnumerator) getBindingFromASTName("e5", 2);
asserValueEquals(e.getValue(), 5);
}
@@ -1505,7 +1495,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// A a;
public void testUsingDirectiveWithQualifiedName_269727() {
- getBindingFromASTName("A a", 1, ICPPClassType.class);
+ getBindingFromASTName("A a", 1, ICPPClassType.class);
}
// void f(int (&v)[1]);
@@ -1516,11 +1506,11 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// f(a); f(b);
// }
public void testArrayTypeWithSize_269926() {
- IFunction f1= getBindingFromASTName("f(a)", 1, IFunction.class);
- IFunction f2= getBindingFromASTName("f(b)", 1, IFunction.class);
- assertFalse(f1.equals(f2));
+ IFunction f1 = getBindingFromASTName("f(a)", 1, IFunction.class);
+ IFunction f2 = getBindingFromASTName("f(b)", 1, IFunction.class);
+ assertFalse(f1.equals(f2));
}
-
+
// struct Params {
// constexpr Params(int, int) {}
// };
@@ -1544,7 +1534,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// {params, 0},
// },
// };
-
+
// // empty file
public void testArrayWithOneElement_508254() throws Exception {
checkBindings();
@@ -1565,13 +1555,13 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// B::m(0);
// }
public void testNestedClass_284665() {
- ICPPClassType b0 = getBindingFromASTName("B {", 1, ICPPClassType.class);
- assertFalse(b0 instanceof IIndexBinding);
- ICPPConstructor b1 = getBindingFromASTName("B(int x)", 1, ICPPConstructor.class);
- assertFalse(b1 instanceof IIndexBinding);
- ICPPClassType b2 = getBindingFromASTName("B(0)", 1, ICPPClassType.class);
- ICPPMethod b3 = getBindingFromASTName("m(0)", 1, ICPPMethod.class);
- assertFalse(b3 instanceof IIndexBinding);
+ ICPPClassType b0 = getBindingFromASTName("B {", 1, ICPPClassType.class);
+ assertFalse(b0 instanceof IIndexBinding);
+ ICPPConstructor b1 = getBindingFromASTName("B(int x)", 1, ICPPConstructor.class);
+ assertFalse(b1 instanceof IIndexBinding);
+ ICPPClassType b2 = getBindingFromASTName("B(0)", 1, ICPPClassType.class);
+ ICPPMethod b3 = getBindingFromASTName("m(0)", 1, ICPPMethod.class);
+ assertFalse(b3 instanceof IIndexBinding);
}
// class A {
@@ -1582,7 +1572,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// m(a);
// }
public void testInlineFriendFunction_284690() {
- getBindingFromASTName("m(a)", 1, IFunction.class);
+ getBindingFromASTName("m(a)", 1, IFunction.class);
}
// namespace ns {
@@ -1619,11 +1609,11 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// gb(a);
// }
public void testInlineNamespace_305980a() {
- IFunction f= getBindingFromASTName("fa(s)", 2);
- f= getBindingFromASTName("fb(s)", 2);
- f= getBindingFromASTName("f(s)", 1);
- f= getBindingFromASTName("g(a)", 1);
- f= getBindingFromASTName("gb(a)", 2);
+ IFunction f = getBindingFromASTName("fa(s)", 2);
+ f = getBindingFromASTName("fb(s)", 2);
+ f = getBindingFromASTName("f(s)", 1);
+ f = getBindingFromASTName("g(a)", 1);
+ f = getBindingFromASTName("gb(a)", 2);
}
// namespace ns {
@@ -1662,11 +1652,11 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// gb(a);
// }
public void testInlineNamespace_305980am() {
- IFunction f= getBindingFromASTName("fa(s)", 2);
- f= getBindingFromASTName("fb(s)", 2);
- f= getBindingFromASTName("f(s)", 1);
- f= getBindingFromASTName("g(a)", 1);
- f= getBindingFromASTName("gb(a)", 2);
+ IFunction f = getBindingFromASTName("fa(s)", 2);
+ f = getBindingFromASTName("fb(s)", 2);
+ f = getBindingFromASTName("f(s)", 1);
+ f = getBindingFromASTName("g(a)", 1);
+ f = getBindingFromASTName("gb(a)", 2);
}
// namespace ns {
@@ -1680,8 +1670,8 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// ns::a; //2
// }
public void testInlineNamespace_305980b() {
- IVariable v1= getBindingFromASTName("a; //1", 1);
- IVariable v2= getBindingFromASTName("a; //2", 1);
+ IVariable v1 = getBindingFromASTName("a; //1", 1);
+ IVariable v2 = getBindingFromASTName("a; //2", 1);
assertEquals(v1, v2);
}
@@ -1702,10 +1692,10 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// ns::a; //4
// }
public void testInlineNamespace_305980bm() {
- IVariable v1= getBindingFromASTName("a; //1", 1);
- IVariable v2= getBindingFromASTName("a; //2", 1);
- IVariable v3= getBindingFromASTName("a; //3", 1);
- IVariable v4= getBindingFromASTName("a; //4", 1);
+ IVariable v1 = getBindingFromASTName("a; //1", 1);
+ IVariable v2 = getBindingFromASTName("a; //2", 1);
+ IVariable v3 = getBindingFromASTName("a; //3", 1);
+ IVariable v4 = getBindingFromASTName("a; //4", 1);
assertEquals(v1, v2);
assertEquals(v2, v3);
assertEquals(v3, v4);
@@ -1730,7 +1720,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// ::g(1);
// }
public void testInlineNamespace_305980c() {
- IFunction ref= getBindingFromASTName("f(1)", 1);
+ IFunction ref = getBindingFromASTName("f(1)", 1);
assertEquals("void (char)", ASTTypeUtil.getType(ref.getType()));
getBindingFromASTName("g(1)", 1);
}
@@ -1757,15 +1747,15 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// ::g(1);
// }
public void testInlineNamespace_305980cm() {
- IFunction ref= getBindingFromASTName("f(1)", 1);
+ IFunction ref = getBindingFromASTName("f(1)", 1);
assertEquals("void (char)", ASTTypeUtil.getType(ref.getType()));
getBindingFromASTName("g(1)", 1);
}
-
+
// namespace std {
// inline namespace __cxx11 { }
// }
-
+
// namespace std {
// namespace __cxx11 {
// class string {};
@@ -1784,7 +1774,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// void alias::fun() {
// }
public void testNamespaceAliasAsQualifier_356493a() {
- IFunction ref= getBindingFromASTName("fun", 0);
+ IFunction ref = getBindingFromASTName("fun", 0);
assertEquals("ns", ref.getOwner().getName());
}
@@ -1796,7 +1786,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// void alias::fun() {
// }
public void testNamespaceAliasAsQualifier_356493b() {
- IFunction ref= getBindingFromASTName("fun", 0);
+ IFunction ref = getBindingFromASTName("fun", 0);
assertEquals("ns", ref.getOwner().getName());
}
@@ -1817,7 +1807,6 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
getBindingFromASTName("g(b)", 1, ICPPFunction.class);
}
-
// namespace {
// class A {};
// }
@@ -1978,19 +1967,19 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
public void testNameLookupFromArrayModifier_435075() {
checkBindings();
}
-
+
// struct S {
// int* a;
// int* b;
// };
- //
+ //
// constexpr S waldo = { nullptr, waldo.a };
-
+
// // empty file
public void testVariableInitializerThatReferencesVariable_508254a() throws Exception {
checkBindings();
}
-
+
// struct S {
// int* a;
// int* b;
@@ -2005,7 +1994,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// static const constexpr T greebo[] = {
// { waldo.a },
// };
-
+
// // empty file
public void testVariableInitializerThatReferencesVariable_508254b() throws Exception {
checkBindings();
@@ -2039,12 +2028,12 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// c5->m();//5
// }
public void testOverridden_248846() throws Exception {
- ICPPMethod m0= getBindingFromFirstIdentifier("m();//0");
- ICPPMethod m1= getBindingFromFirstIdentifier("m();//1");
- ICPPMethod m2= getBindingFromFirstIdentifier("m();//2");
- ICPPMethod m3= getBindingFromFirstIdentifier("m(0);");
- ICPPMethod m4= getBindingFromFirstIdentifier("m();//4");
- ICPPMethod m5= getBindingFromFirstIdentifier("m();//5");
+ ICPPMethod m0 = getBindingFromFirstIdentifier("m();//0");
+ ICPPMethod m1 = getBindingFromFirstIdentifier("m();//1");
+ ICPPMethod m2 = getBindingFromFirstIdentifier("m();//2");
+ ICPPMethod m3 = getBindingFromFirstIdentifier("m(0);");
+ ICPPMethod m4 = getBindingFromFirstIdentifier("m();//4");
+ ICPPMethod m5 = getBindingFromFirstIdentifier("m();//5");
assertFalse(ClassTypeHelper.isVirtual(m0));
assertFalse(ClassTypeHelper.isVirtual(m3));
@@ -2074,20 +2063,20 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
assertFalse(ClassTypeHelper.isOverrider(m5, m2));
assertTrue(ClassTypeHelper.isOverrider(m4, m2));
- ICPPMethod[] ors= ClassTypeHelper.findOverridden(m0);
+ ICPPMethod[] ors = ClassTypeHelper.findOverridden(m0);
assertEquals(0, ors.length);
- ors= ClassTypeHelper.findOverridden(m1);
+ ors = ClassTypeHelper.findOverridden(m1);
assertEquals(0, ors.length);
- ors= ClassTypeHelper.findOverridden(m2);
+ ors = ClassTypeHelper.findOverridden(m2);
assertEquals(1, ors.length);
assertEquals(ors[0], m1);
- ors= ClassTypeHelper.findOverridden(m3);
+ ors = ClassTypeHelper.findOverridden(m3);
assertEquals(0, ors.length);
- ors= ClassTypeHelper.findOverridden(m4);
+ ors = ClassTypeHelper.findOverridden(m4);
assertEquals(2, ors.length);
assertEquals(ors[0], m2);
assertEquals(ors[1], m1);
- ors= ClassTypeHelper.findOverridden(m5);
+ ors = ClassTypeHelper.findOverridden(m5);
assertEquals(1, ors.length);
assertEquals(ors[0], m1);
}
@@ -2380,10 +2369,10 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// auto test = 123_X;
public void testUserDefinedLiteralResolution3() throws Exception {
- ICPPVariable v= getBindingFromFirstIdentifier("test");
- assertTrue(v.getType() instanceof IProblemType);
+ ICPPVariable v = getBindingFromFirstIdentifier("test");
+ assertTrue(v.getType() instanceof IProblemType);
}
-
+
// struct A {
// virtual bool foo() = 0;
// };
@@ -2391,7 +2380,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// struct B : A {
// bool foo();
// };
-
+
// class B;
// int main() {
// B waldo;
@@ -2404,7 +2393,6 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
assertEquals(0, pureVirtuals.length);
}
-
// class A {
// friend class B;
// };
@@ -2413,7 +2401,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
public void testFriendClassDeclaration_508338() throws Exception {
getProblemFromFirstIdentifier("B*");
}
-
+
// class waldo {
// static waldo instance;
//
@@ -2421,21 +2409,21 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// };
//
// waldo waldo::instance;
-
+
// // empty file
public void testStaticFieldOfEnclosingType_508254() throws Exception {
checkBindings();
}
-
+
// namespace {
// struct {} waldo;
// }
-
+
// // empty file
public void testAnonymousStructInAnonymousNamespace_508254() throws Exception {
checkBindings();
}
-
+
// struct base {
// int* ptr;
// };
@@ -2448,7 +2436,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// struct Foo {
// shared_ptr m_variable = 0;
// };
-
+
// int main() {
// Foo a; // Error: Type 'Foo' could not be resolved
// }
@@ -2457,7 +2445,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
}
// // empty file
-
+
// template <typename T>
// struct base {
// constexpr base() : p(0) {}
@@ -2475,15 +2463,15 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
public void testDelegatingConstructorCallInConstexprConstructor_514595() throws Exception {
checkBindings();
}
-
+
// enum class NoneType { None };
// const NoneType None = None;
-
+
// // empty file
public void testSelfReferencingVariable_510484() throws Exception {
checkBindings();
}
-
+
// class Foo {
// struct Bar;
// void func();
@@ -2498,7 +2486,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
public void testNestedClassDefinedOutOfLine_502999() throws Exception {
checkBindings();
}
-
+
// class MyClass
// {
// public:
@@ -2559,7 +2547,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// const MyClass MyClass::CONSTANT_NAME24( 24 );
// const MyClass MyClass::CONSTANT_NAME25( 25 );
// const MyClass MyClass::CONSTANT_NAME26( 26 );
-
+
// // empty file
public void testOOM_529646() throws Exception {
checkBindings();
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java
index e7bc7246104..6c4e7560dd2 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java
@@ -80,13 +80,23 @@ import junit.framework.TestSuite;
public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBase {
public static class SingleProject extends IndexCPPTemplateResolutionTest {
- public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true));}
- public static TestSuite suite() {return suite(SingleProject.class);}
+ public SingleProject() {
+ setStrategy(new SinglePDOMTestStrategy(true));
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
public static class ProjectWithDepProj extends IndexCPPTemplateResolutionTest {
- public ProjectWithDepProj() {setStrategy(new ReferencedProject(true));}
- public static TestSuite suite() {return suite(ProjectWithDepProj.class);}
+ public ProjectWithDepProj() {
+ setStrategy(new ReferencedProject(true));
+ }
+
+ public static TestSuite suite() {
+ return suite(ProjectWithDepProj.class);
+ }
@Override
public void testDefaultTemplateArgInHeader_264988() throws Exception {
@@ -104,62 +114,62 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
setStrategy(new SinglePDOMTestStrategy(true));
}
- // template<typename _TpAllocator>
- // struct Allocator {
- // typedef _TpAllocator& alloc_reference;
- // template<typename _TpRebind>
- // struct rebind {
- // typedef Allocator<_TpRebind> other;
- // };
- // };
- //
- // template<typename _Tp, typename _Alloc = Allocator<_Tp> >
- // struct Vec {
- // typedef typename _Alloc::template rebind<_Tp>::other::alloc_reference reference;
- // };
+ // template<typename _TpAllocator>
+ // struct Allocator {
+ // typedef _TpAllocator& alloc_reference;
+ // template<typename _TpRebind>
+ // struct rebind {
+ // typedef Allocator<_TpRebind> other;
+ // };
+ // };
+ //
+ // template<typename _Tp, typename _Alloc = Allocator<_Tp> >
+ // struct Vec {
+ // typedef typename _Alloc::template rebind<_Tp>::other::alloc_reference reference;
+ // };
// void f(Vec<int>::reference r) {}
- public void testRebindPattern_214017_1() throws Exception {
- IBinding b0= getBindingFromASTName("r)", 1);
- assertInstance(b0, ICPPVariable.class);
+ public void testRebindPattern_214017_1() throws Exception {
+ IBinding b0 = getBindingFromASTName("r)", 1);
+ assertInstance(b0, ICPPVariable.class);
IType type = ((ICPPVariable) b0).getType();
type = SemanticUtil.getUltimateType(type, false);
assertInstance(type, IBasicType.class);
assertEquals("int", ASTTypeUtil.getType(type));
- }
-
- // template<typename _TpAllocator>
- // struct Allocator {
- // typedef _TpAllocator& alloc_reference;
- // template<typename _TpRebind>
- // struct rebind {
- // typedef Allocator<_TpRebind> other;
- // };
- // };
- //
- // template<typename _TpBase, typename _AllocBase>
- // struct VecBase {
- // typedef typename _AllocBase::template rebind<_TpBase>::other _Tp_alloc_type;
- // };
- //
- // template<typename _Tp, typename _Alloc = Allocator<_Tp> >
- // struct Vec : public VecBase<_Tp, _Alloc> {
- // typedef typename VecBase<_Tp, _Alloc>::_Tp_alloc_type::alloc_reference reference;
- // };
-
- // void f(Vec<int>::reference r) {}
- public void testRebindPattern_214017_2() throws Exception {
- IBinding b0= getBindingFromASTName("r)", 1);
- assertInstance(b0, ICPPVariable.class);
+ }
+
+ // template<typename _TpAllocator>
+ // struct Allocator {
+ // typedef _TpAllocator& alloc_reference;
+ // template<typename _TpRebind>
+ // struct rebind {
+ // typedef Allocator<_TpRebind> other;
+ // };
+ // };
+ //
+ // template<typename _TpBase, typename _AllocBase>
+ // struct VecBase {
+ // typedef typename _AllocBase::template rebind<_TpBase>::other _Tp_alloc_type;
+ // };
+ //
+ // template<typename _Tp, typename _Alloc = Allocator<_Tp> >
+ // struct Vec : public VecBase<_Tp, _Alloc> {
+ // typedef typename VecBase<_Tp, _Alloc>::_Tp_alloc_type::alloc_reference reference;
+ // };
+
+ // void f(Vec<int>::reference r) {}
+ public void testRebindPattern_214017_2() throws Exception {
+ IBinding b0 = getBindingFromASTName("r)", 1);
+ assertInstance(b0, ICPPVariable.class);
IType type = ((ICPPVariable) b0).getType();
type = SemanticUtil.getUltimateType(type, false);
assertInstance(type, IBasicType.class);
assertEquals("int", ASTTypeUtil.getType(type));
- }
+ }
- // template<typename _TpAllocatorForward>
- // class Allocator;
- //
+ // template<typename _TpAllocatorForward>
+ // class Allocator;
+ //
// template<>
// struct Allocator<void> {
// template<typename _TpRebind>
@@ -167,66 +177,66 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// typedef Allocator<_TpRebind> other;
// };
// };
- //
- // template<typename _TpAllocator>
- // struct Allocator {
- // typedef _TpAllocator& alloc_reference;
- // template<typename _TpRebind>
- // struct rebind {
- // typedef Allocator<_TpRebind> other;
- // };
- // };
- //
- // template<typename _TpBase, typename _AllocBase>
- // struct VecBase {
- // typedef typename _AllocBase::template rebind<_TpBase>::other _Tp_alloc_type;
- // };
- //
- // template<typename _Tp, typename _Alloc = Allocator<_Tp> >
- // struct Vec : public VecBase<_Tp, _Alloc> {
- // typedef typename VecBase<_Tp, _Alloc>::_Tp_alloc_type::alloc_reference reference;
- // };
-
- // void f(Vec<int>::reference r) {}
- public void testRebindPattern_214017_3() throws Exception {
- IBinding b0= getBindingFromASTName("r)", 1);
- assertInstance(b0, ICPPVariable.class);
+ //
+ // template<typename _TpAllocator>
+ // struct Allocator {
+ // typedef _TpAllocator& alloc_reference;
+ // template<typename _TpRebind>
+ // struct rebind {
+ // typedef Allocator<_TpRebind> other;
+ // };
+ // };
+ //
+ // template<typename _TpBase, typename _AllocBase>
+ // struct VecBase {
+ // typedef typename _AllocBase::template rebind<_TpBase>::other _Tp_alloc_type;
+ // };
+ //
+ // template<typename _Tp, typename _Alloc = Allocator<_Tp> >
+ // struct Vec : public VecBase<_Tp, _Alloc> {
+ // typedef typename VecBase<_Tp, _Alloc>::_Tp_alloc_type::alloc_reference reference;
+ // };
+
+ // void f(Vec<int>::reference r) {}
+ public void testRebindPattern_214017_3() throws Exception {
+ IBinding b0 = getBindingFromASTName("r)", 1);
+ assertInstance(b0, ICPPVariable.class);
IType type = ((ICPPVariable) b0).getType();
type = SemanticUtil.getUltimateType(type, false);
assertInstance(type, IBasicType.class);
assertEquals("int", ASTTypeUtil.getType(type));
- }
-
- // template<typename _TpAllocator>
- // struct Allocator {
- // typedef _TpAllocator& alloc_reference;
- // template<typename _TpRebind>
- // struct rebind {
- // typedef Allocator<_TpRebind> other;
- // };
- // };
- //
- // template<typename _TpBase, typename _AllocBase>
- // struct VecBase {
- // typedef typename _AllocBase::template rebind<_TpBase*>::other unreferenced;
- // typedef typename _AllocBase::template rebind<_TpBase>::other _Tp_alloc_type;
- // };
- //
- // template<typename _Tp, typename _Alloc = Allocator<_Tp> >
- // struct Vec : public VecBase<_Tp, _Alloc> {
- // typedef typename VecBase<_Tp, _Alloc>::_Tp_alloc_type::alloc_reference reference;
- // };
+ }
+
+ // template<typename _TpAllocator>
+ // struct Allocator {
+ // typedef _TpAllocator& alloc_reference;
+ // template<typename _TpRebind>
+ // struct rebind {
+ // typedef Allocator<_TpRebind> other;
+ // };
+ // };
+ //
+ // template<typename _TpBase, typename _AllocBase>
+ // struct VecBase {
+ // typedef typename _AllocBase::template rebind<_TpBase*>::other unreferenced;
+ // typedef typename _AllocBase::template rebind<_TpBase>::other _Tp_alloc_type;
+ // };
+ //
+ // template<typename _Tp, typename _Alloc = Allocator<_Tp> >
+ // struct Vec : public VecBase<_Tp, _Alloc> {
+ // typedef typename VecBase<_Tp, _Alloc>::_Tp_alloc_type::alloc_reference reference;
+ // };
// void f(int s);
//
// void test(Vec<int>::reference p) {
// f(p);
// }
- public void testRebindPattern_276610() throws Exception {
- getBindingFromASTName("f(p)", 1, ICPPFunction.class);
- }
+ public void testRebindPattern_276610() throws Exception {
+ getBindingFromASTName("f(p)", 1, ICPPFunction.class);
+ }
- // class Str1 {
+ // class Str1 {
// public:
// Str1(const char* s) {
// s_ = s;
@@ -258,15 +268,14 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// c1.m2("aaa"); // problem
// }
public void testUnindexedConstructorInstanceImplicitReferenceToDeferred() throws Exception {
- IBinding b0= getBindingFromASTName("C1<char> c1", 8);
- IBinding b1= getBindingFromASTName("m1(\"aaa\")", 2);
- IBinding b2= getBindingFromASTName("m2(\"aaa\")", 2);
+ IBinding b0 = getBindingFromASTName("C1<char> c1", 8);
+ IBinding b1 = getBindingFromASTName("m1(\"aaa\")", 2);
+ IBinding b2 = getBindingFromASTName("m2(\"aaa\")", 2);
- assertEquals(1, getIndex().findNames(b1, IIndex.FIND_REFERENCES).length);
- assertEquals(1, getIndex().findNames(b2, IIndex.FIND_REFERENCES).length);
+ assertEquals(1, getIndex().findNames(b1, IIndex.FIND_REFERENCES).length);
+ assertEquals(1, getIndex().findNames(b2, IIndex.FIND_REFERENCES).length);
}
-
// template<typename T>
// class X {
// public: static void foo() {}
@@ -277,7 +286,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// X<A>::foo();
// }
public void testUnindexedMethodInstance() {
- IBinding b0= getBindingFromASTName("foo()", 3);
+ IBinding b0 = getBindingFromASTName("foo()", 3);
assertInstance(b0, ICPPMethod.class);
}
@@ -291,9 +300,9 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// x.assign("aaa");
// }
public void testUnindexedMethodInstance2() throws Exception {
- IBinding b0= getBindingFromASTName("assign(\"aaa\")", 6);
+ IBinding b0 = getBindingFromASTName("assign(\"aaa\")", 6);
assertInstance(b0, ICPPMethod.class);
- assertEquals(1, getIndex().findNames(b0, IIndex.FIND_REFERENCES).length);
+ assertEquals(1, getIndex().findNames(b0, IIndex.FIND_REFERENCES).length);
IParameter[] parameters = ((ICPPMethod) b0).getParameters();
IFunctionType type = ((ICPPMethod) b0).getType();
}
@@ -306,7 +315,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// X<A> xa= new X<A>();
// }
public void testUnindexedConstructorInstance() {
- IBinding b0= getBindingFromImplicitASTName("X<A>()", 4);
+ IBinding b0 = getBindingFromImplicitASTName("X<A>()", 4);
assertInstance(b0, ICPPConstructor.class);
}
@@ -332,11 +341,11 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// c1a.m2(*new StrT<A>(new A()));
// }
public void testUnindexedConstructorInstanceImplicitReference3() throws Exception {
- IBinding b0= getBindingFromASTName("C1< StrT<A> >", 2);
- IBinding b1= getBindingFromASTName("StrT<A> > c1a", 7);
- IBinding b2= getBindingFromASTName("StrT<A>(", 7);
- IBinding b3= getBindingFromASTName("c1a;", 3);
- IBinding b4= getBindingFromASTName("m2(*", 2);
+ IBinding b0 = getBindingFromASTName("C1< StrT<A> >", 2);
+ IBinding b1 = getBindingFromASTName("StrT<A> > c1a", 7);
+ IBinding b2 = getBindingFromASTName("StrT<A>(", 7);
+ IBinding b3 = getBindingFromASTName("c1a;", 3);
+ IBinding b4 = getBindingFromASTName("m2(*", 2);
}
// class Str1 {
@@ -372,11 +381,11 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// m2("aaa"); // problem
// }
public void testUnindexedConstructorInstanceImplicitReference() throws Exception {
- IBinding b0= getBindingFromASTName("m1(\"aaa\")", 2);
- IBinding b1= getBindingFromASTName("m2(\"aaa\")", 2);
+ IBinding b0 = getBindingFromASTName("m1(\"aaa\")", 2);
+ IBinding b1 = getBindingFromASTName("m2(\"aaa\")", 2);
- assertEquals(1, getIndex().findNames(b0, IIndex.FIND_REFERENCES).length);
- assertEquals(1, getIndex().findNames(b1, IIndex.FIND_REFERENCES).length);
+ assertEquals(1, getIndex().findNames(b0, IIndex.FIND_REFERENCES).length);
+ assertEquals(1, getIndex().findNames(b1, IIndex.FIND_REFERENCES).length);
}
// // Bryan W.'s example from bugzilla#167098
@@ -400,40 +409,40 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// // foo -> CPPMethodTemplateSpecialization
// // foo<int,int> -> CPPMethodInstance
// }
- public void testCPPConstructorTemplateSpecialization() throws Exception {
- IBinding b0= getBindingFromASTName("D<int> *var", 1);
- IBinding b1= getBindingFromASTName("D<int> *var", 6);
-
- assertInstance(b0, ICPPClassTemplate.class);
- assertInstance(b0, ICPPClassType.class);
- assertInstance(b1, ICPPTemplateInstance.class);
- assertInstance(b1, ICPPClassType.class);
-
- // ICPPClassType _ct= (ICPPClassType) b1;
- // ICPPConstructor[] _ctcs= _ct.getConstructors();
- // assertEquals(3, _ctcs.length); // two implicit plus the constructor template
-
- IBinding b2= getBindingFromASTName("D<int>(", 1);
- IBinding b3= getBindingFromImplicitASTName("D<int>(", 6);
-
- assertInstance(b2, ICPPClassTemplate.class); // *D*<int>(5, 6)
- assertInstance(b2, ICPPClassType.class); // *D*<int>(5, 6)
- assertInstance(b3, ICPPTemplateInstance.class); // *D<int>*(5, 6)
- assertInstance(b3, ICPPConstructor.class); // *D<int>*(5, 6)
-
- //
- // ICPPClassType ct= (ICPPClassType) b2;
- // ICPPConstructor[] ctcs= ct.getConstructors();
- // assertEquals(3, ctcs.length); // two implicit plus the constructor template
-
- IBinding tidSpc= ((ICPPTemplateInstance)b3).getSpecializedBinding();
- assertInstance(tidSpc, ICPPConstructor.class);
- assertInstance(tidSpc, ICPPSpecialization.class);
- assertInstance(tidSpc, ICPPFunctionTemplate.class);
- }
+ public void testCPPConstructorTemplateSpecialization() throws Exception {
+ IBinding b0 = getBindingFromASTName("D<int> *var", 1);
+ IBinding b1 = getBindingFromASTName("D<int> *var", 6);
+
+ assertInstance(b0, ICPPClassTemplate.class);
+ assertInstance(b0, ICPPClassType.class);
+ assertInstance(b1, ICPPTemplateInstance.class);
+ assertInstance(b1, ICPPClassType.class);
+
+ // ICPPClassType _ct= (ICPPClassType) b1;
+ // ICPPConstructor[] _ctcs= _ct.getConstructors();
+ // assertEquals(3, _ctcs.length); // two implicit plus the constructor template
+
+ IBinding b2 = getBindingFromASTName("D<int>(", 1);
+ IBinding b3 = getBindingFromImplicitASTName("D<int>(", 6);
+
+ assertInstance(b2, ICPPClassTemplate.class); // *D*<int>(5, 6)
+ assertInstance(b2, ICPPClassType.class); // *D*<int>(5, 6)
+ assertInstance(b3, ICPPTemplateInstance.class); // *D<int>*(5, 6)
+ assertInstance(b3, ICPPConstructor.class); // *D<int>*(5, 6)
+
+ //
+ // ICPPClassType ct= (ICPPClassType) b2;
+ // ICPPConstructor[] ctcs= ct.getConstructors();
+ // assertEquals(3, ctcs.length); // two implicit plus the constructor template
+
+ IBinding tidSpc = ((ICPPTemplateInstance) b3).getSpecializedBinding();
+ assertInstance(tidSpc, ICPPConstructor.class);
+ assertInstance(tidSpc, ICPPSpecialization.class);
+ assertInstance(tidSpc, ICPPFunctionTemplate.class);
+ }
// class B {};
- //
+ //
// template<typename T>
// class A {
// public:
@@ -448,7 +457,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// a.f= foo<B>;
// }
public void testOverloadedFunctionTemplate() {
- IBinding b0= getBindingFromASTName("foo<B>;", 6);
+ IBinding b0 = getBindingFromASTName("foo<B>;", 6);
assertInstance(b0, ICPPFunction.class);
assertInstance(b0, ICPPSpecialization.class);
}
@@ -515,15 +524,15 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// f.s.foo(*new A());
// }
public void testTemplateTemplateParameter() throws Exception {
- IBinding b0= getBindingFromASTName("Foo<A,X>", 3);
- IBinding b1= getBindingFromASTName("Foo<A,X>", 8);
- IBinding b2= getBindingFromASTName("f.s.foo", 1);
- IBinding b3= getBindingFromASTName("s.foo", 1);
- IBinding b4= getBindingFromASTName("foo(*", 3);
+ IBinding b0 = getBindingFromASTName("Foo<A,X>", 3);
+ IBinding b1 = getBindingFromASTName("Foo<A,X>", 8);
+ IBinding b2 = getBindingFromASTName("f.s.foo", 1);
+ IBinding b3 = getBindingFromASTName("s.foo", 1);
+ IBinding b4 = getBindingFromASTName("foo(*", 3);
assertInstance(b0, ICPPClassTemplate.class);
assertInstance(b0, ICPPClassType.class);
- ICPPTemplateParameter[] ps= ((ICPPClassTemplate)b0).getTemplateParameters();
+ ICPPTemplateParameter[] ps = ((ICPPClassTemplate) b0).getTemplateParameters();
assertEquals(2, ps.length);
assertInstance(ps[0], ICPPTemplateTypeParameter.class);
assertInstance(ps[1], ICPPTemplateTemplateParameter.class);
@@ -531,24 +540,23 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertInstance(b1, ICPPTemplateInstance.class);
assertInstance(b1, ICPPClassType.class);
- ICPPTemplateArgument[] args= ((ICPPTemplateInstance) b1).getTemplateArguments();
+ ICPPTemplateArgument[] args = ((ICPPTemplateInstance) b1).getTemplateArguments();
assertInstance(args[0].getTypeValue(), ICPPClassType.class);
assertInstance(args[1].getTypeValue(), ICPPClassTemplate.class);
assertInstance(args[1].getTypeValue(), ICPPClassType.class);
- ICPPTemplateParameterMap om= ((ICPPTemplateInstance) b1).getTemplateParameterMap();
+ ICPPTemplateParameterMap om = ((ICPPTemplateInstance) b1).getTemplateParameterMap();
assertEquals(2, om.getAllParameterPositions().length);
assertInstance(om.getArgument(0).getTypeValue(), ICPPClassType.class);
assertInstance(om.getArgument(1).getTypeValue(), ICPPClassType.class);
assertInstance(om.getArgument(1).getTypeValue(), ICPPClassTemplate.class);
- IBinding b1_spcd= ((ICPPTemplateInstance) b1).getSpecializedBinding();
+ IBinding b1_spcd = ((ICPPTemplateInstance) b1).getSpecializedBinding();
assertInstance(b1_spcd, ICPPClassTemplate.class);
assertInstance(b1_spcd, ICPPClassType.class);
- assertTrue(((IType)b1_spcd).isSameType((IType)b0));
+ assertTrue(((IType) b1_spcd).isSameType((IType) b0));
}
-
// template<typename T1, typename T2>
// class Foo {
// public:
@@ -573,27 +581,24 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// Y y;
// Z z;
public void testInstanceInheritance() throws Exception {
- IBinding[] bs= {
- getBindingFromASTName("X x;", 1),
- getBindingFromASTName("Y y;", 1),
- getBindingFromASTName("Z z;", 1)
- };
+ IBinding[] bs = { getBindingFromASTName("X x;", 1), getBindingFromASTName("Y y;", 1),
+ getBindingFromASTName("Z z;", 1) };
for (IBinding b : bs) {
assertInstance(b, ICPPClassType.class);
- ICPPClassType c= (ICPPClassType) b;
- assertEquals(1, c.getBases().length);
- ICPPClassType xb= (ICPPClassType) c.getBases()[0].getBaseClass();
- assertInstance(xb, ICPPTemplateInstance.class);
- ICPPTemplateParameter[] templateParameters =
- ((ICPPTemplateInstance) xb).getTemplateDefinition().getTemplateParameters();
- assertInstance(templateParameters[0], ICPPTemplateTypeParameter.class);
- assertInstance(templateParameters[1], ICPPTemplateTypeParameter.class);
- ICPPTemplateParameterMap args= ((ICPPTemplateInstance) xb).getTemplateParameterMap();
- assertInstance(args.getArgument(0).getTypeValue(), ICPPClassType.class);
- assertInstance(args.getArgument(1).getTypeValue(), ICPPClassType.class);
- }
- }
+ ICPPClassType c = (ICPPClassType) b;
+ assertEquals(1, c.getBases().length);
+ ICPPClassType xb = (ICPPClassType) c.getBases()[0].getBaseClass();
+ assertInstance(xb, ICPPTemplateInstance.class);
+ ICPPTemplateParameter[] templateParameters = ((ICPPTemplateInstance) xb).getTemplateDefinition()
+ .getTemplateParameters();
+ assertInstance(templateParameters[0], ICPPTemplateTypeParameter.class);
+ assertInstance(templateParameters[1], ICPPTemplateTypeParameter.class);
+ ICPPTemplateParameterMap args = ((ICPPTemplateInstance) xb).getTemplateParameterMap();
+ assertInstance(args.getArgument(0).getTypeValue(), ICPPClassType.class);
+ assertInstance(args.getArgument(1).getTypeValue(), ICPPClassType.class);
+ }
+ }
// namespace ns {
// template<typename T1>
@@ -642,32 +647,32 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// template<typename T3> class D<B, T3> {};
// template<typename T3> class D<C, T3> {};
public void testClassPartialSpecializations() throws Exception {
- IBinding b0= getBindingFromASTName("D<A, T3>", 8);
- IBinding b1= getBindingFromASTName("D<B, T3>", 8);
- IBinding b2= getBindingFromASTName("D<C, T3>", 8);
- IBinding b3= getBindingFromASTName("D<B", 1);
-
- List spBindings= new ArrayList();
- assertInstance(b0, ICPPClassTemplatePartialSpecialization.class);
- spBindings.add(((ICPPClassTemplatePartialSpecialization) b0).getPrimaryClassTemplate());
-
- assertInstance(b1, ICPPClassTemplatePartialSpecialization.class);
- spBindings.add(((ICPPClassTemplatePartialSpecialization) b1).getPrimaryClassTemplate());
-
- assertInstance(b2, ICPPClassTemplatePartialSpecialization.class);
- spBindings.add(((ICPPClassTemplatePartialSpecialization) b2).getPrimaryClassTemplate());
-
- for (int i= 0; i < spBindings.size(); i++) {
- for (int j= 0; j < spBindings.size(); j++) {
- IType ty1= (IType) spBindings.get(i);
- IType ty2= (IType) spBindings.get(j);
- assertTrue(ty1.isSameType(ty2));
- }
- }
+ IBinding b0 = getBindingFromASTName("D<A, T3>", 8);
+ IBinding b1 = getBindingFromASTName("D<B, T3>", 8);
+ IBinding b2 = getBindingFromASTName("D<C, T3>", 8);
+ IBinding b3 = getBindingFromASTName("D<B", 1);
+
+ List spBindings = new ArrayList();
+ assertInstance(b0, ICPPClassTemplatePartialSpecialization.class);
+ spBindings.add(((ICPPClassTemplatePartialSpecialization) b0).getPrimaryClassTemplate());
+
+ assertInstance(b1, ICPPClassTemplatePartialSpecialization.class);
+ spBindings.add(((ICPPClassTemplatePartialSpecialization) b1).getPrimaryClassTemplate());
+
+ assertInstance(b2, ICPPClassTemplatePartialSpecialization.class);
+ spBindings.add(((ICPPClassTemplatePartialSpecialization) b2).getPrimaryClassTemplate());
+
+ for (int i = 0; i < spBindings.size(); i++) {
+ for (int j = 0; j < spBindings.size(); j++) {
+ IType ty1 = (IType) spBindings.get(i);
+ IType ty2 = (IType) spBindings.get(j);
+ assertTrue(ty1.isSameType(ty2));
+ }
+ }
- assertInstance(b3, ICPPClassTemplate.class);
- ICPPClassTemplate ct= (ICPPClassTemplate) b3;
- assertEquals(3, ct.getPartialSpecializations().length);
+ assertInstance(b3, ICPPClassTemplate.class);
+ ICPPClassTemplate ct = (ICPPClassTemplate) b3;
+ assertEquals(3, ct.getPartialSpecializations().length);
}
// template<typename T1>
@@ -690,27 +695,27 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// X<int> x;
// }
public void testClassImplicitInstantiations_188274() throws Exception {
- IBinding b2= getBindingFromASTName("X<int>", 6);
+ IBinding b2 = getBindingFromASTName("X<int>", 6);
assertInstance(b2, ICPPClassType.class);
assertInstance(b2, ICPPTemplateInstance.class);
- ICPPClassType ct2= (ICPPClassType) b2;
- ICPPBase[] bss2= ct2.getBases();
+ ICPPClassType ct2 = (ICPPClassType) b2;
+ ICPPBase[] bss2 = ct2.getBases();
assertEquals(1, bss2.length);
assertInstance(bss2[0].getBaseClass(), ICPPClassType.class);
- ICPPClassType ct2b= (ICPPClassType) bss2[0].getBaseClass();
+ ICPPClassType ct2b = (ICPPClassType) bss2[0].getBaseClass();
assertInstance(ct2b, ICPPTemplateInstance.class);
- IBinding b0= getBindingFromASTName("B<int>", 6);
+ IBinding b0 = getBindingFromASTName("B<int>", 6);
assertInstance(b0, ICPPClassType.class);
- ICPPClassType ct= (ICPPClassType) b0;
- ICPPBase[] bss= ct.getBases();
+ ICPPClassType ct = (ICPPClassType) b0;
+ ICPPBase[] bss = ct.getBases();
assertEquals(1, bss.length);
assertInstance(bss[0].getBaseClass(), ICPPClassType.class);
- IBinding b1= getBindingFromASTName("B<long>", 7);
+ IBinding b1 = getBindingFromASTName("B<long>", 7);
assertInstance(b1, ICPPClassType.class);
- ICPPClassType ct1= (ICPPClassType) b1;
- ICPPBase[] bss1= ct1.getBases();
+ ICPPClassType ct1 = (ICPPClassType) b1;
+ ICPPBase[] bss1 = ct1.getBases();
assertEquals(1, bss1.length);
assertInstance(bss1[0].getBaseClass(), ICPPClassType.class);
}
@@ -729,38 +734,38 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// B t;
// int x;
// B foo(B t) { B x= *new B(); return x; }
- // void bar(B t, int& x) { x++; }
- // };
+ // void bar(B t, int& x) { x++; }
+ // };
- // A<B> ab;
- public void testClassSpecializationMethods() throws Exception {
- IBinding b0= getBindingFromASTName("A<B> ab", 4);
- assertInstance(b0, ICPPClassType.class);
- assertInstance(b0, ICPPSpecialization.class);
+ // A<B> ab;
+ public void testClassSpecializationMethods() throws Exception {
+ IBinding b0 = getBindingFromASTName("A<B> ab", 4);
+ assertInstance(b0, ICPPClassType.class);
+ assertInstance(b0, ICPPSpecialization.class);
- ICPPClassType ct= (ICPPClassType) b0;
- ICPPMethod[] dms= ct.getDeclaredMethods();
- assertEquals(2, dms.length);
+ ICPPClassType ct = (ICPPClassType) b0;
+ ICPPMethod[] dms = ct.getDeclaredMethods();
+ assertEquals(2, dms.length);
- // if the specialization was used, we have 2 fields.
- ICPPField[] fs= ct.getDeclaredFields();
- assertEquals(2, fs.length);
+ // if the specialization was used, we have 2 fields.
+ ICPPField[] fs = ct.getDeclaredFields();
+ assertEquals(2, fs.length);
- ICPPMethod foo= dms[0].getName().equals("foo") ? dms[0] : dms[1];
- ICPPMethod bar= dms[0].getName().equals("bar") ? dms[0] : dms[1];
+ ICPPMethod foo = dms[0].getName().equals("foo") ? dms[0] : dms[1];
+ ICPPMethod bar = dms[0].getName().equals("bar") ? dms[0] : dms[1];
- assertEquals(foo.getName(), "foo");
- assertEquals(bar.getName(), "bar");
+ assertEquals(foo.getName(), "foo");
+ assertEquals(bar.getName(), "bar");
- assertInstance(foo.getType().getReturnType(), ICPPClassType.class);
- assertEquals(((ICPPClassType)foo.getType().getReturnType()).getName(), "B");
- assertEquals(foo.getType().getParameterTypes().length, 1);
- assertInstance(foo.getType().getParameterTypes()[0], ICPPClassType.class);
- assertEquals(((ICPPClassType)foo.getType().getParameterTypes()[0]).getName(), "B");
+ assertInstance(foo.getType().getReturnType(), ICPPClassType.class);
+ assertEquals(((ICPPClassType) foo.getType().getReturnType()).getName(), "B");
+ assertEquals(foo.getType().getParameterTypes().length, 1);
+ assertInstance(foo.getType().getParameterTypes()[0], ICPPClassType.class);
+ assertEquals(((ICPPClassType) foo.getType().getParameterTypes()[0]).getName(), "B");
- assertInstance(bar.getType().getReturnType(), ICPPBasicType.class);
- assertEquals(((ICPPBasicType)bar.getType().getReturnType()).getType(), IBasicType.t_void);
- }
+ assertInstance(bar.getType().getReturnType(), ICPPBasicType.class);
+ assertEquals(((ICPPBasicType) bar.getType().getReturnType()).getType(), IBasicType.t_void);
+ }
// template<class T>
// auto trailing_return_type(T& p) -> decltype(p.m());
@@ -798,7 +803,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// template<typename T> class A {
// public:
- // typedef T TD;
+ // typedef T TD;
// };
//
// class B {};
@@ -812,14 +817,14 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// A<C>::TD bar2= bar;
// }
public void testTypedefSpecialization() {
- IBinding b0= getBindingFromASTName("TD foo2", 2);
- IBinding b1= getBindingFromASTName("TD bar2", 2);
+ IBinding b0 = getBindingFromASTName("TD foo2", 2);
+ IBinding b1 = getBindingFromASTName("TD bar2", 2);
assertInstance(b0, ITypedef.class);
assertInstance(b1, ITypedef.class);
assertInstance(b0, ICPPSpecialization.class);
assertInstance(b1, ICPPSpecialization.class);
- ICPPTemplateParameterMap om0= ((ICPPSpecialization) b0).getTemplateParameterMap();
- ICPPTemplateParameterMap om1= ((ICPPSpecialization) b1).getTemplateParameterMap();
+ ICPPTemplateParameterMap om0 = ((ICPPSpecialization) b0).getTemplateParameterMap();
+ ICPPTemplateParameterMap om1 = ((ICPPSpecialization) b1).getTemplateParameterMap();
assertEquals(1, om0.getAllParameterPositions().length);
assertEquals(1, om1.getAllParameterPositions().length);
assertInstance(om0.getArgument(0).getTypeValue(), ICPPClassType.class);
@@ -840,7 +845,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// x.m(1);
// }
public void testTypedefSpecialization_213861() throws Exception {
- IBinding b0= getBindingFromASTName("m(1)", 1);
+ IBinding b0 = getBindingFromASTName("m(1)", 1);
assertInstance(b0, ICPPMethod.class);
}
@@ -864,15 +869,15 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// foo<C1,C3>(*new C1(), *new C3());
// }
public void testFunctionTemplateSpecializations() throws Exception {
- IBinding b0= getBindingFromASTName("foo<C1>(", 3);
- IBinding b1= getBindingFromASTName("foo<C2>(", 3);
- IBinding b2= getBindingFromASTName("foo<C3>(", 3);
- IBinding b3= getBindingFromASTName("foo<C1,C2>(", 3);
- IBinding b4= getBindingFromASTName("foo<C2,C3>(", 3);
- IBinding b5= getBindingFromASTName("foo<C3,C1>(", 3);
- IBinding b6= getBindingFromASTName("foo<C2,C1>(", 3);
- IBinding b7= getBindingFromASTName("foo<C3,C2>(", 3);
- IBinding b8= getBindingFromASTName("foo<C1,C3>(", 3);
+ IBinding b0 = getBindingFromASTName("foo<C1>(", 3);
+ IBinding b1 = getBindingFromASTName("foo<C2>(", 3);
+ IBinding b2 = getBindingFromASTName("foo<C3>(", 3);
+ IBinding b3 = getBindingFromASTName("foo<C1,C2>(", 3);
+ IBinding b4 = getBindingFromASTName("foo<C2,C3>(", 3);
+ IBinding b5 = getBindingFromASTName("foo<C3,C1>(", 3);
+ IBinding b6 = getBindingFromASTName("foo<C2,C1>(", 3);
+ IBinding b7 = getBindingFromASTName("foo<C3,C2>(", 3);
+ IBinding b8 = getBindingFromASTName("foo<C1,C3>(", 3);
}
// class A {}; class B{}; class C {};
@@ -891,64 +896,64 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// foo(c,a); // function specialization (1)
// }
public void testFunctionInstanceSpecializationsParameters() throws Exception {
- IBinding b0= getBindingFromASTName("foo(a,b)", 3);
+ IBinding b0 = getBindingFromASTName("foo(a,b)", 3);
assertInstance(b0, ICPPFunction.class);
assertInstance(b0, ICPPTemplateInstance.class);
- ICPPFunctionType b0type= ((ICPPFunction) b0).getType();
+ ICPPFunctionType b0type = ((ICPPFunction) b0).getType();
assertInstance(b0type.getReturnType(), ICPPBasicType.class);
- IType[] b0_ptypes= b0type.getParameterTypes();
+ IType[] b0_ptypes = b0type.getParameterTypes();
assertEquals(2, b0_ptypes.length);
assertInstance(b0_ptypes[0], ICPPClassType.class);
assertInstance(b0_ptypes[1], ICPPClassType.class);
assertEquals("A", ((ICPPClassType) b0_ptypes[0]).getName());
assertEquals("B", ((ICPPClassType) b0_ptypes[1]).getName());
- IParameter[] b0_pms= ((ICPPFunction) b0).getParameters();
+ IParameter[] b0_pms = ((ICPPFunction) b0).getParameters();
assertEquals(2, b0_pms.length);
assertInstance(b0_pms[0].getType(), ICPPClassType.class);
assertInstance(b0_pms[1].getType(), ICPPClassType.class);
assertEquals("A", ((ICPPClassType) b0_pms[0].getType()).getName());
assertEquals("B", ((ICPPClassType) b0_pms[1].getType()).getName());
- IBinding b0_spcd= ((ICPPTemplateInstance) b0).getSpecializedBinding();
+ IBinding b0_spcd = ((ICPPTemplateInstance) b0).getSpecializedBinding();
assertInstance(b0_spcd, ICPPFunction.class);
assertInstance(b0_spcd, ICPPTemplateDefinition.class);
- IParameter[] b0_spcd_pms= ((ICPPFunction)b0_spcd).getParameters();
+ IParameter[] b0_spcd_pms = ((ICPPFunction) b0_spcd).getParameters();
assertEquals(2, b0_spcd_pms.length);
assertInstance(b0_spcd_pms[0].getType(), ICPPTemplateTypeParameter.class);
assertInstance(b0_spcd_pms[1].getType(), ICPPTemplateTypeParameter.class);
assertEquals("T1", ((ICPPTemplateTypeParameter) b0_spcd_pms[0].getType()).getName());
assertEquals("T2", ((ICPPTemplateTypeParameter) b0_spcd_pms[1].getType()).getName());
- ICPPTemplateParameterMap b0_am= ((ICPPSpecialization)b0).getTemplateParameterMap();
+ ICPPTemplateParameterMap b0_am = ((ICPPSpecialization) b0).getTemplateParameterMap();
assertEquals(2, b0_am.getAllParameterPositions().length);
assertInstance(b0_am.getArgument(0).getTypeValue(), ICPPClassType.class);
assertInstance(b0_am.getArgument(1).getTypeValue(), ICPPClassType.class);
assertEquals("A", ((ICPPClassType) b0_am.getArgument(0).getTypeValue()).getName());
assertEquals("B", ((ICPPClassType) b0_am.getArgument(1).getTypeValue()).getName());
- ICPPFunctionType b0_spcd_type= ((ICPPFunction) b0_spcd).getType();
+ ICPPFunctionType b0_spcd_type = ((ICPPFunction) b0_spcd).getType();
assertInstance(b0_spcd_type.getReturnType(), ICPPBasicType.class);
- IType[] b0_spcd_ptypes= b0_spcd_type.getParameterTypes();
+ IType[] b0_spcd_ptypes = b0_spcd_type.getParameterTypes();
assertEquals(2, b0_spcd_ptypes.length);
assertInstance(b0_spcd_ptypes[0], ICPPTemplateTypeParameter.class);
assertInstance(b0_spcd_ptypes[1], ICPPTemplateTypeParameter.class);
assertEquals("T1", ((ICPPTemplateTypeParameter) b0_spcd_ptypes[0]).getName());
assertEquals("T2", ((ICPPTemplateTypeParameter) b0_spcd_ptypes[1]).getName());
- IBinding b1= getBindingFromASTName("foo(c,a)", 3);
+ IBinding b1 = getBindingFromASTName("foo(c,a)", 3);
assertInstance(b1, ICPPFunction.class);
- ICPPFunctionType b1type= ((ICPPFunction) b1).getType();
+ ICPPFunctionType b1type = ((ICPPFunction) b1).getType();
assertInstance(b1type.getReturnType(), ICPPBasicType.class);
- IType[] b1_ptypes= b1type.getParameterTypes();
+ IType[] b1_ptypes = b1type.getParameterTypes();
assertEquals(2, b1_ptypes.length);
assertInstance(b1_ptypes[0], ICPPClassType.class);
assertInstance(b1_ptypes[1], ICPPClassType.class);
assertEquals("C", ((ICPPClassType) b1_ptypes[0]).getName());
assertEquals("A", ((ICPPClassType) b1_ptypes[1]).getName());
- IParameter[] b1_pms= ((ICPPFunction)b1).getParameters();
+ IParameter[] b1_pms = ((ICPPFunction) b1).getParameters();
assertEquals(2, b1_pms.length);
assertInstance(b1_pms[0].getType(), ICPPClassType.class);
assertInstance(b1_pms[1].getType(), ICPPClassType.class);
@@ -956,33 +961,33 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertEquals("A", ((ICPPClassType) b1_pms[1].getType()).getName());
assertInstance(b1, ICPPSpecialization.class);
- ICPPSpecialization b1s= (ICPPSpecialization) b1;
- IBinding b1_spcd= b1s.getSpecializedBinding();
+ ICPPSpecialization b1s = (ICPPSpecialization) b1;
+ IBinding b1_spcd = b1s.getSpecializedBinding();
assertInstance(b1_spcd, ICPPFunction.class);
assertInstance(b1_spcd, ICPPTemplateDefinition.class);
- ICPPFunctionType b1_spcd_type= ((ICPPFunction) b1_spcd).getType();
+ ICPPFunctionType b1_spcd_type = ((ICPPFunction) b1_spcd).getType();
assertInstance(b1_spcd_type.getReturnType(), ICPPBasicType.class);
- IType[] b1_spcd_ptypes= b1_spcd_type.getParameterTypes();
+ IType[] b1_spcd_ptypes = b1_spcd_type.getParameterTypes();
assertEquals(2, b1_spcd_ptypes.length);
assertInstance(b1_spcd_ptypes[0], ICPPTemplateTypeParameter.class);
assertInstance(b1_spcd_ptypes[1], ICPPTemplateTypeParameter.class);
assertEquals("T1", ((ICPPTemplateTypeParameter) b1_spcd_ptypes[0]).getName());
assertEquals("T2", ((ICPPTemplateTypeParameter) b1_spcd_ptypes[1]).getName());
- IParameter[] b1_spcd_pms= ((ICPPFunction)b1_spcd).getParameters();
+ IParameter[] b1_spcd_pms = ((ICPPFunction) b1_spcd).getParameters();
assertEquals(2, b1_spcd_pms.length);
assertInstance(b1_spcd_pms[0].getType(), ICPPTemplateTypeParameter.class);
assertInstance(b1_spcd_pms[1].getType(), ICPPTemplateTypeParameter.class);
assertEquals("T1", ((ICPPTemplateTypeParameter) b1_spcd_pms[0].getType()).getName());
assertEquals("T2", ((ICPPTemplateTypeParameter) b1_spcd_pms[1].getType()).getName());
- ICPPTemplateParameterMap b1_am= b1s.getTemplateParameterMap();
+ ICPPTemplateParameterMap b1_am = b1s.getTemplateParameterMap();
assertEquals(2, b1_am.getAllParameterPositions().length);
assertInstance(b1_am.getArgument(0).getTypeValue(), ICPPClassType.class);
assertInstance(b1_am.getArgument(1).getTypeValue(), ICPPClassType.class);
- assertEquals("C", ((ICPPClassType)b1_am.getArgument(0).getTypeValue()).getName());
- assertEquals("A", ((ICPPClassType)b1_am.getArgument(1).getTypeValue()).getName());
+ assertEquals("C", ((ICPPClassType) b1_am.getArgument(0).getTypeValue()).getName());
+ assertEquals("A", ((ICPPClassType) b1_am.getArgument(1).getTypeValue()).getName());
}
// class A {};
@@ -995,30 +1000,30 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// foo(a);
// }
public void testFunctionInstanceParameters() throws Exception {
- IBinding b0= getBindingFromFirstIdentifier("foo(a)");
+ IBinding b0 = getBindingFromFirstIdentifier("foo(a)");
assertInstance(b0, ICPPTemplateInstance.class);
assertInstance(b0, ICPPFunction.class);
- ICPPFunction f= (ICPPFunction) b0;
- ICPPFunctionType type= f.getType();
- IType rt= type.getReturnType();
- IType[] pts= type.getParameterTypes();
+ ICPPFunction f = (ICPPFunction) b0;
+ ICPPFunctionType type = f.getType();
+ IType rt = type.getReturnType();
+ IType[] pts = type.getParameterTypes();
- IParameter[] ps= f.getParameters();
+ IParameter[] ps = f.getParameters();
assertEquals(1, ps.length);
- ICPPParameter param= (ICPPParameter) ps[0];
+ ICPPParameter param = (ICPPParameter) ps[0];
assertInstance(param, ICPPSpecialization.class);
- IType paramType= param.getType();
+ IType paramType = param.getType();
assertInstance(paramType, ICPPClassType.class);
- ICPPParameter paramSpec= (ICPPParameter) ((ICPPSpecialization) param).getSpecializedBinding();
+ ICPPParameter paramSpec = (ICPPParameter) ((ICPPSpecialization) param).getSpecializedBinding();
assertInstance(paramSpec.getType(), ICPPTemplateTypeParameter.class);
- ICPPTemplateTypeParameter ttp= (ICPPTemplateTypeParameter) paramSpec.getType();
+ ICPPTemplateTypeParameter ttp = (ICPPTemplateTypeParameter) paramSpec.getType();
assertEquals("T", ttp.getName());
assertNull(ttp.getDefault());
- ICPPTemplateInstance inst= (ICPPTemplateInstance) b0;
- IBinding sp= inst.getSpecializedBinding();
+ ICPPTemplateInstance inst = (ICPPTemplateInstance) b0;
+ IBinding sp = inst.getSpecializedBinding();
assertInstance(sp, ICPPFunction.class);
assertInstance(sp, ICPPTemplateDefinition.class);
}
@@ -1036,7 +1041,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// func(&a, &A::m);
// }
public void testFunctionTemplate_245030() throws Exception {
- ICPPFunction f= getBindingFromFirstIdentifier("func(&a, &A::m)");
+ ICPPFunction f = getBindingFromFirstIdentifier("func(&a, &A::m)");
assertInstance(f, ICPPTemplateInstance.class);
}
@@ -1057,7 +1062,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// func(a, b);
// }
public void testFunctionTemplate_319498() throws Exception {
- ICPPFunction f= getBindingFromFirstIdentifier("func(a, b)");
+ ICPPFunction f = getBindingFromFirstIdentifier("func(a, b)");
assertInstance(f, ICPPTemplateInstance.class);
}
@@ -1099,11 +1104,11 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertInstance(b1b, ICPPClassType.class);
assertInstance(b1b, ICPPSpecialization.class);
- ICPPSpecialization b1spc= (ICPPSpecialization) b1b;
- ICPPTemplateParameterMap b1om= b1spc.getTemplateParameterMap();
+ ICPPSpecialization b1spc = (ICPPSpecialization) b1b;
+ ICPPTemplateParameterMap b1om = b1spc.getTemplateParameterMap();
assertEquals(1, b1om.getAllParameterPositions().length);
assertInstance(b1om.getArgument(0).getTypeValue(), ICPPClassType.class);
- ICPPClassType b1pct= (ICPPClassType) b1om.getArgument(0).getTypeValue();
+ ICPPClassType b1pct = (ICPPClassType) b1om.getArgument(0).getTypeValue();
assertEquals("B", b1pct.getName());
IBinding b2a = getBindingFromASTName("Foo<B> b2;", 3);
@@ -1114,11 +1119,11 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertInstance(b2b, ICPPClassType.class);
assertInstance(b2b, ICPPSpecialization.class);
- ICPPSpecialization b2spc= (ICPPSpecialization) b2b;
- ICPPTemplateParameterMap b2om= b2spc.getTemplateParameterMap();
+ ICPPSpecialization b2spc = (ICPPSpecialization) b2b;
+ ICPPTemplateParameterMap b2om = b2spc.getTemplateParameterMap();
assertEquals(1, b2om.getAllParameterPositions().length);
assertInstance(b2om.getArgument(0).getTypeValue(), ICPPClassType.class);
- ICPPClassType b2pct= (ICPPClassType) b2om.getArgument(0).getTypeValue();
+ ICPPClassType b2pct = (ICPPClassType) b2om.getArgument(0).getTypeValue();
assertEquals("B", b2pct.getName());
}
@@ -1151,40 +1156,40 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// D<A,A> daa;
public void testClassPartialSpecializations_199572() throws Exception {
- IBinding b0= getBindingFromASTName("D<A,A>", 6);
+ IBinding b0 = getBindingFromASTName("D<A,A>", 6);
assertInstance(b0, ICPPTemplateInstance.class);
assertInstance(b0, ICPPClassType.class);
- IBinding b1= getBindingFromASTName("D<A,A>", 1);
+ IBinding b1 = getBindingFromASTName("D<A,A>", 1);
assertInstance(b1, ICPPTemplateDefinition.class);
assertInstance(b1, ICPPClassType.class);
}
- // template<typename _TpAllocator>
- // class Allocator {
- // public:
- // typedef _TpAllocator& alloc_reference;
- // };
+ // template<typename _TpAllocator>
+ // class Allocator {
+ // public:
+ // typedef _TpAllocator& alloc_reference;
+ // };
//
- // template<typename _TpRebind>
- // struct rebind {
- // typedef Allocator<_TpRebind> other;
- // };
+ // template<typename _TpRebind>
+ // struct rebind {
+ // typedef Allocator<_TpRebind> other;
+ // };
//
- // template<typename _Tp, typename _Alloc = Allocator<_Tp> >
- // class Vec {
- // public:
- // typedef typename rebind<_Tp>::other::alloc_reference reference;
- // };
+ // template<typename _Tp, typename _Alloc = Allocator<_Tp> >
+ // class Vec {
+ // public:
+ // typedef typename rebind<_Tp>::other::alloc_reference reference;
+ // };
// void f(Vec<int>::reference r) {}
- public void testTemplateTypedef_214447() throws Exception {
- IBinding b0= getBindingFromASTName("r)", 1);
- assertInstance(b0, ICPPVariable.class);
+ public void testTemplateTypedef_214447() throws Exception {
+ IBinding b0 = getBindingFromASTName("r)", 1);
+ assertInstance(b0, ICPPVariable.class);
IType type = ((ICPPVariable) b0).getType();
type = SemanticUtil.getUltimateType(type, false);
assertInstance(type, IBasicType.class);
assertEquals("int", ASTTypeUtil.getType(type));
- }
+ }
// template <typename T>
// struct D;
@@ -1236,14 +1241,14 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// class D : public C<T> {};
// class E : public C<A> {};
// void foo(B b) {}
- // template<>
- // class C<X> {
- // public:
+ // template<>
+ // class C<X> {
+ // public:
// X t;
// operator B() {B b; return b;}
- // };
+ // };
- // class F : public C<A> {};
+ // class F : public C<A> {};
// void refs() {
// C<A> c;
// foo(c);
@@ -1251,108 +1256,110 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// foo(d);
// E e;
// foo(e);
- // F f;
+ // F f;
// foo(f);
- // C<X> cx;
- // foo(cx);
+ // C<X> cx;
+ // foo(cx);
// }
- public void testUserDefinedConversionOperator_224364() throws Exception {
- IBinding ca= getBindingFromASTName("C<A>", 4);
- assertInstance(ca, ICPPClassType.class);
- assertInstance(ca, ICPPTemplateInstance.class);
+ public void testUserDefinedConversionOperator_224364() throws Exception {
+ IBinding ca = getBindingFromASTName("C<A>", 4);
+ assertInstance(ca, ICPPClassType.class);
+ assertInstance(ca, ICPPTemplateInstance.class);
- IBinding foo1= getBindingFromASTName("foo(c)", 3);
+ IBinding foo1 = getBindingFromASTName("foo(c)", 3);
- IBinding da= getBindingFromASTName("D<A>", 4);
- assertInstance(da, ICPPClassType.class);
- assertInstance(da, ICPPTemplateInstance.class);
+ IBinding da = getBindingFromASTName("D<A>", 4);
+ assertInstance(da, ICPPClassType.class);
+ assertInstance(da, ICPPTemplateInstance.class);
- IBinding foo2= getBindingFromASTName("foo(d)", 3);
- IBinding foo3= getBindingFromASTName("foo(e)", 3);
- IBinding foo4= getBindingFromASTName("foo(cx)", 3);
+ IBinding foo2 = getBindingFromASTName("foo(d)", 3);
+ IBinding foo3 = getBindingFromASTName("foo(e)", 3);
+ IBinding foo4 = getBindingFromASTName("foo(cx)", 3);
assertEquals(foo1, foo2);
assertEquals(foo2, foo3);
assertEquals(foo3, foo4);
- }
-
- // template<typename T>
- // class A {};
- //
- // class B {};
- //
- // template<>
- // class A<B> {};
-
- // class C {};
- //
- // A<B> ab;
- // A<C> ac;
- public void testEnclosingScopes_a() throws Exception {
- ICPPSpecialization b0= getBindingFromASTName("A<B>", 4, ICPPSpecialization.class, ICPPClassType.class);
- ICPPTemplateInstance b1= getBindingFromASTName("A<C>", 4, ICPPTemplateInstance.class, ICPPClassType.class);
-
- ICPPClassType sc0= assertInstance(b0.getSpecializedBinding(), ICPPClassType.class);
- ICPPClassType sc1= assertInstance(b1.getSpecializedBinding(), ICPPClassType.class);
- assertTrue(sc0.isSameType(sc1));
-
- assertEquals(EScopeKind.eGlobal, sc0.getScope().getKind());
- assertEquals(EScopeKind.eGlobal, b0.getScope().getKind());
- }
-
- // template<typename T>
- // class A {
- // public:
- // class B {};
- // };
- //
- // class C {}; class D {};
- //
- // template<>
- // class A<C> {
- // public:
- // class B {};
- // };
-
- // void refs() {
- // A<C>::B acb;
- // A<D>::B adb;
- // }
- public void testEnclosingScopes_b() throws Exception {
- ICPPClassType b0= getBindingFromASTName("B acb", 1, ICPPClassType.class);
- ICPPClassType b1= getBindingFromASTName("B adb", 1, ICPPClassType.class, ICPPSpecialization.class);
- ICPPClassType b2= getBindingFromASTName("A<C>", 4, ICPPClassType.class, ICPPSpecialization.class);
-
- IIndexBinding[] sr = getIndex().findBindings("A".toCharArray(), new IndexFilter() {
- @Override
- public boolean acceptBinding(IBinding binding) throws CoreException {
- return !(binding instanceof ICPPSpecialization);
- }
- }, npm());
- assertTrue(sr.length == 1);
- ICPPClassType b3= (ICPPClassType) sr[0];
-
- sr = getIndex().findBindings(new char[][] {"A".toCharArray(), "B".toCharArray()}, new IndexFilter() {
- @Override
- public boolean acceptBinding(IBinding binding) throws CoreException {
- return binding instanceof ICPPSpecialization;
- }
- }, npm());
- assertTrue(sr.length == 1);
- ICPPClassType b4= (ICPPClassType) sr[0];
-
- assertFalse(b0 instanceof ICPPSpecialization);
-
- IIndexScope s0= (IIndexScope) b0.getScope();
- IIndexScope s4= (IIndexScope) b4.getScope();
- IScope s1= b1.getScope();
-
- assertTrue(((IType)s0.getScopeBinding()).isSameType((IType)((IIndexScope)b2.getCompositeScope()).getScopeBinding()));
- ICPPClassScope cs1= assertInstance(s1, ICPPClassScope.class);
- assertInstance(cs1.getClassType(), ICPPClassType.class);
- assertInstance(cs1.getClassType(), ICPPTemplateInstance.class);
- assertTrue(((IType)((ICPPClassSpecialization) s4.getScopeBinding()).getSpecializedBinding()).isSameType( (IType) ((IIndexScope)b3.getCompositeScope()).getScopeBinding() ));
- }
+ }
+
+ // template<typename T>
+ // class A {};
+ //
+ // class B {};
+ //
+ // template<>
+ // class A<B> {};
+
+ // class C {};
+ //
+ // A<B> ab;
+ // A<C> ac;
+ public void testEnclosingScopes_a() throws Exception {
+ ICPPSpecialization b0 = getBindingFromASTName("A<B>", 4, ICPPSpecialization.class, ICPPClassType.class);
+ ICPPTemplateInstance b1 = getBindingFromASTName("A<C>", 4, ICPPTemplateInstance.class, ICPPClassType.class);
+
+ ICPPClassType sc0 = assertInstance(b0.getSpecializedBinding(), ICPPClassType.class);
+ ICPPClassType sc1 = assertInstance(b1.getSpecializedBinding(), ICPPClassType.class);
+ assertTrue(sc0.isSameType(sc1));
+
+ assertEquals(EScopeKind.eGlobal, sc0.getScope().getKind());
+ assertEquals(EScopeKind.eGlobal, b0.getScope().getKind());
+ }
+
+ // template<typename T>
+ // class A {
+ // public:
+ // class B {};
+ // };
+ //
+ // class C {}; class D {};
+ //
+ // template<>
+ // class A<C> {
+ // public:
+ // class B {};
+ // };
+
+ // void refs() {
+ // A<C>::B acb;
+ // A<D>::B adb;
+ // }
+ public void testEnclosingScopes_b() throws Exception {
+ ICPPClassType b0 = getBindingFromASTName("B acb", 1, ICPPClassType.class);
+ ICPPClassType b1 = getBindingFromASTName("B adb", 1, ICPPClassType.class, ICPPSpecialization.class);
+ ICPPClassType b2 = getBindingFromASTName("A<C>", 4, ICPPClassType.class, ICPPSpecialization.class);
+
+ IIndexBinding[] sr = getIndex().findBindings("A".toCharArray(), new IndexFilter() {
+ @Override
+ public boolean acceptBinding(IBinding binding) throws CoreException {
+ return !(binding instanceof ICPPSpecialization);
+ }
+ }, npm());
+ assertTrue(sr.length == 1);
+ ICPPClassType b3 = (ICPPClassType) sr[0];
+
+ sr = getIndex().findBindings(new char[][] { "A".toCharArray(), "B".toCharArray() }, new IndexFilter() {
+ @Override
+ public boolean acceptBinding(IBinding binding) throws CoreException {
+ return binding instanceof ICPPSpecialization;
+ }
+ }, npm());
+ assertTrue(sr.length == 1);
+ ICPPClassType b4 = (ICPPClassType) sr[0];
+
+ assertFalse(b0 instanceof ICPPSpecialization);
+
+ IIndexScope s0 = (IIndexScope) b0.getScope();
+ IIndexScope s4 = (IIndexScope) b4.getScope();
+ IScope s1 = b1.getScope();
+
+ assertTrue(((IType) s0.getScopeBinding())
+ .isSameType((IType) ((IIndexScope) b2.getCompositeScope()).getScopeBinding()));
+ ICPPClassScope cs1 = assertInstance(s1, ICPPClassScope.class);
+ assertInstance(cs1.getClassType(), ICPPClassType.class);
+ assertInstance(cs1.getClassType(), ICPPTemplateInstance.class);
+ assertTrue(((IType) ((ICPPClassSpecialization) s4.getScopeBinding()).getSpecializedBinding())
+ .isSameType((IType) ((IIndexScope) b3.getCompositeScope()).getScopeBinding()));
+ }
// class A {};
//
@@ -1366,45 +1373,45 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// };
// X<A>::Y::Z xayz;
- public void testEnclosingScopes_c() throws Exception {
- ICPPClassType b0= getBindingFromASTName("Y::Z x", 1, ICPPClassType.class);
- ICPPClassType b1= getBindingFromASTName("Z xayz", 1, ICPPClassType.class);
-
- IScope s0= b0.getScope(), s1= b1.getScope();
-
- ICPPClassScope cs0= assertInstance(s0, ICPPClassScope.class);
- assertInstance(cs0.getClassType(), ICPPClassType.class);
- assertInstance(cs0.getClassType(), ICPPSpecialization.class);
-
- ICPPClassScope cs1= assertInstance(s1, ICPPClassScope.class);
- assertInstance(cs1.getClassType(), ICPPClassType.class);
- assertInstance(cs1.getClassType(), ICPPSpecialization.class);
- }
-
- // class A {}; class B {};
- //
- // template<typename T1, typename T2>
- // class X {};
- //
- // template<typename T3>
- // class X<T3, A> {
- // public:
- // class N {};
- // };
-
- // X<B,A>::N n;
- public void testEnclosingScopes_d() throws Exception {
- ICPPClassType b0= getBindingFromASTName("N n", 1, ICPPClassType.class, ICPPSpecialization.class);
- ICPPClassType b1= assertInstance(((ICPPSpecialization) b0).getSpecializedBinding(), ICPPClassType.class);
-
- ICPPClassScope s0= assertInstance(b0.getScope(), ICPPClassScope.class);
- assertInstance(s0.getClassType(), ICPPTemplateInstance.class);
-
- ICPPClassScope s1= assertInstance(b1.getScope(), ICPPClassScope.class);
- assertInstance(s1.getClassType(), ICPPTemplateDefinition.class);
-
- assertEquals(EScopeKind.eGlobal, s1.getClassType().getScope().getKind());
- }
+ public void testEnclosingScopes_c() throws Exception {
+ ICPPClassType b0 = getBindingFromASTName("Y::Z x", 1, ICPPClassType.class);
+ ICPPClassType b1 = getBindingFromASTName("Z xayz", 1, ICPPClassType.class);
+
+ IScope s0 = b0.getScope(), s1 = b1.getScope();
+
+ ICPPClassScope cs0 = assertInstance(s0, ICPPClassScope.class);
+ assertInstance(cs0.getClassType(), ICPPClassType.class);
+ assertInstance(cs0.getClassType(), ICPPSpecialization.class);
+
+ ICPPClassScope cs1 = assertInstance(s1, ICPPClassScope.class);
+ assertInstance(cs1.getClassType(), ICPPClassType.class);
+ assertInstance(cs1.getClassType(), ICPPSpecialization.class);
+ }
+
+ // class A {}; class B {};
+ //
+ // template<typename T1, typename T2>
+ // class X {};
+ //
+ // template<typename T3>
+ // class X<T3, A> {
+ // public:
+ // class N {};
+ // };
+
+ // X<B,A>::N n;
+ public void testEnclosingScopes_d() throws Exception {
+ ICPPClassType b0 = getBindingFromASTName("N n", 1, ICPPClassType.class, ICPPSpecialization.class);
+ ICPPClassType b1 = assertInstance(((ICPPSpecialization) b0).getSpecializedBinding(), ICPPClassType.class);
+
+ ICPPClassScope s0 = assertInstance(b0.getScope(), ICPPClassScope.class);
+ assertInstance(s0.getClassType(), ICPPTemplateInstance.class);
+
+ ICPPClassScope s1 = assertInstance(b1.getScope(), ICPPClassScope.class);
+ assertInstance(s1.getClassType(), ICPPTemplateDefinition.class);
+
+ assertEquals(EScopeKind.eGlobal, s1.getClassType().getScope().getKind());
+ }
// typedef signed int SI;
//
@@ -1413,13 +1420,13 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// const SI y= 99;
// A<y> ay;
- public void testNonTypeTemplateParameter_207840() {
- ICPPVariable b0= getBindingFromASTName("y>", 1, ICPPVariable.class);
- ICPPClassType b1= getBindingFromASTName("A<y>", 1, ICPPClassType.class, ICPPTemplateDefinition.class);
- ICPPTemplateInstance b2= getBindingFromASTName("A<y>", 4, ICPPTemplateInstance.class, ICPPClassType.class);
- ICPPTemplateParameterMap args= b2.getTemplateParameterMap();
- assertEquals(1, args.getAllParameterPositions().length);
- }
+ public void testNonTypeTemplateParameter_207840() {
+ ICPPVariable b0 = getBindingFromASTName("y>", 1, ICPPVariable.class);
+ ICPPClassType b1 = getBindingFromASTName("A<y>", 1, ICPPClassType.class, ICPPTemplateDefinition.class);
+ ICPPTemplateInstance b2 = getBindingFromASTName("A<y>", 4, ICPPTemplateInstance.class, ICPPClassType.class);
+ ICPPTemplateParameterMap args = b2.getTemplateParameterMap();
+ assertEquals(1, args.getAllParameterPositions().length);
+ }
// template <class T> class A {
// class B { T t; };
@@ -1485,7 +1492,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// }
public void testVectorIterator() throws Exception {
ICPPField t2 = getBindingFromASTName("member; // it->member", 6, ICPPField.class);
- ICPPClassType ct= t2.getClassOwner();
+ ICPPClassType ct = t2.getClassOwner();
assertEquals("MyStruct", ct.getName());
final IType type = t2.getType();
@@ -1547,17 +1554,17 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// A<B, 'y'>::Y y;
// A<B, 'z'>::Z z;
public void testNonTypeCharArgumentDisambiguation() throws Exception {
- ICPPClassType b2= getBindingFromASTName("A<B, 'x'>", 9, ICPPClassType.class, ICPPTemplateInstance.class);
- ICPPClassType b3= getBindingFromASTName("A<B, 'y'>", 9, ICPPClassType.class, ICPPTemplateInstance.class);
- ICPPClassType b4= getBindingFromASTName("A<B, 'z'>", 9, ICPPClassType.class, ICPPTemplateInstance.class);
+ ICPPClassType b2 = getBindingFromASTName("A<B, 'x'>", 9, ICPPClassType.class, ICPPTemplateInstance.class);
+ ICPPClassType b3 = getBindingFromASTName("A<B, 'y'>", 9, ICPPClassType.class, ICPPTemplateInstance.class);
+ ICPPClassType b4 = getBindingFromASTName("A<B, 'z'>", 9, ICPPClassType.class, ICPPTemplateInstance.class);
assertTrue(!b2.isSameType(b3));
assertTrue(!b3.isSameType(b4));
assertTrue(!b4.isSameType(b2));
- ICPPClassType X= getBindingFromASTName("X x", 1, ICPPClassType.class);
- ICPPClassType Y= getBindingFromASTName("Y y", 1, ICPPClassType.class);
- ICPPClassType Z= getBindingFromASTName("Z z", 1, ICPPClassType.class);
+ ICPPClassType X = getBindingFromASTName("X x", 1, ICPPClassType.class);
+ ICPPClassType Y = getBindingFromASTName("Y y", 1, ICPPClassType.class);
+ ICPPClassType Z = getBindingFromASTName("Z z", 1, ICPPClassType.class);
assertTrue(!X.isSameType(Y));
assertTrue(!Y.isSameType(Z));
@@ -1575,8 +1582,8 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// A<B, true>::X x; //3 should be an error
// A<B, false>::Y y; //4 should be an error
public void testNonTypeBooleanArgumentDisambiguation() throws Exception {
- ICPPClassType X= getBindingFromASTName("X x; //1", 1, ICPPClassType.class);
- ICPPClassType Y= getBindingFromASTName("Y y; //2", 1, ICPPClassType.class);
+ ICPPClassType X = getBindingFromASTName("X x; //1", 1, ICPPClassType.class);
+ ICPPClassType Y = getBindingFromASTName("Y y; //2", 1, ICPPClassType.class);
getProblemFromASTName("X x; //3", 1);
getProblemFromASTName("Y y; //4", 1);
@@ -1598,11 +1605,11 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// A<1> a1;
// }
public void testConstantPropagationFromHeader() throws Exception {
- ICPPClassType a5a= getBindingFromASTName("A<FIVE>", 7, ICPPClassType.class, ICPPSpecialization.class);
- ICPPClassType a5b= getBindingFromASTName("A<CINQ>", 7, ICPPClassType.class, ICPPSpecialization.class);
- ICPPClassType a5c= getBindingFromASTName("A<FUNF>", 7, ICPPClassType.class, ICPPSpecialization.class);
- ICPPClassType a5d= getBindingFromASTName("A<5>", 4, ICPPClassType.class, ICPPSpecialization.class);
- ICPPClassType a1= getBindingFromASTName("A<1>", 4, ICPPClassType.class, ICPPTemplateInstance.class);
+ ICPPClassType a5a = getBindingFromASTName("A<FIVE>", 7, ICPPClassType.class, ICPPSpecialization.class);
+ ICPPClassType a5b = getBindingFromASTName("A<CINQ>", 7, ICPPClassType.class, ICPPSpecialization.class);
+ ICPPClassType a5c = getBindingFromASTName("A<FUNF>", 7, ICPPClassType.class, ICPPSpecialization.class);
+ ICPPClassType a5d = getBindingFromASTName("A<5>", 4, ICPPClassType.class, ICPPSpecialization.class);
+ ICPPClassType a1 = getBindingFromASTName("A<1>", 4, ICPPClassType.class, ICPPTemplateInstance.class);
assertTrue(a5a.isSameType(a5b));
assertTrue(a5b.isSameType(a5c));
@@ -1615,7 +1622,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertTrue(!a1.isSameType(a5d));
}
- // template<int I>
+ // template<int I>
// class That {
// public:
// That(int x) {}
@@ -1640,9 +1647,9 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertFalse(th1sCtor instanceof ICPPSpecialization);ICPPTemplateNonTypeParameter np= ba.assertNonProblem("I)", 1, ICPPTemplateNonTypeParameter.class);
*/
- ICPPTemplateNonTypeParameter np= getBindingFromASTName("I>(I)", 1, ICPPTemplateNonTypeParameter.class);
- ICPPConstructor clazz= getBindingFromASTName("That<I>(I)", 4, ICPPConstructor.class);
- ICPPConstructor ctor= getBindingFromASTName("That<I>(I)", 7, ICPPConstructor.class);
+ ICPPTemplateNonTypeParameter np = getBindingFromASTName("I>(I)", 1, ICPPTemplateNonTypeParameter.class);
+ ICPPConstructor clazz = getBindingFromASTName("That<I>(I)", 4, ICPPConstructor.class);
+ ICPPConstructor ctor = getBindingFromASTName("That<I>(I)", 7, ICPPConstructor.class);
}
// template<typename I>
@@ -1661,32 +1668,31 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// inline This<I>::This() : That<I>() {
// }
public void testParameterReferenceInChainInitializer_b() throws Exception {
- ICPPClassType tid= getBindingFromASTName("This<I>::T", 7, ICPPClassType.class);
+ ICPPClassType tid = getBindingFromASTName("This<I>::T", 7, ICPPClassType.class);
assertFalse(tid instanceof ICPPSpecialization);
- ICPPConstructor th1sCtor= getBindingFromASTName("This() :", 4, ICPPConstructor.class);
+ ICPPConstructor th1sCtor = getBindingFromASTName("This() :", 4, ICPPConstructor.class);
assertFalse(th1sCtor instanceof ICPPSpecialization);
- ICPPTemplateTypeParameter np= getBindingFromASTName("I>()", 1, ICPPTemplateTypeParameter.class);
- ICPPConstructor clazz= getBindingFromASTName("That<I>()", 4, ICPPConstructor.class);
- ICPPConstructor ctor= getBindingFromASTName("That<I>()", 7, ICPPConstructor.class);
+ ICPPTemplateTypeParameter np = getBindingFromASTName("I>()", 1, ICPPTemplateTypeParameter.class);
+ ICPPConstructor clazz = getBindingFromASTName("That<I>()", 4, ICPPConstructor.class);
+ ICPPConstructor ctor = getBindingFromASTName("That<I>()", 7, ICPPConstructor.class);
}
-
// template<typename T> class CT {
// public: int field;
// };
// CT<int> v1;
public void testUniqueSpecializations_241641() throws Exception {
- ICPPVariable v1= getBindingFromASTName("v1", 2, ICPPVariable.class);
- ICPPVariable v2= getBindingFromASTName("v1", 2, ICPPVariable.class);
+ ICPPVariable v1 = getBindingFromASTName("v1", 2, ICPPVariable.class);
+ ICPPVariable v2 = getBindingFromASTName("v1", 2, ICPPVariable.class);
- IType t1= v1.getType();
+ IType t1 = v1.getType();
assertInstance(t1, ICPPClassType.class);
- ICPPClassType ct= (ICPPClassType) t1;
- IBinding f1= ct.getCompositeScope().find("field")[0];
- IBinding f2= ct.getCompositeScope().find("field")[0];
+ ICPPClassType ct = (ICPPClassType) t1;
+ IBinding f1 = ct.getCompositeScope().find("field")[0];
+ IBinding f2 = ct.getCompositeScope().find("field")[0];
assertSame(f1, f2);
}
@@ -1697,19 +1703,21 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// CT<int> v1;
public void testUniqueInstance_241641() throws Exception {
- IASTName name= findName("v1", 2);
- ICPPVariable v1= getBindingFromASTName("v1", 2, ICPPVariable.class);
+ IASTName name = findName("v1", 2);
+ ICPPVariable v1 = getBindingFromASTName("v1", 2, ICPPVariable.class);
- IType t1= v1.getType();
+ IType t1 = v1.getType();
assertInstance(t1, ICPPTemplateInstance.class);
- ICPPTemplateInstance inst= (ICPPTemplateInstance) t1;
+ ICPPTemplateInstance inst = (ICPPTemplateInstance) t1;
final ICPPClassTemplate tmplDef = (ICPPClassTemplate) inst.getTemplateDefinition();
- IBinding inst2= CPPTemplates.instantiate(tmplDef, inst.getTemplateArguments());
+ IBinding inst2 = CPPTemplates.instantiate(tmplDef, inst.getTemplateArguments());
assertSame(inst, inst2);
- IBinding charInst1= CPPTemplates.instantiate(tmplDef, new ICPPTemplateArgument[] {new CPPTemplateTypeArgument(new CPPBasicType(Kind.eChar, 0))});
- IBinding charInst2= CPPTemplates.instantiate(tmplDef, new ICPPTemplateArgument[] {new CPPTemplateTypeArgument(new CPPBasicType(Kind.eChar, 0))});
+ IBinding charInst1 = CPPTemplates.instantiate(tmplDef,
+ new ICPPTemplateArgument[] { new CPPTemplateTypeArgument(new CPPBasicType(Kind.eChar, 0)) });
+ IBinding charInst2 = CPPTemplates.instantiate(tmplDef,
+ new ICPPTemplateArgument[] { new CPPTemplateTypeArgument(new CPPBasicType(Kind.eChar, 0)) });
assertSame(charInst1, charInst2);
}
@@ -1722,50 +1730,49 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// x.method();
// }
public void testMethodSpecialization_248927() throws Exception {
- ICPPMethod m= getBindingFromASTName("method", 6, ICPPMethod.class);
+ ICPPMethod m = getBindingFromASTName("method", 6, ICPPMethod.class);
assertInstance(m, ICPPSpecialization.class);
- ICPPClassType ct= m.getClassOwner();
+ ICPPClassType ct = m.getClassOwner();
assertInstance(ct, ICPPTemplateInstance.class);
- ICPPMethod[] ms= ct.getDeclaredMethods();
+ ICPPMethod[] ms = ct.getDeclaredMethods();
assertEquals(1, ms.length);
assertEquals(m, ms[0]);
}
- // template<class T, class U> class A {};
- // template<class T> class A<T, int> {
- // void foo(T t);
- // };
+ // template<class T, class U> class A {};
+ // template<class T> class A<T, int> {
+ // void foo(T t);
+ // };
// template<class T> void A<T, int>::foo(T t) {}
- public void testBug177418() throws Exception {
- ICPPMethod m= getBindingFromASTName("foo", 3, ICPPMethod.class);
- ICPPClassType owner= m.getClassOwner();
+ public void testBug177418() throws Exception {
+ ICPPMethod m = getBindingFromASTName("foo", 3, ICPPMethod.class);
+ ICPPClassType owner = m.getClassOwner();
assertInstance(owner, ICPPClassTemplatePartialSpecialization.class);
- }
-
-
- // template<typename T> class XT {
- // int f;
- // void m();
- // };
-
- // template<typename T> void XT<T>::m() {
- // m(); // 1
- // f; // 1
- // this->m(); // 2
- // this->f; // 2
- // };
- public void testUnknownBindings_264988() throws Exception {
- ICPPMethod m= getBindingFromASTName("m(); // 1", 1, ICPPMethod.class);
+ }
+
+ // template<typename T> class XT {
+ // int f;
+ // void m();
+ // };
+
+ // template<typename T> void XT<T>::m() {
+ // m(); // 1
+ // f; // 1
+ // this->m(); // 2
+ // this->f; // 2
+ // };
+ public void testUnknownBindings_264988() throws Exception {
+ ICPPMethod m = getBindingFromASTName("m(); // 1", 1, ICPPMethod.class);
assertFalse(m instanceof ICPPUnknownBinding);
- m= getBindingFromASTName("m(); // 2", 1, ICPPMethod.class);
+ m = getBindingFromASTName("m(); // 2", 1, ICPPMethod.class);
assertFalse(m instanceof ICPPUnknownBinding);
- ICPPField f= getBindingFromASTName("f; // 1", 1, ICPPField.class);
+ ICPPField f = getBindingFromASTName("f; // 1", 1, ICPPField.class);
assertFalse(f instanceof ICPPUnknownBinding);
- f= getBindingFromASTName("f; // 2", 1, ICPPField.class);
+ f = getBindingFromASTName("f; // 2", 1, ICPPField.class);
assertFalse(f instanceof ICPPUnknownBinding);
- }
+ }
// template <typename T= int> class XT;
@@ -1774,7 +1781,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// XT<> x;
// };
public void testDefaultTemplateArgInHeader_264988() throws Exception {
- ICPPTemplateInstance ti= getBindingFromASTName("XT<>", 4, ICPPTemplateInstance.class);
+ ICPPTemplateInstance ti = getBindingFromASTName("XT<>", 4, ICPPTemplateInstance.class);
}
// typedef int TInt;
@@ -1786,7 +1793,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// TInt t;
// }
public void testParentScopeOfSpecialization_267013() throws Exception {
- ITypedef ti= getBindingFromASTName("TInt", 4, ITypedef.class);
+ ITypedef ti = getBindingFromASTName("TInt", 4, ITypedef.class);
}
// struct __true_type {};
@@ -1879,7 +1886,6 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
getBindingFromASTName("Noder2<int>", 11, ICPPClassSpecialization.class);
}
-
// template <typename> struct CT;
// template <typename T> struct CT {
// T f;
@@ -1895,7 +1901,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
public void testTemplateParameterWithoutName_300978() throws Exception {
getBindingFromASTName("x;", 1, ICPPField.class);
ICPPClassSpecialization ctx = getBindingFromASTName("CT<X>", 5, ICPPClassSpecialization.class);
- ICPPClassTemplate ct= (ICPPClassTemplate) ctx.getSpecializedBinding();
+ ICPPClassTemplate ct = (ICPPClassTemplate) ctx.getSpecializedBinding();
assertEquals("T", ct.getTemplateParameters()[0].getName());
}
@@ -1914,7 +1920,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// }
public void testExplicitSpecializations_296427() throws Exception {
ICPPTemplateInstance inst;
- inst= getBindingFromASTName("X<int>", 0);
+ inst = getBindingFromASTName("X<int>", 0);
assertFalse(inst.isExplicitSpecialization());
inst = getBindingFromASTName("Y<int>", 0);
assertTrue(inst.isExplicitSpecialization());
@@ -1990,14 +1996,14 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// TXT x;
public void testClassSpecialization_354086() throws Exception {
- ICPPClassType ct= getBindingFromASTName("TXT", 0, ICPPClassType.class);
+ ICPPClassType ct = getBindingFromASTName("TXT", 0, ICPPClassType.class);
ICPPMethod[] methods = ct.getAllDeclaredMethods();
assertEquals(2, methods.length);
- methods= ct.getConstructors();
+ methods = ct.getConstructors();
assertEquals(2, methods.length);
- methods= ct.getMethods();
+ methods = ct.getMethods();
assertEquals(14, methods.length);
ICPPBase[] bases = ct.getBases();
@@ -2115,7 +2121,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// };
// typedef foo<remove_const<const int>::type>::type t;
public void testCurrentInstanceOfClassTemplatePartialSpec_368404() throws Exception {
- ITypedef tdef= getBindingFromASTName("type t;", 4, ITypedef.class);
+ ITypedef tdef = getBindingFromASTName("type t;", 4, ITypedef.class);
assertEquals("int", ASTTypeUtil.getType(tdef, true));
}
@@ -2634,7 +2640,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// static_assert(D<10>(1000000000) == 10, "");
public void testOOM_497875() throws Exception {
// TODO(sprigogin): Uncomment after http://bugs.eclipse.org/497931 is fixed.
-// checkBindings();
+ // checkBindings();
}
// template <typename>
@@ -2847,7 +2853,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
public void testInfiniteRecursionMarshallingTemplateDefinition_439923() throws Exception {
checkBindings();
}
-
+
// template<typename T> struct Constraint {
// typedef T Type;
// static const int Scale = 1;
@@ -2863,7 +2869,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// void Operations<4>::operation(typename Constraint<Q>::Type) {
// value<Q>(Constraint<Q>::Scale);
// }
-
+
// // empty source file
public void testInfiniteRecursion_516648() throws Exception {
checkBindings();
@@ -3033,17 +3039,17 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
public void testStackOverflow_462764() throws Exception {
checkBindings();
}
-
+
// template <typename>
// struct base {
// constexpr base() {}
// };
- //
+ //
// template <typename T>
// struct derived : base<T> {
// constexpr derived() : base<T>() {}
// };
-
+
// derived<int> waldo;
public void testSerializationOfUnknownConstructor_490475() throws Exception {
IASTName waldoName = findName("waldo", 5);
@@ -3056,25 +3062,25 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// Trigger deserialization of constructor chain execution
((ICPPConstructor) constructor).getConstructorChainExecution(waldoName);
}
-
+
// template <typename F>
// struct S {
// F f;
- // };
+ // };
//
// template <typename F>
// auto foo(F f) -> decltype(S<F>{f});
-
+
// void bar() {
// foo([]{});
// }
public void testBracedInitList_490475() throws Exception {
checkBindings();
}
-
+
// struct Cat { void meow(); };
// struct Dog { void woof(); };
-
+
// template <typename T>
// Dog bar(T);
//
@@ -3090,11 +3096,11 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
public void testUnqualifiedFunctionCallInTemplate_402498() throws Exception {
checkBindings();
}
-
+
// template<typename T> struct traits;
- // template <typename> struct M;
- //
+ // template <typename> struct M;
+ //
// template<typename T>
// struct traits<M<T>> {
// typedef T type;
@@ -3117,7 +3123,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// struct normal<T*> {
// typedef T value_type;
// };
-
+
// template <class Iterator>
// struct iterator_value {
// typedef typename iterator_traits<Iterator>::value_type type;
@@ -3148,14 +3154,14 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// };
//
// void waldo(char);
- //
+ //
// void foo(sub_match<Iter> w) {
// waldo(w);
// }
public void testRegression_516338() throws Exception {
checkBindings();
}
-
+
// struct Foo {
// char value[1];
// constexpr Foo() : value{0} {
@@ -3163,12 +3169,12 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// }
// };
// constexpr auto foo = Foo{};
-
+
// // empty file
public void testAssignmentToMemberArrayElement_514363() throws Exception {
checkBindings();
}
-
+
// template <typename>
// struct Outer {
// static struct {
@@ -3177,14 +3183,14 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// };
//
// auto waldo = Outer<int>::static_field;
-
+
// int x = waldo.field;
public void testSpecializationOfAnonymousClass_528456() throws Exception {
checkBindings();
}
-
+
// // empty file
-
+
// namespace std {
// template <class E>
// struct initializer_list {
@@ -3213,10 +3219,10 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
public void testConstexprInitListConstructor_519091() throws Exception {
checkBindings();
}
-
+
// template <typename T> T&& declval();
- //
- // template <typename Value, typename Func,
+ //
+ // template <typename Value, typename Func,
// typename Requires = decltype(declval<Func>()(declval<Value>()))>
// void apply(Value, Func);
//
@@ -3227,14 +3233,14 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
//
// void consume(int);
// void callInCpp1(int i);
-
+
// void callInCpp1(int i) {
// apply(i, &consume);
// }
public void testClassCastException_533216() throws Exception {
checkBindings();
}
-
+
// template <int N>
// struct array {};
//
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPVariableTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPVariableTemplateResolutionTest.java
index 118dd6430b8..d33fb2b7140 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPVariableTemplateResolutionTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPVariableTemplateResolutionTest.java
@@ -86,8 +86,8 @@ public class IndexCPPVariableTemplateResolutionTest extends IndexBindingResoluti
public void testExplicitVariableInstance() {
checkBindings();
ICPPVariableTemplate pi = getBindingFromASTName("pi", 0);
- ICPPVariableInstance piOfInt =
- getBindingFromASTName("pi<int>", 0, ICPPVariableInstance.class, IIndexBinding.class);
+ ICPPVariableInstance piOfInt = getBindingFromASTName("pi<int>", 0, ICPPVariableInstance.class,
+ IIndexBinding.class);
assertEquals(pi, piOfInt.getSpecializedBinding());
}
@@ -101,8 +101,8 @@ public class IndexCPPVariableTemplateResolutionTest extends IndexBindingResoluti
public void testExplicitFieldInstance() {
checkBindings();
ICPPFieldTemplate pi = getBindingFromASTName("pi", 0);
- ICPPVariableInstance piOfDouble = getBindingFromASTName("pi<double>", 0,
- ICPPVariableInstance.class, ICPPField.class, IIndexBinding.class);
+ ICPPVariableInstance piOfDouble = getBindingFromASTName("pi<double>", 0, ICPPVariableInstance.class,
+ ICPPField.class, IIndexBinding.class);
assertEquals(pi, piOfDouble.getSpecializedBinding());
}
@@ -114,8 +114,8 @@ public class IndexCPPVariableTemplateResolutionTest extends IndexBindingResoluti
public void testVariableSpecialization() {
checkBindings();
ICPPVariableTemplate pi = getBindingFromASTName("pi", 0);
- ICPPVariableInstance piOfInt =
- getBindingFromASTName("pi<int>", 0, ICPPVariableInstance.class, IIndexBinding.class);
+ ICPPVariableInstance piOfInt = getBindingFromASTName("pi<int>", 0, ICPPVariableInstance.class,
+ IIndexBinding.class);
assertEquals(pi, piOfInt.getSpecializedBinding());
}
@@ -129,8 +129,8 @@ public class IndexCPPVariableTemplateResolutionTest extends IndexBindingResoluti
public void testFieldSpecialization() {
checkBindings();
ICPPFieldTemplate pi = getBindingFromASTName("pi", 0);
- ICPPVariableInstance piOfDouble = getBindingFromASTName("pi<double>", 0,
- ICPPVariableInstance.class, ICPPField.class, IIndexBinding.class);
+ ICPPVariableInstance piOfDouble = getBindingFromASTName("pi<double>", 0, ICPPVariableInstance.class,
+ ICPPField.class, IIndexBinding.class);
assertEquals(pi, piOfDouble.getSpecializedBinding());
}
@@ -142,8 +142,8 @@ public class IndexCPPVariableTemplateResolutionTest extends IndexBindingResoluti
// template<> constexpr double S::pi<double> = 4;
public void testFieldSpecializationInRef() {
checkBindings();
- ICPPVariableInstance piOfDouble = getBindingFromASTName("pi<double>", 0,
- ICPPVariableInstance.class, ICPPField.class);
+ ICPPVariableInstance piOfDouble = getBindingFromASTName("pi<double>", 0, ICPPVariableInstance.class,
+ ICPPField.class);
}
// template<typename T, int I> T c = T(I);
@@ -154,11 +154,10 @@ public class IndexCPPVariableTemplateResolutionTest extends IndexBindingResoluti
checkBindings();
ICPPVariableTemplate c = getBindingFromASTName("c", 0);
- ICPPVariableInstance cOfFloat = getBindingFromASTName("c<float, 100>", 0,
- ICPPVariableInstance.class);
+ ICPPVariableInstance cOfFloat = getBindingFromASTName("c<float, 100>", 0, ICPPVariableInstance.class);
- assertInstance(cOfFloat.getSpecializedBinding(),
- ICPPVariableTemplatePartialSpecialization.class, IIndexBinding.class);
+ assertInstance(cOfFloat.getSpecializedBinding(), ICPPVariableTemplatePartialSpecialization.class,
+ IIndexBinding.class);
assertEquals(c,
((ICPPVariableTemplatePartialSpecialization) cOfFloat.getSpecializedBinding()).getPrimaryTemplate());
@@ -172,11 +171,10 @@ public class IndexCPPVariableTemplateResolutionTest extends IndexBindingResoluti
checkBindings();
ICPPVariableTemplate c = getBindingFromASTName("c", 0);
- ICPPVariableInstance cOfIntPtr = getBindingFromASTName("c<int*>", 0,
- ICPPVariableInstance.class);
+ ICPPVariableInstance cOfIntPtr = getBindingFromASTName("c<int*>", 0, ICPPVariableInstance.class);
- assertInstance(cOfIntPtr.getSpecializedBinding(),
- ICPPVariableTemplatePartialSpecialization.class, IIndexBinding.class);
+ assertInstance(cOfIntPtr.getSpecializedBinding(), ICPPVariableTemplatePartialSpecialization.class,
+ IIndexBinding.class);
assertEquals(c,
((ICPPVariableTemplatePartialSpecialization) cOfIntPtr.getSpecializedBinding()).getPrimaryTemplate());
@@ -192,16 +190,16 @@ public class IndexCPPVariableTemplateResolutionTest extends IndexBindingResoluti
checkBindings();
ICPPVariableTemplate c = getBindingFromASTName("c", 0);
- ICPPVariableInstance cOfIntPtr = getBindingFromASTName("c<float, 100>", 0,
- ICPPVariableInstance.class, ICPPField.class);
+ ICPPVariableInstance cOfIntPtr = getBindingFromASTName("c<float, 100>", 0, ICPPVariableInstance.class,
+ ICPPField.class);
- assertInstance(cOfIntPtr.getSpecializedBinding(),
- ICPPVariableTemplatePartialSpecialization.class, IIndexBinding.class, ICPPField.class);
+ assertInstance(cOfIntPtr.getSpecializedBinding(), ICPPVariableTemplatePartialSpecialization.class,
+ IIndexBinding.class, ICPPField.class);
- assertEquals(c.getClass(),
- ((ICPPVariableTemplatePartialSpecialization) cOfIntPtr.getSpecializedBinding()).getPrimaryTemplate().getClass());
+ assertEquals(c.getClass(), ((ICPPVariableTemplatePartialSpecialization) cOfIntPtr.getSpecializedBinding())
+ .getPrimaryTemplate().getClass());
}
-
+
// template <typename T>
// constexpr bool templ = true;
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCompositeTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCompositeTests.java
index b6adee02be2..0c812759568 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCompositeTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCompositeTests.java
@@ -55,7 +55,7 @@ public class IndexCompositeTests extends BaseTestCase {
private static final int REFD = IIndexManager.ADD_DEPENDENT;
private static final int BOTH = REFS | REFD;
- private static final IndexFilter FILTER= new IndexFilter() {
+ private static final IndexFilter FILTER = new IndexFilter() {
@Override
public boolean acceptBinding(IBinding binding) throws CoreException {
if (binding instanceof ICPPMethod) {
@@ -68,8 +68,8 @@ public class IndexCompositeTests extends BaseTestCase {
IIndex index;
protected StringBuilder[] getContentsForTest(int blocks) throws IOException {
- return TestSourceReader.getContentsForTest(
- CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), blocks);
+ return TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "parser", getClass(),
+ getName(), blocks);
}
protected ICProject createAndAddProject(ProjectBuilder builder) throws Exception {
@@ -96,15 +96,23 @@ public class IndexCompositeTests extends BaseTestCase {
ICProject cprojA = createAndAddProject(pb);
projects.add(cprojA);
- setIndex(cprojB, NONE); assertBCount(1, 1);
- setIndex(cprojB, REFS); assertBCount(1, 1);
- setIndex(cprojB, REFD); assertBCount(2, 2);
- setIndex(cprojB, BOTH); assertBCount(2, 2);
+ setIndex(cprojB, NONE);
+ assertBCount(1, 1);
+ setIndex(cprojB, REFS);
+ assertBCount(1, 1);
+ setIndex(cprojB, REFD);
+ assertBCount(2, 2);
+ setIndex(cprojB, BOTH);
+ assertBCount(2, 2);
- setIndex(cprojA, NONE); assertBCount(1, 1);
- setIndex(cprojA, REFS); assertBCount(2, 2);
- setIndex(cprojA, REFD); assertBCount(1, 1);
- setIndex(cprojA, BOTH); assertBCount(2, 2);
+ setIndex(cprojA, NONE);
+ assertBCount(1, 1);
+ setIndex(cprojA, REFS);
+ assertBCount(2, 2);
+ setIndex(cprojA, REFD);
+ assertBCount(1, 1);
+ setIndex(cprojA, BOTH);
+ assertBCount(2, 2);
} finally {
for (ICProject project : projects) {
project.getProject().delete(true, true, new NullProgressMonitor());
@@ -155,15 +163,16 @@ public class IndexCompositeTests extends BaseTestCase {
* projA: 3, 3, 0, 2 + projB + projC
*/
- final int gC= 6, aC= gC + 2;
- final int gB= 6, aB= gB + 1;
- final int gA= 3, aA= gA + 3;
+ final int gC = 6, aC = gC + 2;
+ final int gB = 6, aB = gB + 1;
+ final int gA = 3, aA = gA + 3;
- final int gBC= gB + gC - 1, aBC= aB + aC - 1;
- final int gABC= gA + gBC - 1, aABC= aA + aBC - 1;
+ final int gBC = gB + gC - 1, aBC = aB + aC - 1;
+ final int gABC = gA + gBC - 1, aABC = aA + aBC - 1;
setIndex(cprojC, NONE);
- assertBCount(gC, aC); assertNamespaceXMemberCount(1);
+ assertBCount(gC, aC);
+ assertNamespaceXMemberCount(1);
assertFieldCount("C1", 1);
setIndex(cprojC, REFS);
@@ -265,22 +274,22 @@ public class IndexCompositeTests extends BaseTestCase {
projects.add(cprojC);
/* A C |
- * \ / | Depends On / References
- * B V
- *
+ * \ / | Depends On / References
+ * B V
+ *
* Defines Global, Defines Namespace, Ext. References Global, Ext. References Namespace
* projC: 7, 2, 1, 1
* projB: 4, 1, 0, 0
* projA: 4, 1, 1, 1
*/
- final int gC= 7, aC= gC + 2;
- final int gB= 4, aB= gB + 1;
- final int gA= 4, aA= gA + 1;
+ final int gC = 7, aC = gC + 2;
+ final int gB = 4, aB = gB + 1;
+ final int gA = 4, aA = gA + 1;
- final int gBC= gB + gC - 1, aBC= aB + aC - 1;
- final int gAB= gA + gB - 1, aAB= aA + aB - 1;
- final int gABC= gA + gBC - 1, aABC= aA + aBC - 1;
+ final int gBC = gB + gC - 1, aBC = aB + aC - 1;
+ final int gAB = gA + gB - 1, aAB = aA + aB - 1;
+ final int gABC = gA + gBC - 1, aABC = aA + aBC - 1;
setIndex(cprojC, NONE);
assertBCount(gBC, aBC);
@@ -363,22 +372,22 @@ public class IndexCompositeTests extends BaseTestCase {
projects.add(cprojB);
/* B |
- * / \ | Depends On / References
- * A C V
- *
+ * / \ | Depends On / References
+ * A C V
+ *
* Defines Global, Defines Namespace, References Global, References Namespace
* projC: 6, 1, 0, 0
* projB: 4, 2, 2, 1
* projA: 3, 1, 0, 0
*/
- final int gC= 6, aC= gC + 1;
- final int gB= 4, aB= gB + 2;
- final int gA= 3, aA= gA + 1;
+ final int gC = 6, aC = gC + 1;
+ final int gB = 4, aB = gB + 2;
+ final int gA = 3, aA = gA + 1;
- final int gBC= gB + gC - 1, aBC= aB + aC - 1;
- final int gAB= gA + gB - 1, aAB= aA + aB - 1;
- final int gABC= gA + gBC - 1, aABC= aA + aBC - 1;
+ final int gBC = gB + gC - 1, aBC = aB + aC - 1;
+ final int gAB = gA + gB - 1, aAB = aA + aB - 1;
+ final int gABC = gA + gBC - 1, aABC = aA + aBC - 1;
setIndex(cprojC, NONE);
assertBCount(gC, aC);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexGPPBindingResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexGPPBindingResolutionTest.java
index f24b9edef4f..1b362f46077 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexGPPBindingResolutionTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexGPPBindingResolutionTest.java
@@ -71,13 +71,23 @@ public abstract class IndexGPPBindingResolutionTest extends IndexBindingResoluti
}
public static class SingleProject extends IndexGPPBindingResolutionTest {
- public SingleProject() { setStrategy(new GPPSinglePDOMTestStrategy()); }
- public static TestSuite suite() { return suite(SingleProject.class); }
+ public SingleProject() {
+ setStrategy(new GPPSinglePDOMTestStrategy());
+ }
+
+ public static TestSuite suite() {
+ return suite(SingleProject.class);
+ }
}
public static class ProjectWithDepProj extends IndexGPPBindingResolutionTest {
- public ProjectWithDepProj() { setStrategy(new GPPReferencedProject()); }
- public static TestSuite suite() { return suite(ProjectWithDepProj.class); }
+ public ProjectWithDepProj() {
+ setStrategy(new GPPReferencedProject());
+ }
+
+ public static TestSuite suite() {
+ return suite(ProjectWithDepProj.class);
+ }
}
public static void addTests(TestSuite suite) {
@@ -93,7 +103,7 @@ public abstract class IndexGPPBindingResolutionTest extends IndexBindingResoluti
// .f = 3.1
// };
public void testDesignatedInitializer() throws Exception {
- IField f= getBindingFromASTName("f", 0);
+ IField f = getBindingFromASTName("f", 0);
}
// template <typename T>
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexIncludeTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexIncludeTest.java
index b2c26add43f..4f59f62f746 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexIncludeTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexIncludeTest.java
@@ -47,7 +47,7 @@ import junit.framework.TestSuite;
public class IndexIncludeTest extends IndexTestBase {
public static TestSuite suite() {
- TestSuite suite= suite(IndexIncludeTest.class, "_");
+ TestSuite suite = suite(IndexIncludeTest.class, "_");
suite.addTest(new IndexIncludeTest("deleteProject"));
return suite;
}
@@ -63,14 +63,14 @@ public class IndexIncludeTest extends IndexTestBase {
public void setUp() throws Exception {
super.setUp();
if (fProject == null) {
- fProject= createProject(true, "resources/indexTests/includes");
- IPathEntry[] entries= new IPathEntry[] {
- CoreModel.newIncludeEntry(fProject.getPath(), null,
- fProject.getResource().getLocation()) };
+ fProject = createProject(true, "resources/indexTests/includes");
+ IPathEntry[] entries = new IPathEntry[] {
+ CoreModel.newIncludeEntry(fProject.getPath(), null, fProject.getResource().getLocation()) };
fProject.setRawPathEntries(entries, npm());
- IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "false");
+ IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG,
+ "false");
}
- fIndex= CCorePlugin.getIndexManager().getIndex(fProject);
+ fIndex = CCorePlugin.getIndexManager().getIndex(fProject);
}
@Override
@@ -86,11 +86,13 @@ public class IndexIncludeTest extends IndexTestBase {
public void testFastIndexer() throws Exception {
CCorePlugin.getIndexManager().setIndexerId(fProject, IPDOMManager.ID_FAST_INDEXER);
- IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "false");
+ IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG,
+ "false");
waitForIndexer();
checkHeader(false);
- IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "true");
+ IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG,
+ "true");
waitForIndexer();
checkHeader(true);
@@ -104,7 +106,7 @@ public class IndexIncludeTest extends IndexTestBase {
private void checkHeader(boolean all) throws Exception {
fIndex.acquireReadLock();
try {
- IIndexBinding[] result= fIndex.findBindings(Pattern.compile(".*included"), true, IndexFilter.ALL, npm());
+ IIndexBinding[] result = fIndex.findBindings(Pattern.compile(".*included"), true, IndexFilter.ALL, npm());
assertEquals(all ? 2 : 1, result.length);
} finally {
fIndex.releaseReadLock();
@@ -112,15 +114,16 @@ public class IndexIncludeTest extends IndexTestBase {
}
private void checkContext() throws Exception {
- final long timestamp= System.currentTimeMillis();
- final IFile file= (IFile) fProject.getProject().findMember(new Path("included.h"));
+ final long timestamp = System.currentTimeMillis();
+ final IFile file = (IFile) fProject.getProject().findMember(new Path("included.h"));
assertNotNull("Can't find included.h", file);
waitForIndexer();
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
- file.setContents(new ByteArrayInputStream("int included; int CONTEXT;\n".getBytes()), false, false, npm());
+ file.setContents(new ByteArrayInputStream("int included; int CONTEXT;\n".getBytes()), false, false,
+ npm());
file.setLocalTimeStamp(timestamp + 1000);
}
}, npm());
@@ -128,13 +131,14 @@ public class IndexIncludeTest extends IndexTestBase {
waitUntilFileIsIndexed(fIndex, file);
fIndex.acquireReadLock();
try {
- IIndexFile ifile= getIndexFile(file);
+ IIndexFile ifile = getIndexFile(file);
assertTrue("Timestamp not ok", ifile.getTimestamp() >= timestamp);
- IIndexBinding[] result= fIndex.findBindings(Pattern.compile("testInclude_cpp"), true, IndexFilter.ALL, npm());
+ IIndexBinding[] result = fIndex.findBindings(Pattern.compile("testInclude_cpp"), true, IndexFilter.ALL,
+ npm());
assertEquals(1, result.length);
- result= fIndex.findBindings("testInclude_cpp".toCharArray(), IndexFilter.ALL, npm());
+ result = fIndex.findBindings("testInclude_cpp".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, result.length);
} finally {
fIndex.releaseReadLock();
@@ -153,17 +157,17 @@ public class IndexIncludeTest extends IndexTestBase {
// #include <system20061107.h>
public void testIncludeProperties() throws Exception {
waitForIndexer();
- TestScannerProvider.sIncludes= new String[] { fProject.getProject().getLocation().toOSString() };
- String content= readTaggedComment("source20061107");
+ TestScannerProvider.sIncludes = new String[] { fProject.getProject().getLocation().toOSString() };
+ String content = readTaggedComment("source20061107");
TestSourceReader.createFile(fProject.getProject(), "user20061107.h", "");
TestSourceReader.createFile(fProject.getProject(), "system20061107.h", "");
- IFile file= TestSourceReader.createFile(fProject.getProject(), "source20061107.cpp", content);
+ IFile file = TestSourceReader.createFile(fProject.getProject(), "source20061107.cpp", content);
waitUntilFileIsIndexed(fIndex, file);
fIndex.acquireReadLock();
try {
- IIndexFile ifile= getIndexFile(file);
- IIndexInclude[] includes= ifile.getIncludes();
+ IIndexFile ifile = getIndexFile(file);
+ IIndexInclude[] includes = ifile.getIncludes();
assertEquals(2, includes.length);
checkInclude(includes[0], content, "user20061107.h", false);
@@ -174,19 +178,18 @@ public class IndexIncludeTest extends IndexTestBase {
}
public void testIncludeProperties_2() throws Exception {
- TestScannerProvider.sIncludes= new String[] { fProject.getProject().getLocation().toOSString() };
+ TestScannerProvider.sIncludes = new String[] { fProject.getProject().getLocation().toOSString() };
TestSourceReader.createFile(fProject.getProject(), "header20061107.h", "");
String content = "// comment \n#include \"header20061107.h\"\n";
- IFile file= TestSourceReader.createFile(fProject.getProject(), "intermed20061107.h", content);
+ IFile file = TestSourceReader.createFile(fProject.getProject(), "intermed20061107.h", content);
TestSourceReader.createFile(fProject.getProject(), "source20061107.cpp", "#include \"intermed20061107.h\"\n");
CCorePlugin.getIndexManager().reindex(fProject);
waitForIndexer();
-
fIndex.acquireReadLock();
try {
- IIndexFile ifile= getIndexFile(file);
- IIndexInclude[] includes= ifile.getIncludes();
+ IIndexFile ifile = getIndexFile(file);
+ IIndexInclude[] includes = ifile.getIncludes();
assertEquals(1, includes.length);
checkInclude(includes[0], content, "header20061107.h", false);
@@ -196,16 +199,16 @@ public class IndexIncludeTest extends IndexTestBase {
}
public void testInactiveInclude() throws Exception {
- TestScannerProvider.sIncludes= new String[] { fProject.getProject().getLocation().toOSString() };
+ TestScannerProvider.sIncludes = new String[] { fProject.getProject().getLocation().toOSString() };
String content = "#if 0\n#include \"inactive20070213.h\"\n#endif\n";
- IFile file= TestSourceReader.createFile(fProject.getProject(), "source20070213.cpp", content);
+ IFile file = TestSourceReader.createFile(fProject.getProject(), "source20070213.cpp", content);
CCorePlugin.getIndexManager().reindex(fProject);
waitForIndexer();
fIndex.acquireReadLock();
try {
- IIndexFile ifile= getIndexFile(file);
- IIndexInclude[] includes= ifile.getIncludes();
+ IIndexFile ifile = getIndexFile(file);
+ IIndexInclude[] includes = ifile.getIncludes();
assertEquals(1, includes.length);
assertFalse(includes[0].isActive());
@@ -216,16 +219,16 @@ public class IndexIncludeTest extends IndexTestBase {
}
public void testUnresolvedInclude() throws Exception {
- TestScannerProvider.sIncludes= new String[] { fProject.getProject().getLocation().toOSString() };
+ TestScannerProvider.sIncludes = new String[] { fProject.getProject().getLocation().toOSString() };
String content = "#include \"unresolved20070213.h\"\n";
- IFile file= TestSourceReader.createFile(fProject.getProject(), "source20070214.cpp", content);
+ IFile file = TestSourceReader.createFile(fProject.getProject(), "source20070214.cpp", content);
CCorePlugin.getIndexManager().reindex(fProject);
waitForIndexer();
fIndex.acquireReadLock();
try {
- IIndexFile ifile= getIndexFile(file);
- IIndexInclude[] includes= ifile.getIncludes();
+ IIndexFile ifile = getIndexFile(file);
+ IIndexInclude[] includes = ifile.getIncludes();
assertEquals(1, includes.length);
assertTrue(includes[0].isActive());
@@ -236,8 +239,9 @@ public class IndexIncludeTest extends IndexTestBase {
}
}
- private void checkInclude(IIndexInclude include, String content, String includeName, boolean isSystem) throws CoreException {
- int offset= content.indexOf(includeName);
+ private void checkInclude(IIndexInclude include, String content, String includeName, boolean isSystem)
+ throws CoreException {
+ int offset = content.indexOf(includeName);
assertEquals(offset, include.getNameOffset());
assertEquals(includeName.length(), include.getNameLength());
assertEquals(isSystem, include.isSystemInclude());
@@ -246,14 +250,13 @@ public class IndexIncludeTest extends IndexTestBase {
public void testUpdateOfIncluded() throws Exception {
String content1 = "int CONTEXT_20070404(x);\n";
String content2 = "int CONTEXT_20070404(y);\n";
- String content3 =
- "#define CONTEXT_20070404(x) ctx_20070404##x\n" +
- "#include \"included_20070404.h\"\n" +
- "int source_20070404;\n";
+ String content3 = "#define CONTEXT_20070404(x) ctx_20070404##x\n" + "#include \"included_20070404.h\"\n"
+ + "int source_20070404;\n";
TestSourceReader.createFile(fProject.getProject(), "included_20070404.h", content1);
TestSourceReader.createFile(fProject.getProject(), "notIncluded_20070404.h", "int notIncluded_20070404\n;");
TestSourceReader.createFile(fProject.getProject(), "includer_20070404.cpp", content3);
- IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "false");
+ IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG,
+ "false");
CCorePlugin.getIndexManager().reindex(fProject);
waitForIndexer();
@@ -261,7 +264,7 @@ public class IndexIncludeTest extends IndexTestBase {
try {
assertEquals(0, fIndex.findBindings("notIncluded_20070404".toCharArray(), IndexFilter.ALL, npm()).length);
assertEquals(1, fIndex.findBindings("source_20070404".toCharArray(), IndexFilter.ALL, npm()).length);
- IBinding[] bindings= fIndex.findBindings("ctx_20070404x".toCharArray(), IndexFilter.ALL, npm());
+ IBinding[] bindings = fIndex.findBindings("ctx_20070404x".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
assertTrue(bindings[0] instanceof IVariable);
} finally {
@@ -278,7 +281,7 @@ public class IndexIncludeTest extends IndexTestBase {
fIndex.acquireReadLock();
try {
assertEquals(0, fIndex.findBindings("notIncluded_20070404".toCharArray(), IndexFilter.ALL, npm()).length);
- IBinding[] bindings= fIndex.findBindings("ctx_20070404y".toCharArray(), IndexFilter.ALL, npm());
+ IBinding[] bindings = fIndex.findBindings("ctx_20070404y".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
assertTrue(bindings[0] instanceof IVariable);
} finally {
@@ -296,10 +299,10 @@ public class IndexIncludeTest extends IndexTestBase {
// #include "header1.h"
// #include "header2.h"
public void testParsingInContext_bug220358() throws Exception {
- CharSequence[] sources= getContentsForTest(4);
- IFile h1= TestSourceReader.createFile(fProject.getProject(), "header1.h", sources[0].toString());
- IFile h2= TestSourceReader.createFile(fProject.getProject(), "header2.h", sources[1].toString());
- IFile s1= TestSourceReader.createFile(fProject.getProject(), "s1.cpp", sources[3].toString());
+ CharSequence[] sources = getContentsForTest(4);
+ IFile h1 = TestSourceReader.createFile(fProject.getProject(), "header1.h", sources[0].toString());
+ IFile h2 = TestSourceReader.createFile(fProject.getProject(), "header2.h", sources[1].toString());
+ IFile s1 = TestSourceReader.createFile(fProject.getProject(), "s1.cpp", sources[3].toString());
// make sure it is parsed in context
waitForIndexer();
CCorePlugin.getIndexManager().reindex(fProject);
@@ -307,7 +310,7 @@ public class IndexIncludeTest extends IndexTestBase {
fIndex.acquireReadLock();
try {
- IIndexBinding[] binding= fIndex.findBindings("ok_1_220358".toCharArray(), IndexFilter.ALL_DECLARED, npm());
+ IIndexBinding[] binding = fIndex.findBindings("ok_1_220358".toCharArray(), IndexFilter.ALL_DECLARED, npm());
assertEquals(1, binding.length);
assertTrue(binding[0] instanceof IVariable);
} finally {
@@ -315,11 +318,11 @@ public class IndexIncludeTest extends IndexTestBase {
}
// change header2:
- h2= TestSourceReader.createFile(fProject.getProject(), "header2.h", sources[2].toString());
+ h2 = TestSourceReader.createFile(fProject.getProject(), "header2.h", sources[2].toString());
TestSourceReader.waitUntilFileIsIndexed(fIndex, h2, INDEXER_TIMEOUT_MILLISEC);
fIndex.acquireReadLock();
try {
- IIndexBinding[] binding= fIndex.findBindings("ok_2_220358".toCharArray(), IndexFilter.ALL_DECLARED, npm());
+ IIndexBinding[] binding = fIndex.findBindings("ok_2_220358".toCharArray(), IndexFilter.ALL_DECLARED, npm());
assertEquals(1, binding.length);
assertTrue(binding[0] instanceof IVariable);
} finally {
@@ -329,25 +332,25 @@ public class IndexIncludeTest extends IndexTestBase {
// #include "resolved20070426.h"
public void testFixedContext() throws Exception {
- TestScannerProvider.sIncludes= new String[] { fProject.getProject().getLocation().toOSString() };
- String source= getContentsForTest(1)[0].toString();
- IFile header= TestSourceReader.createFile(fProject.getProject(), "resolved20070426.h", "");
- IFile s1= TestSourceReader.createFile(fProject.getProject(), "s1.cpp", source);
+ TestScannerProvider.sIncludes = new String[] { fProject.getProject().getLocation().toOSString() };
+ String source = getContentsForTest(1)[0].toString();
+ IFile header = TestSourceReader.createFile(fProject.getProject(), "resolved20070426.h", "");
+ IFile s1 = TestSourceReader.createFile(fProject.getProject(), "s1.cpp", source);
// make sure it is parsed in context
waitForIndexer();
CCorePlugin.getIndexManager().reindex(fProject);
waitForIndexer();
- IFile s2= TestSourceReader.createFile(fProject.getProject(), "s2.cpp", source);
+ IFile s2 = TestSourceReader.createFile(fProject.getProject(), "s2.cpp", source);
TestSourceReader.waitUntilFileIsIndexed(fIndex, s2, INDEXER_TIMEOUT_MILLISEC);
fIndex.acquireReadLock();
try {
- IIndexFile ifile= getIndexFile(header);
- IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
+ IIndexFile ifile = getIndexFile(header);
+ IIndexInclude[] includes = fIndex.findIncludedBy(ifile);
assertEquals(2, includes.length);
- IIndexInclude context= ifile.getParsedInContext();
+ IIndexInclude context = ifile.getParsedInContext();
assertNotNull(context);
assertEquals(s1.getFullPath().toString(), context.getIncludedByLocation().getFullPath());
@@ -357,34 +360,34 @@ public class IndexIncludeTest extends IndexTestBase {
fIndex.releaseReadLock();
}
- s1= TestSourceReader.createFile(fProject.getProject(), "s1.cpp", source + "\nint a20070426;");
+ s1 = TestSourceReader.createFile(fProject.getProject(), "s1.cpp", source + "\nint a20070426;");
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_TIMEOUT_MILLISEC);
fIndex.acquireReadLock();
try {
assertEquals(1, fIndex.findBindings("a20070426".toCharArray(), IndexFilter.ALL_DECLARED, npm()).length);
- IIndexFile ifile= getIndexFile(header);
- IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
+ IIndexFile ifile = getIndexFile(header);
+ IIndexInclude[] includes = fIndex.findIncludedBy(ifile);
assertEquals(2, includes.length);
assertEquals(s1.getFullPath().toString(), includes[0].getIncludedByLocation().getFullPath());
assertEquals(s2.getFullPath().toString(), includes[1].getIncludedByLocation().getFullPath());
- IIndexInclude context= ifile.getParsedInContext();
+ IIndexInclude context = ifile.getParsedInContext();
assertNotNull(context);
assertEquals(s1.getFullPath().toString(), context.getIncludedByLocation().getFullPath());
} finally {
fIndex.releaseReadLock();
}
- s2= TestSourceReader.createFile(fProject.getProject(), "s2.cpp", source + "\nint b20070426;");
+ s2 = TestSourceReader.createFile(fProject.getProject(), "s2.cpp", source + "\nint b20070426;");
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_TIMEOUT_MILLISEC);
fIndex.acquireReadLock();
try {
assertEquals(1, fIndex.findBindings("b20070426".toCharArray(), IndexFilter.ALL_DECLARED, npm()).length);
- IIndexFile ifile= getIndexFile(header);
- IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
+ IIndexFile ifile = getIndexFile(header);
+ IIndexInclude[] includes = fIndex.findIncludedBy(ifile);
assertEquals(2, includes.length);
assertEquals(s1.getFullPath().toString(), includes[0].getIncludedByLocation().getFullPath());
assertEquals(s2.getFullPath().toString(), includes[1].getIncludedByLocation().getFullPath());
- IIndexInclude context= ifile.getParsedInContext();
+ IIndexInclude context = ifile.getParsedInContext();
assertNotNull(context);
assertEquals(s1.getFullPath().toString(), context.getIncludedByLocation().getFullPath());
} finally {
@@ -412,45 +415,45 @@ public class IndexIncludeTest extends IndexTestBase {
// #include "unesolved20070427.h"
public void testUpdateIncludes() throws Exception {
waitForIndexer();
- TestScannerProvider.sIncludes= new String[] { fProject.getProject().getLocation().toOSString() };
- CharSequence[] source= getContentsForTest(4);
- IFile header= TestSourceReader.createFile(fProject.getProject(), "resolved20070427.h", "");
- IFile s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
+ TestScannerProvider.sIncludes = new String[] { fProject.getProject().getLocation().toOSString() };
+ CharSequence[] source = getContentsForTest(4);
+ IFile header = TestSourceReader.createFile(fProject.getProject(), "resolved20070427.h", "");
+ IFile s1 = TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
source[0].toString() + "\nint a20070427;");
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_TIMEOUT_MILLISEC);
standardCheckUpdateIncludes(header, s1, "a20070427");
- s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
+ s1 = TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
source[0].toString() + "\nint b20070427;");
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_TIMEOUT_MILLISEC);
standardCheckUpdateIncludes(header, s1, "b20070427");
- s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
+ s1 = TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
source[1].toString() + "\nint c20070427;");
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_TIMEOUT_MILLISEC);
checkUpdateIncludes1(header, s1, "c20070427");
- s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
+ s1 = TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
source[0].toString() + "\nint d20070427;");
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_TIMEOUT_MILLISEC);
standardCheckUpdateIncludes(header, s1, "d20070427");
- s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
+ s1 = TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
source[2].toString() + "\nint e20070427;");
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_TIMEOUT_MILLISEC);
checkUpdateIncludes2(header, s1, "e20070427");
- s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
+ s1 = TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
source[0].toString() + "\nint f20070427;");
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_TIMEOUT_MILLISEC);
standardCheckUpdateIncludes(header, s1, "f20070427");
- s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
+ s1 = TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
source[3].toString() + "\nint g20070427;");
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_TIMEOUT_MILLISEC);
checkUpdateIncludes3(header, s1, "g20070427");
- s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
+ s1 = TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
source[0].toString() + "\nint h20070427;");
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_TIMEOUT_MILLISEC);
standardCheckUpdateIncludes(header, s1, "h20070427");
@@ -479,25 +482,26 @@ public class IndexIncludeTest extends IndexTestBase {
// #include "h2.h"
public void testMultiVariantHeaderUpdate() throws Exception {
waitForIndexer();
- TestScannerProvider.sIncludes= new String[] { fProject.getProject().getLocation().toOSString() };
- StringBuilder[] contents= getContentsForTest(4);
+ TestScannerProvider.sIncludes = new String[] { fProject.getProject().getLocation().toOSString() };
+ StringBuilder[] contents = getContentsForTest(4);
final StringBuilder h1Contents = contents[0];
- final IFile h1= TestSourceReader.createFile(fProject.getProject(), "h1.h", h1Contents.toString());
- IFile h2= TestSourceReader.createFile(fProject.getProject(), "h2.h", contents[1].toString());
- IFile s1= TestSourceReader.createFile(fProject.getProject(), "s1.cpp", contents[2].toString());
- IFile s2= TestSourceReader.createFile(fProject.getProject(), "s2.cpp", contents[3].toString());
+ final IFile h1 = TestSourceReader.createFile(fProject.getProject(), "h1.h", h1Contents.toString());
+ IFile h2 = TestSourceReader.createFile(fProject.getProject(), "h2.h", contents[1].toString());
+ IFile s1 = TestSourceReader.createFile(fProject.getProject(), "s1.cpp", contents[2].toString());
+ IFile s2 = TestSourceReader.createFile(fProject.getProject(), "s2.cpp", contents[3].toString());
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_TIMEOUT_MILLISEC);
TestSourceReader.waitUntilFileIsIndexed(fIndex, s2, INDEXER_TIMEOUT_MILLISEC);
fIndex.acquireReadLock();
try {
- IIndexFile[] indexFiles = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(h1));
+ IIndexFile[] indexFiles = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID,
+ IndexLocationFactory.getWorkspaceIFL(h1));
assertEquals(3, indexFiles.length);
} finally {
fIndex.releaseReadLock();
}
- final long timestamp= System.currentTimeMillis();
+ final long timestamp = System.currentTimeMillis();
while (true) {
int pos = h1Contents.indexOf("int");
if (pos < 0)
@@ -515,7 +519,8 @@ public class IndexIncludeTest extends IndexTestBase {
fIndex.acquireReadLock();
try {
- IIndexFile[] indexFiles = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(h1));
+ IIndexFile[] indexFiles = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID,
+ IndexLocationFactory.getWorkspaceIFL(h1));
assertEquals(3, indexFiles.length);
for (IIndexFile indexFile : indexFiles) {
assertTrue("Timestamp not ok", indexFile.getTimestamp() >= timestamp);
@@ -561,19 +566,20 @@ public class IndexIncludeTest extends IndexTestBase {
// #endif // H1_H_
public void testPragmaOnceChange() throws Exception {
waitForIndexer();
- TestScannerProvider.sIncludes= new String[] { fProject.getProject().getLocation().toOSString() };
- CharSequence[] contents= getContentsForTest(5);
+ TestScannerProvider.sIncludes = new String[] { fProject.getProject().getLocation().toOSString() };
+ CharSequence[] contents = getContentsForTest(5);
final CharSequence h1Contents = contents[0];
- final IFile h1= TestSourceReader.createFile(fProject.getProject(), "h1.h", h1Contents.toString());
- IFile h2= TestSourceReader.createFile(fProject.getProject(), "h2.h", contents[1].toString());
- IFile s1= TestSourceReader.createFile(fProject.getProject(), "s1.cpp", contents[2].toString());
+ final IFile h1 = TestSourceReader.createFile(fProject.getProject(), "h1.h", h1Contents.toString());
+ IFile h2 = TestSourceReader.createFile(fProject.getProject(), "h2.h", contents[1].toString());
+ IFile s1 = TestSourceReader.createFile(fProject.getProject(), "s1.cpp", contents[2].toString());
waitUntilFileIsIndexed(fIndex, s1);
- IFile s2= TestSourceReader.createFile(fProject.getProject(), "s2.cpp", contents[3].toString());
+ IFile s2 = TestSourceReader.createFile(fProject.getProject(), "s2.cpp", contents[3].toString());
waitUntilFileIsIndexed(fIndex, s2);
fIndex.acquireReadLock();
try {
- IIndexFile[] indexFiles = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(h1));
+ IIndexFile[] indexFiles = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID,
+ IndexLocationFactory.getWorkspaceIFL(h1));
assertEquals(3, indexFiles.length);
for (IIndexFile indexFile : indexFiles) {
assertFalse(indexFile.hasPragmaOnceSemantics());
@@ -584,7 +590,7 @@ public class IndexIncludeTest extends IndexTestBase {
}
// Change h1.h so that it has the pragma-once semantics.
- final long t1= System.currentTimeMillis();
+ final long t1 = System.currentTimeMillis();
final String changedContents = contents[4].toString();
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@Override
@@ -597,7 +603,8 @@ public class IndexIncludeTest extends IndexTestBase {
fIndex.acquireReadLock();
try {
- IIndexFile[] indexFiles = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(h1));
+ IIndexFile[] indexFiles = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID,
+ IndexLocationFactory.getWorkspaceIFL(h1));
assertEquals(1, indexFiles.length);
for (IIndexFile indexFile : indexFiles) {
assertTrue("Timestamp not ok", indexFile.getTimestamp() >= t1);
@@ -610,7 +617,7 @@ public class IndexIncludeTest extends IndexTestBase {
}
// Change h1.h back to the original state without the pragma-once semantics.
- final long t2= System.currentTimeMillis();
+ final long t2 = System.currentTimeMillis();
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
@@ -622,7 +629,8 @@ public class IndexIncludeTest extends IndexTestBase {
fIndex.acquireReadLock();
try {
- IIndexFile[] indexFiles = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(h1));
+ IIndexFile[] indexFiles = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID,
+ IndexLocationFactory.getWorkspaceIFL(h1));
assertEquals(3, indexFiles.length);
for (IIndexFile indexFile : indexFiles) {
assertTrue("Timestamp not ok", indexFile.getTimestamp() >= t2);
@@ -639,9 +647,9 @@ public class IndexIncludeTest extends IndexTestBase {
try {
assertEquals(1, fIndex.findBindings(tag.toCharArray(), IndexFilter.ALL_DECLARED, npm()).length);
- IIndexFile ifile= getIndexFile(header);
- IIndexFile sfile= getIndexFile(s1);
- IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
+ IIndexFile ifile = getIndexFile(header);
+ IIndexFile sfile = getIndexFile(s1);
+ IIndexInclude[] includes = fIndex.findIncludedBy(ifile);
assertEquals(1, includes.length);
assertEquals(s1.getFullPath().toString(), includes[0].getIncludedByLocation().getFullPath());
assertEquals(header.getFullPath().toString(), includes[0].getIncludesLocation().getFullPath());
@@ -649,7 +657,7 @@ public class IndexIncludeTest extends IndexTestBase {
assertTrue(includes[0].isResolved());
assertFalse(includes[0].isSystemInclude());
- includes= fIndex.findIncludes(sfile);
+ includes = fIndex.findIncludes(sfile);
assertEquals(3, includes.length);
assertEquals(header.getFullPath().toString(), includes[0].getIncludesLocation().getFullPath());
assertEquals(s1.getFullPath().toString(), includes[0].getIncludedByLocation().getFullPath());
@@ -678,12 +686,12 @@ public class IndexIncludeTest extends IndexTestBase {
try {
assertEquals(1, fIndex.findBindings(tag.toCharArray(), IndexFilter.ALL_DECLARED, npm()).length);
- IIndexFile ifile= getIndexFile(header);
- IIndexFile sfile= getIndexFile(s1);
- IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
+ IIndexFile ifile = getIndexFile(header);
+ IIndexFile sfile = getIndexFile(s1);
+ IIndexInclude[] includes = fIndex.findIncludedBy(ifile);
assertEquals(0, includes.length);
- includes= fIndex.findIncludes(sfile);
+ includes = fIndex.findIncludes(sfile);
assertEquals(2, includes.length);
assertNull(includes[0].getIncludesLocation());
@@ -707,9 +715,9 @@ public class IndexIncludeTest extends IndexTestBase {
try {
assertEquals(1, fIndex.findBindings(tag.toCharArray(), IndexFilter.ALL_DECLARED, npm()).length);
- IIndexFile ifile= getIndexFile(header);
- IIndexFile sfile= getIndexFile(s1);
- IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
+ IIndexFile ifile = getIndexFile(header);
+ IIndexFile sfile = getIndexFile(s1);
+ IIndexInclude[] includes = fIndex.findIncludedBy(ifile);
assertEquals(1, includes.length);
assertEquals(s1.getFullPath().toString(), includes[0].getIncludedByLocation().getFullPath());
assertEquals(header.getFullPath().toString(), includes[0].getIncludesLocation().getFullPath());
@@ -717,7 +725,7 @@ public class IndexIncludeTest extends IndexTestBase {
assertTrue(includes[0].isResolved());
assertTrue(includes[0].isSystemInclude());
- includes= fIndex.findIncludes(sfile);
+ includes = fIndex.findIncludes(sfile);
assertEquals(2, includes.length);
assertEquals(header.getFullPath().toString(), includes[0].getIncludesLocation().getFullPath());
assertEquals(s1.getFullPath().toString(), includes[0].getIncludedByLocation().getFullPath());
@@ -740,9 +748,9 @@ public class IndexIncludeTest extends IndexTestBase {
try {
assertEquals(1, fIndex.findBindings(tag.toCharArray(), IndexFilter.ALL_DECLARED, npm()).length);
- IIndexFile ifile= getIndexFile(header);
- IIndexFile sfile= getIndexFile(s1);
- IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
+ IIndexFile ifile = getIndexFile(header);
+ IIndexFile sfile = getIndexFile(s1);
+ IIndexInclude[] includes = fIndex.findIncludedBy(ifile);
assertEquals(1, includes.length);
assertEquals(s1.getFullPath().toString(), includes[0].getIncludedByLocation().getFullPath());
assertEquals(header.getFullPath().toString(), includes[0].getIncludesLocation().getFullPath());
@@ -750,7 +758,7 @@ public class IndexIncludeTest extends IndexTestBase {
assertTrue(includes[0].isResolved());
assertFalse(includes[0].isSystemInclude());
- includes= fIndex.findIncludes(sfile);
+ includes = fIndex.findIncludes(sfile);
assertEquals(2, includes.length);
assertEquals(header.getFullPath().toString(), includes[0].getIncludesLocation().getFullPath());
assertEquals(s1.getFullPath().toString(), includes[0].getIncludedByLocation().getFullPath());
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexListenerTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexListenerTest.java
index b152141b1a1..a50df390fa3 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexListenerTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexListenerTest.java
@@ -55,9 +55,9 @@ public class IndexListenerTest extends BaseTestCase {
}
public void testIdleListener() throws Exception {
- final Object mutex= new Object();
- final int[] state= new int[] {0, 0, 0};
- IIndexManager im= CCorePlugin.getIndexManager();
+ final Object mutex = new Object();
+ final int[] state = new int[] { 0, 0, 0 };
+ IIndexManager im = CCorePlugin.getIndexManager();
waitForIndexer(fProject1);
waitForIndexer(fProject2);
@@ -67,11 +67,10 @@ public class IndexListenerTest extends BaseTestCase {
synchronized (mutex) {
if (event.indexerIsIdle()) {
state[0]++;
- state[2]= 0;
- }
- else {
+ state[2] = 0;
+ } else {
state[1]++;
- state[2]= 1;
+ state[2] = 1;
}
mutex.notify();
}
@@ -80,11 +79,11 @@ public class IndexListenerTest extends BaseTestCase {
im.addIndexerStateListener(listener);
try {
- IFile file= TestSourceReader.createFile(fProject1.getProject(), "test.cpp", "int a;");
+ IFile file = TestSourceReader.createFile(fProject1.getProject(), "test.cpp", "int a;");
synchronized (mutex) {
- if (state[0]+state[1] < 2) {
+ if (state[0] + state[1] < 2) {
mutex.wait(8000);
- if (state[0]+state[1] < 2) {
+ if (state[0] + state[1] < 2) {
mutex.wait(5000);
}
}
@@ -92,16 +91,15 @@ public class IndexListenerTest extends BaseTestCase {
assertEquals(1, state[1]);
assertEquals(0, state[2]);
}
- }
- finally {
+ } finally {
im.removeIndexerStateListener(listener);
}
}
public void testChangeListener() throws Exception {
- final Object mutex= new Object();
- final List projects= new ArrayList();
- IIndexManager im= CCorePlugin.getIndexManager();
+ final Object mutex = new Object();
+ final List projects = new ArrayList();
+ IIndexManager im = CCorePlugin.getIndexManager();
waitForIndexer(fProject1);
waitForIndexer(fProject2);
@@ -119,7 +117,7 @@ public class IndexListenerTest extends BaseTestCase {
im.addIndexChangeListener(listener);
try {
- IFile file= TestSourceReader.createFile(fProject1.getProject(), "test.cpp", "int a;");
+ IFile file = TestSourceReader.createFile(fProject1.getProject(), "test.cpp", "int a;");
synchronized (mutex) {
mutex.wait(8000);
@@ -128,8 +126,8 @@ public class IndexListenerTest extends BaseTestCase {
assertTrue(projects.contains(fProject1));
projects.clear();
- IFile file1= TestSourceReader.createFile(fProject1.getProject(), "test.cpp", "int b;");
- IFile file2= TestSourceReader.createFile(fProject2.getProject(), "test.cpp", "int c;");
+ IFile file1 = TestSourceReader.createFile(fProject1.getProject(), "test.cpp", "int b;");
+ IFile file2 = TestSourceReader.createFile(fProject2.getProject(), "test.cpp", "int c;");
synchronized (mutex) {
mutex.wait(1000);
if (projects.size() < 2) {
@@ -140,8 +138,7 @@ public class IndexListenerTest extends BaseTestCase {
assertTrue(projects.contains(fProject1));
assertTrue(projects.contains(fProject2));
projects.clear();
- }
- finally {
+ } finally {
im.removeIndexChangeListener(listener);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexLocationTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexLocationTest.java
index 856d600548c..08c5484d046 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexLocationTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexLocationTest.java
@@ -52,8 +52,8 @@ import org.osgi.framework.Bundle;
import junit.framework.Test;
public class IndexLocationTest extends BaseTestCase {
- private static final boolean isWin= Platform.getOS().equals(Platform.OS_WIN32);
- protected List projects= new ArrayList();
+ private static final boolean isWin = Platform.getOS().equals(Platform.OS_WIN32);
+ protected List projects = new ArrayList();
protected ICProject cproject;
public static Test suite() {
@@ -63,16 +63,18 @@ public class IndexLocationTest extends BaseTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- cproject= CProjectHelper.createCProject("LocationTests"+System.currentTimeMillis(), "bin", IPDOMManager.ID_FAST_INDEXER);
+ cproject = CProjectHelper.createCProject("LocationTests" + System.currentTimeMillis(), "bin",
+ IPDOMManager.ID_FAST_INDEXER);
deleteOnTearDown(cproject);
}
@Override
protected void tearDown() throws Exception {
- for (Iterator i= projects.iterator(); i.hasNext(); ) {
- ICProject ptd= (ICProject) i.next();
+ for (Iterator i = projects.iterator(); i.hasNext();) {
+ ICProject ptd = (ICProject) i.next();
if (ptd != null) {
- ptd.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ ptd.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
super.tearDown();
@@ -89,7 +91,7 @@ public class IndexLocationTest extends BaseTestCase {
// #include "ABS_EXTERNAL"
// class baz {};
public void testBasicLocations() throws Exception {
- File externalHeader = new File(CProjectHelper.freshDir(),"external.h");
+ File externalHeader = new File(CProjectHelper.freshDir(), "external.h");
try {
Bundle b = CTestPlugin.getDefault().getBundle();
@@ -97,7 +99,8 @@ public class IndexLocationTest extends BaseTestCase {
IFile file1 = TestSourceReader.createFile(cproject.getProject(), "header.h", testData[0].toString());
createExternalFile(externalHeader, testData[1].toString());
- String content = testData[2].toString().replaceAll("ABS_EXTERNAL", externalHeader.getAbsolutePath().replaceAll("\\\\","\\\\\\\\"));
+ String content = testData[2].toString().replaceAll("ABS_EXTERNAL",
+ externalHeader.getAbsolutePath().replaceAll("\\\\", "\\\\\\\\"));
IFile file3 = TestSourceReader.createFile(cproject.getProject(), "source.cpp", content);
CCorePlugin.getIndexManager().reindex(cproject);
@@ -106,9 +109,12 @@ public class IndexLocationTest extends BaseTestCase {
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
index.acquireReadLock();
try {
- IBinding[] bs1 = index.findBindings(Pattern.compile("foo"), true, IndexFilter.ALL, new NullProgressMonitor());
- IBinding[] bs2 = index.findBindings(Pattern.compile("bar"), true, IndexFilter.ALL, new NullProgressMonitor());
- IBinding[] bs3 = index.findBindings(Pattern.compile("baz"), true, IndexFilter.ALL, new NullProgressMonitor());
+ IBinding[] bs1 = index.findBindings(Pattern.compile("foo"), true, IndexFilter.ALL,
+ new NullProgressMonitor());
+ IBinding[] bs2 = index.findBindings(Pattern.compile("bar"), true, IndexFilter.ALL,
+ new NullProgressMonitor());
+ IBinding[] bs3 = index.findBindings(Pattern.compile("baz"), true, IndexFilter.ALL,
+ new NullProgressMonitor());
assertEquals(1, bs1.length);
assertEquals(1, bs2.length);
assertEquals(1, bs3.length);
@@ -126,30 +132,24 @@ public class IndexLocationTest extends BaseTestCase {
assertEquals(1, nms3.length);
URI workspaceRoot = ResourcesPlugin.getWorkspace().getRoot().getLocationURI();
assertEquals(
- ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(cproject.getProject().getName()+"/header.h")).getLocationURI(),
- nms1[0].getFile().getLocation().getURI()
- );
+ ResourcesPlugin.getWorkspace().getRoot()
+ .getFile(new Path(cproject.getProject().getName() + "/header.h")).getLocationURI(),
+ nms1[0].getFile().getLocation().getURI());
+ assertEquals(externalHeader.toURI(), nms2[0].getFile().getLocation().getURI());
assertEquals(
- externalHeader.toURI(),
- nms2[0].getFile().getLocation().getURI()
- );
- assertEquals(
- ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(cproject.getProject().getName()+"/source.cpp")).getLocationURI(),
- nms3[0].getFile().getLocation().getURI()
- );
+ ResourcesPlugin.getWorkspace().getRoot()
+ .getFile(new Path(cproject.getProject().getName() + "/source.cpp")).getLocationURI(),
+ nms3[0].getFile().getLocation().getURI());
assertEquals(
- ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(cproject.getProject().getName()+"/header.h")).getFullPath(),
- new Path(nms1[0].getFile().getLocation().getFullPath())
- );
- assertEquals(
- null,
- nms2[0].getFile().getLocation().getFullPath()
- );
+ ResourcesPlugin.getWorkspace().getRoot()
+ .getFile(new Path(cproject.getProject().getName() + "/header.h")).getFullPath(),
+ new Path(nms1[0].getFile().getLocation().getFullPath()));
+ assertEquals(null, nms2[0].getFile().getLocation().getFullPath());
assertEquals(
- ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(cproject.getProject().getName()+"/source.cpp")).getFullPath(),
- new Path(nms3[0].getFile().getLocation().getFullPath())
- );
+ ResourcesPlugin.getWorkspace().getRoot()
+ .getFile(new Path(cproject.getProject().getName() + "/source.cpp")).getFullPath(),
+ new Path(nms3[0].getFile().getLocation().getFullPath()));
} finally {
index.releaseReadLock();
}
@@ -162,7 +162,7 @@ public class IndexLocationTest extends BaseTestCase {
public void testLinkedFilesIndexedAsWithinProject() throws Exception {
File location = new File(CProjectHelper.freshDir(), "external2.h");
createExternalFile(location, "struct External {};\n");
- IFolder content= cproject.getProject().getFolder("content");
+ IFolder content = cproject.getProject().getFolder("content");
content.createLink(new Path(location.getParentFile().getAbsolutePath()), IResource.NONE, npm());
CCorePlugin.getIndexManager().reindex(cproject);
@@ -171,31 +171,32 @@ public class IndexLocationTest extends BaseTestCase {
waitUntilFileIsIndexed(index, content.getFile("external2.h"));
index.acquireReadLock();
try {
- IBinding[] bs= index.findBindings("External".toCharArray(), IndexFilter.ALL, npm());
+ IBinding[] bs = index.findBindings("External".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bs.length);
- IIndexName[] nms= index.findNames(bs[0], IIndex.FIND_ALL_OCCURRENCES);
+ IIndexName[] nms = index.findNames(bs[0], IIndex.FIND_ALL_OCCURRENCES);
assertEquals(1, nms.length);
- IIndexFileLocation ilocation= nms[0].getFile().getLocation();
- assertEquals("/"+cproject.getProject().getName()+"/content/external2.h", ilocation.getFullPath());
+ IIndexFileLocation ilocation = nms[0].getFile().getLocation();
+ assertEquals("/" + cproject.getProject().getName() + "/content/external2.h", ilocation.getFullPath());
} finally {
index.releaseReadLock();
}
}
public void testSameFileLinkedToOnceInTwoProjects_186214() throws Exception {
- File location = new File(CProjectHelper.freshDir(),"external2.h");
+ File location = new File(CProjectHelper.freshDir(), "external2.h");
createExternalFile(location, "struct External {};\n");
assertTrue(location.isFile());
- IFolder content= cproject.getProject().getFolder("content");
+ IFolder content = cproject.getProject().getFolder("content");
content.createLink(new Path(location.getParentFile().getAbsolutePath()), IResource.NONE, null);
final IFile file = content.getFile("external2.h");
assertTrue(file.exists());
- ICProject cproject2= CProjectHelper.createCProject("LocationTests2"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
+ ICProject cproject2 = CProjectHelper.createCProject("LocationTests2" + System.currentTimeMillis(), "bin",
+ IPDOMManager.ID_NO_INDEXER);
deleteOnTearDown(cproject2);
- IFolder content2= cproject2.getProject().getFolder("content");
+ IFolder content2 = cproject2.getProject().getFolder("content");
content2.createLink(new Path(location.getParentFile().getAbsolutePath()), IResource.NONE, null);
assertTrue(content2.getFile("external2.h").exists());
@@ -205,69 +206,60 @@ public class IndexLocationTest extends BaseTestCase {
waitForIndexer(cproject);
index.acquireReadLock();
try {
- IBinding[] bs= index.findBindings("External".toCharArray(), IndexFilter.ALL, npm());
+ IBinding[] bs = index.findBindings("External".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bs.length);
- IIndexName[] nms= index.findNames(bs[0], IIndex.FIND_ALL_OCCURRENCES);
+ IIndexName[] nms = index.findNames(bs[0], IIndex.FIND_ALL_OCCURRENCES);
assertEquals(1, nms.length);
- IIndexFileLocation ilocation= nms[0].getFile().getLocation();
- assertEquals("/"+cproject.getProject().getName()+"/content/external2.h", ilocation.getFullPath());
+ IIndexFileLocation ilocation = nms[0].getFile().getLocation();
+ assertEquals("/" + cproject.getProject().getName() + "/content/external2.h", ilocation.getFullPath());
} finally {
index.releaseReadLock();
}
}
public void testResourceContainerRelativeLocationConverter() throws Exception {
- ICProject emptyCProject= CProjectHelper.createCProject("Empty", "bin", IPDOMManager.ID_NO_INDEXER);
+ ICProject emptyCProject = CProjectHelper.createCProject("Empty", "bin", IPDOMManager.ID_NO_INDEXER);
deleteOnTearDown(emptyCProject);
- String[] paths = new String[] {"this.cpp", "inc/header.h", "a b c/d/e f/g.h", "a \\b /c.d"};
+ String[] paths = new String[] { "this.cpp", "inc/header.h", "a b c/d/e f/g.h", "a \\b /c.d" };
for (String path : paths) {
- IFile file= cproject.getProject().getFile(path);
- IIndexFileLocation ifl1= IndexLocationFactory.getWorkspaceIFL(file);
- ResourceContainerRelativeLocationConverter prlc1= new ResourceContainerRelativeLocationConverter(cproject.getProject());
- String r1= prlc1.toInternalFormat(ifl1);
+ IFile file = cproject.getProject().getFile(path);
+ IIndexFileLocation ifl1 = IndexLocationFactory.getWorkspaceIFL(file);
+ ResourceContainerRelativeLocationConverter prlc1 = new ResourceContainerRelativeLocationConverter(
+ cproject.getProject());
+ String r1 = prlc1.toInternalFormat(ifl1);
assertNotNull(r1);
- ResourceContainerRelativeLocationConverter prlc2= new ResourceContainerRelativeLocationConverter(emptyCProject.getProject());
- IIndexFileLocation ifl2= prlc2.fromInternalFormat(r1);
+ ResourceContainerRelativeLocationConverter prlc2 = new ResourceContainerRelativeLocationConverter(
+ emptyCProject.getProject());
+ IIndexFileLocation ifl2 = prlc2.fromInternalFormat(r1);
assertNotNull(ifl2);
- assertEquals(
- new Path(ifl1.getFullPath()).removeFirstSegments(1),
- new Path(ifl2.getFullPath()).removeFirstSegments(1)
- );
+ assertEquals(new Path(ifl1.getFullPath()).removeFirstSegments(1),
+ new Path(ifl2.getFullPath()).removeFirstSegments(1));
}
}
public void testURLC_RCRLC_Interaction1() throws Exception {
- String[] winPaths = new String[] {
- "c:/foo/bar/baz.cpp",
- "c:\\foo\\bar\\a b c\\baz.cpp",
- "c:/foo/bar/a b/baz.cpp",
- "c:\\foo\\bar\\a b c\\a b/baz.cpp"
- };
- String[] unxPaths = new String[] {
- "/home/cdt/foo/bar/baz.cpp",
- "/home/cdt/foo/bar/a b c/baz.cpp",
- "/home/cdt/foo/bar/a b/baz.cpp",
- "/home/cdt/foo/bar/a b c/a b/baz.cpp"
- };
+ String[] winPaths = new String[] { "c:/foo/bar/baz.cpp", "c:\\foo\\bar\\a b c\\baz.cpp",
+ "c:/foo/bar/a b/baz.cpp", "c:\\foo\\bar\\a b c\\a b/baz.cpp" };
+ String[] unxPaths = new String[] { "/home/cdt/foo/bar/baz.cpp", "/home/cdt/foo/bar/a b c/baz.cpp",
+ "/home/cdt/foo/bar/a b/baz.cpp", "/home/cdt/foo/bar/a b c/a b/baz.cpp" };
URI base = URIUtil.toURI(isWin ? "c:/foo/bar/" : "/home/cdt/foo/bar/");
- String[] paths= isWin ? winPaths : unxPaths;
- String[] expectedFullPaths = new String[] {
- "/"+cproject.getProject().getName()+"/baz.cpp",
- "/"+cproject.getProject().getName()+"/a b c/baz.cpp",
- "/"+cproject.getProject().getName()+"/a b/baz.cpp",
- "/"+cproject.getProject().getName()+"/a b c/a b/baz.cpp"
- };
- IContainer root= ResourcesPlugin.getWorkspace().getRoot();
+ String[] paths = isWin ? winPaths : unxPaths;
+ String[] expectedFullPaths = new String[] { "/" + cproject.getProject().getName() + "/baz.cpp",
+ "/" + cproject.getProject().getName() + "/a b c/baz.cpp",
+ "/" + cproject.getProject().getName() + "/a b/baz.cpp",
+ "/" + cproject.getProject().getName() + "/a b c/a b/baz.cpp" };
+ IContainer root = ResourcesPlugin.getWorkspace().getRoot();
// loc -uri-> raw -project-> loc
- for (int i= 0; i < paths.length; i++) {
+ for (int i = 0; i < paths.length; i++) {
IIndexFileLocation ifl1 = IndexLocationFactory.getExternalIFL(paths[i]);
URIRelativeLocationConverter urlc = new URIRelativeLocationConverter(base);
String r1 = urlc.toInternalFormat(ifl1);
assertNotNull(r1);
- ResourceContainerRelativeLocationConverter prlc= new ResourceContainerRelativeLocationConverter(cproject.getProject());
- IIndexFileLocation ifl2= prlc.fromInternalFormat(r1);
- String r2= prlc.toInternalFormat(ifl2);
+ ResourceContainerRelativeLocationConverter prlc = new ResourceContainerRelativeLocationConverter(
+ cproject.getProject());
+ IIndexFileLocation ifl2 = prlc.fromInternalFormat(r1);
+ String r2 = prlc.toInternalFormat(ifl2);
assertNotNull(r2);
assertNull(ifl1.getFullPath());
assertEquals(expectedFullPaths[i], ifl2.getFullPath());
@@ -277,75 +269,56 @@ public class IndexLocationTest extends BaseTestCase {
}
public void testURLC_RCRLC_Interaction2() throws Exception {
- String[] winPaths = new String[] {
- "a b c/d/e f/g.h",
- "a \\b /c.d",
- "/a b c/d-e/f.g"
- };
- String[] unxPaths = new String[] {
- "a b c/d/e f/g.h",
- "a /b /c.d",
- "/a b c/d-e/f.g"
- };
- String[] paths= isWin ? winPaths : unxPaths;
+ String[] winPaths = new String[] { "a b c/d/e f/g.h", "a \\b /c.d", "/a b c/d-e/f.g" };
+ String[] unxPaths = new String[] { "a b c/d/e f/g.h", "a /b /c.d", "/a b c/d-e/f.g" };
+ String[] paths = isWin ? winPaths : unxPaths;
String basePath = isWin ? "c:/foo/bar/" : "/home/cdt/foo/bar/";
- String[] expectedFullPaths = new String[] {
- "/"+cproject.getProject().getName()+"/a b c/d/e f/g.h",
- "/"+cproject.getProject().getName()+"/a /b /c.d",
- "/"+cproject.getProject().getName()+"/a b c/d-e/f.g"
- };
+ String[] expectedFullPaths = new String[] { "/" + cproject.getProject().getName() + "/a b c/d/e f/g.h",
+ "/" + cproject.getProject().getName() + "/a /b /c.d",
+ "/" + cproject.getProject().getName() + "/a b c/d-e/f.g" };
URI base = makeDirectoryURI(basePath);
URIRelativeLocationConverter c1 = new URIRelativeLocationConverter(base);
// loc -project-> raw -uri-> loc
- for (int i= 0; i < paths.length; i++) {
- IFile file= cproject.getProject().getFile(paths[i]);
- IIndexFileLocation ifl1= IndexLocationFactory.getWorkspaceIFL(file);
- ResourceContainerRelativeLocationConverter prlc= new ResourceContainerRelativeLocationConverter(cproject.getProject());
- String r1= prlc.toInternalFormat(ifl1);
+ for (int i = 0; i < paths.length; i++) {
+ IFile file = cproject.getProject().getFile(paths[i]);
+ IIndexFileLocation ifl1 = IndexLocationFactory.getWorkspaceIFL(file);
+ ResourceContainerRelativeLocationConverter prlc = new ResourceContainerRelativeLocationConverter(
+ cproject.getProject());
+ String r1 = prlc.toInternalFormat(ifl1);
assertNotNull(r1);
- IIndexFileLocation ifl2= c1.fromInternalFormat(r1);
+ IIndexFileLocation ifl2 = c1.fromInternalFormat(r1);
assertNotNull(ifl2);
assertEquals(expectedFullPaths[i], ifl1.getFullPath());
assertNull(ifl2.getFullPath());
assertEquals(cproject.getProject().getFile(paths[i]).getLocationURI(), ifl1.getURI());
- assertEquals(URIUtil.toURI(basePath+paths[i]).normalize(), ifl2.getURI());
+ assertEquals(URIUtil.toURI(basePath + paths[i]).normalize(), ifl2.getURI());
}
}
public void testURLC_RCRLC_Interaction3() throws Exception {
- IFolder linkedFolder= cproject.getProject().getFolder("linkedFolder");
- String[] winPaths = new String[] {
- "a b c/d/e f/g.h",
- "a \\b /c.d",
- "/a b c/d-e/f.g"
- };
- String[] unxPaths = new String[] {
- "a b c/d/e f/g.h",
- "a /b /c.d",
- "/a b c/d-e/f.g"
- };
- String[] paths= isWin ? winPaths : unxPaths;
+ IFolder linkedFolder = cproject.getProject().getFolder("linkedFolder");
+ String[] winPaths = new String[] { "a b c/d/e f/g.h", "a \\b /c.d", "/a b c/d-e/f.g" };
+ String[] unxPaths = new String[] { "a b c/d/e f/g.h", "a /b /c.d", "/a b c/d-e/f.g" };
+ String[] paths = isWin ? winPaths : unxPaths;
String basePath = isWin ? "c:/foo/bar/" : "/home/cdt/foo/bar/";
- String[] expectedFullPaths = new String[] {
- linkedFolder.getFullPath()+"/a b c/d/e f/g.h",
- linkedFolder.getFullPath()+"/a /b /c.d",
- linkedFolder.getFullPath()+"/a b c/d-e/f.g"
- };
+ String[] expectedFullPaths = new String[] { linkedFolder.getFullPath() + "/a b c/d/e f/g.h",
+ linkedFolder.getFullPath() + "/a /b /c.d", linkedFolder.getFullPath() + "/a b c/d-e/f.g" };
// loc -project-> raw -uri-> loc
URI base = makeDirectoryURI(basePath);
URIRelativeLocationConverter c1 = new URIRelativeLocationConverter(base);
- for (int i= 0; i < paths.length; i++) {
- IFile file= linkedFolder.getFile(paths[i]);
- IIndexFileLocation ifl1= IndexLocationFactory.getWorkspaceIFL(file);
- ResourceContainerRelativeLocationConverter prlc= new ResourceContainerRelativeLocationConverter(linkedFolder);
- String r1= prlc.toInternalFormat(ifl1);
+ for (int i = 0; i < paths.length; i++) {
+ IFile file = linkedFolder.getFile(paths[i]);
+ IIndexFileLocation ifl1 = IndexLocationFactory.getWorkspaceIFL(file);
+ ResourceContainerRelativeLocationConverter prlc = new ResourceContainerRelativeLocationConverter(
+ linkedFolder);
+ String r1 = prlc.toInternalFormat(ifl1);
assertNotNull(r1);
- IIndexFileLocation ifl2= c1.fromInternalFormat(r1);
+ IIndexFileLocation ifl2 = c1.fromInternalFormat(r1);
assertNotNull(ifl2);
assertEquals(expectedFullPaths[i], ifl1.getFullPath());
assertNull(ifl2.getFullPath());
assertEquals(linkedFolder.getFile(paths[i]).getLocationURI(), ifl1.getURI());
- assertEquals(URIUtil.toURI(basePath+paths[i]).normalize(), ifl2.getURI());
+ assertEquals(URIUtil.toURI(basePath + paths[i]).normalize(), ifl2.getURI());
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiFileTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiFileTest.java
index c7e98b3c159..7ca69525757 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiFileTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiFileTest.java
@@ -205,7 +205,7 @@ public class IndexMultiFileTest extends IndexBindingResolutionTestBase {
// test.h
// friend int operator*(double, C) { return 0; }
-
+
// test.cpp *
// namespace N {
//
@@ -215,7 +215,7 @@ public class IndexMultiFileTest extends IndexBindingResolutionTestBase {
// friend int operator*(unrelated, unrelated) { return 0; }
// };
// }
- //
+ //
// template <typename = int>
// struct C : public N::B {
// #include "test.h"
@@ -232,10 +232,10 @@ public class IndexMultiFileTest extends IndexBindingResolutionTestBase {
//
// template <typename T>
// struct atomic<T*>;
-
+
// test1.cpp
// #include "test.h"
-
+
// test2.cpp *
// #include "test.h"
//
@@ -249,7 +249,7 @@ public class IndexMultiFileTest extends IndexBindingResolutionTestBase {
public void testClassTemplatePartialSpecialization_470726() throws Exception {
checkBindings();
}
-
+
// test.h
// template <bool = false>
// struct base {};
@@ -258,10 +258,10 @@ public class IndexMultiFileTest extends IndexBindingResolutionTestBase {
// struct derived : private base<B> {
// constexpr derived() : base<B>() {}
// };
-
+
// test1.cpp
// #include "test.h"
-
+
// test2.cpp *
// template <typename = void>
// struct base {};
@@ -346,7 +346,6 @@ public class IndexMultiFileTest extends IndexBindingResolutionTestBase {
public void testStackOverflow_514459() throws Exception {
checkBindings();
}
-
//test.hpp *
// template <typename> class A {};
@@ -365,7 +364,7 @@ public class IndexMultiFileTest extends IndexBindingResolutionTestBase {
public void testAliasTemplateReferencingSameName_518937() throws Exception {
checkBindings();
}
-
+
//h1.h
// class A {
// friend class B1;
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiVariantHeaderTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiVariantHeaderTest.java
index bc6f561849d..d8edeaece68 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiVariantHeaderTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiVariantHeaderTest.java
@@ -156,8 +156,8 @@ public class IndexMultiVariantHeaderTest extends IndexBindingResolutionTestBase
// a.cpp *
// #include "a.h"
public void testSignificantMacroDetection_367753a() throws Exception {
- IASTName includeName= findName("a.h", 0);
- IASTPreprocessorIncludeStatement inc= (IASTPreprocessorIncludeStatement) includeName.getParent();
+ IASTName includeName = findName("a.h", 0);
+ IASTPreprocessorIncludeStatement inc = (IASTPreprocessorIncludeStatement) includeName.getParent();
assertTrue(inc.isResolved());
assertEquals("{}", inc.getSignificantMacros().toString());
assertNotNull(inc.getImportedIndexFile());
@@ -180,8 +180,8 @@ public class IndexMultiVariantHeaderTest extends IndexBindingResolutionTestBase
// a.cpp *
// #include "a.h"
public void testSignificantMacroDetection_367753b() throws Exception {
- IASTName includeName= findName("a.h", 0);
- IASTPreprocessorIncludeStatement inc= (IASTPreprocessorIncludeStatement) includeName.getParent();
+ IASTName includeName = findName("a.h", 0);
+ IASTPreprocessorIncludeStatement inc = (IASTPreprocessorIncludeStatement) includeName.getParent();
assertTrue(inc.isResolved());
assertEquals("{}", inc.getSignificantMacros().toString());
assertNotNull(inc.getImportedIndexFile());
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexNamesTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexNamesTests.java
index a66a2303630..679717f85e1 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexNamesTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexNamesTests.java
@@ -53,9 +53,9 @@ public class IndexNamesTests extends BaseTestCase {
@Override
protected void setUp() throws CoreException {
- fCProject= CProjectHelper.createCCProject("__encNamesTest__", "bin", IPDOMManager.ID_FAST_INDEXER);
+ fCProject = CProjectHelper.createCCProject("__encNamesTest__", "bin", IPDOMManager.ID_FAST_INDEXER);
CCorePlugin.getIndexManager().reindex(fCProject);
- fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
+ fIndex = CCorePlugin.getIndexManager().getIndex(fCProject);
}
@Override
@@ -70,8 +70,8 @@ public class IndexNamesTests extends BaseTestCase {
}
public String getComment() throws IOException {
- CharSequence[] contents = TestSourceReader.getContentsForTest(
- CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), 1);
+ CharSequence[] contents = TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "parser",
+ getClass(), getName(), 1);
return contents[0].toString();
}
@@ -84,10 +84,10 @@ public class IndexNamesTests extends BaseTestCase {
}
protected Pattern[] getPattern(String qname) {
- String[] parts= qname.split("::");
- Pattern[] result= new Pattern[parts.length];
+ String[] parts = qname.split("::");
+ Pattern[] result = new Pattern[parts.length];
for (int i = 0; i < result.length; i++) {
- result[i]= Pattern.compile(parts[i]);
+ result[i] = Pattern.compile(parts[i]);
}
return result;
}
@@ -112,31 +112,31 @@ public class IndexNamesTests extends BaseTestCase {
// };
public void testNestingWithFunction() throws Exception {
waitForIndexer();
- String content= getComment();
- IFile file= createFile(getProject().getProject(), "test.cpp", content);
+ String content = getComment();
+ IFile file = createFile(getProject().getProject(), "test.cpp", content);
waitUntilFileIsIndexed(file, 4000);
fIndex.acquireReadLock();
try {
- IIndexBinding[] mainBS= fIndex.findBindings(getPattern("main"), true, IndexFilter.ALL, npm());
+ IIndexBinding[] mainBS = fIndex.findBindings(getPattern("main"), true, IndexFilter.ALL, npm());
assertLength(1, mainBS);
- IIndexBinding mainB= mainBS[0];
+ IIndexBinding mainB = mainBS[0];
- IIndexName[] names= fIndex.findDefinitions(mainB);
+ IIndexName[] names = fIndex.findDefinitions(mainB);
assertLength(1, names);
- IIndexName main= names[0];
+ IIndexName main = names[0];
assertNull(main.getEnclosingDefinition());
- IIndexName[] enclosed= main.getEnclosedNames();
+ IIndexName[] enclosed = main.getEnclosedNames();
assertLength(2, enclosed);
assertName("func", enclosed[0]);
assertName("var", enclosed[1]);
- IIndexName enclosing= enclosed[0].getEnclosingDefinition();
+ IIndexName enclosing = enclosed[0].getEnclosingDefinition();
assertNotNull(enclosing);
assertName("main", enclosing);
- enclosing= enclosed[1].getEnclosingDefinition();
+ enclosing = enclosed[1].getEnclosingDefinition();
assertNotNull(enclosing);
assertName("main", enclosing);
} finally {
@@ -170,66 +170,66 @@ public class IndexNamesTests extends BaseTestCase {
// };
public void testNestingWithMethod() throws Exception {
waitForIndexer();
- String content= getComment();
- IFile file= createFile(getProject().getProject(), "test.cpp", content);
+ String content = getComment();
+ IFile file = createFile(getProject().getProject(), "test.cpp", content);
waitUntilFileIsIndexed(file, 4000);
fIndex.acquireReadLock();
try {
- IIndexBinding[] mainBS= fIndex.findBindings(getPattern("main"), true, IndexFilter.ALL, npm());
+ IIndexBinding[] mainBS = fIndex.findBindings(getPattern("main"), true, IndexFilter.ALL, npm());
assertLength(1, mainBS);
- IIndexBinding mainB= mainBS[0];
+ IIndexBinding mainB = mainBS[0];
- IIndexName[] names= fIndex.findDefinitions(mainB);
+ IIndexName[] names = fIndex.findDefinitions(mainB);
assertLength(1, names);
- IIndexName main= names[0];
+ IIndexName main = names[0];
assertNull(main.getEnclosingDefinition());
- IIndexName[] enclosed= main.getEnclosedNames();
+ IIndexName[] enclosed = main.getEnclosedNames();
assertLength(4, enclosed);
assertName("C", enclosed[0]); // Class reference
assertName("C", enclosed[1]); // Implicit ctor call
assertName("func", enclosed[2]);
assertName("var", enclosed[3]);
- IIndexName enclosing= enclosed[0].getEnclosingDefinition();
+ IIndexName enclosing = enclosed[0].getEnclosingDefinition();
assertNotNull(enclosing);
assertName("main", enclosing);
- enclosing= enclosed[1].getEnclosingDefinition();
+ enclosing = enclosed[1].getEnclosingDefinition();
assertNotNull(enclosing);
assertName("main", enclosing);
- enclosing= enclosed[2].getEnclosingDefinition();
+ enclosing = enclosed[2].getEnclosingDefinition();
assertNotNull(enclosing);
assertName("main", enclosing);
- enclosing= enclosed[3].getEnclosingDefinition();
+ enclosing = enclosed[3].getEnclosingDefinition();
assertNotNull(enclosing);
assertName("main", enclosing);
- IIndexBinding funcB= fIndex.findBinding(enclosed[2]);
+ IIndexBinding funcB = fIndex.findBinding(enclosed[2]);
assertNotNull(funcB);
- names= fIndex.findDefinitions(funcB);
+ names = fIndex.findDefinitions(funcB);
assertLength(1, names);
- IIndexName funcdef= names[0];
+ IIndexName funcdef = names[0];
assertNull(funcdef.getEnclosingDefinition());
- enclosed= funcdef.getEnclosedNames();
+ enclosed = funcdef.getEnclosedNames();
assertLength(3, enclosed);
assertName("C", enclosed[0]);
assertName("func", enclosed[1]);
assertName("var", enclosed[2]);
- enclosing= enclosed[0].getEnclosingDefinition();
+ enclosing = enclosed[0].getEnclosingDefinition();
assertNotNull(enclosing);
assertName("func", enclosing);
- enclosing= enclosed[1].getEnclosingDefinition();
+ enclosing = enclosed[1].getEnclosingDefinition();
assertNotNull(enclosing);
assertName("func", enclosing);
- enclosing= enclosed[2].getEnclosingDefinition();
+ enclosing = enclosed[2].getEnclosingDefinition();
assertNotNull(enclosing);
assertName("func", enclosing);
} finally {
@@ -265,18 +265,18 @@ public class IndexNamesTests extends BaseTestCase {
// }
public void testCouldBePolymorphicMethodCall_Bug156691() throws Exception {
waitForIndexer();
- String content= getComment();
- IFile file= createFile(getProject().getProject(), "test.cpp", content);
+ String content = getComment();
+ IFile file = createFile(getProject().getProject(), "test.cpp", content);
waitUntilFileIsIndexed(file, 4000);
- boolean[] couldbepolymorphic= {true, false, true, false, true, false, false, false};
- String[] container= {"Y", "X", "X", "X", "X", "X", "X", "X" };
+ boolean[] couldbepolymorphic = { true, false, true, false, true, false, false, false };
+ String[] container = { "Y", "X", "X", "X", "X", "X", "X", "X" };
fIndex.acquireReadLock();
try {
- IIndexFile ifile= getIndexFile(ILinkage.CPP_LINKAGE_ID, file);
- IIndexName[] names= ifile.findNames(0, content.length());
- int j= 0;
+ IIndexFile ifile = getIndexFile(ILinkage.CPP_LINKAGE_ID, file);
+ IIndexName[] names = ifile.findNames(0, content.length());
+ int j = 0;
for (IIndexName indexName : names) {
if (indexName.isReference() && indexName.toString().equals("vm")) {
assertEquals(couldbepolymorphic[j], indexName.couldBePolymorphicMethodCall());
@@ -304,15 +304,15 @@ public class IndexNamesTests extends BaseTestCase {
// };
public void testAddressOfPolymorphicMethod_Bug363731() throws Exception {
waitForIndexer();
- String content= getComment();
- IFile file= createFile(getProject().getProject(), "test.cpp", content);
+ String content = getComment();
+ IFile file = createFile(getProject().getProject(), "test.cpp", content);
waitUntilFileIsIndexed(file, 4000);
fIndex.acquireReadLock();
try {
- IIndexFile ifile= getIndexFile(ILinkage.CPP_LINKAGE_ID, file);
- IIndexName[] names= ifile.findNames(0, content.length());
- int j= 0;
+ IIndexFile ifile = getIndexFile(ILinkage.CPP_LINKAGE_ID, file);
+ IIndexName[] names = ifile.findNames(0, content.length());
+ int j = 0;
for (IIndexName indexName : names) {
if (indexName.isReference() && indexName.toString().equals("foo")) {
assertEquals(true, indexName.couldBePolymorphicMethodCall());
@@ -357,27 +357,26 @@ public class IndexNamesTests extends BaseTestCase {
// }
public void testReadWriteFlagsC() throws Exception {
waitForIndexer();
- String content= getComment();
- IFile file= createFile(getProject().getProject(), "test.c", content);
+ String content = getComment();
+ IFile file = createFile(getProject().getProject(), "test.c", content);
waitUntilFileIsIndexed(file, 4000);
checkReadWriteFlags(file, ILinkage.C_LINKAGE_ID, 41);
}
- private void checkReadWriteFlags(IFile file, int linkageID, int count) throws InterruptedException,
- CoreException {
+ private void checkReadWriteFlags(IFile file, int linkageID, int count) throws InterruptedException, CoreException {
fIndex.acquireReadLock();
try {
- IIndexFile ifile= getIndexFile(linkageID, file);
- IIndexName[] names= ifile.findNames(0, Integer.MAX_VALUE);
- int j= 0;
+ IIndexFile ifile = getIndexFile(linkageID, file);
+ IIndexName[] names = ifile.findNames(0, Integer.MAX_VALUE);
+ int j = 0;
for (IIndexName indexName : names) {
final String name = indexName.toString();
- final char c0= name.length() > 0 ? name.charAt(0) : 0;
+ final char c0 = name.length() > 0 ? name.charAt(0) : 0;
if ((c0 == '_' || c0 == 'r' || c0 == 'w') && indexName.isReference()) {
- boolean isRead= name.charAt(0) == 'r';
- boolean isWrite= c0 == 'w' || (isRead && name.length() > 1 && name.charAt(1) == 'w');
- String msg= name + "(j=" + j + "):";
+ boolean isRead = name.charAt(0) == 'r';
+ boolean isWrite = c0 == 'w' || (isRead && name.length() > 1 && name.charAt(1) == 'w');
+ String msg = name + "(j=" + j + "):";
assertEquals("Read access for " + msg, isRead, indexName.isReadAccess());
assertEquals("Write access for " + msg, isWrite, indexName.isWriteAccess());
j++;
@@ -429,14 +428,13 @@ public class IndexNamesTests extends BaseTestCase {
// }
public void testReadWriteFlagsCpp() throws Exception {
waitForIndexer();
- String content= getComment();
- IFile file= createFile(getProject().getProject(), "test.cpp", content);
+ String content = getComment();
+ IFile file = createFile(getProject().getProject(), "test.cpp", content);
waitUntilFileIsIndexed(file, 4000);
checkReadWriteFlags(file, ILinkage.CPP_LINKAGE_ID, 48);
}
-
// int _i, ri, wi, rwi;
// void f(int&, int);
// void g(int, int&);
@@ -446,8 +444,8 @@ public class IndexNamesTests extends BaseTestCase {
// }
public void testRWInSecondArg() throws Exception {
waitForIndexer();
- String content= getComment();
- IFile file= createFile(getProject().getProject(), "testRWInSecondArg.cpp", content);
+ String content = getComment();
+ IFile file = createFile(getProject().getProject(), "testRWInSecondArg.cpp", content);
waitUntilFileIsIndexed(file, 4000);
checkReadWriteFlags(file, ILinkage.CPP_LINKAGE_ID, 4);
@@ -463,8 +461,8 @@ public class IndexNamesTests extends BaseTestCase {
// }
public void testRWInConstructorCall_328528() throws Exception {
waitForIndexer();
- String content= getComment();
- IFile file= createFile(getProject().getProject(), "testRWInConstructorCall.cpp", content);
+ String content = getComment();
+ IFile file = createFile(getProject().getProject(), "testRWInConstructorCall.cpp", content);
waitUntilFileIsIndexed(file, 4000);
checkReadWriteFlags(file, ILinkage.CPP_LINKAGE_ID, 2);
@@ -480,8 +478,8 @@ public class IndexNamesTests extends BaseTestCase {
// }
public void testRWInArrayInitializer_328528() throws Exception {
waitForIndexer();
- String content= getComment();
- IFile file= createFile(getProject().getProject(), "testRWInArrayInitializer.cpp", content);
+ String content = getComment();
+ IFile file = createFile(getProject().getProject(), "testRWInArrayInitializer.cpp", content);
waitUntilFileIsIndexed(file, 4000);
checkReadWriteFlags(file, ILinkage.CPP_LINKAGE_ID, 2);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java
index 34b21113967..d0a62652447 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java
@@ -75,23 +75,23 @@ import junit.framework.TestSuite;
public class IndexProviderManagerTest extends IndexTestBase {
private static final int A_FRAGMENT_OPTION = IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION;
- final static DummyProviderTraces DPT= DummyProviderTraces.getInstance();
- final static Class DP1= Providers.Dummy1.class;
- final static Class DP2= Providers.Dummy2.class;
- final static Class DP3= Providers.Dummy3.class;
- final static Class DP4= Providers.Dummy4.class;
- final static Class DP5= Providers.Dummy5.class;
- final static Class[] DPS= new Class[] {DP4, DP2, DP1, DP3, DP5};
+ final static DummyProviderTraces DPT = DummyProviderTraces.getInstance();
+ final static Class DP1 = Providers.Dummy1.class;
+ final static Class DP2 = Providers.Dummy2.class;
+ final static Class DP3 = Providers.Dummy3.class;
+ final static Class DP4 = Providers.Dummy4.class;
+ final static Class DP5 = Providers.Dummy5.class;
+ final static Class[] DPS = new Class[] { DP4, DP2, DP1, DP3, DP5 };
/*
* Fictional compatibility ranges for testing
*/
- final static VersionRange VERSION_400= new VersionRange("36");
- final static VersionRange VERSION_401= new VersionRange("[36,37]");
- final static VersionRange VERSION_405= new VersionRange("[37,39]");
- final static VersionRange VERSION_502= new VersionRange("[89,91]");
+ final static VersionRange VERSION_400 = new VersionRange("36");
+ final static VersionRange VERSION_401 = new VersionRange("[36,37]");
+ final static VersionRange VERSION_405 = new VersionRange("[37,39]");
+ final static VersionRange VERSION_502 = new VersionRange("[89,91]");
- final CCorePlugin core= CCorePlugin.getDefault();
+ final CCorePlugin core = CCorePlugin.getDefault();
public IndexProviderManagerTest() {
super("IndexProviderManagerTest");
@@ -110,8 +110,9 @@ public class IndexProviderManagerTest extends IndexTestBase {
@Override
protected void tearDown() throws Exception {
DPT.enabled = false;
- IndexProviderManager ipm= ((PDOMManager)CCorePlugin.getIndexManager()).getIndexProviderManager();
- ipm.reset(); ipm.startup();
+ IndexProviderManager ipm = ((PDOMManager) CCorePlugin.getIndexManager()).getIndexProviderManager();
+ ipm.reset();
+ ipm.startup();
}
public void testProvider_SimpleLifeCycle_200958() throws Exception {
@@ -120,24 +121,26 @@ public class IndexProviderManagerTest extends IndexTestBase {
List cprojects = new ArrayList(), expectedTrace = new ArrayList();
try {
- for(int i=0; i<3; i++) {
- ICProject cproject = CProjectHelper.createCProject("P"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
+ for (int i = 0; i < 3; i++) {
+ ICProject cproject = CProjectHelper.createCProject("P" + System.currentTimeMillis(), "bin",
+ IPDOMManager.ID_NO_INDEXER);
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
cprojects.add(cproject);
expectedTrace.add(cproject);
}
for (Class element : DPS)
assertEquals(expectedTrace, DPT.getProjectsTrace(element));
- for(int i=0; i<expectedTrace.size(); i++) {
+ for (int i = 0; i < expectedTrace.size(); i++) {
ICProject cproject = (ICProject) expectedTrace.get(i);
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
}
for (Class element : DPS)
assertEquals(expectedTrace, DPT.getProjectsTrace(element));
} finally {
- for(int i=0; i<cprojects.size(); i++) {
+ for (int i = 0; i < cprojects.size(); i++) {
ICProject cproject = (ICProject) expectedTrace.get(i);
- cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
}
@@ -148,20 +151,22 @@ public class IndexProviderManagerTest extends IndexTestBase {
List expectedTrace = new ArrayList();
ICProject cproject = null;
try {
- String name = "P"+System.currentTimeMillis();
+ String name = "P" + System.currentTimeMillis();
cproject = CProjectHelper.createCProject(name, "bin", IPDOMManager.ID_NO_INDEXER);
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
expectedTrace.add(cproject);
assertEquals(expectedTrace, DPT.getProjectsTrace(DP1));
- cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
cproject = CProjectHelper.createCProject(name, "bin", IPDOMManager.ID_NO_INDEXER);
index = CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
expectedTrace.add(cproject);
assertEquals(expectedTrace, DPT.getProjectsTrace(DP1));
} finally {
- if(cproject!=null) {
- cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ if (cproject != null) {
+ cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
}
@@ -177,7 +182,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
ICProject cproject = null;
try {
- String name = "P"+System.currentTimeMillis();
+ String name = "P" + System.currentTimeMillis();
cproject = CProjectHelper.createCProject(name, "bin", IPDOMManager.ID_NO_INDEXER);
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
expectedTrace.add(cproject);
@@ -192,50 +197,48 @@ public class IndexProviderManagerTest extends IndexTestBase {
index = CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
assertEquals(expectedTrace, DPT.getProjectsTrace(DP1));
} finally {
- if(cproject!=null) {
- cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ if (cproject != null) {
+ cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
}
public void testVersioning_IncompatibleIgnored() throws Exception {
- IndexProviderManager ipm= ((PDOMManager)CCorePlugin.getIndexManager()).getIndexProviderManager();
+ IndexProviderManager ipm = ((PDOMManager) CCorePlugin.getIndexManager()).getIndexProviderManager();
ICProject cproject = null;
try {
- cproject= CProjectHelper.createCCProject("IndexFactoryConfigurationUsageTest", IPDOMManager.ID_NO_INDEXER);
- IProject project= cproject.getProject();
-
+ cproject = CProjectHelper.createCCProject("IndexFactoryConfigurationUsageTest", IPDOMManager.ID_NO_INDEXER);
+ IProject project = cproject.getProject();
MockState mockState = new MockState(cproject);
mockState.setConfig(MockState.REL_V1_ID);
- IIndexProvider provider1= new IIndexFragmentProvider() {
- IIndexFragment[] fragments= new IIndexFragment[] {
- new MockPDOM("contentID.contentA", "36"),
- new MockPDOM("contentID.contentA", "37"),
- new MockPDOM("contentID.foo", "90"),
- new MockPDOM("contentID.bar", "91"),
- new MockPDOM("contentID.baz", "89")
- };
+ IIndexProvider provider1 = new IIndexFragmentProvider() {
+ IIndexFragment[] fragments = new IIndexFragment[] { new MockPDOM("contentID.contentA", "36"),
+ new MockPDOM("contentID.contentA", "37"), new MockPDOM("contentID.foo", "90"),
+ new MockPDOM("contentID.bar", "91"), new MockPDOM("contentID.baz", "89") };
+
@Override
public IIndexFragment[] getIndexFragments(ICConfigurationDescription config) {
return fragments;
}
+
@Override
public boolean providesFor(ICProject project) throws CoreException {
return true;
}
};
- IIndexProvider provider2= new IIndexFragmentProvider() {
- IIndexFragment[] fragments= new IIndexFragment[] {
- new MockPDOM("contentID.baz", "90"),
- new MockPDOM("contentID.contentA", "38"),
- };
+ IIndexProvider provider2 = new IIndexFragmentProvider() {
+ IIndexFragment[] fragments = new IIndexFragment[] { new MockPDOM("contentID.baz", "90"),
+ new MockPDOM("contentID.contentA", "38"), };
+
@Override
public IIndexFragment[] getIndexFragments(ICConfigurationDescription config) {
return fragments;
}
+
@Override
public boolean providesFor(ICProject project) throws CoreException {
return true;
@@ -244,56 +247,56 @@ public class IndexProviderManagerTest extends IndexTestBase {
waitForIndexer(cproject);
setExpectedNumberOfLoggedNonOKStatusObjects(3); // foo, bar and baz have no compatible fragments available
- ipm.reset(VERSION_405); ipm.startup();
- ipm.addIndexProvider(provider1); ipm.addIndexProvider(provider2);
+ ipm.reset(VERSION_405);
+ ipm.startup();
+ ipm.addIndexProvider(provider1);
+ ipm.addIndexProvider(provider2);
IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
assertEquals(1, actual.length);
assertFragmentPresent("contentID.contentA", "38", actual);
} finally {
- if(cproject!=null) {
- cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ if (cproject != null) {
+ cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
}
public void testVersioning_NoCompatibleVersionsFound() throws Exception {
- IndexProviderManager ipm= ((PDOMManager)CCorePlugin.getIndexManager()).getIndexProviderManager();
+ IndexProviderManager ipm = ((PDOMManager) CCorePlugin.getIndexManager()).getIndexProviderManager();
ICProject cproject = null;
try {
- cproject= CProjectHelper.createCCProject("IndexFactoryConfigurationUsageTest", IPDOMManager.ID_NO_INDEXER);
- IProject project= cproject.getProject();
-
+ cproject = CProjectHelper.createCCProject("IndexFactoryConfigurationUsageTest", IPDOMManager.ID_NO_INDEXER);
+ IProject project = cproject.getProject();
MockState mockState = new MockState(cproject);
mockState.setConfig(MockState.REL_V1_ID);
- IIndexProvider provider1= new IIndexFragmentProvider() {
- IIndexFragment[] fragments= new IIndexFragment[] {
- new MockPDOM("contentID.contentA", "36"),
- new MockPDOM("contentID.contentA", "37"),
- new MockPDOM("contentID.foo", "90"),
- new MockPDOM("contentID.bar", "91"),
- new MockPDOM("contentID.baz", "89")
- };
+ IIndexProvider provider1 = new IIndexFragmentProvider() {
+ IIndexFragment[] fragments = new IIndexFragment[] { new MockPDOM("contentID.contentA", "36"),
+ new MockPDOM("contentID.contentA", "37"), new MockPDOM("contentID.foo", "90"),
+ new MockPDOM("contentID.bar", "91"), new MockPDOM("contentID.baz", "89") };
+
@Override
public IIndexFragment[] getIndexFragments(ICConfigurationDescription config) {
return fragments;
}
+
@Override
public boolean providesFor(ICProject project) throws CoreException {
return true;
}
};
- IIndexProvider provider2= new IIndexFragmentProvider() {
- IIndexFragment[] fragments= new IIndexFragment[] {
- new MockPDOM("contentID.contentA", "41"),
- };
+ IIndexProvider provider2 = new IIndexFragmentProvider() {
+ IIndexFragment[] fragments = new IIndexFragment[] { new MockPDOM("contentID.contentA", "41"), };
+
@Override
public IIndexFragment[] getIndexFragments(ICConfigurationDescription config) {
return fragments;
}
+
@Override
public boolean providesFor(ICProject project) throws CoreException {
return true;
@@ -303,8 +306,10 @@ public class IndexProviderManagerTest extends IndexTestBase {
waitForIndexer(cproject);
setExpectedNumberOfLoggedNonOKStatusObjects(1); // contentA has no compatible fragments available
- ipm.reset(VERSION_502); ipm.startup();
- ipm.addIndexProvider(provider1); ipm.addIndexProvider(provider2);
+ ipm.reset(VERSION_502);
+ ipm.startup();
+ ipm.addIndexProvider(provider1);
+ ipm.addIndexProvider(provider2);
IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
assertEquals(3, actual.length);
@@ -312,26 +317,27 @@ public class IndexProviderManagerTest extends IndexTestBase {
assertFragmentPresent("contentID.bar", "91", actual);
assertFragmentPresent("contentID.baz", "89", actual);
} finally {
- if(cproject!=null) {
- cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ if (cproject != null) {
+ cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
}
private void assertFragmentPresent(String id, String version, IIndexFragment[] fragments) throws Exception {
for (IIndexFragment candidate : fragments) {
- String cid= null, csver= null;
+ String cid = null, csver = null;
try {
candidate.acquireReadLock();
- cid= candidate.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID);
- csver= candidate.getProperty(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_VERSION);
+ cid = candidate.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID);
+ csver = candidate.getProperty(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_VERSION);
} finally {
candidate.releaseReadLock();
}
- if(id.equals(cid) && version.equals(csver))
+ if (id.equals(cid) && version.equals(csver))
return;
}
- fail("Fragment matching (id="+id+",version="+version+") was not present");
+ fail("Fragment matching (id=" + id + ",version=" + version + ") was not present");
}
public void testIndexFactoryConfigurationUsage() throws Exception {
@@ -339,17 +345,17 @@ public class IndexProviderManagerTest extends IndexTestBase {
ICProject cproject = null;
// Modifying the .project file triggers an indexer job, suppress that:
- DeltaAnalyzer.sSuppressPotentialTUs= true;
+ DeltaAnalyzer.sSuppressPotentialTUs = true;
try {
cproject = CProjectHelper.createCCProject("IndexFactoryConfigurationUsageTest", IPDOMManager.ID_NO_INDEXER);
- IProject project= cproject.getProject();
+ IProject project = cproject.getProject();
- ICProjectDescription pd= core.getProjectDescription(project);
- ICConfigurationDescription cfg1= newCfg(pd, "project", "config1");
- ICConfigurationDescription cfg2= newCfg(pd, "project", "config2");
+ ICProjectDescription pd = core.getProjectDescription(project);
+ ICConfigurationDescription cfg1 = newCfg(pd, "project", "config1");
+ ICConfigurationDescription cfg2 = newCfg(pd, "project", "config2");
core.setProjectDescription(project, pd);
- index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
+ index = CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
waitForIndexer(cproject);
DPT.reset(DP1);
@@ -359,17 +365,17 @@ public class IndexProviderManagerTest extends IndexTestBase {
changeActiveConfiguration(cproject, cfg1);
DPT.reset(DP1);
- index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
+ index = CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
assertEquals(0, DPT.getProjectsTrace(DP1).size());
assertEquals(1, DPT.getCfgsTrace(DP1).size());
- assertEquals("project.config1", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId());
+ assertEquals("project.config1", ((ICConfigurationDescription) DPT.getCfgsTrace(DP1).get(0)).getId());
changeActiveConfiguration(cproject, cfg2);
DPT.reset(DP1);
- index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
+ index = CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
assertEquals(0, DPT.getProjectsTrace(DP1).size());
assertEquals(1, DPT.getCfgsTrace(DP1).size());
- assertEquals("project.config2", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId());
+ assertEquals("project.config2", ((ICConfigurationDescription) DPT.getCfgsTrace(DP1).get(0)).getId());
DPT.reset(DP1);
changeConfigRelations(cproject, ICProjectDescriptionPreferences.CONFIGS_INDEPENDENT);
@@ -378,36 +384,38 @@ public class IndexProviderManagerTest extends IndexTestBase {
changeActiveConfiguration(cproject, cfg1);
DPT.reset(DP1);
- index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
+ index = CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
assertEquals(0, DPT.getProjectsTrace(DP1).size());
assertEquals(1, DPT.getCfgsTrace(DP1).size());
// should still be config2, as the change in active configuration does not matter
- assertEquals("project.config2", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId());
+ assertEquals("project.config2", ((ICConfigurationDescription) DPT.getCfgsTrace(DP1).get(0)).getId());
changeActiveConfiguration(cproject, cfg2);
DPT.reset(DP1);
- index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
+ index = CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
assertEquals(0, DPT.getProjectsTrace(DP1).size());
assertEquals(1, DPT.getCfgsTrace(DP1).size());
// there should be no change from the previous state (also config2)
- assertEquals("project.config2", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId());
+ assertEquals("project.config2", ((ICConfigurationDescription) DPT.getCfgsTrace(DP1).get(0)).getId());
} finally {
- DeltaAnalyzer.sSuppressPotentialTUs= false;
+ DeltaAnalyzer.sSuppressPotentialTUs = false;
if (cproject != null) {
- cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
}
public void testGetProvidedFragments() throws Exception {
- ICProject cproject= CProjectHelper.createCProject("IndexProviderManagerTest", "bin", IPDOMManager.ID_NO_INDEXER);
+ ICProject cproject = CProjectHelper.createCProject("IndexProviderManagerTest", "bin",
+ IPDOMManager.ID_NO_INDEXER);
try {
MockState mockState = new MockState(cproject);
MockStateIndexFragmentProvider provider1 = new MockStateIndexFragmentProvider(cproject);
MockStateIndexFragmentProvider provider2 = new MockStateIndexFragmentProvider(cproject);
- IndexProviderManager ipm = ((PDOMManager)CCorePlugin.getIndexManager()).getIndexProviderManager();
+ IndexProviderManager ipm = ((PDOMManager) CCorePlugin.getIndexManager()).getIndexProviderManager();
ipm.addIndexProvider(provider1);
ipm.addIndexProvider(provider2);
@@ -501,72 +509,77 @@ public class IndexProviderManagerTest extends IndexTestBase {
assertTrue(ArrayUtil.contains(fragments, provider2.fragments[3]));
} finally {
if (cproject != null) {
- cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
}
public void testProviderUsageFilter() throws Exception {
// The provider 'Providers.Counter' is registered 7 times with different usage filters.
- ICProject cproject= null;
+ ICProject cproject = null;
try {
- cproject = CProjectHelper.createCProject("P"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
+ cproject = CProjectHelper.createCProject("P" + System.currentTimeMillis(), "bin",
+ IPDOMManager.ID_NO_INDEXER);
- Providers.Counter.fCounter= 0;
+ Providers.Counter.fCounter = 0;
CCorePlugin.getIndexManager().getIndex(cproject, IIndexManager.ADD_EXTENSION_FRAGMENTS_ADD_IMPORT);
assertEquals(7, Providers.Counter.fCounter);
- Providers.Counter.fCounter= 0;
+ Providers.Counter.fCounter = 0;
CCorePlugin.getIndexManager().getIndex(cproject, IIndexManager.ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY);
assertEquals(6, Providers.Counter.fCounter);
- Providers.Counter.fCounter= 0;
+ Providers.Counter.fCounter = 0;
CCorePlugin.getIndexManager().getIndex(cproject, IIndexManager.ADD_EXTENSION_FRAGMENTS_CONTENT_ASSIST);
assertEquals(5, Providers.Counter.fCounter);
- Providers.Counter.fCounter= 0;
+ Providers.Counter.fCounter = 0;
CCorePlugin.getIndexManager().getIndex(cproject, IIndexManager.ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER);
assertEquals(4, Providers.Counter.fCounter);
- Providers.Counter.fCounter= 0;
+ Providers.Counter.fCounter = 0;
CCorePlugin.getIndexManager().getIndex(cproject, IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION);
assertEquals(3, Providers.Counter.fCounter);
- Providers.Counter.fCounter= 0;
+ Providers.Counter.fCounter = 0;
CCorePlugin.getIndexManager().getIndex(cproject, IIndexManager.ADD_EXTENSION_FRAGMENTS_SEARCH);
assertEquals(2, Providers.Counter.fCounter);
- Providers.Counter.fCounter= 0;
+ Providers.Counter.fCounter = 0;
CCorePlugin.getIndexManager().getIndex(cproject, IIndexManager.ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY);
assertEquals(1, Providers.Counter.fCounter);
- Providers.Counter.fCounter= 0;
+ Providers.Counter.fCounter = 0;
CCorePlugin.getIndexManager().getIndex(cproject);
assertEquals(0, Providers.Counter.fCounter);
} finally {
if (cproject != null) {
- cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
}
-
- private ICConfigurationDescription newCfg(ICProjectDescription des, String project, String config) throws CoreException {
- CDefaultConfigurationData data= new CDefaultConfigurationData(project+"."+config, project+" "+config+" name", null);
+ private ICConfigurationDescription newCfg(ICProjectDescription des, String project, String config)
+ throws CoreException {
+ CDefaultConfigurationData data = new CDefaultConfigurationData(project + "." + config,
+ project + " " + config + " name", null);
data.initEmptyData();
return des.createConfiguration(CCorePlugin.DEFAULT_PROVIDER_ID, data);
}
- private void changeActiveConfiguration(ICProject cproject, ICConfigurationDescription cfg) throws CoreException, InterruptedException {
- ICProjectDescription pd= core.getProjectDescription(cproject.getProject());
+ private void changeActiveConfiguration(ICProject cproject, ICConfigurationDescription cfg)
+ throws CoreException, InterruptedException {
+ ICProjectDescription pd = core.getProjectDescription(cproject.getProject());
pd.setActiveConfiguration(pd.getConfigurationById(cfg.getId()));
core.setProjectDescription(cproject.getProject(), pd);
waitForIndexer(cproject);
}
private void changeConfigRelations(ICProject cproject, int option) throws CoreException, InterruptedException {
- ICProjectDescription pd= core.getProjectDescription(cproject.getProject());
+ ICProjectDescription pd = core.getProjectDescription(cproject.getProject());
pd.setConfigurationRelations(option);
core.setProjectDescription(cproject.getProject(), pd);
waitForIndexer(cproject);
@@ -598,21 +611,22 @@ class MockStateIndexFragmentProvider extends MockStateIndexProvider implements I
super(cproject);
fragments = new IIndexFragment[MockState.states.size()];
- for(int i=0; i<MockState.states.size(); i++) {
- fragments[i] = new MockPDOM("mock.test.index."+System.identityHashCode(this)+"."+i, PDOM.versionString(PDOM.getDefaultVersion()));
+ for (int i = 0; i < MockState.states.size(); i++) {
+ fragments[i] = new MockPDOM("mock.test.index." + System.identityHashCode(this) + "." + i,
+ PDOM.versionString(PDOM.getDefaultVersion()));
}
}
@Override
public IIndexFragment[] getIndexFragments(ICConfigurationDescription config) throws CoreException {
int index = MockState.states.indexOf(config.getId());
- index = invert ? (fragments.length-1)-index : index;
+ index = invert ? (fragments.length - 1) - index : index;
// nb. we're checking this after inverting on purpose
- if(index == MockState.states.indexOf(MockState.DBG_V1_ID)) {
+ if (index == MockState.states.indexOf(MockState.DBG_V1_ID)) {
return new IIndexFragment[0];
} else {
- return new IIndexFragment[] {fragments[index]};
+ return new IIndexFragment[] { fragments[index] };
}
}
}
@@ -622,8 +636,8 @@ class MockConfig implements ICConfigurationDescription {
IProject project;
MockConfig(String id, IProject project) {
- this.id= id;
- this.project= project;
+ this.id = id;
+ this.project = project;
}
@Override
@@ -632,29 +646,25 @@ class MockConfig implements ICConfigurationDescription {
}
@Override
- public ICConfigExtensionReference create(String extensionPoint,
- String extension) throws CoreException {
+ public ICConfigExtensionReference create(String extensionPoint, String extension) throws CoreException {
return null;
}
@Override
- public ICExternalSetting createExternalSetting(String[] languageIDs,
- String[] contentTypeIds, String[] extensions,
+ public ICExternalSetting createExternalSetting(String[] languageIDs, String[] contentTypeIds, String[] extensions,
ICSettingEntry[] entries) throws WriteAccessException {
return null;
}
@Override
- public ICFileDescription createFileDescription(IPath path,
- ICResourceDescription base) throws CoreException,
- WriteAccessException {
+ public ICFileDescription createFileDescription(IPath path, ICResourceDescription base)
+ throws CoreException, WriteAccessException {
return null;
}
@Override
- public ICFolderDescription createFolderDescription(IPath path,
- ICFolderDescription base) throws CoreException,
- WriteAccessException {
+ public ICFolderDescription createFolderDescription(IPath path, ICFolderDescription base)
+ throws CoreException, WriteAccessException {
return null;
}
@@ -714,8 +724,7 @@ class MockConfig implements ICConfigurationDescription {
}
@Override
- public ICResourceDescription getResourceDescription(IPath path,
- boolean exactPath) {
+ public ICResourceDescription getResourceDescription(IPath path, boolean exactPath) {
return null;
}
@@ -725,64 +734,128 @@ class MockConfig implements ICConfigurationDescription {
}
@Override
- public ICFolderDescription getRootFolderDescription() {return null;}
+ public ICFolderDescription getRootFolderDescription() {
+ return null;
+ }
+
@Override
- public Object getSessionProperty(QualifiedName name) {return null;}
+ public Object getSessionProperty(QualifiedName name) {
+ return null;
+ }
+
@Override
- public ICSourceEntry[] getSourceEntries() {return null;}
+ public ICSourceEntry[] getSourceEntries() {
+ return null;
+ }
+
@Override
- public ICTargetPlatformSetting getTargetPlatformSetting() {return null;}
+ public ICTargetPlatformSetting getTargetPlatformSetting() {
+ return null;
+ }
+
@Override
- public boolean isActive() {return false;}
+ public boolean isActive() {
+ return false;
+ }
+
@Override
- public boolean isModified() {return false;}
+ public boolean isModified() {
+ return false;
+ }
+
@Override
- public boolean isPreferenceConfiguration() {return false;}
+ public boolean isPreferenceConfiguration() {
+ return false;
+ }
+
@Override
- public void remove(ICConfigExtensionReference ext) throws CoreException {}
+ public void remove(ICConfigExtensionReference ext) throws CoreException {
+ }
+
@Override
- public void remove(String extensionPoint) throws CoreException {}
+ public void remove(String extensionPoint) throws CoreException {
+ }
+
@Override
- public void removeExternalSetting(ICExternalSetting setting) throws WriteAccessException {}
+ public void removeExternalSetting(ICExternalSetting setting) throws WriteAccessException {
+ }
+
@Override
- public void removeExternalSettings() throws WriteAccessException {}
+ public void removeExternalSettings() throws WriteAccessException {
+ }
+
@Override
- public void removeResourceDescription(ICResourceDescription des)
- throws CoreException, WriteAccessException {}
+ public void removeResourceDescription(ICResourceDescription des) throws CoreException, WriteAccessException {
+ }
+
@Override
- public void setActive() throws WriteAccessException {}
+ public void setActive() throws WriteAccessException {
+ }
+
@Override
- public void setConfigurationData(String buildSystemId,
- CConfigurationData data) throws WriteAccessException {}
+ public void setConfigurationData(String buildSystemId, CConfigurationData data) throws WriteAccessException {
+ }
+
@Override
- public void setDescription(String des) throws WriteAccessException {}
+ public void setDescription(String des) throws WriteAccessException {
+ }
+
@Override
- public void setName(String name) throws WriteAccessException {}
+ public void setName(String name) throws WriteAccessException {
+ }
+
@Override
- public void setReferenceInfo(Map<String, String> refs) throws WriteAccessException {}
+ public void setReferenceInfo(Map<String, String> refs) throws WriteAccessException {
+ }
+
@Override
- public void setSessionProperty(QualifiedName name, Object value) {}
+ public void setSessionProperty(QualifiedName name, Object value) {
+ }
+
@Override
- public void setSourceEntries(ICSourceEntry[] entries) throws CoreException,
- WriteAccessException {}
+ public void setSourceEntries(ICSourceEntry[] entries) throws CoreException, WriteAccessException {
+ }
+
@Override
- public ICSettingObject[] getChildSettings() {return null;}
+ public ICSettingObject[] getChildSettings() {
+ return null;
+ }
+
@Override
- public ICConfigurationDescription getConfiguration() {return null;}
+ public ICConfigurationDescription getConfiguration() {
+ return null;
+ }
+
@Override
- public String getName() {return null;}
+ public String getName() {
+ return null;
+ }
+
@Override
- public ICSettingContainer getParent() {return null;}
+ public ICSettingContainer getParent() {
+ return null;
+ }
+
@Override
- public int getType() {return 0;}
+ public int getType() {
+ return 0;
+ }
+
@Override
- public boolean isReadOnly() {return false;}
+ public boolean isReadOnly() {
+ return false;
+ }
+
@Override
- public boolean isValid() {return false;}
+ public boolean isValid() {
+ return false;
+ }
+
@Override
public ICStorageElement getStorage(String id, boolean create) throws CoreException {
return null;
}
+
@Override
public ICStorageElement importStorage(String id, ICStorageElement storage) {
return null;
@@ -803,10 +876,12 @@ class MockConfig implements ICConfigurationDescription {
}
@Override
- public void setExternalSettingsProviderIds(String[] ids) {}
+ public void setExternalSettingsProviderIds(String[] ids) {
+ }
@Override
- public void updateExternalSettingsProviders(String[] ids) {}
+ public void updateExternalSettingsProviders(String[] ids) {
+ }
@Override
public ICSourceEntry[] getResolvedSourceEntries() {
@@ -819,7 +894,8 @@ class MockConfig implements ICConfigurationDescription {
}
@Override
- public void setReadOnly(boolean readOnly, boolean keepModify) {}
+ public void setReadOnly(boolean readOnly, boolean keepModify) {
+ }
}
/*
@@ -830,14 +906,15 @@ class MockState {
public static final String REL_V2_ID = "rel_v2";
public static final String DBG_V1_ID = "dbg_v1";
public static final String DBG_V2_ID = "dbg_v2";
- public static final List states = new ArrayList(Arrays.asList(new String[]{REL_V1_ID, REL_V2_ID, DBG_V1_ID, DBG_V2_ID}));
+ public static final List states = new ArrayList(
+ Arrays.asList(new String[] { REL_V1_ID, REL_V2_ID, DBG_V1_ID, DBG_V2_ID }));
private final IProject project;
private String currentConfig;
public MockState(ICProject cproject) {
this.currentConfig = REL_V1_ID;
- this.project= cproject.getProject();
+ this.project = cproject.getProject();
}
public ICConfigurationDescription getCurrentConfig() {
@@ -854,19 +931,19 @@ class MockPDOM extends EmptyIndexFragment {
String version;
MockPDOM(String id, String version) {
- this.id= id;
- this.version= version;
+ this.id = id;
+ this.version = version;
}
@Override
public String getProperty(String propertyName) throws CoreException {
- if(IIndexFragment.PROPERTY_FRAGMENT_ID.equals(propertyName)) {
+ if (IIndexFragment.PROPERTY_FRAGMENT_ID.equals(propertyName)) {
return id;
}
- if(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_ID.equals(propertyName)) {
+ if (IIndexFragment.PROPERTY_FRAGMENT_FORMAT_ID.equals(propertyName)) {
return PDOM.FRAGMENT_PROPERTY_VALUE_FORMAT_ID;
}
- if(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_VERSION.equals(propertyName)) {
+ if (IIndexFragment.PROPERTY_FRAGMENT_FORMAT_VERSION.equals(propertyName)) {
return version;
}
return null;
@@ -874,6 +951,6 @@ class MockPDOM extends EmptyIndexFragment {
@Override
public String toString() {
- return "[Mock index fragment "+id+"."+System.identityHashCode(this)+"]";
+ return "[Mock index fragment " + id + "." + System.identityHashCode(this) + "]";
}
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexSearchTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexSearchTest.java
index 186492f2cae..e67be0df2ce 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexSearchTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexSearchTest.java
@@ -43,7 +43,7 @@ public class IndexSearchTest extends IndexTestBase {
private static final IndexFilter INDEX_FILTER = IndexFilter.ALL_DECLARED;
public static TestSuite suite() {
- TestSuite suite= suite(IndexSearchTest.class, "_");
+ TestSuite suite = suite(IndexSearchTest.class, "_");
suite.addTest(new IndexSearchTest("deleteProject"));
return suite;
}
@@ -59,9 +59,9 @@ public class IndexSearchTest extends IndexTestBase {
public void setUp() throws Exception {
super.setUp();
if (fProject == null) {
- fProject= createProject(true, "resources/indexTests/search");
+ fProject = createProject(true, "resources/indexTests/search");
}
- fIndex= CCorePlugin.getIndexManager().getIndex(fProject);
+ fIndex = CCorePlugin.getIndexManager().getIndex(fProject);
fIndex.acquireReadLock();
}
@@ -105,136 +105,137 @@ public class IndexSearchTest extends IndexTestBase {
public void testFindClassInNamespace() throws CoreException {
String scl = "C160913";
- Pattern pcl= Pattern.compile(scl);
+ Pattern pcl = Pattern.compile(scl);
String sns = "ns160913";
- Pattern pns= Pattern.compile(sns);
+ Pattern pns = Pattern.compile(sns);
IIndexBinding[] bindings;
- bindings= fIndex.findBindings(pcl, true, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(pcl, true, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
checkIsClass(bindings[0]);
- bindings= fIndex.findBindings(scl.toCharArray(), INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(scl.toCharArray(), INDEX_FILTER, npm());
assertEquals(1, bindings.length);
checkIsClass(bindings[0]);
- bindings= fIndex.findBindings(pcl, false, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(pcl, false, INDEX_FILTER, npm());
assertEquals(3, bindings.length);
checkIsClass(bindings[0]);
checkIsClass(bindings[1]);
checkIsClass(bindings[2]);
- bindings= fIndex.findBindings(new Pattern[]{pns, pcl}, true, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(new Pattern[] { pns, pcl }, true, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
checkIsClass(bindings[0]);
- bindings= fIndex.findBindings(new char[][]{sns.toCharArray(), scl.toCharArray()}, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(new char[][] { sns.toCharArray(), scl.toCharArray() }, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
checkIsClass(bindings[0]);
- bindings= fIndex.findBindings(new Pattern[]{pns, pcl}, false, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(new Pattern[] { pns, pcl }, false, INDEX_FILTER, npm());
assertEquals(2, bindings.length);
checkIsClass(bindings[0]);
checkIsClass(bindings[1]);
- bindings= fIndex.findBindings(new Pattern[]{pns, pns, pcl}, true, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(new Pattern[] { pns, pns, pcl }, true, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
checkIsClass(bindings[0]);
- bindings= fIndex.findBindings(new char[][]{sns.toCharArray(), sns.toCharArray(), scl.toCharArray()}, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(new char[][] { sns.toCharArray(), sns.toCharArray(), scl.toCharArray() },
+ INDEX_FILTER, npm());
assertEquals(1, bindings.length);
checkIsClass(bindings[0]);
- bindings= fIndex.findBindings(new Pattern[]{pns, pns, pcl}, false, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(new Pattern[] { pns, pns, pcl }, false, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
checkIsClass(bindings[0]);
}
public void testFindNamespaceInNamespace() throws CoreException {
- Pattern pcl= Pattern.compile("C160913");
- Pattern pns= Pattern.compile("ns160913");
- char[] scl= pcl.pattern().toCharArray();
- char[] sns= pns.pattern().toCharArray();
+ Pattern pcl = Pattern.compile("C160913");
+ Pattern pns = Pattern.compile("ns160913");
+ char[] scl = pcl.pattern().toCharArray();
+ char[] sns = pns.pattern().toCharArray();
IIndexBinding[] bindings;
- bindings= fIndex.findBindings(pns, true, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(pns, true, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
checkIsNamespace(bindings[0]);
- bindings= fIndex.findBindings(sns, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(sns, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
checkIsNamespace(bindings[0]);
- bindings= fIndex.findBindings(pns, false, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(pns, false, INDEX_FILTER, npm());
assertEquals(2, bindings.length);
checkIsNamespace(bindings[0]);
checkIsNamespace(bindings[1]);
- bindings= fIndex.findBindings(new Pattern[]{pns, pns}, true, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(new Pattern[] { pns, pns }, true, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
checkIsNamespace(bindings[0]);
- bindings= fIndex.findBindings(new char[][]{sns, sns}, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(new char[][] { sns, sns }, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
checkIsNamespace(bindings[0]);
- bindings= fIndex.findBindings(new Pattern[]{pns, pns}, false, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(new Pattern[] { pns, pns }, false, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
checkIsNamespace(bindings[0]);
}
public void testClassInUnnamedNamespace() throws CoreException {
- Pattern pcl= Pattern.compile("CInUnnamed160913");
+ Pattern pcl = Pattern.compile("CInUnnamed160913");
IIndexBinding[] bindings;
// The binding in the unnamed namespace is not visible in global scope.
- bindings= fIndex.findBindings(pcl, true, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(pcl, true, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
assertTrue(bindings[0].isFileLocal());
- bindings= fIndex.findBindings(pcl.pattern().toCharArray(), INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(pcl.pattern().toCharArray(), INDEX_FILTER, npm());
assertEquals(1, bindings.length);
assertTrue(bindings[0].isFileLocal());
}
public void testFindEnumerator() throws CoreException {
- Pattern pEnumeration= Pattern.compile("E20061017");
- Pattern pEnumerator= Pattern.compile("e20061017");
- char[] sEnumeration= pEnumeration.pattern().toCharArray();
- char[] sEnumerator= pEnumerator.pattern().toCharArray();
+ Pattern pEnumeration = Pattern.compile("E20061017");
+ Pattern pEnumerator = Pattern.compile("e20061017");
+ char[] sEnumeration = pEnumeration.pattern().toCharArray();
+ char[] sEnumerator = pEnumerator.pattern().toCharArray();
IIndexBinding[] bindings;
// Enumerators are found in global scope.
- bindings= fIndex.findBindings(pEnumerator, true, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(pEnumerator, true, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
checkIsEnumerator(bindings[0]);
- bindings= fIndex.findBindings(pEnumerator, false, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(pEnumerator, false, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
checkIsEnumerator(bindings[0]);
- bindings= fIndex.findBindings(new Pattern[]{pEnumeration, pEnumerator}, true, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(new Pattern[] { pEnumeration, pEnumerator }, true, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
- bindings= fIndex.findBindings(new char[][]{sEnumeration, sEnumerator}, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(new char[][] { sEnumeration, sEnumerator }, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
- bindings= fIndex.findBindings(new Pattern[]{pEnumeration, pEnumerator}, false, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(new Pattern[] { pEnumeration, pEnumerator }, false, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
- bindings= fIndex.findBindings(pEnumeration, true, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(pEnumeration, true, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
checkIsEnumeration(bindings[0]);
- bindings= fIndex.findBindings(sEnumeration, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(sEnumeration, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
checkIsEnumeration(bindings[0]);
- bindings= fIndex.findBindings(pEnumeration, false, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(pEnumeration, false, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
checkIsEnumeration(bindings[0]);
}
@@ -242,61 +243,61 @@ public class IndexSearchTest extends IndexTestBase {
public void testCaseInsensitivePatternSearch_239669() throws CoreException {
IIndexBinding[] bindings;
- Pattern pEnumAndEnumeration= Pattern.compile("E20061017", Pattern.CASE_INSENSITIVE);
- Pattern pEnumeration= Pattern.compile("E20061017");
- bindings= fIndex.findBindings(pEnumAndEnumeration, true, INDEX_FILTER, npm());
+ Pattern pEnumAndEnumeration = Pattern.compile("E20061017", Pattern.CASE_INSENSITIVE);
+ Pattern pEnumeration = Pattern.compile("E20061017");
+ bindings = fIndex.findBindings(pEnumAndEnumeration, true, INDEX_FILTER, npm());
assertEquals(2, bindings.length);
- bindings= fIndex.findBindings(pEnumeration, true, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(pEnumeration, true, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
- pEnumAndEnumeration= Pattern.compile("E2006101.*", Pattern.CASE_INSENSITIVE);
- pEnumeration= Pattern.compile("E2006101.*");
- bindings= fIndex.findBindings(pEnumAndEnumeration, true, INDEX_FILTER, npm());
+ pEnumAndEnumeration = Pattern.compile("E2006101.*", Pattern.CASE_INSENSITIVE);
+ pEnumeration = Pattern.compile("E2006101.*");
+ bindings = fIndex.findBindings(pEnumAndEnumeration, true, INDEX_FILTER, npm());
assertEquals(2, bindings.length);
- bindings= fIndex.findBindings(pEnumeration, true, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(pEnumeration, true, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
- Pattern macro1= Pattern.compile("Foo", Pattern.CASE_INSENSITIVE);
- Pattern macro2= Pattern.compile("Foo");
- bindings= fIndex.findMacroContainers(macro1, INDEX_FILTER, npm());
+ Pattern macro1 = Pattern.compile("Foo", Pattern.CASE_INSENSITIVE);
+ Pattern macro2 = Pattern.compile("Foo");
+ bindings = fIndex.findMacroContainers(macro1, INDEX_FILTER, npm());
assertEquals(2, bindings.length);
- bindings= fIndex.findMacroContainers(macro2, INDEX_FILTER, npm());
+ bindings = fIndex.findMacroContainers(macro2, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
- macro1= Pattern.compile("Foo.*", Pattern.CASE_INSENSITIVE);
- macro2= Pattern.compile("Foo.*");
- bindings= fIndex.findMacroContainers(macro1, INDEX_FILTER, npm());
+ macro1 = Pattern.compile("Foo.*", Pattern.CASE_INSENSITIVE);
+ macro2 = Pattern.compile("Foo.*");
+ bindings = fIndex.findMacroContainers(macro1, INDEX_FILTER, npm());
assertEquals(2, bindings.length);
- bindings= fIndex.findMacroContainers(macro2, INDEX_FILTER, npm());
+ bindings = fIndex.findMacroContainers(macro2, INDEX_FILTER, npm());
assertEquals(1, bindings.length);
}
-
public void testFindStatic_161216() throws CoreException {
- Pattern pFunc= Pattern.compile("staticFunc20061017");
- Pattern pVar= Pattern.compile("staticVar20061017");
+ Pattern pFunc = Pattern.compile("staticFunc20061017");
+ Pattern pVar = Pattern.compile("staticVar20061017");
IIndexBinding[] bindings;
- bindings= fIndex.findBindings(pFunc, false, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(pFunc, false, INDEX_FILTER, npm());
assertEquals(2, bindings.length);
checkIsFunction(bindings[0]);
checkIsFunction(bindings[1]);
- bindings= fIndex.findBindings(pVar, false, INDEX_FILTER, npm());
+ bindings = fIndex.findBindings(pVar, false, INDEX_FILTER, npm());
assertEquals(2, bindings.length);
checkIsVariable(bindings[0]);
checkIsVariable(bindings[1]);
}
public void testSanityOfMayHaveChildren() throws CoreException {
- PDOM pdom= (PDOM) ((CIndex) fIndex).getFragments()[0];
+ PDOM pdom = (PDOM) ((CIndex) fIndex).getFragments()[0];
pdom.accept(new IPDOMVisitor() {
- LinkedList stack= new LinkedList();
+ LinkedList stack = new LinkedList();
+
@Override
public boolean visit(IPDOMNode node) throws CoreException {
if (!stack.isEmpty()) {
- Object last= stack.getLast();
+ Object last = stack.getLast();
if (last instanceof PDOMBinding) {
assertTrue(((PDOMBinding) last).mayHaveChildren());
}
@@ -304,6 +305,7 @@ public class IndexSearchTest extends IndexTestBase {
stack.add(node);
return true;
}
+
@Override
public void leave(IPDOMNode node) throws CoreException {
assertEquals(stack.removeLast(), node);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexTestBase.java
index e3cb01a823c..2e91daf522a 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexTestBase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexTestBase.java
@@ -33,18 +33,19 @@ public class IndexTestBase extends BaseTestCase {
super(name);
}
- protected ICProject createProject(final boolean useCpp, final String importSource) throws CoreException, InterruptedException {
+ protected ICProject createProject(final boolean useCpp, final String importSource)
+ throws CoreException, InterruptedException {
// Create the project
- final ICProject[] result= new ICProject[] {null};
+ final ICProject[] result = new ICProject[] { null };
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
workspace.run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
- String name= "IndexTest_" + System.currentTimeMillis();
+ String name = "IndexTest_" + System.currentTimeMillis();
if (useCpp) {
- result[0]= CProjectHelper.createCCProject(name, null, IPDOMManager.ID_NO_INDEXER);
+ result[0] = CProjectHelper.createCCProject(name, null, IPDOMManager.ID_NO_INDEXER);
} else {
- result[0]= CProjectHelper.createCProject(name, null, IPDOMManager.ID_NO_INDEXER);
+ result[0] = CProjectHelper.createCProject(name, null, IPDOMManager.ID_NO_INDEXER);
}
CProjectHelper.importSourcesFromPlugin(result[0], CTestPlugin.getDefault().getBundle(), importSource);
}
@@ -59,8 +60,8 @@ public class IndexTestBase extends BaseTestCase {
return TestSourceReader.readTaggedComment(CTestPlugin.getDefault().getBundle(), "parser", getClass(), tag);
}
- protected StringBuilder[] getContentsForTest(int blocks) throws IOException {
- return TestSourceReader.getContentsForTest(
- CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), blocks);
- }
+ protected StringBuilder[] getContentsForTest(int blocks) throws IOException {
+ return TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "parser", getClass(),
+ getName(), blocks);
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexUpdateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexUpdateTests.java
index fee07dcea0e..6ceee77a9f9 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexUpdateTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexUpdateTests.java
@@ -69,7 +69,7 @@ import junit.framework.TestSuite;
public class IndexUpdateTests extends IndexTestBase {
private static final String EXPLICIT = "explicit";
private static final String VIRTUAL = "virtual";
- private static final String PURE_VIRTUAL= "pure-virtual";
+ private static final String PURE_VIRTUAL = "pure-virtual";
private static final String PROTECTED = "protected";
private static final String PUBLIC = "public";
private static final String PRIVATE = "private";
@@ -81,10 +81,10 @@ public class IndexUpdateTests extends IndexTestBase {
private static final String AUTO = "auto";
private static final String SHORT = "short int";
private static final String INT = "int";
- private static final String IMPLICIT= "implicit";
+ private static final String IMPLICIT = "implicit";
public static TestSuite suite() {
- TestSuite suite= suite(IndexUpdateTests.class, "_");
+ TestSuite suite = suite(IndexUpdateTests.class, "_");
suite.addTest(new IndexUpdateTests("deleteProject"));
return suite;
}
@@ -105,23 +105,23 @@ public class IndexUpdateTests extends IndexTestBase {
public void setUp() throws Exception {
super.setUp();
if (fCppProject == null) {
- fCppProject= CProjectHelper.createCCProject("indexUpdateTestsCpp", null, IPDOMManager.ID_FAST_INDEXER);
+ fCppProject = CProjectHelper.createCCProject("indexUpdateTestsCpp", null, IPDOMManager.ID_FAST_INDEXER);
}
if (fCProject == null) {
- fCProject= CProjectHelper.createCProject("indexUpdateTestsC", null, IPDOMManager.ID_FAST_INDEXER);
+ fCProject = CProjectHelper.createCProject("indexUpdateTestsC", null, IPDOMManager.ID_FAST_INDEXER);
}
waitForIndexer(fCppProject);
waitForIndexer(fCProject);
- fIndex= CCorePlugin.getIndexManager().getIndex(new ICProject[] {fCProject, fCppProject});
+ fIndex = CCorePlugin.getIndexManager().getIndex(new ICProject[] { fCProject, fCppProject });
}
private void setupHeader(int totalFileVersions, boolean cpp) throws Exception {
if (fContents == null) {
- fContents= getContentsForTest(totalFileVersions);
- fContentUsed= -1;
+ fContents = getContentsForTest(totalFileVersions);
+ fContentUsed = -1;
}
- IProject project= cpp ? fCppProject.getProject() : fCProject.getProject();
- fHeader= TestSourceReader.createFile(project, "header.h", fContents[++fContentUsed].toString());
+ IProject project = cpp ? fCppProject.getProject() : fCProject.getProject();
+ fHeader = TestSourceReader.createFile(project, "header.h", fContents[++fContentUsed].toString());
waitForIndexer(fCppProject);
waitForIndexer(fCProject);
}
@@ -129,19 +129,20 @@ public class IndexUpdateTests extends IndexTestBase {
private void updateHeader() throws Exception {
// Append variable comment to the end of the file to change its contents.
// Indexer would not reindex the file if its contents remain the same.
- IProject project= fHeader.getProject();
- fHeader= TestSourceReader.createFile(project, "header.h",
+ IProject project = fHeader.getProject();
+ fHeader = TestSourceReader.createFile(project, "header.h",
fContents[++fContentUsed].toString() + "\n// " + fContentUsed);
waitUntilFileIsIndexed(fIndex, fHeader);
}
private void setupFile(int totalFileVersions, boolean cpp) throws Exception {
if (fContents == null) {
- fContents= getContentsForTest(totalFileVersions);
- fContentUsed= -1;
+ fContents = getContentsForTest(totalFileVersions);
+ fContentUsed = -1;
}
- ICProject cproject= cpp ? fCppProject : fCProject;
- fFile= TestSourceReader.createFile(cproject.getProject(), "file" + (cpp ? ".cpp" : ".c"), fContents[++fContentUsed].toString());
+ ICProject cproject = cpp ? fCppProject : fCProject;
+ fFile = TestSourceReader.createFile(cproject.getProject(), "file" + (cpp ? ".cpp" : ".c"),
+ fContents[++fContentUsed].toString());
TestSourceReader.waitUntilFileIsIndexed(fIndex, fFile, INDEXER_TIMEOUT_MILLISEC);
waitForIndexer(cproject);
}
@@ -149,14 +150,14 @@ public class IndexUpdateTests extends IndexTestBase {
private void updateFile() throws Exception {
// Append variable comment to the end of the file to change its contents.
// Indexer would not reindex the file if its contents remain the same.
- fFile= TestSourceReader.createFile(fFile.getParent(), fFile.getName(),
+ fFile = TestSourceReader.createFile(fFile.getParent(), fFile.getName(),
fContents[++fContentUsed].toString() + "\n// " + fContentUsed);
waitUntilFileIsIndexed(fIndex, fFile);
}
@Override
public void tearDown() throws Exception {
- fIndex= null;
+ fIndex = null;
if (fFile != null) {
fFile.delete(true, npm());
}
@@ -169,11 +170,11 @@ public class IndexUpdateTests extends IndexTestBase {
public void deleteProject() {
if (fCProject != null) {
CProjectHelper.delete(fCProject);
- fCProject= null;
+ fCProject = null;
}
if (fCppProject != null) {
CProjectHelper.delete(fCppProject);
- fCppProject= null;
+ fCppProject = null;
}
}
@@ -190,9 +191,9 @@ public class IndexUpdateTests extends IndexTestBase {
updateFile();
checkVariable("globalVar", SHORT, new String[] {});
updateFile();
- checkVariable("globalVar", INT, new String[] {AUTO});
+ checkVariable("globalVar", INT, new String[] { AUTO });
updateFile();
- checkVariable("globalVar", INT, new String[] {REGISTER});
+ checkVariable("globalVar", INT, new String[] { REGISTER });
}
private void checkVariable(String name, String type, String[] modifiers) throws Exception {
@@ -209,11 +210,11 @@ public class IndexUpdateTests extends IndexTestBase {
fIndex.acquireReadLock();
try {
IBinding b = findBinding(name);
- IValue v= null;
+ IValue v = null;
if (b instanceof IVariable)
- v= ((IVariable) b).getInitialValue();
+ v = ((IVariable) b).getInitialValue();
else if (b instanceof IEnumerator)
- v= ((IEnumerator) b).getValue();
+ v = ((IEnumerator) b).getValue();
else
fail();
@@ -242,10 +243,10 @@ public class IndexUpdateTests extends IndexTestBase {
}
private IIndexBinding findBinding(String name) throws CoreException {
- String[] names= name.split("::");
- char[][] nchars= new char[names.length][];
+ String[] names = name.split("::");
+ char[][] nchars = new char[names.length][];
for (int i = 0; i < nchars.length; i++) {
- nchars[i]= names[i].toCharArray();
+ nchars[i] = names[i].toCharArray();
}
IIndexBinding[] bindings = fIndex.findBindings(nchars, IndexFilter.ALL_DECLARED, npm());
return bindings.length > 0 ? bindings[0] : null;
@@ -266,11 +267,11 @@ public class IndexUpdateTests extends IndexTestBase {
// register int globalVar;
public void testGlobalCppVariable() throws Exception {
setupFile(3, true);
- checkCppVariable("globalVar", INT, new String[]{});
+ checkCppVariable("globalVar", INT, new String[] {});
updateFile();
- checkCppVariable("globalVar", SHORT, new String[]{});
+ checkCppVariable("globalVar", SHORT, new String[] {});
updateFile();
- checkCppVariable("globalVar", INT, new String[]{});
+ checkCppVariable("globalVar", INT, new String[] {});
}
private void checkCppVariable(String name, String type, String[] modifiers) throws Exception {
@@ -297,13 +298,13 @@ public class IndexUpdateTests extends IndexTestBase {
// inline int globalFunction(char a){};
public void testCFunction() throws Exception {
setupFile(4, false);
- checkFunction("globalFunction", new String[] {INT, INT, INT}, new String[]{});
+ checkFunction("globalFunction", new String[] { INT, INT, INT }, new String[] {});
updateFile();
- checkFunction("globalFunction", new String[] {SHORT, INT, INT}, new String[]{});
+ checkFunction("globalFunction", new String[] { SHORT, INT, INT }, new String[] {});
updateFile();
- checkFunction("globalFunction", new String[] {INT, CHAR}, new String[]{});
+ checkFunction("globalFunction", new String[] { INT, CHAR }, new String[] {});
updateFile();
- checkFunction("globalFunction", new String[] {INT, CHAR}, new String[]{INLINE});
+ checkFunction("globalFunction", new String[] { INT, CHAR }, new String[] { INLINE });
}
private void checkFunction(String name, String[] types, String[] modifiers) throws Exception {
@@ -316,10 +317,9 @@ public class IndexUpdateTests extends IndexTestBase {
}
}
- private void checkFunction(IFunction func, String[] types, String[] modifiers)
- throws DOMException {
+ private void checkFunction(IFunction func, String[] types, String[] modifiers) throws DOMException {
assertEquals(msg(), types[0], ASTTypeUtil.getType(func.getType().getReturnType()));
- IParameter[] params= func.getParameters();
+ IParameter[] params = func.getParameters();
assertEquals(msg(), types.length - 1, params.length);
for (int i = 0; i < params.length; i++) {
IParameter parameter = params[i];
@@ -329,7 +329,6 @@ public class IndexUpdateTests extends IndexTestBase {
checkModifier(modifiers, STATIC, func.isStatic());
}
-
// int globalFunction(int a, int b){};
// short globalFunction(int a, int b){};
@@ -339,27 +338,25 @@ public class IndexUpdateTests extends IndexTestBase {
// inline int globalFunction(char a){};
public void testCppFunction() throws Exception {
setupFile(4, true);
- checkFunction("globalFunction", new String[] {INT, INT, INT}, new String[]{});
+ checkFunction("globalFunction", new String[] { INT, INT, INT }, new String[] {});
updateFile();
- checkFunction("globalFunction", new String[] {SHORT, INT, INT}, new String[]{});
+ checkFunction("globalFunction", new String[] { SHORT, INT, INT }, new String[] {});
updateFile();
- checkFunction("globalFunction", new String[] {INT, CHAR}, new String[]{});
+ checkFunction("globalFunction", new String[] { INT, CHAR }, new String[] {});
updateFile();
- checkFunction("globalFunction", new String[] {INT, CHAR}, new String[]{INLINE});
+ checkFunction("globalFunction", new String[] { INT, CHAR }, new String[] { INLINE });
}
-
// struct my_struct {int fField;};
// struct my_struct {short fField;};
public void testCField() throws Exception {
setupFile(2, false);
- checkVariable("my_struct::fField", INT, new String[]{});
+ checkVariable("my_struct::fField", INT, new String[] {});
updateFile();
- checkVariable("my_struct::fField", SHORT, new String[]{});
+ checkVariable("my_struct::fField", SHORT, new String[] {});
}
-
// class MyClass {int fField;};
// class MyClass {short fField;};
@@ -375,19 +372,19 @@ public class IndexUpdateTests extends IndexTestBase {
// class MyClass {private: static int fField;};
public void testCppField() throws Exception {
setupFile(7, true);
- checkCppField("MyClass::fField", INT, new String[]{PRIVATE});
+ checkCppField("MyClass::fField", INT, new String[] { PRIVATE });
updateFile();
- checkCppField("MyClass::fField", SHORT, new String[]{PRIVATE});
+ checkCppField("MyClass::fField", SHORT, new String[] { PRIVATE });
updateFile();
- checkCppField("MyClass::fField", INT, new String[]{PRIVATE, MUTABLE});
+ checkCppField("MyClass::fField", INT, new String[] { PRIVATE, MUTABLE });
updateFile();
- checkCppField("MyClass::fField", INT, new String[]{PUBLIC});
+ checkCppField("MyClass::fField", INT, new String[] { PUBLIC });
updateFile();
- checkCppField("MyClass::fField", INT, new String[]{PROTECTED});
+ checkCppField("MyClass::fField", INT, new String[] { PROTECTED });
updateFile();
- checkCppField("MyClass::fField", INT, new String[]{PRIVATE});
+ checkCppField("MyClass::fField", INT, new String[] { PRIVATE });
updateFile();
- checkCppField("MyClass::fField", INT, new String[]{PRIVATE, STATIC});
+ checkCppField("MyClass::fField", INT, new String[] { PRIVATE, STATIC });
}
private void checkCppField(String name, String type, String[] modifiers) throws Exception {
@@ -402,7 +399,7 @@ public class IndexUpdateTests extends IndexTestBase {
}
private void checkCppMember(ICPPMember member, String[] modifiers) throws Exception {
- int visibility= member.getVisibility();
+ int visibility = member.getVisibility();
checkModifier(modifiers, PUBLIC, visibility == ICPPMember.v_public);
checkModifier(modifiers, PROTECTED, visibility == ICPPMember.v_protected);
checkModifier(modifiers, PRIVATE, visibility == ICPPMember.v_private);
@@ -429,25 +426,25 @@ public class IndexUpdateTests extends IndexTestBase {
// class MyClass {virtual int method(char a) = 0;};
public void testCppMethod() throws Exception {
setupFile(10, true);
- checkCppMethod("MyClass::method", new String[] {INT, INT, INT}, new String[]{PRIVATE});
+ checkCppMethod("MyClass::method", new String[] { INT, INT, INT }, new String[] { PRIVATE });
updateFile();
- checkCppMethod("MyClass::method", new String[] {SHORT, INT, INT}, new String[]{PRIVATE});
+ checkCppMethod("MyClass::method", new String[] { SHORT, INT, INT }, new String[] { PRIVATE });
updateFile();
- checkCppMethod("MyClass::method", new String[] {INT, CHAR}, new String[]{PRIVATE});
+ checkCppMethod("MyClass::method", new String[] { INT, CHAR }, new String[] { PRIVATE });
updateFile();
- checkCppMethod("MyClass::method", new String[] {INT, CHAR}, new String[]{PRIVATE, INLINE});
+ checkCppMethod("MyClass::method", new String[] { INT, CHAR }, new String[] { PRIVATE, INLINE });
updateFile();
- checkCppMethod("MyClass::method", new String[] {INT, CHAR}, new String[]{PRIVATE, VIRTUAL});
+ checkCppMethod("MyClass::method", new String[] { INT, CHAR }, new String[] { PRIVATE, VIRTUAL });
updateFile();
- checkCppMethod("MyClass::method", new String[] {INT, CHAR}, new String[]{PUBLIC});
+ checkCppMethod("MyClass::method", new String[] { INT, CHAR }, new String[] { PUBLIC });
updateFile();
- checkCppMethod("MyClass::method", new String[] {INT, CHAR}, new String[]{PROTECTED});
+ checkCppMethod("MyClass::method", new String[] { INT, CHAR }, new String[] { PROTECTED });
updateFile();
- checkCppMethod("MyClass::method", new String[] {INT, CHAR}, new String[]{PRIVATE});
+ checkCppMethod("MyClass::method", new String[] { INT, CHAR }, new String[] { PRIVATE });
updateFile();
- checkCppMethod("MyClass::method", new String[] {INT, CHAR}, new String[]{PRIVATE, INLINE});
+ checkCppMethod("MyClass::method", new String[] { INT, CHAR }, new String[] { PRIVATE, INLINE });
updateFile();
- checkCppMethod("MyClass::method", new String[] {INT, CHAR}, new String[]{PRIVATE, VIRTUAL, PURE_VIRTUAL});
+ checkCppMethod("MyClass::method", new String[] { INT, CHAR }, new String[] { PRIVATE, VIRTUAL, PURE_VIRTUAL });
}
// class MyClass {protected: int method(int a, int b);};
@@ -459,11 +456,11 @@ public class IndexUpdateTests extends IndexTestBase {
// char MyClass::method(int a, int b);
public void testFixedCppMethod() throws Exception {
setupHeader(3, true);
- checkCppMethod("MyClass::method", new String[] {INT, INT, INT}, new String[]{PROTECTED});
+ checkCppMethod("MyClass::method", new String[] { INT, INT, INT }, new String[] { PROTECTED });
setupFile(0, true);
- checkCppMethod("MyClass::method", new String[] {INT, INT, INT}, new String[]{PROTECTED});
+ checkCppMethod("MyClass::method", new String[] { INT, INT, INT }, new String[] { PROTECTED });
updateFile();
- checkCppMethod("MyClass::method", new String[] {INT, INT, INT}, new String[]{PROTECTED});
+ checkCppMethod("MyClass::method", new String[] { INT, INT, INT }, new String[] { PROTECTED });
}
private void checkCppMethod(String name, String[] types, String[] modifiers) throws Exception {
@@ -476,8 +473,7 @@ public class IndexUpdateTests extends IndexTestBase {
}
}
- private void checkCppMethod(ICPPMethod method, String[] types, String[] modifiers)
- throws DOMException, Exception {
+ private void checkCppMethod(ICPPMethod method, String[] types, String[] modifiers) throws DOMException, Exception {
checkFunction(method, types, modifiers);
checkCppMember(method, modifiers);
checkModifier(modifiers, VIRTUAL, method.isVirtual());
@@ -498,17 +494,17 @@ public class IndexUpdateTests extends IndexTestBase {
// class MyClass {private: MyClass(char a, int b);};
public void testCppConstructor() throws Exception {
setupFile(6, true);
- checkCppConstructor("MyClass::MyClass", new String[] {"", INT, INT}, new String[]{PRIVATE});
+ checkCppConstructor("MyClass::MyClass", new String[] { "", INT, INT }, new String[] { PRIVATE });
updateFile();
- checkCppConstructor("MyClass::MyClass", new String[] {"", CHAR, INT}, new String[]{PRIVATE});
+ checkCppConstructor("MyClass::MyClass", new String[] { "", CHAR, INT }, new String[] { PRIVATE });
updateFile();
- checkCppConstructor("MyClass::MyClass", new String[] {"", CHAR, INT}, new String[]{PRIVATE,EXPLICIT});
+ checkCppConstructor("MyClass::MyClass", new String[] { "", CHAR, INT }, new String[] { PRIVATE, EXPLICIT });
updateFile();
- checkCppConstructor("MyClass::MyClass", new String[] {"", CHAR, INT}, new String[]{PUBLIC});
+ checkCppConstructor("MyClass::MyClass", new String[] { "", CHAR, INT }, new String[] { PUBLIC });
updateFile();
- checkCppConstructor("MyClass::MyClass", new String[] {"", CHAR, INT}, new String[]{PROTECTED});
+ checkCppConstructor("MyClass::MyClass", new String[] { "", CHAR, INT }, new String[] { PROTECTED });
updateFile();
- checkCppConstructor("MyClass::MyClass", new String[] {"", CHAR, INT}, new String[]{PRIVATE});
+ checkCppConstructor("MyClass::MyClass", new String[] { "", CHAR, INT }, new String[] { PRIVATE });
}
private void checkCppConstructor(String name, String[] types, String[] modifiers) throws Exception {
@@ -538,30 +534,20 @@ public class IndexUpdateTests extends IndexTestBase {
// class MyClass {};
public void testImplicitMethods() throws Exception {
setupFile(5, true);
- checkImplicitMethods("MyClass",
- new String[] {IMPLICIT, PUBLIC},
- new String[] {IMPLICIT, PUBLIC},
- new String[] {IMPLICIT, PUBLIC});
+ checkImplicitMethods("MyClass", new String[] { IMPLICIT, PUBLIC }, new String[] { IMPLICIT, PUBLIC },
+ new String[] { IMPLICIT, PUBLIC });
updateFile();
- checkImplicitMethods("MyClass",
- new String[] {PROTECTED},
- new String[] {IMPLICIT, PUBLIC},
- new String[] {IMPLICIT, PUBLIC});
+ checkImplicitMethods("MyClass", new String[] { PROTECTED }, new String[] { IMPLICIT, PUBLIC },
+ new String[] { IMPLICIT, PUBLIC });
updateFile();
- checkImplicitMethods("MyClass",
- null, // no default constructor, because we declared the copy constructor.
- new String[] {EXPLICIT, PRIVATE},
- new String[] {IMPLICIT, PUBLIC});
+ checkImplicitMethods("MyClass", null, // no default constructor, because we declared the copy constructor.
+ new String[] { EXPLICIT, PRIVATE }, new String[] { IMPLICIT, PUBLIC });
updateFile();
- checkImplicitMethods("MyClass",
- new String[] {IMPLICIT, PUBLIC},
- new String[] {IMPLICIT, PUBLIC},
- new String[] {INLINE, PUBLIC});
+ checkImplicitMethods("MyClass", new String[] { IMPLICIT, PUBLIC }, new String[] { IMPLICIT, PUBLIC },
+ new String[] { INLINE, PUBLIC });
updateFile();
- checkImplicitMethods("MyClass",
- new String[] {IMPLICIT, PUBLIC},
- new String[] {IMPLICIT, PUBLIC},
- new String[] {IMPLICIT, PUBLIC});
+ checkImplicitMethods("MyClass", new String[] { IMPLICIT, PUBLIC }, new String[] { IMPLICIT, PUBLIC },
+ new String[] { IMPLICIT, PUBLIC });
}
private void checkImplicitMethods(String name, String[] m1, String[] m2, String[] m3) throws Exception {
@@ -570,36 +556,39 @@ public class IndexUpdateTests extends IndexTestBase {
final char[] nchars = name.toCharArray();
final String refType = name + " &";
final String constRefType = "const " + refType;
- IIndexBinding[] ctors= fIndex.findBindings(new char[][] {nchars, nchars}, IndexFilter.ALL_DECLARED_OR_IMPLICIT, npm());
+ IIndexBinding[] ctors = fIndex.findBindings(new char[][] { nchars, nchars },
+ IndexFilter.ALL_DECLARED_OR_IMPLICIT, npm());
- int count= 0;
+ int count = 0;
for (int i = 0; i < ctors.length; i++) {
- IIndexBinding ctor= ctors[i];
+ IIndexBinding ctor = ctors[i];
if (ctor.isFileLocal()) {
- ctors[count++]= ctor;
+ ctors[count++] = ctor;
}
}
assertEquals(m1 == null ? 1 : 2, count);
final IType[] parameterTypes = ((ICPPConstructor) ctors[0]).getType().getParameterTypes();
if (parameterTypes.length != 1 || !(parameterTypes[0] instanceof ICPPReferenceType)) {
- IIndexBinding h= ctors[0]; ctors[0]= ctors[1]; ctors[1]= h;
+ IIndexBinding h = ctors[0];
+ ctors[0] = ctors[1];
+ ctors[1] = h;
}
if (m1 != null) {
- checkCppConstructor((ICPPConstructor) ctors[1], new String[] {""}, m1);
+ checkCppConstructor((ICPPConstructor) ctors[1], new String[] { "" }, m1);
}
- checkCppConstructor((ICPPConstructor) ctors[0], new String[] {"", constRefType}, m2);
+ checkCppConstructor((ICPPConstructor) ctors[0], new String[] { "", constRefType }, m2);
- IIndexBinding[] assignmentOps= fIndex.findBindings(
- new char[][] {nchars, "operator =".toCharArray() }, IndexFilter.ALL_DECLARED_OR_IMPLICIT, npm());
- count= 0;
+ IIndexBinding[] assignmentOps = fIndex.findBindings(new char[][] { nchars, "operator =".toCharArray() },
+ IndexFilter.ALL_DECLARED_OR_IMPLICIT, npm());
+ count = 0;
for (int i = 0; i < assignmentOps.length; i++) {
- IIndexBinding assignmentOp= assignmentOps[i];
+ IIndexBinding assignmentOp = assignmentOps[i];
if (assignmentOp.isFileLocal()) {
- assignmentOps[count++]= assignmentOp;
+ assignmentOps[count++] = assignmentOp;
}
}
assertEquals(1, count);
- checkCppMethod((ICPPMethod) assignmentOps[0], new String[]{refType, constRefType}, m3);
+ checkCppMethod((ICPPMethod) assignmentOps[0], new String[] { refType, constRefType }, m3);
} finally {
fIndex.releaseReadLock();
}
@@ -802,14 +791,14 @@ public class IndexUpdateTests extends IndexTestBase {
long pdomid;
try {
binding = (ICPPClassTemplate) findBinding("CT");
- assertEquals(ICPPClassType.k_class , binding.getKey());
+ assertEquals(ICPPClassType.k_class, binding.getKey());
ICPPTemplateParameter[] tpars = binding.getTemplateParameters();
assertEquals(1, tpars.length);
assertTrue(tpars[0] instanceof ICPPTemplateTypeParameter);
assertEquals(0, tpars[0].getParameterID());
assertEquals("T", tpars[0].getName());
assertNull(tpars[0].getDefaultValue());
- pdomid= ((IAdaptable) tpars[0]).getAdapter(PDOMNode.class).getRecord();
+ pdomid = ((IAdaptable) tpars[0]).getAdapter(PDOMNode.class).getRecord();
} finally {
fIndex.releaseReadLock();
}
@@ -818,7 +807,7 @@ public class IndexUpdateTests extends IndexTestBase {
fIndex.acquireReadLock();
try {
binding = (ICPPClassTemplate) findBinding("CT");
- assertEquals(ICPPClassType.k_class , binding.getKey());
+ assertEquals(ICPPClassType.k_class, binding.getKey());
ICPPTemplateParameter[] tpars = binding.getTemplateParameters();
assertEquals(1, tpars.length);
assertTrue(tpars[0] instanceof ICPPTemplateTypeParameter);
@@ -833,7 +822,7 @@ public class IndexUpdateTests extends IndexTestBase {
fIndex.acquireReadLock();
try {
binding = (ICPPClassTemplate) findBinding("CT");
- assertEquals(ICPPClassType.k_class , binding.getKey());
+ assertEquals(ICPPClassType.k_class, binding.getKey());
ICPPTemplateParameter[] tpars = binding.getTemplateParameters();
assertEquals(1, tpars.length);
assertTrue(tpars[0] instanceof ICPPTemplateTypeParameter);
@@ -848,7 +837,7 @@ public class IndexUpdateTests extends IndexTestBase {
fIndex.acquireReadLock();
try {
binding = (ICPPClassTemplate) findBinding("CT");
- assertEquals(ICompositeType.k_struct , binding.getKey());
+ assertEquals(ICompositeType.k_struct, binding.getKey());
ICPPTemplateParameter[] tpars = binding.getTemplateParameters();
assertEquals(2, tpars.length);
assertTrue(tpars[0] instanceof ICPPTemplateNonTypeParameter);
@@ -865,13 +854,13 @@ public class IndexUpdateTests extends IndexTestBase {
fIndex.acquireReadLock();
try {
binding = (ICPPClassTemplate) findBinding("CT");
- assertEquals(ICPPClassType.k_class , binding.getKey());
+ assertEquals(ICPPClassType.k_class, binding.getKey());
ICPPTemplateParameter[] tpars = binding.getTemplateParameters();
assertEquals(1, tpars.length);
assertTrue(tpars[0] instanceof ICPPTemplateTemplateParameter);
assertEquals("V", tpars[0].getName());
assertEquals(0, tpars[0].getParameterID());
- tpars= ((ICPPTemplateTemplateParameter) tpars[0]).getTemplateParameters();
+ tpars = ((ICPPTemplateTemplateParameter) tpars[0]).getTemplateParameters();
assertEquals(1, tpars.length);
assertTrue(tpars[0] instanceof ICPPTemplateTypeParameter);
assertEquals(0x10000, tpars[0].getParameterID());
@@ -884,13 +873,13 @@ public class IndexUpdateTests extends IndexTestBase {
fIndex.acquireReadLock();
try {
binding = (ICPPClassTemplate) findBinding("CT");
- assertEquals(ICPPClassType.k_class , binding.getKey());
+ assertEquals(ICPPClassType.k_class, binding.getKey());
ICPPTemplateParameter[] tpars = binding.getTemplateParameters();
assertEquals(1, tpars.length);
assertTrue(tpars[0] instanceof ICPPTemplateTemplateParameter);
assertEquals("V", tpars[0].getName());
assertEquals(0, tpars[0].getParameterID());
- tpars= ((ICPPTemplateTemplateParameter) tpars[0]).getTemplateParameters();
+ tpars = ((ICPPTemplateTemplateParameter) tpars[0]).getTemplateParameters();
assertEquals(1, tpars.length);
assertTrue(tpars[0] instanceof ICPPTemplateTemplateParameter);
assertEquals(0x10000, tpars[0].getParameterID());
@@ -903,7 +892,7 @@ public class IndexUpdateTests extends IndexTestBase {
fIndex.acquireReadLock();
try {
binding = (ICPPClassTemplate) findBinding("CT");
- assertEquals(ICPPClassType.k_class , binding.getKey());
+ assertEquals(ICPPClassType.k_class, binding.getKey());
ICPPTemplateParameter[] tpars = binding.getTemplateParameters();
assertEquals(1, tpars.length);
assertTrue(tpars[0] instanceof ICPPTemplateTypeParameter);
@@ -922,7 +911,7 @@ public class IndexUpdateTests extends IndexTestBase {
// globalVar= 1;
// }
public void testChangingSourceBeforeHeader_Bug171834() throws Exception {
- CModelListener.sSuppressUpdateOfLastRecentlyUsed= false;
+ CModelListener.sSuppressUpdateOfLastRecentlyUsed = false;
setupHeader(2, true);
setupFile(0, true);
IBinding binding;
@@ -936,7 +925,8 @@ public class IndexUpdateTests extends IndexTestBase {
fIndex.releaseReadLock();
}
- fFile= TestSourceReader.createFile(fFile.getParent(), fFile.getName(), fContents[1].toString().replaceAll("globalVar", "newVar"));
+ fFile = TestSourceReader.createFile(fFile.getParent(), fFile.getName(),
+ fContents[1].toString().replaceAll("globalVar", "newVar"));
TestSourceReader.waitUntilFileIsIndexed(fIndex, fFile, INDEXER_TIMEOUT_MILLISEC);
fIndex.acquireReadLock();
@@ -948,7 +938,8 @@ public class IndexUpdateTests extends IndexTestBase {
fIndex.releaseReadLock();
}
- fHeader= TestSourceReader.createFile(fHeader.getParent(), fHeader.getName(), fContents[0].toString().replaceAll("globalVar", "newVar"));
+ fHeader = TestSourceReader.createFile(fHeader.getParent(), fHeader.getName(),
+ fContents[0].toString().replaceAll("globalVar", "newVar"));
waitUntilFileIsIndexed(fIndex, fHeader);
fIndex.acquireReadLock();
@@ -961,7 +952,6 @@ public class IndexUpdateTests extends IndexTestBase {
}
}
-
// int globalVar;
// void func();
@@ -1163,11 +1153,12 @@ public class IndexUpdateTests extends IndexTestBase {
try {
IBinding client = findBinding(clientClassBinding);
IBinding supplier = findBinding(supplierBinding);
- assertNotNull("Unable to find binding with name \""+clientClassBinding+"\"", client);
- assertTrue("Unable to find binding with name \""+clientClassBinding+"\"", client instanceof ICPPClassType);
- assertNotNull("Unable to find binding with name \""+supplierBinding+"\"", supplier);
- assertTrue(((ICPPClassType)client).getFriends().length == 1);
- assertTrue(((ICPPClassType)client).getFriends()[0].equals(supplier));
+ assertNotNull("Unable to find binding with name \"" + clientClassBinding + "\"", client);
+ assertTrue("Unable to find binding with name \"" + clientClassBinding + "\"",
+ client instanceof ICPPClassType);
+ assertNotNull("Unable to find binding with name \"" + supplierBinding + "\"", supplier);
+ assertTrue(((ICPPClassType) client).getFriends().length == 1);
+ assertTrue(((ICPPClassType) client).getFriends()[0].equals(supplier));
} finally {
fIndex.releaseReadLock();
}
@@ -1177,9 +1168,10 @@ public class IndexUpdateTests extends IndexTestBase {
fIndex.acquireReadLock();
try {
IBinding client = findBinding(clientClassBinding);
- assertNotNull("Unable to find binding with name \""+clientClassBinding+"\"", client);
- assertTrue("Unable to find binding with name \""+clientClassBinding+"\"", client instanceof ICPPClassType);
- assertTrue(((ICPPClassType)client).getFriends().length == 0);
+ assertNotNull("Unable to find binding with name \"" + clientClassBinding + "\"", client);
+ assertTrue("Unable to find binding with name \"" + clientClassBinding + "\"",
+ client instanceof ICPPClassType);
+ assertTrue(((ICPPClassType) client).getFriends().length == 0);
} finally {
fIndex.releaseReadLock();
}
@@ -1194,10 +1186,10 @@ public class IndexUpdateTests extends IndexTestBase {
public void testTypedeletion_Bug294306() throws Exception {
setupHeader(2, true);
setupFile(2, true);
- checkFunction("useRef", new String[]{"void", "int"}, new String[]{});
+ checkFunction("useRef", new String[] { "void", "int" }, new String[] {});
fContentUsed--;
updateFile();
- checkFunction("useRef", new String[]{"char", "int"}, new String[]{});
+ checkFunction("useRef", new String[] { "char", "int" }, new String[] {});
}
// void f(int a, int b=0);
@@ -1288,7 +1280,7 @@ public class IndexUpdateTests extends IndexTestBase {
fIndex.acquireReadLock();
try {
final IIndexBinding binding = findBinding("X");
- id1= ((PDOMFile) binding.getLocalToFile()).getRecord();
+ id1 = ((PDOMFile) binding.getLocalToFile()).getRecord();
} finally {
fIndex.releaseReadLock();
}
@@ -1297,7 +1289,7 @@ public class IndexUpdateTests extends IndexTestBase {
fIndex.acquireReadLock();
try {
final IIndexBinding binding = findBinding("X");
- id2= ((PDOMFile) binding.getLocalToFile()).getRecord();
+ id2 = ((PDOMFile) binding.getLocalToFile()).getRecord();
} finally {
fIndex.releaseReadLock();
}
@@ -1377,7 +1369,7 @@ public class IndexUpdateTests extends IndexTestBase {
try {
final IEnumerator e = (IEnumerator) findBinding("AE_ON");
assertNotNull(e);
- name1= e.getOwner().getName();
+ name1 = e.getOwner().getName();
} finally {
fIndex.releaseReadLock();
}
@@ -1419,7 +1411,7 @@ public class IndexUpdateTests extends IndexTestBase {
try {
final IEnumerator e = (IEnumerator) findBinding("AE_ON");
assertNotNull(e);
- name1= e.getOwner().getName();
+ name1 = e.getOwner().getName();
} finally {
fIndex.releaseReadLock();
}
@@ -1503,7 +1495,6 @@ public class IndexUpdateTests extends IndexTestBase {
}
}
-
// int dummy;
//#include "A.h"
@@ -1532,8 +1523,9 @@ public class IndexUpdateTests extends IndexTestBase {
assertEquals(0, barBinding.length);
bIndex.releaseReadLock();
- IFile fileAh = (IFile) ((ITranslationUnit)projectA.findElement(Path.fromOSString("A.h"))).getResource();
- fileAh = TestSourceReader.createFile(projectA.getSourceRoots()[0].getResource(), Path.fromOSString("A.h"), "void bar(){}\n");
+ IFile fileAh = (IFile) ((ITranslationUnit) projectA.findElement(Path.fromOSString("A.h"))).getResource();
+ fileAh = TestSourceReader.createFile(projectA.getSourceRoots()[0].getResource(), Path.fromOSString("A.h"),
+ "void bar(){}\n");
TestSourceReader.waitUntilFileIsIndexed(aIndex, fileAh, INDEXER_TIMEOUT_SEC * 1000);
TestSourceReader.waitUntilFileIsIndexed(bIndex, fileAh, INDEXER_TIMEOUT_SEC * 1000);
bIndex.acquireReadLock();
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/ProjectBuilder.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/ProjectBuilder.java
index 073e46c28a3..c470af4b362 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/ProjectBuilder.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/ProjectBuilder.java
@@ -54,13 +54,12 @@ class ProjectBuilder {
}
ICProject create() throws Exception {
- ICProject result = cpp ?
- CProjectHelper.createCCProject(name, "bin", IPDOMManager.ID_NO_INDEXER) :
- CProjectHelper.createCProject(name, "bin", IPDOMManager.ID_NO_INDEXER);
+ ICProject result = cpp ? CProjectHelper.createCCProject(name, "bin", IPDOMManager.ID_NO_INDEXER)
+ : CProjectHelper.createCProject(name, "bin", IPDOMManager.ID_NO_INDEXER);
- IFile lastFile= null;
+ IFile lastFile = null;
for (Map.Entry<String, String> entry : path2content.entrySet()) {
- lastFile= TestSourceReader.createFile(result.getProject(), new Path(entry.getKey()), entry.getValue());
+ lastFile = TestSourceReader.createFile(result.getProject(), new Path(entry.getKey()), entry.getValue());
}
IProjectDescription desc = result.getProject().getDescription();
@@ -72,7 +71,7 @@ class ProjectBuilder {
if (lastFile != null) {
// Call reindex explicitly since setting indexer ID doesn't trigger reindexing.
indexManager.reindex(result);
- IIndex index= indexManager.getIndex(result);
+ IIndex index = indexManager.getIndex(result);
BaseTestCase.waitUntilFileIsIndexed(index, lastFile);
}
BaseTestCase.waitForIndexer(result);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TeamSharedIndexTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TeamSharedIndexTest.java
index b70323d579e..1bcdecaf8b3 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TeamSharedIndexTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TeamSharedIndexTest.java
@@ -50,7 +50,7 @@ public class TeamSharedIndexTest extends IndexTestBase {
return suite(TeamSharedIndexTest.class);
}
- private final Collection fProjects= new LinkedList();
+ private final Collection fProjects = new LinkedList();
private static final IIndexManager fPDOMManager = CCorePlugin.getIndexManager();
public TeamSharedIndexTest(String name) {
@@ -75,14 +75,15 @@ public class TeamSharedIndexTest extends IndexTestBase {
private void registerProject(ICProject prj) {
fProjects.add(prj);
}
+
private void unregisterProject(ICProject prj) {
fProjects.remove(prj);
}
private ICProject createProject(String name) throws CoreException, InterruptedException {
- ModelJoiner mj= new ModelJoiner();
+ ModelJoiner mj = new ModelJoiner();
try {
- ICProject project= CProjectHelper.createCCProject(name, null, IPDOMManager.ID_NO_INDEXER);
+ ICProject project = CProjectHelper.createCCProject(name, null, IPDOMManager.ID_NO_INDEXER);
registerProject(project);
TestSourceReader.createFile(project.getProject(), "a.cpp", "int a;");
TestSourceReader.createFile(project.getProject(), "b.cpp", "int b;");
@@ -99,49 +100,48 @@ public class TeamSharedIndexTest extends IndexTestBase {
private ICProject recreateProject(final String prjName) throws Exception {
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
- ModelJoiner pj= new ModelJoiner();
+ ModelJoiner pj = new ModelJoiner();
try {
- final IProject prjHandle= workspace.getRoot().getProject(prjName);
+ final IProject prjHandle = workspace.getRoot().getProject(prjName);
workspace.run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
- IProjectDescription desc= IDEWorkbenchPlugin.getPluginWorkspace().newProjectDescription(prjName);
+ IProjectDescription desc = IDEWorkbenchPlugin.getPluginWorkspace().newProjectDescription(prjName);
prjHandle.create(desc, npm());
prjHandle.open(0, npm());
}
}, null);
- pj.join(); // in order we are sure the indexer task has been scheduled before joining the indexer
+ pj.join(); // in order we are sure the indexer task has been scheduled before joining the indexer
} finally {
pj.dispose();
}
- ICProject result= CoreModel.getDefault().create(workspace.getRoot().getProject(prjName));
+ ICProject result = CoreModel.getDefault().create(workspace.getRoot().getProject(prjName));
waitForIndexer(result);
return result;
}
private void checkVariable(ICProject prj, String var, int expectedCount)
throws CoreException, InterruptedException {
- IIndex index= fPDOMManager.getIndex(prj);
+ IIndex index = fPDOMManager.getIndex(prj);
index.acquireReadLock();
try {
- IBinding[] binding= index.findBindings(var.toCharArray(), IndexFilter.ALL, npm());
- int count= 0;
+ IBinding[] binding = index.findBindings(var.toCharArray(), IndexFilter.ALL, npm());
+ int count = 0;
assertTrue(binding.length < 2);
if (binding.length == 1) {
assertTrue(binding[0] instanceof IVariable);
- count= index.findNames(binding[0], IIndex.FIND_ALL_OCCURRENCES).length;
+ count = index.findNames(binding[0], IIndex.FIND_ALL_OCCURRENCES).length;
}
assertEquals(var, expectedCount, count);
- }
- finally {
+ } finally {
index.releaseReadLock();
}
}
public void testDefaultExport() throws Exception {
- String prjName= "__testDefaultExport__";
- ICProject prj= createProject(prjName);
- String loc= IndexerPreferences.getIndexImportLocation(prj.getProject());
+ String prjName = "__testDefaultExport__";
+ ICProject prj = createProject(prjName);
+ String loc = IndexerPreferences.getIndexImportLocation(prj.getProject());
checkVariable(prj, "a", 1);
checkVariable(prj, "b", 1);
checkVariable(prj, "c", 1);
@@ -173,9 +173,9 @@ public class TeamSharedIndexTest extends IndexTestBase {
}
public void testExportWithFileChange() throws Exception {
- String prjName= "__testExportWithChange__";
- ICProject prj= createProject(prjName);
- String loc= IndexerPreferences.getIndexImportLocation(prj.getProject());
+ String prjName = "__testExportWithChange__";
+ ICProject prj = createProject(prjName);
+ String loc = IndexerPreferences.getIndexImportLocation(prj.getProject());
checkVariable(prj, "a", 1);
checkVariable(prj, "b", 1);
checkVariable(prj, "c", 1);
@@ -203,15 +203,15 @@ public class TeamSharedIndexTest extends IndexTestBase {
private void changeFile(ICProject prj) throws CoreException {
final IFile file = prj.getProject().getFile("a.cpp");
final File location = file.getLocation().toFile();
- final long lm= location.lastModified();
+ final long lm = location.lastModified();
file.setContents(new ByteArrayInputStream("int d;".getBytes()), true, false, npm());
if (location.lastModified() == lm) {
- location.setLastModified(lm+1000);
+ location.setLastModified(lm + 1000);
}
}
private void deleteAndWait(ICProject prj) throws CoreException {
- ModelJoiner dj= new ModelJoiner();
+ ModelJoiner dj = new ModelJoiner();
try {
prj.getProject().delete(false, true, npm());
dj.join();
@@ -221,9 +221,9 @@ public class TeamSharedIndexTest extends IndexTestBase {
}
public void testExportWithFileChangeFake() throws Exception {
- String prjName= "__testExportWithChangeFake__";
- ICProject prj= createProject(prjName);
- String loc= IndexerPreferences.getIndexImportLocation(prj.getProject());
+ String prjName = "__testExportWithChangeFake__";
+ ICProject prj = createProject(prjName);
+ String loc = IndexerPreferences.getIndexImportLocation(prj.getProject());
checkVariable(prj, "a", 1);
checkVariable(prj, "b", 1);
checkVariable(prj, "c", 1);
@@ -255,9 +255,9 @@ public class TeamSharedIndexTest extends IndexTestBase {
}
public void testExportWithAddition() throws Exception {
- String prjName= "__testExportWithAddition__";
- ICProject prj= createProject(prjName);
- String loc= IndexerPreferences.getIndexImportLocation(prj.getProject());
+ String prjName = "__testExportWithAddition__";
+ ICProject prj = createProject(prjName);
+ String loc = IndexerPreferences.getIndexImportLocation(prj.getProject());
checkVariable(prj, "a", 1);
checkVariable(prj, "b", 1);
checkVariable(prj, "c", 1);
@@ -283,9 +283,9 @@ public class TeamSharedIndexTest extends IndexTestBase {
}
public void testExportWithAdditionFake() throws Exception {
- String prjName= "__testExportWithAdditionFake__";
- ICProject prj= createProject(prjName);
- String loc= IndexerPreferences.getIndexImportLocation(prj.getProject());
+ String prjName = "__testExportWithAdditionFake__";
+ ICProject prj = createProject(prjName);
+ String loc = IndexerPreferences.getIndexImportLocation(prj.getProject());
checkVariable(prj, "a", 1);
checkVariable(prj, "b", 1);
checkVariable(prj, "c", 1);
@@ -318,9 +318,9 @@ public class TeamSharedIndexTest extends IndexTestBase {
}
public void testExportWithRemoval() throws Exception {
- String prjName= "__testExportWithRemoval__";
- ICProject prj= createProject(prjName);
- String loc= IndexerPreferences.getIndexImportLocation(prj.getProject());
+ String prjName = "__testExportWithRemoval__";
+ ICProject prj = createProject(prjName);
+ String loc = IndexerPreferences.getIndexImportLocation(prj.getProject());
checkVariable(prj, "a", 1);
checkVariable(prj, "b", 1);
checkVariable(prj, "c", 1);
@@ -345,9 +345,9 @@ public class TeamSharedIndexTest extends IndexTestBase {
}
public void testExportWithRemovalFake() throws Exception {
- String prjName= "__testExportWithRemovalFake__";
- ICProject prj= createProject(prjName);
- String loc= IndexerPreferences.getIndexImportLocation(prj.getProject());
+ String prjName = "__testExportWithRemovalFake__";
+ ICProject prj = createProject(prjName);
+ String loc = IndexerPreferences.getIndexImportLocation(prj.getProject());
checkVariable(prj, "a", 1);
checkVariable(prj, "b", 1);
checkVariable(prj, "c", 1);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TrilogyPerformanceTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TrilogyPerformanceTest.java
index 907e855ad53..58265b29df5 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TrilogyPerformanceTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TrilogyPerformanceTest.java
@@ -47,7 +47,7 @@ public class TrilogyPerformanceTest extends IndexTestBase {
super.setUp();
Bundle b = CTestPlugin.getDefault().getBundle();
if (cproject == null) {
- cproject= createProject(true, "resources/indexTests/trilogy");
+ cproject = createProject(true, "resources/indexTests/trilogy");
}
}
@@ -59,16 +59,18 @@ public class TrilogyPerformanceTest extends IndexTestBase {
// you must have the Windows SDK installed and the INETSDK env var setup
public void testIndexTrilogyPerformanceTimes() throws CoreException, InterruptedException {
- if(Platform.getOS().equals(Platform.OS_WIN32)) {
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
waitForIndexer(cproject);
- TestScannerProvider.sIncludes = new String[]{EnvironmentReader.getEnvVar("INETSDK")+"\\Include"};
- IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "true");
+ TestScannerProvider.sIncludes = new String[] { EnvironmentReader.getEnvVar("INETSDK") + "\\Include" };
+ IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG,
+ "true");
long start = System.currentTimeMillis();
CCorePlugin.getIndexManager().reindex(cproject);
waitForIndexer(cproject);
- System.out.println("Took: "+(System.currentTimeMillis() - start));
- IIndex index= CCorePlugin.getIndexManager().getIndex(cproject);
- IBinding[] binding = index.findBindings(Pattern.compile("IXMLElementCollection"), false, IndexFilter.ALL, new NullProgressMonitor());
+ System.out.println("Took: " + (System.currentTimeMillis() - start));
+ IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
+ IBinding[] binding = index.findBindings(Pattern.compile("IXMLElementCollection"), false, IndexFilter.ALL,
+ new NullProgressMonitor());
assertEquals(1, binding.length);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeExpensiveTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeExpensiveTests.java
index 5e8bdb77677..6243210c693 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeExpensiveTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeExpensiveTests.java
@@ -24,25 +24,25 @@ import junit.framework.Test;
* expensive and cpu hungry.
*/
public class BTreeExpensiveTests extends BTreeTests {
-
+
public static Test suite() {
return suite(BTreeExpensiveTests.class);
}
-
+
public void testBySortedSetMirror() throws Exception {
sortedMirrorTest(100);
}
-
+
// @Override
@Override
public void testInsertion() throws Exception {
super.testInsertion();
}
-
+
/*
* N.B. Each of the following tests are quite expensive (i.e. > 10mins each on a 2Ghz machine)
*/
-
+
public void testBySortedSetMirror1682762087() throws Exception {
System.out.println("1682762087 Full Checking");
trial(1682762087, true); // exposed bugs in 2a,b
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeTests.java
index 1496708c0af..85ccc104029 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeTests.java
@@ -38,7 +38,7 @@ import junit.framework.Test;
* @author aferguso
*/
public class BTreeTests extends BaseTestCase {
- private static int DEBUG= 0;
+ private static int DEBUG = 0;
protected File dbFile;
protected Database db;
protected BTree btree;
@@ -66,7 +66,6 @@ public class BTreeTests extends BaseTestCase {
dbFile.deleteOnExit();
}
-
public void testBySortedSetMirrorLite() throws Exception {
sortedMirrorTest(8);
}
@@ -136,8 +135,8 @@ public class BTreeTests extends BaseTestCase {
trialImp(seed, checkCorrectnessEachIteration, random, pInsert);
}
- private void trialImp(int seed, final boolean checkCorrectnessEachIteration, Random random,
- double pInsert) throws Exception {
+ private void trialImp(int seed, final boolean checkCorrectnessEachIteration, Random random, double pInsert)
+ throws Exception {
final int degree = 2 + random.nextInt(11);
final int nIterations = random.nextInt(100000);
final SortedSet expected = new TreeSet();
@@ -146,7 +145,7 @@ public class BTreeTests extends BaseTestCase {
init(degree);
if (DEBUG > 0)
- System.out.print("\t " + seed + " " + (nIterations/1000) + "K: ");
+ System.out.print("\t " + seed + " " + (nIterations / 1000) + "K: ");
for (int i = 0; i < nIterations; i++) {
if (random.nextDouble() < pInsert) {
Integer value = random.nextInt(Integer.MAX_VALUE);
@@ -197,6 +196,7 @@ public class BTreeTests extends BaseTestCase {
final Iterator i = expected.iterator();
btree.accept(new IBTreeVisitor() {
int k;
+
@Override
public int compare(long record) throws CoreException {
return 0;
@@ -207,7 +207,7 @@ public class BTreeTests extends BaseTestCase {
if (record != 0) {
BTMockRecord btValue = new BTMockRecord(record, db);
if (i.hasNext()) {
- Integer exp = ((Integer)i.next());
+ Integer exp = ((Integer) i.next());
assertEquals(msg + " Differ at index: " + k, btValue.intValue(), exp.intValue());
k++;
} else {
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CCompositeTypeTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CCompositeTypeTests.java
index e9880338f87..f8c920ead7c 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CCompositeTypeTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CCompositeTypeTests.java
@@ -44,40 +44,42 @@ public class CCompositeTypeTests extends PDOMTestBase {
@Override
protected void setUp() throws Exception {
CCompositeTypeTests foo = null;
-
+
project = createProject("compositeTypeTests");
pdom = (PDOM) CCoreInternals.getPDOMManager().getPDOM(project);
pdom.acquireReadLock();
}
-
+
@Override
protected void tearDown() throws Exception {
pdom.releaseReadLock();
if (project != null) {
- project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
-
+
//TODO PDOM does not distinguish between a struct or union in C
public void _testSimpleCStructureDistinction() throws Exception {
assertType(pdom, "SimpleCStructure", ICompositeType.class);
- IIndexBinding[] bindings = pdom.findBindings(Pattern.compile("SimpleCStructure"), false, IndexFilter.ALL, new NullProgressMonitor());
+ IIndexBinding[] bindings = pdom.findBindings(Pattern.compile("SimpleCStructure"), false, IndexFilter.ALL,
+ new NullProgressMonitor());
assertEquals(1, bindings.length);
- assertEquals(ICompositeType.k_struct, ((ICompositeType)bindings[0]).getKey());
+ assertEquals(ICompositeType.k_struct, ((ICompositeType) bindings[0]).getKey());
}
-
+
// test struct definitions and struct member declarations in C
public void testSimpleCStructureDeclarations() throws Exception {
assertDeclarationCount(pdom, "SimpleCStructure", 1);
assertDeclarationCount(pdom, "SimpleCStructure::scsa", 1);
}
-
+
// test struct definitions and struct member definitions in C
public void testSimpleCStructureDefinitions() throws Exception {
assertDefinitionCount(pdom, "SimpleCStructure", 1);
assertDefinitionCount(pdom, "SimpleCStructure::scsa", 1);
}
-
+
// test struct definitions and struct member references in C
public void testSimpleCStructureReferences() throws Exception {
assertReferenceCount(pdom, "SimpleCStructure", 2);
@@ -90,7 +92,7 @@ public class CCompositeTypeTests extends PDOMTestBase {
assertType(pdom, "CStructure2", ICompositeType.class);
assertType(pdom, "CStructure3", ICompositeType.class);
}
-
+
// test "nested" struct declarations in C, they should not nest
public void testDeepCStructureDeclarations() throws Exception {
assertDeclarationCount(pdom, "CStructure1", 1);
@@ -99,7 +101,7 @@ public class CCompositeTypeTests extends PDOMTestBase {
assertDeclarationCount(pdom, "CStructure1::CStructure2::CStructure3", 0);
assertDeclarationCount(pdom, "CStructure3", 1);
}
-
+
// test "nested" struct member declarations in C, they should not nest
public void testDeepCStructureMemberDeclarations() throws Exception {
assertDeclarationCount(pdom, "CStructure1::cs1a", 1);
@@ -110,7 +112,7 @@ public class CCompositeTypeTests extends PDOMTestBase {
assertDeclarationCount(pdom, "CStructure1::CStructure2::CStructure3::cs3a", 0);
assertDeclarationCount(pdom, "CStructure3::cs3a", 1);
}
-
+
// test "nested" struct definitions in C, they should not nest
public void testDeepCStructureDefinitions() throws Exception {
assertDefinitionCount(pdom, "CStructure1", 1);
@@ -139,7 +141,7 @@ public class CCompositeTypeTests extends PDOMTestBase {
assertReferenceCount(pdom, "CStructure1::CStructure2::CStructure3", 0);
assertReferenceCount(pdom, "CStructure3", 2);
}
-
+
// test "nested" struct member references in C, they should not nest
public void testDeepCStructureMemberReferences() throws Exception {
assertReferenceCount(pdom, "CStructure1::cs1a", 2);
@@ -150,128 +152,129 @@ public class CCompositeTypeTests extends PDOMTestBase {
assertReferenceCount(pdom, "CStructure1::CStructure2::CStructure3::cs3a", 0);
assertReferenceCount(pdom, "CStructure3::cs3a", 8);
}
-
-// TODO PDOM does not distinguish between a struct or union in C
+
+ // TODO PDOM does not distinguish between a struct or union in C
public void _testCUnionDistinction() throws Exception {
- IIndexBinding[] bindings = pdom.findBindings(Pattern.compile("CUnion1"), false, IndexFilter.ALL, new NullProgressMonitor());
+ IIndexBinding[] bindings = pdom.findBindings(Pattern.compile("CUnion1"), false, IndexFilter.ALL,
+ new NullProgressMonitor());
assertEquals(1, bindings.length);
- assertEquals(ICompositeType.k_union, ((ICompositeType)bindings[0]).getKey());
+ assertEquals(ICompositeType.k_union, ((ICompositeType) bindings[0]).getKey());
}
-
+
//test union and "nested" union declarations in C, but there is no nesting in C
public void testCUnionDeclarations() throws Exception {
assertDeclarationCount(pdom, "CUnion1", 1);
assertDeclarationCount(pdom, "CUnion1::CUnion2", 0);
assertDeclarationCount(pdom, "CUnion2", 1);
}
-
+
//test union and "nested" union definitons in C, but there is no nesting in C
public void testCUnionDefinitions() throws Exception {
assertDefinitionCount(pdom, "CUnion1", 1);
assertDefinitionCount(pdom, "CUnion1::CUnion2", 0);
assertDefinitionCount(pdom, "CUnion2", 1);
}
-
+
//test union and "nested" union references in C, but there is no nesting in C
public void testCUnionReferences() throws Exception {
assertReferenceCount(pdom, "CUnion1", 2);
assertReferenceCount(pdom, "CUnion1::CUnion2", 0);
assertReferenceCount(pdom, "CUnion2", 2);
}
-
+
//test union member declarations in C
public void testCUnionMemberDeclarations() throws Exception {
assertDeclarationCount(pdom, "CUnion1::cu1a", 1);
assertDeclarationCount(pdom, "CUnion1::cu1d", 1);
}
-
+
//test union member defintions in C
public void testCUnionMemberDefinitions() throws Exception {
assertDefinitionCount(pdom, "CUnion1::cu1a", 1);
assertDefinitionCount(pdom, "CUnion1::cu1d", 1);
}
-
+
//test union member references in C
public void testCUnionMemberReferences() throws Exception {
assertReferenceCount(pdom, "CUnion1::cu1a", 2);
assertReferenceCount(pdom, "CUnion1::cu1d", 1);
}
-
+
// test "nested" unions and structs declarations in C, they should not nest
public void testCMixedDeclarations() throws Exception {
assertDeclarationCount(pdom, "CMixedS1::CMixedU1", 0);
assertDeclarationCount(pdom, "CMixedS1::CMixedU1::CMixedS2", 0);
assertDeclarationCount(pdom, "CMixedS1::CMixedU1::CMixedU2", 0);
assertDeclarationCount(pdom, "CMixedS1::CMixedS3", 0);
-
+
assertDeclarationCount(pdom, "CMixedU1", 1);
assertDeclarationCount(pdom, "CMixedS2", 1);
assertDeclarationCount(pdom, "CMixedU2", 1);
assertDeclarationCount(pdom, "CMixedS3", 1);
}
-
+
// test "nested" unions and structs definitions in C, they should not nest
public void testCMixedDefinitions() throws Exception {
assertDefinitionCount(pdom, "CMixedS1::CMixedU1", 0);
assertDefinitionCount(pdom, "CMixedS1::CMixedU1::CMixedS2", 0);
assertDefinitionCount(pdom, "CMixedS1::CMixedU1::CMixedU2", 0);
assertDefinitionCount(pdom, "CMixedS1::CMixedS3", 0);
-
+
assertDefinitionCount(pdom, "CMixedU1", 1);
assertDefinitionCount(pdom, "CMixedS2", 1);
assertDefinitionCount(pdom, "CMixedU2", 1);
assertDefinitionCount(pdom, "CMixedS3", 1);
}
-
+
// test "nested" unions and structs references in C, they should not nest
public void testCMixedReferences() throws Exception {
assertReferenceCount(pdom, "CMixedS1::CMixedU1", 0);
assertReferenceCount(pdom, "CMixedS1::CMixedU1::CMixedS2", 0);
assertReferenceCount(pdom, "CMixedS1::CMixedU1::CMixedU2", 0);
assertReferenceCount(pdom, "CMixedS1::CMixedS3", 0);
-
+
assertReferenceCount(pdom, "CMixedU1", 2);
assertReferenceCount(pdom, "CMixedS2", 2);
assertReferenceCount(pdom, "CMixedU2", 2);
assertReferenceCount(pdom, "CMixedS3", 2);
}
-
+
// test "nested" union members and struct members declarations in C, they should not nest
public void testCMixedMemberDeclarations() throws Exception {
assertDeclarationCount(pdom, "CMixedS1::CMixedU1::cmu1a", 0);
assertDeclarationCount(pdom, "CMixedS1::CMixedU1::CMixedS2::cms2a", 0);
assertDeclarationCount(pdom, "CMixedS1::CMixedU1::CMixedU2::cmu2a", 0);
assertDeclarationCount(pdom, "CMixedS1::CMixedS3::cms3a", 0);
-
+
assertDeclarationCount(pdom, "CMixedU1::cmu1a", 1);
assertDeclarationCount(pdom, "CMixedS2::cms2a", 1);
assertDeclarationCount(pdom, "CMixedU2::cmu2a", 1);
assertDeclarationCount(pdom, "CMixedS3::cms3a", 1);
}
-
+
// test "nested" union members and struct members definitions in C, they should not nest
public void testCMixedMemberDefinitions() throws Exception {
assertDefinitionCount(pdom, "CMixedS1::CMixedU1::cmu1a", 0);
assertDefinitionCount(pdom, "CMixedS1::CMixedU1::CMixedS2::cms2a", 0);
assertDefinitionCount(pdom, "CMixedS1::CMixedU1::CMixedU2::cmu2a", 0);
assertDefinitionCount(pdom, "CMixedS1::CMixedS3::cms3a", 0);
-
+
assertDefinitionCount(pdom, "CMixedU1::cmu1a", 1);
assertDefinitionCount(pdom, "CMixedS2::cms2a", 1);
assertDefinitionCount(pdom, "CMixedU2::cmu2a", 1);
assertDefinitionCount(pdom, "CMixedS3::cms3a", 1);
}
-
+
// test "nested" union members and struct members references in C, they should not nest
public void testCMixedMemberReferences() throws Exception {
assertReferenceCount(pdom, "CMixedS1::CMixedU1::cmu1a", 0);
assertReferenceCount(pdom, "CMixedS1::CMixedU1::CMixedS2::cms2a", 0);
assertReferenceCount(pdom, "CMixedS1::CMixedU1::CMixedU2::cmu2a", 0);
assertReferenceCount(pdom, "CMixedS1::CMixedS3::cms3a", 0);
-
+
assertReferenceCount(pdom, "CMixedU1::cmu1a", 2);
assertReferenceCount(pdom, "CMixedS2::cms2a", 2);
assertReferenceCount(pdom, "CMixedU2::cmu2a", 2);
assertReferenceCount(pdom, "CMixedS3::cms3a", 2);
- }
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CFunctionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CFunctionTests.java
index 09b31021207..44bdc960ff5 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CFunctionTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CFunctionTests.java
@@ -49,7 +49,8 @@ public class CFunctionTests extends PDOMTestBase {
protected void tearDown() throws Exception {
pdom.releaseReadLock();
if (project != null) {
- project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
@@ -87,19 +88,19 @@ public class CFunctionTests extends PDOMTestBase {
public void testKnRStyleFunctionWithProblemParameters() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "KnRfunctionWithProblemParameters");
assertEquals(1, bindings.length);
- IFunction f= (IFunction) bindings[0];
- IParameter[] params= f.getParameters();
+ IFunction f = (IFunction) bindings[0];
+ IParameter[] params = f.getParameters();
assertEquals(3, params.length);
- assertNull(params[0].getType()); // It's a problem binding in the DOM
+ assertNull(params[0].getType()); // It's a problem binding in the DOM
assertTrue(params[1].getType() instanceof ICBasicType);
- assertTrue(params[2].getType() instanceof ICBasicType);
+ assertTrue(params[2].getType() instanceof ICBasicType);
}
-
+
public void testFunctionWithRegisterParam() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "storageClassCFunction");
assertEquals(1, bindings.length);
- IFunction f= (IFunction) bindings[0];
- IParameter[] params= f.getParameters();
+ IFunction f = (IFunction) bindings[0];
+ IParameter[] params = f.getParameters();
assertEquals(2, params.length);
assertEquals(true, params[0].isRegister());
assertEquals(false, params[1].isRegister());
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPClassTemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPClassTemplateTests.java
index 23e5850851f..27d5886f515 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPClassTemplateTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPClassTemplateTests.java
@@ -48,19 +48,19 @@ import junit.framework.Test;
* Tests PDOM class template related bindings
*/
public class CPPClassTemplateTests extends PDOMInlineCodeTestBase {
-
+
public static Test suite() {
return suite(CPPClassTemplateTests.class);
}
-
+
@Override
public void setUp() throws Exception {
super.setUp();
setUpSections(1);
}
-
+
/*************************************************************************/
-
+
// template<typename T>
// class Foo {};
//
@@ -72,38 +72,38 @@ public class CPPClassTemplateTests extends PDOMInlineCodeTestBase {
// Foo<A> a;
// Foo<B> b;
public void testSpecializations() throws Exception {
- IBinding[] as= pdom.findBindings(new char[][]{{'a'}}, IndexFilter.ALL, npm());
- IBinding[] bs= pdom.findBindings(new char[][]{{'b'}}, IndexFilter.ALL, npm());
-
+ IBinding[] as = pdom.findBindings(new char[][] { { 'a' } }, IndexFilter.ALL, npm());
+ IBinding[] bs = pdom.findBindings(new char[][] { { 'b' } }, IndexFilter.ALL, npm());
+
assertEquals(1, as.length);
assertEquals(1, bs.length);
assertInstance(as[0], ICPPVariable.class);
assertInstance(bs[0], ICPPVariable.class);
-
- ICPPVariable a= (ICPPVariable) as[0];
- ICPPVariable b= (ICPPVariable) bs[0];
-
+
+ ICPPVariable a = (ICPPVariable) as[0];
+ ICPPVariable b = (ICPPVariable) bs[0];
+
assertInstance(a.getType(), ICPPSpecialization.class);
assertInstance(b.getType(), ICPPSpecialization.class);
-
- ICPPSpecialization asp= (ICPPSpecialization) a.getType();
- ICPPSpecialization bsp= (ICPPSpecialization) b.getType();
-
+
+ ICPPSpecialization asp = (ICPPSpecialization) a.getType();
+ ICPPSpecialization bsp = (ICPPSpecialization) b.getType();
+
ICPPTemplateParameterMap aArgs = asp.getTemplateParameterMap();
ICPPTemplateParameterMap bArgs = bsp.getTemplateParameterMap();
assertEquals(1, aArgs.getAllParameterPositions().length);
assertEquals(1, bArgs.getAllParameterPositions().length);
-
+
assertInstance(aArgs.getArgument(0).getTypeValue(), ICPPClassType.class);
assertInstance(bArgs.getArgument(0).getTypeValue(), ICPPClassType.class);
-
+
assertEquals("A", ((ICPPClassType) aArgs.getArgument(0).getTypeValue()).getName());
assertEquals("B", ((ICPPClassType) bArgs.getArgument(0).getTypeValue()).getName());
-
+
assertDeclarationCount(pdom, "a", 1);
assertDeclarationCount(pdom, "b", 1);
}
-
+
// template<typename C>
// class D {
// public:
@@ -111,18 +111,18 @@ public class CPPClassTemplateTests extends PDOMInlineCodeTestBase {
// };
public void testSimpleDefinition() throws Exception {
assertDeclarationCount(pdom, "D", 1);
- IIndexFragmentBinding[] b= pdom.findBindings(new char[][] {{'D'}}, IndexFilter.ALL_DECLARED, npm());
+ IIndexFragmentBinding[] b = pdom.findBindings(new char[][] { { 'D' } }, IndexFilter.ALL_DECLARED, npm());
assertEquals(1, b.length);
assertTrue(b[0] instanceof ICPPClassTemplate);
- ICPPClassTemplate ct= (ICPPClassTemplate) b[0];
- ICPPTemplateParameter[] tp= ct.getTemplateParameters();
+ ICPPClassTemplate ct = (ICPPClassTemplate) b[0];
+ ICPPTemplateParameter[] tp = ct.getTemplateParameters();
assertEquals(1, tp.length);
assertTrue(tp[0] instanceof ICPPTemplateTypeParameter);
- ICPPTemplateTypeParameter ctp= (ICPPTemplateTypeParameter) tp[0];
+ ICPPTemplateTypeParameter ctp = (ICPPTemplateTypeParameter) tp[0];
assertNull(ctp.getDefault());
assertEquals(0, ct.getPartialSpecializations().length);
}
-
+
// template<class C=char> /* typename and class are equivalent in template parameter context */
// class D {
// public:
@@ -130,22 +130,22 @@ public class CPPClassTemplateTests extends PDOMInlineCodeTestBase {
// };
public void testDefinition() throws Exception {
assertDeclarationCount(pdom, "D", 1);
- IIndexFragmentBinding[] b= pdom.findBindings(new char[][] {{'D'}}, IndexFilter.ALL_DECLARED, npm());
+ IIndexFragmentBinding[] b = pdom.findBindings(new char[][] { { 'D' } }, IndexFilter.ALL_DECLARED, npm());
assertEquals(1, b.length);
assertTrue(b[0] instanceof ICPPClassTemplate);
- ICPPClassTemplate ct= (ICPPClassTemplate) b[0];
- ICPPTemplateParameter[] tp= ct.getTemplateParameters();
+ ICPPClassTemplate ct = (ICPPClassTemplate) b[0];
+ ICPPTemplateParameter[] tp = ct.getTemplateParameters();
assertEquals(1, tp.length);
assertTrue(tp[0] instanceof ICPPTemplateTypeParameter);
assertEquals("C", tp[0].getName());
- assertEquals(new String[] {"D","C"}, tp[0].getQualifiedName());
- assertEquals(new char[][] {{'D'},{'C'}}, tp[0].getQualifiedNameCharArray());
- ICPPTemplateTypeParameter ctp= (ICPPTemplateTypeParameter) tp[0];
- IType def= ctp.getDefault();
+ assertEquals(new String[] { "D", "C" }, tp[0].getQualifiedName());
+ assertEquals(new char[][] { { 'D' }, { 'C' } }, tp[0].getQualifiedNameCharArray());
+ ICPPTemplateTypeParameter ctp = (ICPPTemplateTypeParameter) tp[0];
+ IType def = ctp.getDefault();
assertTrue(def instanceof IBasicType);
assertEquals(0, ct.getPartialSpecializations().length);
}
-
+
// class TA {};
// class TC {};
//
@@ -156,44 +156,44 @@ public class CPPClassTemplateTests extends PDOMInlineCodeTestBase {
// };
public void testDefinition2() throws Exception {
assertDeclarationCount(pdom, "E", 1);
- IIndexFragmentBinding[] b= pdom.findBindings(new char[][] {{'E'}}, IndexFilter.ALL_DECLARED, npm());
+ IIndexFragmentBinding[] b = pdom.findBindings(new char[][] { { 'E' } }, IndexFilter.ALL_DECLARED, npm());
assertEquals(1, b.length);
assertTrue(b[0] instanceof ICPPClassTemplate);
- ICPPClassTemplate ct= (ICPPClassTemplate) b[0];
- ICPPTemplateParameter[] tp= ct.getTemplateParameters();
+ ICPPClassTemplate ct = (ICPPClassTemplate) b[0];
+ ICPPTemplateParameter[] tp = ct.getTemplateParameters();
assertEquals(3, tp.length);
-
+
assertTrue(tp[0] instanceof ICPPTemplateTypeParameter);
assertEquals("A", tp[0].getName());
- assertEquals(new String[] {"E","A"}, tp[0].getQualifiedName());
- assertEquals(new char[][] {{'E'},{'A'}}, tp[0].getQualifiedNameCharArray());
- ICPPTemplateTypeParameter ctpa= (ICPPTemplateTypeParameter) tp[0];
- IType defa= ctpa.getDefault();
+ assertEquals(new String[] { "E", "A" }, tp[0].getQualifiedName());
+ assertEquals(new char[][] { { 'E' }, { 'A' } }, tp[0].getQualifiedNameCharArray());
+ ICPPTemplateTypeParameter ctpa = (ICPPTemplateTypeParameter) tp[0];
+ IType defa = ctpa.getDefault();
assertTrue(defa instanceof ICPPClassType);
- ICPPClassType ctdefa= (ICPPClassType) defa;
- assertEquals(new char[][] {{'T','A'}}, ctdefa.getQualifiedNameCharArray());
-
+ ICPPClassType ctdefa = (ICPPClassType) defa;
+ assertEquals(new char[][] { { 'T', 'A' } }, ctdefa.getQualifiedNameCharArray());
+
assertTrue(tp[1] instanceof ICPPTemplateTypeParameter);
assertEquals("B", tp[1].getName());
- assertEquals(new String[] {"E","B"}, tp[1].getQualifiedName());
- assertEquals(new char[][] {{'E'},{'B'}}, tp[1].getQualifiedNameCharArray());
- ICPPTemplateTypeParameter ctpb= (ICPPTemplateTypeParameter) tp[1];
- IType defb= ctpb.getDefault();
+ assertEquals(new String[] { "E", "B" }, tp[1].getQualifiedName());
+ assertEquals(new char[][] { { 'E' }, { 'B' } }, tp[1].getQualifiedNameCharArray());
+ ICPPTemplateTypeParameter ctpb = (ICPPTemplateTypeParameter) tp[1];
+ IType defb = ctpb.getDefault();
assertNull(defb);
-
+
assertTrue(tp[2] instanceof ICPPTemplateTypeParameter);
assertEquals("C", tp[2].getName());
- assertEquals(new String[] {"E","C"}, tp[2].getQualifiedName());
- assertEquals(new char[][] {{'E'},{'C'}}, tp[2].getQualifiedNameCharArray());
- ICPPTemplateTypeParameter ctpc= (ICPPTemplateTypeParameter) tp[2];
- IType defc= ctpc.getDefault();
+ assertEquals(new String[] { "E", "C" }, tp[2].getQualifiedName());
+ assertEquals(new char[][] { { 'E' }, { 'C' } }, tp[2].getQualifiedNameCharArray());
+ ICPPTemplateTypeParameter ctpc = (ICPPTemplateTypeParameter) tp[2];
+ IType defc = ctpc.getDefault();
assertTrue(defc instanceof ICPPClassType);
- ICPPClassType ctdefc= (ICPPClassType) defc;
- assertEquals(new char[][] {{'T','C'}}, ctdefc.getQualifiedNameCharArray());
-
+ ICPPClassType ctdefc = (ICPPClassType) defc;
+ assertEquals(new char[][] { { 'T', 'C' } }, ctdefc.getQualifiedNameCharArray());
+
assertEquals(0, ct.getPartialSpecializations().length);
}
-
+
// template<typename T>
// class Foo {
// public:
@@ -206,23 +206,23 @@ public class CPPClassTemplateTests extends PDOMInlineCodeTestBase {
// foo->f(*new A());
// }
public void testFunctionPointer() throws Exception {
- IIndexFragmentBinding[] bs= pdom.findBindings(new char[][] {"foo".toCharArray()}, IndexFilter.ALL, npm());
+ IIndexFragmentBinding[] bs = pdom.findBindings(new char[][] { "foo".toCharArray() }, IndexFilter.ALL, npm());
assertEquals(1, bs.length);
assertInstance(bs[0], ICPPVariable.class);
- ICPPVariable var= (ICPPVariable) bs[0];
+ ICPPVariable var = (ICPPVariable) bs[0];
assertInstance(var.getType(), ICPPClassType.class);
- ICPPClassType ct= (ICPPClassType) var.getType();
+ ICPPClassType ct = (ICPPClassType) var.getType();
IField[] fields = ClassTypeHelper.getFields(ct);
assertEquals(1, fields.length);
assertInstance(fields[0].getType(), IPointerType.class);
- IPointerType pt= (IPointerType) fields[0].getType();
+ IPointerType pt = (IPointerType) fields[0].getType();
assertInstance(pt.getType(), IFunctionType.class);
- IFunctionType ft= (IFunctionType) pt.getType();
+ IFunctionType ft = (IFunctionType) pt.getType();
assertInstance(ft.getReturnType(), ICPPClassType.class);
assertEquals(1, ft.getParameterTypes().length);
assertInstance(ft.getParameterTypes()[0], ICPPClassType.class);
}
-
+
// template<typename C>
// class D {
// public:
@@ -242,53 +242,54 @@ public class CPPClassTemplateTests extends PDOMInlineCodeTestBase {
public void testExplicitInstantiation() throws Exception {
{
// template
- IIndexFragmentBinding[] b= pdom.findBindings(new char[][] {{'D'}}, IndexFilter.ALL_DECLARED, npm());
+ IIndexFragmentBinding[] b = pdom.findBindings(new char[][] { { 'D' } }, IndexFilter.ALL_DECLARED, npm());
assertEquals(2, b.length);
assertTrue(!(b[0] instanceof ICPPClassTemplate) || !(b[1] instanceof ICPPClassTemplate));
- int i= b[0] instanceof ICPPClassTemplate ? 0 : 1;
-
+ int i = b[0] instanceof ICPPClassTemplate ? 0 : 1;
+
assertInstance(b[i], ICPPClassTemplate.class);
- ICPPClassTemplate ct= (ICPPClassTemplate) b[i];
- ICPPTemplateParameter[] tp= ct.getTemplateParameters();
+ ICPPClassTemplate ct = (ICPPClassTemplate) b[i];
+ ICPPTemplateParameter[] tp = ct.getTemplateParameters();
assertEquals(1, tp.length);
assertInstance(tp[i], ICPPTemplateTypeParameter.class);
- ICPPTemplateTypeParameter ctp= (ICPPTemplateTypeParameter) tp[i];
+ ICPPTemplateTypeParameter ctp = (ICPPTemplateTypeParameter) tp[i];
assertNull(ctp.getDefault());
}
{
assertDeclarationCount(pdom, "dn", 1);
- IIndexFragmentBinding[] b= pdom.findBindings(new char[][] {"dn".toCharArray()}, IndexFilter.ALL, npm());
+ IIndexFragmentBinding[] b = pdom.findBindings(new char[][] { "dn".toCharArray() }, IndexFilter.ALL, npm());
assertEquals(1, b.length);
assertInstance(b[0], ICPPVariable.class);
- ICPPVariable var= (ICPPVariable) b[0];
+ ICPPVariable var = (ICPPVariable) b[0];
assertInstance(var.getType(), ICPPClassType.class);
assertInstance(var.getType(), ICPPSpecialization.class);
- ICPPSpecialization cp= (ICPPSpecialization) var.getType();
- ICPPTemplateParameterMap m= cp.getTemplateParameterMap();
+ ICPPSpecialization cp = (ICPPSpecialization) var.getType();
+ ICPPTemplateParameterMap m = cp.getTemplateParameterMap();
assertEquals(1, m.getAllParameterPositions().length);
ICPPTemplateArgument arg = m.getArgument(0);
assertInstance(arg.getTypeValue(), ICPPClassType.class);
- assertEquals(new String[] {"N"}, ((ICPPClassType) arg.getTypeValue()).getQualifiedName());
+ assertEquals(new String[] { "N" }, ((ICPPClassType) arg.getTypeValue()).getQualifiedName());
}
-
+
{
assertDeclarationCount(pdom, "dint", 1);
- IIndexFragmentBinding[] b= pdom.findBindings(new char[][] {"dint".toCharArray()}, IndexFilter.ALL, npm());
+ IIndexFragmentBinding[] b = pdom.findBindings(new char[][] { "dint".toCharArray() }, IndexFilter.ALL,
+ npm());
assertEquals(1, b.length);
assertTrue(b[0] instanceof ICPPVariable);
- ICPPVariable var= (ICPPVariable) b[0];
+ ICPPVariable var = (ICPPVariable) b[0];
assertInstance(var.getType(), ICPPClassType.class);
assertInstance(var.getType(), ICPPSpecialization.class);
- ICPPSpecialization cp= (ICPPSpecialization) var.getType();
- ICPPTemplateParameterMap m= cp.getTemplateParameterMap();
+ ICPPSpecialization cp = (ICPPSpecialization) var.getType();
+ ICPPTemplateParameterMap m = cp.getTemplateParameterMap();
assertEquals(1, m.getAllParameterPositions().length);
ICPPTemplateArgument arg = m.getArgument(0);
assertInstance(arg.getTypeValue(), IBasicType.class);
assertEquals(IBasicType.Kind.eInt, ((IBasicType) arg.getTypeValue()).getKind());
}
}
-
+
// template<typename xT>
// struct S {
// xT x;
@@ -297,28 +298,28 @@ public class CPPClassTemplateTests extends PDOMInlineCodeTestBase {
// using A = S<aT>;
public void testSimpleAliasDefinition() throws Exception {
assertDeclarationCount(pdom, "A", 1);
- IIndexFragmentBinding[] bindingA= pdom.findBindings(new char[][] {{'A'}}, IndexFilter.ALL_DECLARED, npm());
+ IIndexFragmentBinding[] bindingA = pdom.findBindings(new char[][] { { 'A' } }, IndexFilter.ALL_DECLARED, npm());
assertEquals(1, bindingA.length);
assertTrue(bindingA[0] instanceof ICPPAliasTemplate);
- ICPPAliasTemplate aliasA= (ICPPAliasTemplate) bindingA[0];
- ICPPTemplateParameter[] aliasParameters= aliasA.getTemplateParameters();
+ ICPPAliasTemplate aliasA = (ICPPAliasTemplate) bindingA[0];
+ ICPPTemplateParameter[] aliasParameters = aliasA.getTemplateParameters();
assertEquals(1, aliasParameters.length);
-
+
assertTrue(aliasParameters[0] instanceof ICPPTemplateTypeParameter);
- ICPPTemplateTypeParameter templateParameterAT= (ICPPTemplateTypeParameter) aliasParameters[0];
+ ICPPTemplateTypeParameter templateParameterAT = (ICPPTemplateTypeParameter) aliasParameters[0];
assertEquals("aT", templateParameterAT.getName());
assertNull(templateParameterAT.getDefault());
assertEquals(0, templateParameterAT.getTemplateNestingLevel());
-
+
assertDeclarationCount(pdom, "S", 1);
- IIndexFragmentBinding[] bindingS= pdom.findBindings(new char[][] {{'S'}}, IndexFilter.ALL_DECLARED, npm());
+ IIndexFragmentBinding[] bindingS = pdom.findBindings(new char[][] { { 'S' } }, IndexFilter.ALL_DECLARED, npm());
IType aliasedType = aliasA.getType();
assertTrue(aliasedType instanceof ICPPDeferredClassInstance);
- ICPPDeferredClassInstance deferredClassInstanceS= (ICPPDeferredClassInstance) aliasedType;
+ ICPPDeferredClassInstance deferredClassInstanceS = (ICPPDeferredClassInstance) aliasedType;
assertEquals(1, bindingA.length);
assertEquals(bindingS[0], deferredClassInstanceS.getSpecializedBinding());
}
-
+
// struct D {
// };
// template<typename sT1, typename sT2>
@@ -329,40 +330,40 @@ public class CPPClassTemplateTests extends PDOMInlineCodeTestBase {
// using A = S<aT1, aT2>;
public void testSimpleAliasDefinitionDefaultTemplateArgument() throws Exception {
assertDeclarationCount(pdom, "A", 1);
- IIndexFragmentBinding[] bindingA= pdom.findBindings(new char[][] {{'A'}}, IndexFilter.ALL_DECLARED, npm());
+ IIndexFragmentBinding[] bindingA = pdom.findBindings(new char[][] { { 'A' } }, IndexFilter.ALL_DECLARED, npm());
assertEquals(1, bindingA.length);
assertTrue(bindingA[0] instanceof ICPPAliasTemplate);
- ICPPAliasTemplate aliasA= (ICPPAliasTemplate) bindingA[0];
- ICPPTemplateParameter[] aliasParameters= aliasA.getTemplateParameters();
+ ICPPAliasTemplate aliasA = (ICPPAliasTemplate) bindingA[0];
+ ICPPTemplateParameter[] aliasParameters = aliasA.getTemplateParameters();
assertEquals(2, aliasParameters.length);
-
+
assertTrue(aliasParameters[0] instanceof ICPPTemplateTypeParameter);
- ICPPTemplateTypeParameter templateParameterAT1= (ICPPTemplateTypeParameter) aliasParameters[0];
+ ICPPTemplateTypeParameter templateParameterAT1 = (ICPPTemplateTypeParameter) aliasParameters[0];
assertEquals("aT1", templateParameterAT1.getName());
assertNull(templateParameterAT1.getDefault());
assertEquals(0, templateParameterAT1.getTemplateNestingLevel());
-
+
assertTrue(aliasParameters[1] instanceof ICPPTemplateTypeParameter);
- ICPPTemplateTypeParameter templateParameterAT2= (ICPPTemplateTypeParameter) aliasParameters[1];
+ ICPPTemplateTypeParameter templateParameterAT2 = (ICPPTemplateTypeParameter) aliasParameters[1];
assertEquals("aT2", templateParameterAT2.getName());
IType aT2DefaultArgument = templateParameterAT2.getDefault();
assertNotNull(aT2DefaultArgument);
assertDeclarationCount(pdom, "D", 1);
- IIndexFragmentBinding[] bindingD= pdom.findBindings(new char[][] {{'D'}}, IndexFilter.ALL_DECLARED, npm());
+ IIndexFragmentBinding[] bindingD = pdom.findBindings(new char[][] { { 'D' } }, IndexFilter.ALL_DECLARED, npm());
assertEquals(1, bindingD.length);
assertTrue(bindingD[0] instanceof IType);
- assertTrue(((IType)bindingD[0]).isSameType(aT2DefaultArgument));
+ assertTrue(((IType) bindingD[0]).isSameType(aT2DefaultArgument));
assertEquals(0, templateParameterAT2.getTemplateNestingLevel());
-
+
assertDeclarationCount(pdom, "S", 1);
- IIndexFragmentBinding[] bindingS= pdom.findBindings(new char[][] {{'S'}}, IndexFilter.ALL_DECLARED, npm());
+ IIndexFragmentBinding[] bindingS = pdom.findBindings(new char[][] { { 'S' } }, IndexFilter.ALL_DECLARED, npm());
IType aliasedType = aliasA.getType();
assertTrue(aliasedType instanceof ICPPDeferredClassInstance);
- ICPPDeferredClassInstance deferredClassInstanceS= (ICPPDeferredClassInstance) aliasedType;
+ ICPPDeferredClassInstance deferredClassInstanceS = (ICPPDeferredClassInstance) aliasedType;
assertEquals(1, bindingS.length);
assertEquals(bindingS[0], deferredClassInstanceS.getSpecializedBinding());
}
-
+
// template<boolean sT1, int sT2>
// struct S {
// xT x;
@@ -371,37 +372,37 @@ public class CPPClassTemplateTests extends PDOMInlineCodeTestBase {
// using A = S<aT1, aT2>;
public void testSimpleAliasDefinitionValueTemplateArguments() throws Exception {
assertDeclarationCount(pdom, "A", 1);
- IIndexFragmentBinding[] bindingA= pdom.findBindings(new char[][] {{'A'}}, IndexFilter.ALL_DECLARED, npm());
+ IIndexFragmentBinding[] bindingA = pdom.findBindings(new char[][] { { 'A' } }, IndexFilter.ALL_DECLARED, npm());
assertEquals(1, bindingA.length);
assertTrue(bindingA[0] instanceof ICPPAliasTemplate);
- ICPPAliasTemplate aliasA= (ICPPAliasTemplate) bindingA[0];
- ICPPTemplateParameter[] aliasParameters= aliasA.getTemplateParameters();
+ ICPPAliasTemplate aliasA = (ICPPAliasTemplate) bindingA[0];
+ ICPPTemplateParameter[] aliasParameters = aliasA.getTemplateParameters();
assertEquals(2, aliasParameters.length);
-
+
assertTrue(aliasParameters[0] instanceof ICPPTemplateNonTypeParameter);
- ICPPTemplateNonTypeParameter templateParameterAT1= (ICPPTemplateNonTypeParameter) aliasParameters[0];
+ ICPPTemplateNonTypeParameter templateParameterAT1 = (ICPPTemplateNonTypeParameter) aliasParameters[0];
assertEquals("aT1", templateParameterAT1.getName());
assertNull(templateParameterAT1.getDefaultValue());
assertEquals(0, templateParameterAT1.getTemplateNestingLevel());
-
+
assertTrue(aliasParameters[1] instanceof ICPPTemplateNonTypeParameter);
- ICPPTemplateNonTypeParameter templateParameterAT2= (ICPPTemplateNonTypeParameter) aliasParameters[1];
+ ICPPTemplateNonTypeParameter templateParameterAT2 = (ICPPTemplateNonTypeParameter) aliasParameters[1];
assertEquals("aT2", templateParameterAT2.getName());
ICPPTemplateArgument aT2DefaultArgument = templateParameterAT2.getDefaultValue();
assertNotNull(aT2DefaultArgument);
assertTrue(new CPPBasicType(IBasicType.Kind.eInt, 0).isSameType(aT2DefaultArgument.getTypeOfNonTypeValue()));
assertEquals(5, aT2DefaultArgument.getNonTypeValue().numberValue().longValue());
assertEquals(0, templateParameterAT2.getTemplateNestingLevel());
-
+
assertDeclarationCount(pdom, "S", 1);
- IIndexFragmentBinding[] bindingS= pdom.findBindings(new char[][] {{'S'}}, IndexFilter.ALL_DECLARED, npm());
+ IIndexFragmentBinding[] bindingS = pdom.findBindings(new char[][] { { 'S' } }, IndexFilter.ALL_DECLARED, npm());
IType aliasedType = aliasA.getType();
assertTrue(aliasedType instanceof ICPPDeferredClassInstance);
- ICPPDeferredClassInstance deferredClassInstanceS= (ICPPDeferredClassInstance) aliasedType;
+ ICPPDeferredClassInstance deferredClassInstanceS = (ICPPDeferredClassInstance) aliasedType;
assertEquals(1, bindingS.length);
assertEquals(bindingS[0], deferredClassInstanceS.getSpecializedBinding());
}
-
+
// template<typename T>
// struct S {
// T t;
@@ -410,20 +411,20 @@ public class CPPClassTemplateTests extends PDOMInlineCodeTestBase {
// using A = S<TT>;
public void testSimpleAliasTemplateParameter() throws Exception {
assertDeclarationCount(pdom, "A", 1);
- IIndexFragmentBinding[] bindingA= pdom.findBindings(new char[][] {{'A'}}, IndexFilter.ALL_DECLARED, npm());
+ IIndexFragmentBinding[] bindingA = pdom.findBindings(new char[][] { { 'A' } }, IndexFilter.ALL_DECLARED, npm());
assertEquals(1, bindingA.length);
assertTrue(bindingA[0] instanceof ICPPAliasTemplate);
- ICPPAliasTemplate aliasA= (ICPPAliasTemplate) bindingA[0];
- ICPPTemplateParameter[] aliasParameters= aliasA.getTemplateParameters();
+ ICPPAliasTemplate aliasA = (ICPPAliasTemplate) bindingA[0];
+ ICPPTemplateParameter[] aliasParameters = aliasA.getTemplateParameters();
assertEquals(1, aliasParameters.length);
-
+
assertTrue(aliasParameters[0] instanceof ICPPTemplateTemplateParameter);
- ICPPTemplateTemplateParameter templateParameterTT= (ICPPTemplateTemplateParameter) aliasParameters[0];
+ ICPPTemplateTemplateParameter templateParameterTT = (ICPPTemplateTemplateParameter) aliasParameters[0];
assertEquals("TT", templateParameterTT.getName());
assertNull(templateParameterTT.getDefaultValue());
assertEquals(0, templateParameterTT.getTemplateNestingLevel());
}
-
+
// struct B{};
// template<typename xT>
// struct S {
@@ -435,31 +436,33 @@ public class CPPClassTemplateTests extends PDOMInlineCodeTestBase {
// S<B> sB;
public void testSimpleAliasReference() throws Exception {
assertDeclarationCount(pdom, "A", 1);
- IIndexFragmentBinding[] bindingA= pdom.findBindings(new char[][] {{'A'}}, IndexFilter.ALL_DECLARED, npm());
+ IIndexFragmentBinding[] bindingA = pdom.findBindings(new char[][] { { 'A' } }, IndexFilter.ALL_DECLARED, npm());
assertEquals(1, bindingA.length);
assertInstance(bindingA[0], ICPPAliasTemplate.class);
- ICPPAliasTemplate aliasA= (ICPPAliasTemplate) bindingA[0];
- ICPPTemplateParameter[] aliasParameters= aliasA.getTemplateParameters();
+ ICPPAliasTemplate aliasA = (ICPPAliasTemplate) bindingA[0];
+ ICPPTemplateParameter[] aliasParameters = aliasA.getTemplateParameters();
assertEquals(1, aliasParameters.length);
-
+
assertReferenceCount(pdom, "S", 2);
assertReferenceCount(pdom, "A", 1);
assertDeclarationCount(pdom, "aB", 1);
assertDeclarationCount(pdom, "sB", 1);
-
- IIndexFragmentBinding[] bindingB= pdom.findBindings(new char[][] {{'B'}}, IndexFilter.ALL_DECLARED, npm());
+
+ IIndexFragmentBinding[] bindingB = pdom.findBindings(new char[][] { { 'B' } }, IndexFilter.ALL_DECLARED, npm());
assertEquals(1, bindingB.length);
assertInstance(bindingB[0], ICPPClassType.class);
-
- IIndexFragmentBinding[] bindingVarSB= pdom.findBindings(new char[][] {"sB".toCharArray()}, IndexFilter.ALL, npm());
+
+ IIndexFragmentBinding[] bindingVarSB = pdom.findBindings(new char[][] { "sB".toCharArray() }, IndexFilter.ALL,
+ npm());
assertEquals(1, bindingVarSB.length);
assertInstance(bindingVarSB[0], ICPPVariable.class);
ICPPVariable variableSB = (ICPPVariable) bindingVarSB[0];
IType varSBType = variableSB.getType();
assertInstance(varSBType, ICPPClassSpecialization.class);
ICPPClassSpecialization templateInstanceSB = (ICPPClassSpecialization) varSBType;
-
- IIndexFragmentBinding[] bindingVarAB= pdom.findBindings(new char[][] {"aB".toCharArray()}, IndexFilter.ALL, npm());
+
+ IIndexFragmentBinding[] bindingVarAB = pdom.findBindings(new char[][] { "aB".toCharArray() }, IndexFilter.ALL,
+ npm());
assertEquals(1, bindingVarAB.length);
assertTrue(bindingVarAB[0] instanceof ICPPVariable);
ICPPVariable variableAB = (ICPPVariable) bindingVarAB[0];
@@ -475,13 +478,14 @@ public class CPPClassTemplateTests extends PDOMInlineCodeTestBase {
assertEquals(1, args.length);
assertTrue(((ICPPClassType) bindingB[0]).isSameType(args[0].getTypeValue()));
}
-
+
// template<typename T> class CT {
// template<typename T> using A= T; // nesting level 1
// A<int> x;
- // };
+ // };
public void testPDOMNestedAliasDeclarationNestingLevel() throws Exception {
- IIndexFragmentBinding[] bindingCT = pdom.findBindings(new char[][] { "CT".toCharArray() }, IndexFilter.ALL_DECLARED, npm());
+ IIndexFragmentBinding[] bindingCT = pdom.findBindings(new char[][] { "CT".toCharArray() },
+ IndexFilter.ALL_DECLARED, npm());
assertEquals(1, bindingCT.length);
assertTrue(bindingCT[0] instanceof ICPPClassTemplate);
ICPPClassTemplate templateCT = (ICPPClassTemplate) bindingCT[0];
@@ -491,7 +495,7 @@ public class CPPClassTemplateTests extends PDOMInlineCodeTestBase {
IField x = fields[0];
IType xType = x.getType();
assertTrue(xType instanceof ICPPAliasTemplateInstance);
-
+
ICPPAliasTemplateInstance aliasInstance = (ICPPAliasTemplateInstance) xType;
ICPPAliasTemplate alias = aliasInstance.getTemplateDefinition();
ICPPTemplateParameter[] aliasParameters = alias.getTemplateParameters();
@@ -499,66 +503,65 @@ public class CPPClassTemplateTests extends PDOMInlineCodeTestBase {
ICPPTemplateParameter aliasParameterT = aliasParameters[0];
assertEquals(1, aliasParameterT.getTemplateNestingLevel());
}
-
+
// template<typename T> class CT;
// template<typename T> using A= CT<T>; // nesting level 0
// template<typename T> class CT { // nesting level 0
- // typedef Alias<T> TYPE;
+ // typedef Alias<T> TYPE;
// };
public void testPDOMAliasDeclarationNestingLevel() throws Exception {
assertDeclarationCount(pdom, "A", 1);
- IIndexFragmentBinding[] bindingA= pdom.findBindings(new char[][] {{'A'}}, IndexFilter.ALL_DECLARED, npm());
+ IIndexFragmentBinding[] bindingA = pdom.findBindings(new char[][] { { 'A' } }, IndexFilter.ALL_DECLARED, npm());
assertEquals(1, bindingA.length);
assertTrue(bindingA[0] instanceof ICPPAliasTemplate);
- ICPPAliasTemplate aliasA= (ICPPAliasTemplate) bindingA[0];
- ICPPTemplateParameter[] aliasParameters= aliasA.getTemplateParameters();
+ ICPPAliasTemplate aliasA = (ICPPAliasTemplate) bindingA[0];
+ ICPPTemplateParameter[] aliasParameters = aliasA.getTemplateParameters();
assertEquals(1, aliasParameters.length);
-
+
assertTrue(aliasParameters[0] instanceof ICPPTemplateTypeParameter);
- ICPPTemplateTypeParameter templateParameterT= (ICPPTemplateTypeParameter) aliasParameters[0];
+ ICPPTemplateTypeParameter templateParameterT = (ICPPTemplateTypeParameter) aliasParameters[0];
assertEquals("T", templateParameterT.getName());
assertNull(templateParameterT.getDefault());
assertEquals(0, templateParameterT.getTemplateNestingLevel());
-
+
assertDeclarationCount(pdom, "CT", 2);
- IIndexFragmentBinding[] bindingCT= pdom.findBindings(new char[][] {"CT".toCharArray()}, IndexFilter.ALL_DECLARED, npm());
+ IIndexFragmentBinding[] bindingCT = pdom.findBindings(new char[][] { "CT".toCharArray() },
+ IndexFilter.ALL_DECLARED, npm());
assertEquals(1, bindingCT.length);
assertTrue(bindingCT[0] instanceof ICPPClassTemplate);
- ICPPClassTemplate templateCT= (ICPPClassTemplate) bindingCT[0];
- ICPPTemplateParameter[] ctParameters= templateCT.getTemplateParameters();
+ ICPPClassTemplate templateCT = (ICPPClassTemplate) bindingCT[0];
+ ICPPTemplateParameter[] ctParameters = templateCT.getTemplateParameters();
assertEquals(1, ctParameters.length);
-
+
assertTrue(ctParameters[0] instanceof ICPPTemplateTypeParameter);
- ICPPTemplateTypeParameter templateParameterTofCT= (ICPPTemplateTypeParameter) ctParameters[0];
+ ICPPTemplateTypeParameter templateParameterTofCT = (ICPPTemplateTypeParameter) ctParameters[0];
assertEquals("T", templateParameterTofCT.getName());
assertNull(templateParameterTofCT.getDefault());
assertEquals(0, templateParameterTofCT.getTemplateNestingLevel());
}
-
-
-
+
@Override
protected void assertInstance(Object o, Class c) {
assertNotNull(o);
- assertTrue("Expected "+c.getName()+" but got "+o.getClass().getName(), c.isInstance(o));
+ assertTrue("Expected " + c.getName() + " but got " + o.getClass().getName(), c.isInstance(o));
}
-
+
protected void assertEquals(char[] c1, char[] c2) {
assertTrue(Arrays.equals(c1, c2));
}
-
+
protected void assertEquals(String[] s1, String[] s2) {
assertTrue(Arrays.equals(s1, s2));
}
-
+
protected void assertEquals(char[][] c1, char[][] c2) {
- if(c1==null || c2==null) {
- assertTrue(c1==c2);
+ if (c1 == null || c2 == null) {
+ assertTrue(c1 == c2);
return;
}
-
+
assertEquals(c1.length, c2.length);
- for(int i=0; i<c1.length; i++) {
+ for (int i = 0; i < c1.length; i++) {
assertEquals(c1[i], c2[i]);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPCompositeTypeTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPCompositeTypeTests.java
index ce5a460b2d9..aa87d96edde 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPCompositeTypeTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPCompositeTypeTests.java
@@ -38,21 +38,21 @@ public class CPPCompositeTypeTests extends PDOMTestBase {
@Override
protected void setUp() throws Exception {
CPPCompositeTypeTests foo = null;
-
+
project = createProject("compositeTypeTests");
pdom = (PDOM) CCoreInternals.getPDOMManager().getPDOM(project);
pdom.acquireReadLock();
}
-
+
@Override
protected void tearDown() throws Exception {
pdom.releaseReadLock();
}
-
+
public void testSimpleStructure() throws Exception {
assertType(pdom, "SimpleStructure", ICompositeType.class);
}
-
+
public void testSimpleStructureDeclarations() throws Exception {
assertDeclarationCount(pdom, "SimpleStructure", 1);
assertDeclarationCount(pdom, "SimpleStructure::ssa", 1);
@@ -62,7 +62,7 @@ public class CPPCompositeTypeTests extends PDOMTestBase {
assertDefinitionCount(pdom, "SimpleStructure", 1);
assertDefinitionCount(pdom, "SimpleStructure::ssa", 1);
}
-
+
public void testSimpleStructureReferences() throws Exception {
assertReferenceCount(pdom, "SimpleStructure", 2);
assertReferenceCount(pdom, "SimpleStructure::ssa", 2);
@@ -73,13 +73,13 @@ public class CPPCompositeTypeTests extends PDOMTestBase {
assertType(pdom, "Structure1::Structure2", ICompositeType.class);
assertType(pdom, "Structure1::Structure2::Structure3", ICompositeType.class);
}
-
+
public void testDeepStructureDeclarations() throws Exception {
assertDeclarationCount(pdom, "Structure1", 1);
assertDeclarationCount(pdom, "Structure1::Structure2", 1);
assertDeclarationCount(pdom, "Structure1::Structure2::Structure3", 1);
}
-
+
public void testDeepStructureMemberDeclarations() throws Exception {
assertDeclarationCount(pdom, "Structure1::s1a", 1);
assertDeclarationCount(pdom, "Structure1::s1b", 1);
@@ -87,7 +87,7 @@ public class CPPCompositeTypeTests extends PDOMTestBase {
assertDeclarationCount(pdom, "Structure1::Structure2::s2b", 1);
assertDeclarationCount(pdom, "Structure1::Structure2::Structure3::s3a", 1);
}
-
+
public void testDeepStructureDefinitions() throws Exception {
assertDefinitionCount(pdom, "Structure1", 1);
assertDefinitionCount(pdom, "Structure1::Structure2", 1);
@@ -107,7 +107,7 @@ public class CPPCompositeTypeTests extends PDOMTestBase {
assertReferenceCount(pdom, "Structure1::Structure2", 4);
assertReferenceCount(pdom, "Structure1::Structure2::Structure3", 2);
}
-
+
public void testDeepStructureMemberReferences() throws Exception {
assertReferenceCount(pdom, "Structure1::s1a", 2);
assertReferenceCount(pdom, "Structure1::s1b", 3);
@@ -120,72 +120,72 @@ public class CPPCompositeTypeTests extends PDOMTestBase {
assertDeclarationCount(pdom, "Union1", 1);
assertDeclarationCount(pdom, "Union1::Union2", 1);
}
-
+
public void testUnionDefinitions() throws Exception {
assertDefinitionCount(pdom, "Union1", 1);
assertDefinitionCount(pdom, "Union1::Union2", 1);
}
-
+
public void testUnionReferences() throws Exception {
assertReferenceCount(pdom, "Union1", 4);
assertReferenceCount(pdom, "Union1::Union2", 2);
}
-
+
public void testUnionMemberDeclarations() throws Exception {
assertDeclarationCount(pdom, "Union1::u1a", 1);
assertDeclarationCount(pdom, "Union1::u1d", 1);
}
-
+
public void testUnionMemberDefinitions() throws Exception {
assertDefinitionCount(pdom, "Union1::u1a", 1);
assertDefinitionCount(pdom, "Union1::u1d", 1);
}
-
+
public void testUnionMemberReferences() throws Exception {
assertReferenceCount(pdom, "Union1::u1a", 2);
assertReferenceCount(pdom, "Union1::u1d", 1);
}
-
+
public void testMixedDeclarations() throws Exception {
assertDeclarationCount(pdom, "MixedS1::MixedU1", 1);
assertDeclarationCount(pdom, "MixedS1::MixedU1::MixedS2", 1);
assertDeclarationCount(pdom, "MixedS1::MixedU1::MixedU2", 1);
assertDeclarationCount(pdom, "MixedS1::MixedS3", 1);
}
-
+
public void testMixedDefinitions() throws Exception {
assertDefinitionCount(pdom, "MixedS1::MixedU1", 1);
assertDefinitionCount(pdom, "MixedS1::MixedU1::MixedS2", 1);
assertDefinitionCount(pdom, "MixedS1::MixedU1::MixedU2", 1);
assertDefinitionCount(pdom, "MixedS1::MixedS3", 1);
}
-
+
public void testMixedReferences() throws Exception {
assertReferenceCount(pdom, "MixedS1::MixedU1", 6);
assertReferenceCount(pdom, "MixedS1::MixedU1::MixedS2", 2);
assertReferenceCount(pdom, "MixedS1::MixedU1::MixedU2", 2);
assertReferenceCount(pdom, "MixedS1::MixedS3", 2);
}
-
+
public void testMixedMemberDeclarations() throws Exception {
assertDeclarationCount(pdom, "MixedS1::MixedU1::mu1a", 1);
assertDeclarationCount(pdom, "MixedS1::MixedU1::MixedS2::ms2a", 1);
assertDeclarationCount(pdom, "MixedS1::MixedU1::MixedU2::mu2a", 1);
assertDeclarationCount(pdom, "MixedS1::MixedS3::ms3a", 1);
}
-
+
public void testMixedMemberDefinitions() throws Exception {
assertDefinitionCount(pdom, "MixedS1::MixedU1::mu1a", 1);
assertDefinitionCount(pdom, "MixedS1::MixedU1::MixedS2::ms2a", 1);
assertDefinitionCount(pdom, "MixedS1::MixedU1::MixedU2::mu2a", 1);
assertDefinitionCount(pdom, "MixedS1::MixedS3::ms3a", 1);
}
-
+
public void testMixedMemberReferences() throws Exception {
assertReferenceCount(pdom, "MixedS1::MixedU1::mu1a", 2);
assertReferenceCount(pdom, "MixedS1::MixedU1::MixedS2::ms2a", 2);
assertReferenceCount(pdom, "MixedS1::MixedU1::MixedU2::mu2a", 2);
assertReferenceCount(pdom, "MixedS1::MixedS3::ms3a", 2);
}
-
+
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFieldTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFieldTests.java
index 1e9dcba83bd..15202001fe2 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFieldTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFieldTests.java
@@ -41,7 +41,7 @@ public class CPPFieldTests extends PDOMTestBase {
public static Test suite() {
return suite(CPPFieldTests.class);
}
-
+
@Override
protected void setUp() throws Exception {
project = createProject("fieldTests");
@@ -53,64 +53,65 @@ public class CPPFieldTests extends PDOMTestBase {
protected void tearDown() throws Exception {
pdom.releaseReadLock();
if (project != null) {
- project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
public void testFieldDeclarations() throws Exception {
assertDeclarationCount(pdom, "Class1::c1a", 1);
}
-
+
public void testFieldDefinitions() throws Exception {
assertDefinitionCount(pdom, "Class1::c1a", 1);
}
-
+
public void testFieldReferences() throws Exception {
assertReferenceCount(pdom, "Class1::c1a", 4);
}
-
+
public void testInheritedFieldDeclarations() throws Exception {
assertDeclarationCount(pdom, "Class2::c1a", 0);
}
-
+
public void testInheritedFieldDefinitions() throws Exception {
assertDefinitionCount(pdom, "Class2::c1a", 0);
}
-
+
public void testInheritedFieldReferences() throws Exception {
assertReferenceCount(pdom, "Class2::c1a", 0);
}
-
+
public void testDefaultPrivateField() throws Exception {
assertCPPMemberVisibility(pdom, "Class1::defaultField", ICPPMember.v_private);
}
-
+
public void testPrivateField() throws Exception {
assertCPPMemberVisibility(pdom, "Class1::privateField", ICPPMember.v_private);
}
-
+
public void testProtectedField() throws Exception {
assertCPPMemberVisibility(pdom, "Class1::protectedField", ICPPMember.v_protected);
}
-
+
public void testPublicField() throws Exception {
assertCPPMemberVisibility(pdom, "Class1::publicField", ICPPMember.v_public);
}
-
+
public void testMutableField() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "Class1::mutableField");
assertEquals(1, bindings.length);
ICPPField field = (ICPPField) bindings[0];
assertTrue(field.isMutable());
}
-
+
public void testStaticField() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "Class1::staticField");
assertEquals(1, bindings.length);
ICPPField field = (ICPPField) bindings[0];
assertTrue(field.isStatic());
}
-
+
public void testIntField() throws Exception {
assertFieldType(pdom, "Class1::c1a", IBasicType.t_int);
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTemplateTests.java
index ac4f6d92681..835a10b4ef4 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTemplateTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTemplateTests.java
@@ -27,11 +27,11 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInstanceCache;
import org.eclipse.cdt.internal.core.index.IIndexFragment;
public class CPPFunctionTemplateTests extends PDOMInlineCodeTestBase {
-
+
public static Test suite() {
return suite(CPPFunctionTemplateTests.class);
}
-
+
/*************************************************************************/
// template<typename X>
@@ -55,21 +55,21 @@ public class CPPFunctionTemplateTests extends PDOMInlineCodeTestBase {
// }
public void testSimpleInstantiation() throws Exception {
setUpSections(1);
- IBinding[] bs= pdom.findBindings(new char[][]{"foo".toCharArray()}, IndexFilter.ALL_DECLARED, npm());
+ IBinding[] bs = pdom.findBindings(new char[][] { "foo".toCharArray() }, IndexFilter.ALL_DECLARED, npm());
assertEquals(2, bs.length);
assertInstance(bs[0], ICPPFunctionTemplate.class);
assertInstance(bs[1], ICPPFunctionTemplate.class);
-
- boolean b= ((ICPPFunctionTemplate)bs[0]).getTemplateParameters().length==1;
- ICPPFunctionTemplate fooX= (ICPPFunctionTemplate) bs[b ? 0 : 1];
- ICPPFunctionTemplate fooAB= (ICPPFunctionTemplate) bs[b ? 1 : 0];
-
- List<ICPPTemplateInstance> instances= Arrays.asList(((ICPPInstanceCache) fooX).getAllInstances());
+
+ boolean b = ((ICPPFunctionTemplate) bs[0]).getTemplateParameters().length == 1;
+ ICPPFunctionTemplate fooX = (ICPPFunctionTemplate) bs[b ? 0 : 1];
+ ICPPFunctionTemplate fooAB = (ICPPFunctionTemplate) bs[b ? 1 : 0];
+
+ List<ICPPTemplateInstance> instances = Arrays.asList(((ICPPInstanceCache) fooX).getAllInstances());
assertEquals(3, instances.size());
for (ICPPTemplateInstance inst : instances) {
assertEquals(1, pdom.findNames(inst, IIndexFragment.FIND_REFERENCES).length);
}
- instances= Arrays.asList(((ICPPInstanceCache) fooAB).getAllInstances());
+ instances = Arrays.asList(((ICPPInstanceCache) fooAB).getAllInstances());
assertEquals(6, instances.size());
for (ICPPTemplateInstance inst : instances) {
assertEquals(1, pdom.findNames(inst, IIndexFragment.FIND_REFERENCES).length);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTests.java
index 41d6f719e40..93890dc8307 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTests.java
@@ -62,28 +62,28 @@ public class CPPFunctionTests extends PDOMTestBase {
project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, npm());
}
}
-
+
public void testPointerToFunctionType() throws Exception {
assertDeclarationCount(pdom, "int2intPtr", 1);
- IIndexFragmentBinding[] b=
- pdom.findBindings(new char[][] { "int2intPtr".toCharArray() }, IndexFilter.ALL, npm());
+ IIndexFragmentBinding[] b = pdom.findBindings(new char[][] { "int2intPtr".toCharArray() }, IndexFilter.ALL,
+ npm());
assertEquals(1, b.length);
assertInstance(b[0], ICPPVariable.class);
- ICPPVariable v= (ICPPVariable) b[0];
+ ICPPVariable v = (ICPPVariable) b[0];
assertInstance(v.getType(), IPointerType.class);
- IPointerType pt= (IPointerType) v.getType();
+ IPointerType pt = (IPointerType) v.getType();
assertInstance(pt.getType(), IFunctionType.class);
- IFunctionType ft= (IFunctionType) pt.getType();
+ IFunctionType ft = (IFunctionType) pt.getType();
assertInstance(ft.getReturnType(), ICPPBasicType.class);
assertEquals(1, ft.getParameterTypes().length);
assertInstance(ft.getParameterTypes()[0], ICPPBasicType.class);
}
-
+
public void testFunctionType() throws Exception {
- assertType(pdom, "normalDeclaration1", ICPPFunction.class);
- assertType(pdom, "normalDeclaration2", ICPPFunction.class);
+ assertType(pdom, "normalDeclaration1", ICPPFunction.class);
+ assertType(pdom, "normalDeclaration2", ICPPFunction.class);
}
-
+
public void testFunctionDeclarations() throws Exception {
assertDeclarationCount(pdom, "normalDeclaration1", 1);
assertDeclarationCount(pdom, "normalDeclaration2", 1);
@@ -112,7 +112,7 @@ public class CPPFunctionTests extends PDOMTestBase {
assertEquals(IBasicType.Kind.eFloat, ((ICPPBasicType) parameters[2].getType()).getKind());
assertEquals("p3", parameters[2].getName());
}
-
+
public void testStorageClassSpecParameters() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "storageClassCPPFunction");
assertEquals(1, bindings.length);
@@ -120,7 +120,7 @@ public class CPPFunctionTests extends PDOMTestBase {
IParameter[] parameters = function.getParameters();
assertEquals(2, parameters.length);
}
-
+
public void testExternCPPFunction() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "externCPPFunction");
assertEquals(1, bindings.length);
@@ -161,14 +161,14 @@ public class CPPFunctionTests extends PDOMTestBase {
}
public void testForwardDeclarationType() throws Exception {
- assertType(pdom, "forwardDeclaration", ICPPFunction.class);
+ assertType(pdom, "forwardDeclaration", ICPPFunction.class);
}
-
+
public void testForwardDeclaration() throws Exception {
assertDeclarationCount(pdom, "forwardDeclaration", 2);
assertDefinitionCount(pdom, "forwardDeclaration", 1);
}
-
+
public void testVoidFunction() throws Exception {
assertReturnType(pdom, "voidCPPFunction", IBasicType.t_void);
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPVariableTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPVariableTests.java
index 83022587c19..09b57ce44ea 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPVariableTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPVariableTests.java
@@ -49,10 +49,11 @@ public class CPPVariableTests extends PDOMTestBase {
protected void tearDown() throws Exception {
pdom.releaseReadLock();
if (project != null) {
- project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
-
+
public void testCPPAutoVariable() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "autoCPPVariable");
assertEquals(1, bindings.length);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CVariableTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CVariableTests.java
index 088d74981d0..caf5d01d5a0 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CVariableTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CVariableTests.java
@@ -49,10 +49,11 @@ public class CVariableTests extends PDOMTestBase {
protected void tearDown() throws Exception {
pdom.releaseReadLock();
if (project != null) {
- project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
-
+
public void testCAutoVariable() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "autoCVariable");
assertEquals(1, bindings.length);
@@ -75,7 +76,7 @@ public class CVariableTests extends PDOMTestBase {
}
public void testCStaticVariable() throws Exception {
- // static elements cannot be found on global scope, see bug 161216
+ // static elements cannot be found on global scope, see bug 161216
IBinding[] bindings = findUnqualifiedName(pdom, "staticCVariable");
assertEquals(1, bindings.length);
IVariable variable = (IVariable) bindings[0];
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ChangeConfigurationTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ChangeConfigurationTests.java
index 09dc90c32a5..1188a3e5707 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ChangeConfigurationTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ChangeConfigurationTests.java
@@ -41,22 +41,24 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
public class ChangeConfigurationTests extends PDOMTestBase {
-
+
public static Test suite() {
return suite(ChangeConfigurationTests.class);
}
-
+
private void changeConfigRelations(ICProject project, int option) throws CoreException, InterruptedException {
- ICProjectDescription pd= CCorePlugin.getDefault().getProjectDescription(project.getProject());
+ ICProjectDescription pd = CCorePlugin.getDefault().getProjectDescription(project.getProject());
pd.setConfigurationRelations(option);
CCorePlugin.getDefault().setProjectDescription(project.getProject(), pd);
waitForIndexer(project);
}
-
+
// Emulates ChangeConfigAction
- private void changeProjectConfiguration(IProject project, String configName) throws CoreException, InterruptedException {
- ICProjectDescription prjd = CCorePlugin.getDefault().getProjectDescriptionManager().getProjectDescription(project);
- ICConfigurationDescription[] configs = prjd.getConfigurations();
+ private void changeProjectConfiguration(IProject project, String configName)
+ throws CoreException, InterruptedException {
+ ICProjectDescription prjd = CCorePlugin.getDefault().getProjectDescriptionManager()
+ .getProjectDescription(project);
+ ICConfigurationDescription[] configs = prjd.getConfigurations();
if (configs != null && configs.length > 0) {
for (ICConfigurationDescription config : configs) {
if (config.getName().equals(configName)) {
@@ -76,33 +78,36 @@ public class ChangeConfigurationTests extends PDOMTestBase {
//#endif
public void testRepeatedlyChangeConfig_bug375226() throws Exception {
ModelJoiner mj = new ModelJoiner();
- ICProject cProject = CProjectHelper.createNewStyleCProject("testChangeConfiguration", IPDOMManager.ID_FAST_INDEXER);
+ ICProject cProject = CProjectHelper.createNewStyleCProject("testChangeConfiguration",
+ IPDOMManager.ID_FAST_INDEXER);
IProject project = cProject.getProject();
- StringBuilder[] contents= TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), 1);
- IFile file= TestSourceReader.createFile(cProject.getProject(), new Path("test.c"), contents[0].toString());
+ StringBuilder[] contents = TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "parser",
+ getClass(), getName(), 1);
+ IFile file = TestSourceReader.createFile(cProject.getProject(), new Path("test.c"), contents[0].toString());
mj.join();
mj.dispose();
changeConfigRelations(cProject, ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE);
-
- ICProjectDescription prjd = CCorePlugin.getDefault().getProjectDescriptionManager().getProjectDescription(project);
+
+ ICProjectDescription prjd = CCorePlugin.getDefault().getProjectDescriptionManager()
+ .getProjectDescription(project);
ICConfigurationDescription configuration1 = prjd.getConfigurations()[0];
String firstConfigName = configuration1.getName();
- for(ICLanguageSetting languageSetting : configuration1.getRootFolderDescription().getLanguageSettings())
- {
- languageSetting.setSettingEntries(ICSettingEntry.MACRO, new ICLanguageSettingEntry[] { CDataUtil.createCMacroEntry("MACRO1", null, 0)});
+ for (ICLanguageSetting languageSetting : configuration1.getRootFolderDescription().getLanguageSettings()) {
+ languageSetting.setSettingEntries(ICSettingEntry.MACRO,
+ new ICLanguageSettingEntry[] { CDataUtil.createCMacroEntry("MACRO1", null, 0) });
}
ICConfigurationDescription configuration2 = prjd.createConfiguration("id2", "Configuration2", configuration1);
String secondConfigName = configuration2.getName();
- for(ICLanguageSetting languageSetting : configuration2.getRootFolderDescription().getLanguageSettings())
- {
- languageSetting.setSettingEntries(ICSettingEntry.MACRO, new ICLanguageSettingEntry[] { CDataUtil.createCMacroEntry("MACRO2", null, 0)} );
+ for (ICLanguageSetting languageSetting : configuration2.getRootFolderDescription().getLanguageSettings()) {
+ languageSetting.setSettingEntries(ICSettingEntry.MACRO,
+ new ICLanguageSettingEntry[] { CDataUtil.createCMacroEntry("MACRO2", null, 0) });
}
-
+
CoreModel.getDefault().setProjectDescription(project, prjd);
CCorePlugin.getIndexManager().reindex(cProject);
waitForIndexer(cProject);
-
+
Pattern testFunc1 = Pattern.compile("testFunc1");
Pattern testFunc2 = Pattern.compile("testFunc2");
int i = 0, noTrials = 50;
@@ -111,18 +116,20 @@ public class ChangeConfigurationTests extends PDOMTestBase {
IIndex index = CCorePlugin.getIndexManager().getIndex(cProject);
index.acquireReadLock();
try {
- IBinding[] bindings = index.findBindings(isFirstConfig ? testFunc1 : testFunc2, true, IndexFilter.ALL, new NullProgressMonitor());
- IBinding[] noBindings = index.findBindings(isFirstConfig ? testFunc2 : testFunc1, true, IndexFilter.ALL, new NullProgressMonitor());
+ IBinding[] bindings = index.findBindings(isFirstConfig ? testFunc1 : testFunc2, true, IndexFilter.ALL,
+ new NullProgressMonitor());
+ IBinding[] noBindings = index.findBindings(isFirstConfig ? testFunc2 : testFunc1, true, IndexFilter.ALL,
+ new NullProgressMonitor());
assertEquals(1, bindings.length);
assertEquals(0, noBindings.length);
} finally {
index.releaseReadLock();
}
-
+
String nextConfig = isFirstConfig ? secondConfigName : firstConfigName;
changeProjectConfiguration(project, nextConfig);
waitForIndexer(cProject);
-
+
i++;
} while (i < noTrials);
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ClassTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ClassTests.java
index e48f05fc63a..b698182cfc7 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ClassTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ClassTests.java
@@ -53,7 +53,7 @@ public class ClassTests extends PDOMTestBase {
protected void setUp() throws Exception {
if (pdom == null) {
ICProject project = createProject("classTests");
- pdom = (PDOM)CCoreInternals.getPDOMManager().getPDOM(project);
+ pdom = (PDOM) CCoreInternals.getPDOMManager().getPDOM(project);
}
pdom.acquireReadLock();
}
@@ -74,7 +74,7 @@ public class ClassTests extends PDOMTestBase {
assertNotNull(findMethod(Bmethods, "bf"));
ICPPMethod Bf = findMethod(Bmethods, "f");
assertNotNull(Bf);
- IName [] Bf_refs = pdom.findNames(Bf, IIndex.FIND_REFERENCES);
+ IName[] Bf_refs = pdom.findNames(Bf, IIndex.FIND_REFERENCES);
assertEquals(1, Bf_refs.length);
IASTFileLocation loc = Bf_refs[0].getFileLocation();
assertEquals(offset("class.cpp", "b.f()") + 2, loc.getNodeOffset());
@@ -92,7 +92,7 @@ public class ClassTests extends PDOMTestBase {
public void testNested() throws Exception {
IBinding[] bindings = pdom.findBindings(Pattern.compile("NestedA"), false, IndexFilter.ALL_DECLARED, npm());
assertEquals(1, bindings.length);
- ICPPClassType NestedA = (ICPPClassType)bindings[0];
+ ICPPClassType NestedA = (ICPPClassType) bindings[0];
ICPPClassType[] nested = NestedA.getNestedClasses();
assertEquals(1, nested.length);
ICPPClassType NestedB = nested[0];
@@ -119,8 +119,8 @@ public class ClassTests extends PDOMTestBase {
bindings = ns.find("testRef", null);
assertEquals(1, bindings.length);
IName[] refs = pdom.findNames(bindings[0], IIndex.FIND_REFERENCES);
-// for (int i = 0; i < refs.length; ++i)
-// System.out.println(refs[i].getFileLocation().getNodeOffset());
+ // for (int i = 0; i < refs.length; ++i)
+ // System.out.println(refs[i].getFileLocation().getNodeOffset());
assertEquals(5, refs.length);
}
@@ -158,10 +158,10 @@ public class ClassTests extends PDOMTestBase {
IName[] decls = pdom.findNames(bindings[1], IIndex.FIND_DECLARATIONS_DEFINITIONS);
assertEquals(2, decls.length);
IASTFileLocation loc = decls[0].getFileLocation();
- assertEquals(offset("constructor.cpp","Class1(int num);"), loc.getNodeOffset()); //character offset
+ assertEquals(offset("constructor.cpp", "Class1(int num);"), loc.getNodeOffset()); //character offset
loc = decls[1].getFileLocation();
- assertEquals(offset("constructor.cpp","Class1::Class1") + 8, loc.getNodeOffset()); //character offset
+ assertEquals(offset("constructor.cpp", "Class1::Class1") + 8, loc.getNodeOffset()); //character offset
/* Member initialization */
bindings = pdom.findBindings(Pattern.compile("number"), false, IndexFilter.ALL, npm());
@@ -172,11 +172,11 @@ public class ClassTests extends PDOMTestBase {
loc = refs[0].getFileLocation();
assertEquals(offset("constructor.cpp", "number(num)"), loc.getNodeOffset()); //character offset
- assertEquals(bindings[0], ((PDOMName)refs[0]).getBinding());
+ assertEquals(bindings[0], ((PDOMName) refs[0]).getBinding());
}
public void testAbsenceOfDefaultConstructorWhenExplicitNonDefaultPresentA() throws Exception {
- IndexFilter JUST_CONSTRUCTORS= new IndexFilter() {
+ IndexFilter JUST_CONSTRUCTORS = new IndexFilter() {
@Override
public boolean acceptBinding(IBinding binding) {
return binding instanceof ICPPConstructor;
@@ -188,7 +188,7 @@ public class ClassTests extends PDOMTestBase {
}
public void testAbsenceOfDefaultConstructorWhenExplicitNonDefaultPresentB() throws Exception {
- IndexFilter JUST_CONSTRUCTORS= new IndexFilter() {
+ IndexFilter JUST_CONSTRUCTORS = new IndexFilter() {
@Override
public boolean acceptBinding(IBinding binding) {
return binding instanceof ICPPConstructor;
@@ -200,26 +200,26 @@ public class ClassTests extends PDOMTestBase {
}
public void testClassScope_bug185408() throws Exception {
- char[][] name= {"B".toCharArray(), "bf".toCharArray()};
- IBinding[] bindings= pdom.findBindings(name, IndexFilter.ALL, npm());
+ char[][] name = { "B".toCharArray(), "bf".toCharArray() };
+ IBinding[] bindings = pdom.findBindings(name, IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
- IScope classScope= bindings[0].getScope();
+ IScope classScope = bindings[0].getScope();
assertTrue(classScope instanceof ICPPClassScope);
- bindings= classScope.find("bf", null);
- ICPPMethod method= extractSingleMethod(bindings);
+ bindings = classScope.find("bf", null);
+ ICPPMethod method = extractSingleMethod(bindings);
assertEquals("B", method.getQualifiedName()[0]);
- bindings= classScope.find("f", null);
- method= extractSingleMethod(bindings);
+ bindings = classScope.find("f", null);
+ method = extractSingleMethod(bindings);
assertEquals("A", method.getQualifiedName()[0]);
- bindings= classScope.find("B", null);
- ICPPClassType classType= extractSingleClass(bindings);
+ bindings = classScope.find("B", null);
+ ICPPClassType classType = extractSingleClass(bindings);
assertEquals("B", classType.getQualifiedName()[0]);
- bindings= classScope.find("A", null);
- classType= extractSingleClass(bindings);
+ bindings = classScope.find("A", null);
+ classType = extractSingleClass(bindings);
assertEquals("A", classType.getQualifiedName()[0]);
}
@@ -236,7 +236,7 @@ public class ClassTests extends PDOMTestBase {
}
public void testFinalClass() throws Exception {
- char[][] name = {"E".toCharArray()};
+ char[][] name = { "E".toCharArray() };
IBinding[] bindings = pdom.findBindings(name, IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
assertInstance(bindings[0], ICPPClassType.class);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DBPropertiesTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DBPropertiesTests.java
index a902f924190..eb638a8d35b 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DBPropertiesTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DBPropertiesTests.java
@@ -32,11 +32,11 @@ import org.eclipse.core.runtime.CoreException;
public class DBPropertiesTests extends BaseTestCase {
File dbLoc;
Database db;
-
+
public static Test suite() {
return suite(DBPropertiesTests.class);
}
-
+
@Override
protected void setUp() throws Exception {
dbLoc = File.createTempFile("test", "db");
@@ -44,107 +44,106 @@ public class DBPropertiesTests extends BaseTestCase {
db = new Database(dbLoc, new ChunkCache(), 0, false);
db.setExclusiveLock();
}
-
+
@Override
protected void tearDown() throws Exception {
db.close();
}
-
+
public void testBasic() throws CoreException {
DBProperties properties = new DBProperties(db);
Properties expected = System.getProperties();
- for (Iterator i = expected.keySet().iterator(); i.hasNext(); ) {
+ for (Iterator i = expected.keySet().iterator(); i.hasNext();) {
String key = (String) i.next();
String value = expected.getProperty(key);
if (value != null) {
properties.setProperty(key, value);
}
}
- for (Iterator i = expected.keySet().iterator(); i.hasNext(); ) {
+ for (Iterator i = expected.keySet().iterator(); i.hasNext();) {
String key = (String) i.next();
String aValue = properties.getProperty(key);
assertEquals(expected.getProperty(key), aValue);
}
- for (Iterator i = expected.keySet().iterator(); i.hasNext(); ) {
+ for (Iterator i = expected.keySet().iterator(); i.hasNext();) {
String key = (String) i.next();
properties.removeProperty(key);
}
assertEquals(0, properties.getKeySet().size());
-
+
properties.delete();
}
-
-
+
public void testLong() throws Exception {
DBProperties ps = new DBProperties(db);
-
+
StringBuilder largeValue = new StringBuilder();
- for (int i= 0; i < Database.CHUNK_SIZE * 2; i += 64) {
+ for (int i = 0; i < Database.CHUNK_SIZE * 2; i += 64) {
largeValue.append("********");
ps.setProperty("key", largeValue.toString());
ps.setProperty(largeValue.toString(), "value");
}
-
+
assertEquals(largeValue.toString(), ps.getProperty("key"));
assertEquals("value", ps.getProperty(largeValue.toString()));
-
+
ps.delete();
}
-
+
public void testNulls() throws Exception {
- DBProperties ps= new DBProperties(db);
+ DBProperties ps = new DBProperties(db);
try {
ps.setProperty(null, "val1");
fail("NullPointerException expected");
- } catch(NullPointerException e) {
- } catch(AssertionError e) {
+ } catch (NullPointerException e) {
+ } catch (AssertionError e) {
}
-
+
try {
ps.setProperty("key", null);
fail("NullPointerException expected");
- } catch(NullPointerException e) {
- } catch(AssertionError e) {
+ } catch (NullPointerException e) {
+ } catch (AssertionError e) {
}
try {
ps.setProperty(null, null);
fail("NullPointerException expected");
- } catch(NullPointerException e) {
- } catch(AssertionError e) {
+ } catch (NullPointerException e) {
+ } catch (AssertionError e) {
}
-
+
assertFalse(ps.removeProperty(null));
-
+
assertNull(ps.getProperty(null));
-
- String s= ""+System.currentTimeMillis();
- assertEquals(s, ps.getProperty(null,s));
+
+ String s = "" + System.currentTimeMillis();
+ assertEquals(s, ps.getProperty(null, s));
}
-
+
public void testSeq() throws Exception {
DBProperties ps = new DBProperties(db);
-
+
ps.setProperty("a", "b");
assertEquals("b", ps.getProperty("a"));
assertEquals(1, ps.getKeySet().size());
-
+
ps.setProperty("b", "c");
assertEquals("c", ps.getProperty("b"));
assertEquals(2, ps.getKeySet().size());
-
+
ps.setProperty("a", "c");
assertEquals("c", ps.getProperty("a"));
assertEquals(2, ps.getKeySet().size());
-
+
boolean deleted = ps.removeProperty("c");
assertEquals(false, deleted);
assertEquals(2, ps.getKeySet().size());
-
+
deleted = ps.removeProperty("a");
assertEquals(true, deleted);
assertEquals(1, ps.getKeySet().size());
-
+
ps.delete();
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DatabaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DatabaseTest.java
index 75f4c53070c..9b193fc2885 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DatabaseTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DatabaseTest.java
@@ -78,27 +78,28 @@ public class DatabaseTest extends BaseTestCase {
if (!db.getLocation().delete()) {
db.getLocation().deleteOnExit();
}
- db= null;
+ db = null;
}
public void testBlockSizeAndFirstBlock() throws Exception {
assertEquals(0, db.getVersion());
final int realsize = 42;
- final int deltas = (realsize + Database.BLOCK_HEADER_SIZE + Database.BLOCK_SIZE_DELTA - 1) / Database.BLOCK_SIZE_DELTA;
+ final int deltas = (realsize + Database.BLOCK_HEADER_SIZE + Database.BLOCK_SIZE_DELTA - 1)
+ / Database.BLOCK_SIZE_DELTA;
final int blocksize = deltas * Database.BLOCK_SIZE_DELTA;
- final int freeDeltas= Database.CHUNK_SIZE / Database.BLOCK_SIZE_DELTA - deltas;
+ final int freeDeltas = Database.CHUNK_SIZE / Database.BLOCK_SIZE_DELTA - deltas;
long mem = db.malloc(realsize);
assertEquals(-blocksize, db.getShort(mem - Database.BLOCK_HEADER_SIZE));
db.free(mem);
assertEquals(blocksize, db.getShort(mem - Database.BLOCK_HEADER_SIZE));
- assertEquals(mem, db.getRecPtr((deltas - Database.MIN_BLOCK_DELTAS +1 ) * Database.INT_SIZE));
+ assertEquals(mem, db.getRecPtr((deltas - Database.MIN_BLOCK_DELTAS + 1) * Database.INT_SIZE));
assertEquals(mem + blocksize, db.getRecPtr((freeDeltas - Database.MIN_BLOCK_DELTAS + 1) * Database.INT_SIZE));
}
public void testBug192437() throws Exception {
- File tmp= File.createTempFile("readOnlyEmpty", ".db");
+ File tmp = File.createTempFile("readOnlyEmpty", ".db");
try {
tmp.setReadOnly();
@@ -123,9 +124,10 @@ public class DatabaseTest extends BaseTestCase {
public void testFreeBlockLinking() throws Exception {
final int realsize = 42;
- final int deltas = (realsize + Database.BLOCK_HEADER_SIZE + Database.BLOCK_SIZE_DELTA - 1) / Database.BLOCK_SIZE_DELTA;
+ final int deltas = (realsize + Database.BLOCK_HEADER_SIZE + Database.BLOCK_SIZE_DELTA - 1)
+ / Database.BLOCK_SIZE_DELTA;
final int blocksize = deltas * Database.BLOCK_SIZE_DELTA;
- final int freeDeltas= Database.MIN_BLOCK_DELTAS - deltas;
+ final int freeDeltas = Database.MIN_BLOCK_DELTAS - deltas;
long mem1 = db.malloc(realsize);
long mem2 = db.malloc(realsize);
@@ -172,31 +174,9 @@ public class DatabaseTest extends BaseTestCase {
}
public void testStringsInBTree() throws Exception {
- String[] names = {
- "ARLENE",
- "BRET",
- "CINDY",
- "DENNIS",
- "EMILY",
- "FRANKLIN",
- "GERT",
- "HARVEY",
- "IRENE",
- "JOSE",
- "KATRINA",
- "LEE",
- "MARIA",
- "NATE",
- "OPHELIA",
- "PHILIPPE",
- "RITA",
- "STAN",
- "TAMMY",
- "VINCE",
- "WILMA",
- "ALPHA",
- "BETA"
- };
+ String[] names = { "ARLENE", "BRET", "CINDY", "DENNIS", "EMILY", "FRANKLIN", "GERT", "HARVEY", "IRENE", "JOSE",
+ "KATRINA", "LEE", "MARIA", "NATE", "OPHELIA", "PHILIPPE", "RITA", "STAN", "TAMMY", "VINCE", "WILMA",
+ "ALPHA", "BETA" };
IBTreeComparator comparator = new IBTreeComparator() {
@Override
@@ -232,44 +212,44 @@ public class DatabaseTest extends BaseTestCase {
private final int GT = 1, LT = -1, EQ = 0;
public void testShortStringComparison() throws CoreException {
- Random r= new Random(90210);
+ Random r = new Random(90210);
- assertCMP("", EQ, "", true);
- assertCMP("", EQ, "", false);
+ assertCMP("", EQ, "", true);
+ assertCMP("", EQ, "", false);
doTrials(1000, 1, ShortString.MAX_BYTE_LENGTH / 2, r, true);
doTrials(1000, 1, ShortString.MAX_BYTE_LENGTH / 2, r, false);
doTrials(1000, 1, ShortString.MAX_BYTE_LENGTH, r, true);
doTrials(1000, 1, ShortString.MAX_BYTE_LENGTH, r, false);
- assertCMP("a", LT, "b", true);
+ assertCMP("a", LT, "b", true);
assertCMP("aa", LT, "ab", true);
- assertCMP("a", EQ, "a", true);
+ assertCMP("a", EQ, "a", true);
- assertCMP("a", GT, "A", true);
+ assertCMP("a", GT, "A", true);
assertCMP("aa", GT, "aA", true);
- assertCMP("a", GT, "B", true);
+ assertCMP("a", GT, "B", true);
- assertCMP("a", EQ, "a", false);
- assertCMP("a", EQ, "A", false);
+ assertCMP("a", EQ, "a", false);
+ assertCMP("a", EQ, "A", false);
}
public void testLongStringComparison() throws CoreException {
- Random r= new Random(314159265);
+ Random r = new Random(314159265);
doTrials(100, ShortString.MAX_BYTE_LENGTH + 1, ShortString.MAX_BYTE_LENGTH * 2, r, true);
doTrials(100, ShortString.MAX_BYTE_LENGTH + 1, ShortString.MAX_BYTE_LENGTH * 2, r, false);
}
private void doTrials(int n, int min, int max, Random r, boolean caseSensitive) throws CoreException {
long start = System.currentTimeMillis();
- for (int i= 0; i < n; i++) {
+ for (int i = 0; i < n; i++) {
String a = randomString(min, max, r);
String b = randomString(min, max, r);
int expected = caseSensitive ? a.compareTo(b) : a.compareToIgnoreCase(b);
assertCMP(a, expected, b, caseSensitive);
}
-// System.out.print("Trials: " + n + " Max length: " + max + " ignoreCase: " + !caseSensitive);
-// System.out.println(" Time: " + (System.currentTimeMillis() - start));
+ // System.out.print("Trials: " + n + " Max length: " + max + " ignoreCase: " + !caseSensitive);
+ // System.out.println(" Time: " + (System.currentTimeMillis() - start));
}
private String randomString(int min, int max, Random r) {
@@ -279,7 +259,7 @@ public class DatabaseTest extends BaseTestCase {
private String randomString(int len, Random r) {
StringBuilder result = new StringBuilder(len);
- for (int i= 0; i < len; i++) {
+ for (int i = 0; i < len; i++) {
result.append(randomChar(r));
}
return result.toString();
@@ -332,8 +312,8 @@ public class DatabaseTest extends BaseTestCase {
}
private void assertSignEquals(int a, int b) {
- a= a < 0 ? -1 : (a > 0 ? 1 : 0);
- b= b < 0 ? -1 : (b > 0 ? 1 : 0);
+ a = a < 0 ? -1 : (a > 0 ? 1 : 0);
+ b = b < 0 ? -1 : (b > 0 ? 1 : 0);
assertEquals(a, b);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DefDeclTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DefDeclTests.java
index 75f1c858646..7612ca47e00 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DefDeclTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DefDeclTests.java
@@ -46,7 +46,7 @@ import junit.framework.Test;
/**
* Test that PDOM correctly track declarations, definitions and references of objects.
- *
+ *
* @author ELaskavaia@qnx.com
*/
public class DefDeclTests extends PDOMTestBase {
@@ -54,7 +54,7 @@ public class DefDeclTests extends PDOMTestBase {
protected PDOM pdom;
protected ICProject cproject;
-
+
public static Test suite() {
return suite(DefDeclTests.class);
}
@@ -77,7 +77,7 @@ public class DefDeclTests extends PDOMTestBase {
}
private IBinding findSingleBinding(String elName) throws CoreException {
- IBinding[] binds = pdom.findBindings(Pattern.compile(elName), true, IndexFilter.ALL, null);
+ IBinding[] binds = pdom.findBindings(Pattern.compile(elName), true, IndexFilter.ALL, null);
assertEquals(1, binds.length);
assertEquals(elName, binds[0].getName());
IBinding element = binds[0];
@@ -130,14 +130,14 @@ public class DefDeclTests extends PDOMTestBase {
/**
* Get references defined by flags. If k>0 check that there are k of them.
- *
+ *
* @param binding
* @param k -
* number of references, if k==-1 no check
* @return first references or null of non
* @throws CoreException
*/
- private IName getFirstUsage(IBinding binding, int k, int flags) throws CoreException {
+ private IName getFirstUsage(IBinding binding, int k, int flags) throws CoreException {
IName[] decls = pdom.findNames(binding, flags);
if (k >= 0)
assertEquals(k, decls.length);
@@ -156,7 +156,7 @@ public class DefDeclTests extends PDOMTestBase {
assertEquals(markLine, nodeLine);
}
- private int getMarkLine(String mark, String fileName) throws Exception, BadLocationException {
+ private int getMarkLine(String mark, String fileName) throws Exception, BadLocationException {
int markLine = getLineNumber(offset(fileName, mark), fileName);
return markLine;
}
@@ -175,7 +175,7 @@ public class DefDeclTests extends PDOMTestBase {
}
private IIndexFile getSingleFile(IIndexFileLocation ifl) throws CoreException {
- IIndexFile[] files= pdom.getFiles(ILinkage.C_LINKAGE_ID, ifl);
+ IIndexFile[] files = pdom.getFiles(ILinkage.C_LINKAGE_ID, ifl);
assertEquals(1, files.length);
return files[0];
}
@@ -215,9 +215,11 @@ public class DefDeclTests extends PDOMTestBase {
assertEquals(2, binds.length);
assertTrue(binds[0].isFileLocal() != binds[1].isFileLocal());
if (binds[0].isFileLocal()) {
- IIndexBinding b= binds[0]; binds[0]= binds[1]; binds[1]= b;
+ IIndexBinding b = binds[0];
+ binds[0] = binds[1];
+ binds[1] = b;
}
-
+
assertEquals(elName, binds[0].getName());
checkDefinition(binds[0], "def" + "07", 0);
checkDeclaration(binds[0], "decl" + "07", 1);
@@ -233,25 +235,26 @@ public class DefDeclTests extends PDOMTestBase {
public void testStaticBindings_f08() throws Exception {
String elName = "foo" + "08";
- IIndexFileLocation ifl= IndexLocationFactory.getIFL((ITranslationUnit) cproject.findElement(new Path("func.c")));
- IIndexFile file= getSingleFile(ifl);
- int offset= TestSourceReader.indexOfInFile("foo08();", new Path(ifl.getFullPath()));
- IIndexName[] names= file.findNames(offset, 5);
+ IIndexFileLocation ifl = IndexLocationFactory
+ .getIFL((ITranslationUnit) cproject.findElement(new Path("func.c")));
+ IIndexFile file = getSingleFile(ifl);
+ int offset = TestSourceReader.indexOfInFile("foo08();", new Path(ifl.getFullPath()));
+ IIndexName[] names = file.findNames(offset, 5);
assertEquals(1, names.length);
-
+
IBinding element = pdom.findBinding((IIndexFragmentName) names[0]);
assertEquals(elName, element.getName());
checkDefinition(element, "def" + "08", 1);
checkReference(element, "ref" + "08", 1);
// check the other file
- ifl= IndexLocationFactory.getIFL((ITranslationUnit) cproject.findElement(new Path("second.c")));
- file= getSingleFile(ifl);
- offset= TestSourceReader.indexOfInFile("foo08();", new Path(ifl.getFullPath()));
- names= file.findNames(offset, 5);
+ ifl = IndexLocationFactory.getIFL((ITranslationUnit) cproject.findElement(new Path("second.c")));
+ file = getSingleFile(ifl);
+ offset = TestSourceReader.indexOfInFile("foo08();", new Path(ifl.getFullPath()));
+ names = file.findNames(offset, 5);
assertEquals(1, names.length);
-
- element = pdom.findBinding((IIndexFragmentName)names[0]);
+
+ element = pdom.findBinding((IIndexFragmentName) names[0]);
assertEquals(elName, element.getName());
checkDefinition(element, "defS" + "08", 1);
checkReference(element, "refS" + "08", 1);
@@ -297,16 +300,16 @@ public class DefDeclTests extends PDOMTestBase {
public void testStructAndTypedef_t04() throws Exception {
String num = "_t04";
String elName = "type" + num;
-
+
IBinding[] bindings = pdom.findBindings(Pattern.compile(elName), false, IndexFilter.ALL, null);
- assertEquals(2,bindings.length);
-
+ assertEquals(2, bindings.length);
+
IBinding typedef = bindings[0] instanceof ITypedef ? bindings[0] : bindings[1];
IBinding struct = bindings[0] instanceof ICompositeType ? bindings[0] : bindings[1];
-
+
checkReference(typedef, "ref" + num, 1);
checkDefinition(typedef, "def" + num, 1);
-
+
checkReference(struct, "refS" + num, 1);
checkDefinition(struct, "defS" + num, 1);
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/EnumerationTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/EnumerationTests.java
index 5b2ac9a7a5f..2193846237b 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/EnumerationTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/EnumerationTests.java
@@ -47,7 +47,7 @@ public class EnumerationTests extends PDOMTestBase {
protected void setUp() throws Exception {
if (pdom == null) {
ICProject project = createProject("enumerationTests");
- pdom = (PDOM)CCoreInternals.getPDOMManager().getPDOM(project);
+ pdom = (PDOM) CCoreInternals.getPDOMManager().getPDOM(project);
}
pdom.acquireReadLock();
}
@@ -56,13 +56,13 @@ public class EnumerationTests extends PDOMTestBase {
protected void tearDown() throws Exception {
pdom.releaseReadLock();
}
-
+
public void testC() throws Exception {
// Check bindings
Pattern pattern = Pattern.compile("TestCEnum");
IBinding[] bindings = pdom.findBindings(pattern, false, IndexFilter.ALL, new NullProgressMonitor());
assertEquals(1, bindings.length);
- IEnumeration enumeration = (IEnumeration)bindings[0];
+ IEnumeration enumeration = (IEnumeration) bindings[0];
assertEquals("TestCEnum", enumeration.getName());
IEnumerator[] enumerators = enumeration.getEnumerators();
assertEquals(3, enumerators.length);
@@ -76,19 +76,19 @@ public class EnumerationTests extends PDOMTestBase {
assertEquals("ca", enumerators[0].getName());
assertEquals("cb", enumerators[1].getName());
assertEquals("cc", enumerators[2].getName());
-
- // Declaration of TestEnum
+
+ // Declaration of TestEnum
IName[] enumDecls = pdom.findNames(enumeration, IIndex.FIND_DECLARATIONS_DEFINITIONS);
assertEquals(1, enumDecls.length);
IASTFileLocation loc = enumDecls[0].getFileLocation();
assertEquals(5, loc.getNodeOffset());
-
+
// Reference to TestEnum
IName[] enumRefs = pdom.findNames(enumeration, IIndex.FIND_REFERENCES);
assertEquals(1, enumRefs.length);
loc = enumRefs[0].getFileLocation();
assertEquals(offset("enumTest.c", "TestCEnum test"), loc.getNodeOffset());
-
+
// Reference to a
IName[] aRefs = pdom.findNames(enumerators[0], IIndex.FIND_REFERENCES);
assertEquals(1, aRefs.length);
@@ -101,7 +101,7 @@ public class EnumerationTests extends PDOMTestBase {
Pattern pattern = Pattern.compile("TestCPPEnum");
IBinding[] bindings = pdom.findBindings(pattern, false, IndexFilter.ALL, new NullProgressMonitor());
assertEquals(1, bindings.length);
- IEnumeration enumeration = (IEnumeration)bindings[0];
+ IEnumeration enumeration = (IEnumeration) bindings[0];
assertEquals("TestCPPEnum", enumeration.getName());
IEnumerator[] enumerators = enumeration.getEnumerators();
assertEquals(3, enumerators.length);
@@ -115,19 +115,19 @@ public class EnumerationTests extends PDOMTestBase {
assertEquals("cppa", enumerators[0].getName());
assertEquals("cppb", enumerators[1].getName());
assertEquals("cppc", enumerators[2].getName());
-
- // Declaration of TestEnum
+
+ // Declaration of TestEnum
IName[] enumDecls = pdom.findNames(enumeration, IIndex.FIND_DECLARATIONS_DEFINITIONS);
assertEquals(1, enumDecls.length);
IASTFileLocation loc = enumDecls[0].getFileLocation();
assertEquals(5, loc.getNodeOffset());
-
+
// Reference to TestEnum
IName[] enumRefs = pdom.findNames(enumeration, IIndex.FIND_REFERENCES);
assertEquals(1, enumRefs.length);
loc = enumRefs[0].getFileLocation();
assertEquals(offset("enumTest.cpp", "TestCPPEnum test"), loc.getNodeOffset());
-
+
// Reference to a
IName[] aRefs = pdom.findNames(enumerators[0], IIndex.FIND_REFERENCES);
assertEquals(1, aRefs.length);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/FilesOnReindexTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/FilesOnReindexTests.java
index 4d0d69d23c6..cc4d66dc5b7 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/FilesOnReindexTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/FilesOnReindexTests.java
@@ -56,29 +56,30 @@ public class FilesOnReindexTests extends PDOMTestBase {
protected void tearDown() throws Exception {
pdom.releaseReadLock();
if (project != null) {
- project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
-
+
public void testFilesOnReindex() throws CoreException, InterruptedException {
IFile file = project.getProject().getFile("simple.cpp");
performAssertions(file);
pdom.releaseReadLock();
CCoreInternals.getPDOMManager().reindex(project);
-
+
// wait until the indexer is done
- waitForIndexer(project);
+ waitForIndexer(project);
pdom.acquireReadLock();
performAssertions(file);
}
-
+
void performAssertions(IFile file) throws CoreException {
IIndex index = CCorePlugin.getIndexManager().getIndex(project);
assertTrue(index.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)).length != 0);
-
+
IBinding[] bs = index.findBindings(Pattern.compile("C"), true, IndexFilter.ALL, new NullProgressMonitor());
assertEquals(1, bs.length);
-
+
IIndexBinding binding = (IIndexBinding) bs[0];
IIndexFile file2 = index.findDefinitions(binding)[0].getFile();
assertEquals(file.getLocationURI(), file2.getLocation().getURI());
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/GeneratePDOMApplicationTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/GeneratePDOMApplicationTest.java
index 50b17921b36..4f91310831c 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/GeneratePDOMApplicationTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/GeneratePDOMApplicationTest.java
@@ -57,21 +57,21 @@ import org.osgi.framework.Bundle;
* Tests the GeneratePDOMApplication
*/
public class GeneratePDOMApplicationTest extends PDOMTestBase {
- private static final URI BASEURI= URI.create("file:///base/"); // unimportant what the value is
+ private static final URI BASEURI = URI.create("file:///base/"); // unimportant what the value is
private static final String SDK_VERSION = "com.acme.sdk.version";
- private static final String ACME_SDK_ID= "com.acme.sdk.4.0.1";
- private static final String LOC_TSTPRJ1= "resources/pdomtests/generatePDOMTests/project1";
- private static final String LOC_TSTPRJ2= "resources/pdomtests/generatePDOMTests/project2";
- private static final String LOC_TSTPRJ3= "resources/pdomtests/generatePDOMTests/project3";
- private static final String LOC_CYCINC1= "resources/pdomtests/generatePDOMTests/cyclicIncludes1";
- private static final String LOC_CYCINC2= "resources/pdomtests/generatePDOMTests/cyclicIncludes2";
-
- private static Deque<ICProject> projectsToDeleteOnTearDown= new ArrayDeque<>();
-
+ private static final String ACME_SDK_ID = "com.acme.sdk.4.0.1";
+ private static final String LOC_TSTPRJ1 = "resources/pdomtests/generatePDOMTests/project1";
+ private static final String LOC_TSTPRJ2 = "resources/pdomtests/generatePDOMTests/project2";
+ private static final String LOC_TSTPRJ3 = "resources/pdomtests/generatePDOMTests/project3";
+ private static final String LOC_CYCINC1 = "resources/pdomtests/generatePDOMTests/cyclicIncludes1";
+ private static final String LOC_CYCINC2 = "resources/pdomtests/generatePDOMTests/cyclicIncludes2";
+
+ private static Deque<ICProject> projectsToDeleteOnTearDown = new ArrayDeque<>();
+
public static Test suite() {
return suite(GeneratePDOMApplicationTest.class);
}
-
+
protected File target; // the location of the generated PDOM
@Override
@@ -87,31 +87,26 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
cproject.getProject().delete(true, new NullProgressMonitor());
}
super.tearDown();
- }
+ }
public void testBrokenExportProjectProvider1() throws Exception {
- setExpectedNumberOfLoggedNonOKStatusObjects(1); // IExportProjectProvider implementation returns null for createProject
- doGenerate(new String[] {
- GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(),
- GeneratePDOMApplication.OPT_PROJECTPROVIDER, TestProjectProvider1.class.getName()
- });
+ setExpectedNumberOfLoggedNonOKStatusObjects(1); // IExportProjectProvider implementation returns null for createProject
+ doGenerate(new String[] { GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(),
+ GeneratePDOMApplication.OPT_PROJECTPROVIDER, TestProjectProvider1.class.getName() });
}
public void testBrokenExportProjectProvider2() throws Exception {
- setExpectedNumberOfLoggedNonOKStatusObjects(1); // IExportProjectProvider implementation returns null for getLocationConverter
- doGenerate(new String[] {
- GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(),
- GeneratePDOMApplication.OPT_PROJECTPROVIDER, TestProjectProvider2.class.getName()
- });
+ setExpectedNumberOfLoggedNonOKStatusObjects(1); // IExportProjectProvider implementation returns null for getLocationConverter
+ doGenerate(new String[] { GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(),
+ GeneratePDOMApplication.OPT_PROJECTPROVIDER, TestProjectProvider2.class.getName() });
}
public void testSimpleExportProjectProvider1() throws Exception {
- doGenerate(new String[] {
- GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(),
- GeneratePDOMApplication.OPT_PROJECTPROVIDER, TestProjectProvider3.class.getName()
- });
+ doGenerate(new String[] { GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(),
+ GeneratePDOMApplication.OPT_PROJECTPROVIDER, TestProjectProvider3.class.getName() });
assertTrue(target.exists());
- WritablePDOM wpdom= new WritablePDOM(target, new URIRelativeLocationConverter(BASEURI), LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
+ WritablePDOM wpdom = new WritablePDOM(target, new URIRelativeLocationConverter(BASEURI),
+ LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
verifyProject1Content(wpdom);
String fid;
@@ -126,12 +121,11 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
}
public void testSimpleExportProjectProvider2() throws Exception {
- doGenerate(new String[] {
- GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(),
- GeneratePDOMApplication.OPT_PROJECTPROVIDER, TestProjectProvider4.class.getName()
- });
+ doGenerate(new String[] { GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(),
+ GeneratePDOMApplication.OPT_PROJECTPROVIDER, TestProjectProvider4.class.getName() });
assertTrue(target.exists());
- WritablePDOM wpdom= new WritablePDOM(target, new URIRelativeLocationConverter(BASEURI), LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
+ WritablePDOM wpdom = new WritablePDOM(target, new URIRelativeLocationConverter(BASEURI),
+ LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
verifyProject1Content(wpdom);
wpdom.acquireReadLock();
@@ -149,43 +143,39 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
public void testExternalExportProjectProvider_BadCmdLine1() throws Exception {
setExpectedNumberOfLoggedNonOKStatusObjects(1); // Expected failure: -source must be specified
-
- doGenerate(new String[] {
- GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(),
- GeneratePDOMApplication.OPT_PROJECTPROVIDER, ExternalExportProjectProvider.class.getName()
- });
+
+ doGenerate(new String[] { GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(),
+ GeneratePDOMApplication.OPT_PROJECTPROVIDER, ExternalExportProjectProvider.class.getName() });
assertFalse(target.exists());
}
public void testExternalExportProjectProvider_BadCmdLine2() throws Exception {
- TestProjectProvider4 tpp4= new TestProjectProvider4();
- ICProject cproject= tpp4.createProject();
-
+ TestProjectProvider4 tpp4 = new TestProjectProvider4();
+ ICProject cproject = tpp4.createProject();
+
setExpectedNumberOfLoggedNonOKStatusObjects(1); // Expected failure: -id must be specified
-
- doGenerate(new String[] {
- GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(),
- GeneratePDOMApplication.OPT_PROJECTPROVIDER, ExternalExportProjectProvider.class.getName(),
- ExternalExportProjectProvider.OPT_SOURCE, cproject.getProject().getLocation().toFile().getAbsolutePath()
- });
+
+ doGenerate(new String[] { GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(),
+ GeneratePDOMApplication.OPT_PROJECTPROVIDER, ExternalExportProjectProvider.class.getName(),
+ ExternalExportProjectProvider.OPT_SOURCE,
+ cproject.getProject().getLocation().toFile().getAbsolutePath() });
assertFalse(target.exists());
}
-
+
public void testExternalExportProjectProvider_BadCmdLine3() throws Exception {
- TestProjectProvider4 tpp4= new TestProjectProvider4();
- ICProject cproject= tpp4.createProject();
-
+ TestProjectProvider4 tpp4 = new TestProjectProvider4();
+ ICProject cproject = tpp4.createProject();
+
setExpectedNumberOfLoggedNonOKStatusObjects(1); // Expected failure: -target must be specified
- doGenerate(new String[] {
- GeneratePDOMApplication.OPT_PROJECTPROVIDER, ExternalExportProjectProvider.class.getName(),
- ExternalExportProjectProvider.OPT_SOURCE, cproject.getProject().getLocation().toFile().getAbsolutePath()
- });
+ doGenerate(new String[] { GeneratePDOMApplication.OPT_PROJECTPROVIDER,
+ ExternalExportProjectProvider.class.getName(), ExternalExportProjectProvider.OPT_SOURCE,
+ cproject.getProject().getLocation().toFile().getAbsolutePath() });
assertFalse(target.exists());
}
public void testExternalExportProjectProvider() throws Exception {
- final int[] stateCount= new int[1];
- WritablePDOM wpdom= generatePDOM(LOC_TSTPRJ1, ExternalExportProjectProvider.class, stateCount);
+ final int[] stateCount = new int[1];
+ WritablePDOM wpdom = generatePDOM(LOC_TSTPRJ1, ExternalExportProjectProvider.class, stateCount);
verifyProject1Content(wpdom);
wpdom.acquireReadLock();
@@ -196,42 +186,42 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
} finally {
wpdom.releaseReadLock();
}
- // depending on the timing the index of the temporary project is changed once or twice.
+ // depending on the timing the index of the temporary project is changed once or twice.
assertTrue("state is " + stateCount[0], stateCount[0] == 2 || stateCount[0] == 4);
}
public void testExternalExportProjectProvider_SysIncludes() throws Exception {
- WritablePDOM wpdom= generatePDOM(LOC_TSTPRJ2, ExternalExportProjectProvider.class, null);
+ WritablePDOM wpdom = generatePDOM(LOC_TSTPRJ2, ExternalExportProjectProvider.class, null);
verifyProject2Content(wpdom);
}
-
+
public void testGenerateOnCyclicIncludes1() throws Exception {
// testing for zero NON-OK status objects (see BaseTestCase.setExpectedNumberOfLoggedNonOKStatusObjects)
- WritablePDOM wpdom= generatePDOM(LOC_CYCINC1, ExternalExportProjectProvider.class, null);
+ WritablePDOM wpdom = generatePDOM(LOC_CYCINC1, ExternalExportProjectProvider.class, null);
}
-
+
public void testGenerateOnCyclicIncludes2() throws Exception {
// testing for zero NON-OK status objects (see BaseTestCase.setExpectedNumberOfLoggedNonOKStatusObjects)
- WritablePDOM wpdom= generatePDOM(LOC_CYCINC2, ExternalExportProjectProvider.class, null);
+ WritablePDOM wpdom = generatePDOM(LOC_CYCINC2, ExternalExportProjectProvider.class, null);
}
-
+
public void testExternalExportProjectProvider_CLinkage() throws Exception {
- WritablePDOM wpdom= generatePDOM(LOC_TSTPRJ3, TestProjectProvider5.class, null);
-
- IndexFilter CLinkage= new IndexFilter() {
+ WritablePDOM wpdom = generatePDOM(LOC_TSTPRJ3, TestProjectProvider5.class, null);
+
+ IndexFilter CLinkage = new IndexFilter() {
@Override
public boolean acceptLinkage(ILinkage linkage) {
return linkage.getLinkageID() == ILinkage.C_LINKAGE_ID;
}
};
- IndexFilter CPPLinkage= new IndexFilter() {
+ IndexFilter CPPLinkage = new IndexFilter() {
@Override
public boolean acceptLinkage(ILinkage linkage) {
return linkage.getLinkageID() == ILinkage.CPP_LINKAGE_ID;
}
};
-
+
wpdom.acquireReadLock();
try {
assertEquals(1, wpdom.findBindings(new char[][] { "foo".toCharArray() }, CLinkage, npm()).length);
@@ -244,10 +234,10 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
public void verifyProject1Content(WritablePDOM wpdom) throws Exception {
wpdom.acquireReadLock();
try {
- IBinding[] bindings= wpdom.findBindings(Pattern.compile(".*foo.*"), false, IndexFilter.ALL, PROGRESS);
+ IBinding[] bindings = wpdom.findBindings(Pattern.compile(".*foo.*"), false, IndexFilter.ALL, PROGRESS);
assertEquals(1, bindings.length);
- bindings= wpdom.findBindings(Pattern.compile(".*bar.*"), false, IndexFilter.ALL, PROGRESS);
+ bindings = wpdom.findBindings(Pattern.compile(".*bar.*"), false, IndexFilter.ALL, PROGRESS);
assertEquals(1, bindings.length);
} finally {
wpdom.releaseReadLock();
@@ -257,23 +247,23 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
public void verifyProject2Content(WritablePDOM wpdom) throws Exception {
wpdom.acquireReadLock();
try {
- IBinding[] bindings= wpdom.findBindings(Pattern.compile(".*"), true, IndexFilter.ALL, npm());
+ IBinding[] bindings = wpdom.findBindings(Pattern.compile(".*"), true, IndexFilter.ALL, npm());
assertEquals(2, bindings.length);
- int b= bindings[0].getName().equals("A") ? 1 : 0;
+ int b = bindings[0].getName().equals("A") ? 1 : 0;
assertTrue(bindings[0] instanceof ICPPClassType);
assertTrue(bindings[1] instanceof ICPPClassType);
- assertTrue(((ICPPClassType)bindings[1 - b]).getBases().length == 0);
- assertTrue(((ICPPClassType)bindings[b]).getBases().length == 1);
+ assertTrue(((ICPPClassType) bindings[1 - b]).getBases().length == 0);
+ assertTrue(((ICPPClassType) bindings[b]).getBases().length == 1);
} finally {
wpdom.releaseReadLock();
}
}
private WritablePDOM generatePDOM(String testProject, Class<?> provider, final int[] stateCount) throws Exception {
- IIndexerStateListener listener= null;
+ IIndexerStateListener listener = null;
if (stateCount != null) {
- listener= new IIndexerStateListener() {
+ listener = new IIndexerStateListener() {
@Override
public void indexChanged(IIndexerStateEvent event) {
stateCount[0]++;
@@ -282,154 +272,215 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
CCorePlugin.getIndexManager().joinIndexer(8000, new NullProgressMonitor());
CCorePlugin.getIndexManager().addIndexerStateListener(listener);
}
-
- URL url= FileLocator.find(CTestPlugin.getDefault().getBundle(), new Path(testProject), null);
- String baseDir= FileLocator.toFileURL(url).getFile();
- doGenerate(new String[] {
- GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(),
+ URL url = FileLocator.find(CTestPlugin.getDefault().getBundle(), new Path(testProject), null);
+ String baseDir = FileLocator.toFileURL(url).getFile();
+
+ doGenerate(new String[] { GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(),
GeneratePDOMApplication.OPT_PROJECTPROVIDER, provider.getName(),
- ExternalExportProjectProvider.OPT_SOURCE, baseDir,
- ExternalExportProjectProvider.OPT_FRAGMENT_ID, "generate.pdom.tests.id." + getName()
- });
+ ExternalExportProjectProvider.OPT_SOURCE, baseDir, ExternalExportProjectProvider.OPT_FRAGMENT_ID,
+ "generate.pdom.tests.id." + getName() });
assertTrue(target.exists());
- if (listener!=null) {
+ if (listener != null) {
CCorePlugin.getIndexManager().removeIndexerStateListener(listener);
}
return new WritablePDOM(target, new URIRelativeLocationConverter(BASEURI),
LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
}
-
+
private void doGenerate(String[] args) throws CoreException {
GeneratePDOMApplication app = new GeneratePDOMApplication() {
@Override
- protected void output(String s) {}
+ protected void output(String s) {
+ }
};
- String[] newArgs= new String[args.length+1];
- newArgs[0]= GeneratePDOMApplication.OPT_QUIET;
+ String[] newArgs = new String[args.length + 1];
+ newArgs[0] = GeneratePDOMApplication.OPT_QUIET;
System.arraycopy(args, 0, newArgs, 1, args.length);
- IApplicationContext ac= new MockApplicationContext(newArgs);
+ IApplicationContext ac = new MockApplicationContext(newArgs);
app.start(ac);
}
/*
* IExportProjectProvider test implementations
*/
-
+
public static class TestProjectProvider1 implements IExportProjectProvider {
@Override
- public ICProject createProject() throws CoreException {return null;}
+ public ICProject createProject() throws CoreException {
+ return null;
+ }
+
@Override
- public Map getExportProperties() {return null;}
+ public Map getExportProperties() {
+ return null;
+ }
+
@Override
- public IIndexLocationConverter getLocationConverter(ICProject cproject) {return null;}
+ public IIndexLocationConverter getLocationConverter(ICProject cproject) {
+ return null;
+ }
+
@Override
- public void setApplicationArguments(String[] arguments) {}
+ public void setApplicationArguments(String[] arguments) {
+ }
}
public static class TestProjectProvider2 implements IExportProjectProvider {
@Override
public ICProject createProject() throws CoreException {
- ICProject cproject= CProjectHelper.createCCProject("test" + System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER);
+ ICProject cproject = CProjectHelper.createCCProject("test" + System.currentTimeMillis(), null,
+ IPDOMManager.ID_NO_INDEXER);
projectsToDeleteOnTearDown.add(cproject);
CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ1);
return cproject;
}
+
@Override
- public Map getExportProperties() {return null;}
+ public Map getExportProperties() {
+ return null;
+ }
+
@Override
- public IIndexLocationConverter getLocationConverter(ICProject cproject) {return null;}
+ public IIndexLocationConverter getLocationConverter(ICProject cproject) {
+ return null;
+ }
+
@Override
- public void setApplicationArguments(String[] arguments) {}
+ public void setApplicationArguments(String[] arguments) {
+ }
}
public static class TestProjectProvider3 implements IExportProjectProvider {
@Override
public ICProject createProject() throws CoreException {
- ICProject cproject= CProjectHelper.createCCProject("test" + System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER);
+ ICProject cproject = CProjectHelper.createCCProject("test" + System.currentTimeMillis(), null,
+ IPDOMManager.ID_NO_INDEXER);
projectsToDeleteOnTearDown.add(cproject);
CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ1);
return cproject;
}
+
@Override
- public Map getExportProperties() {return null;}
+ public Map getExportProperties() {
+ return null;
+ }
+
@Override
public IIndexLocationConverter getLocationConverter(ICProject cproject) {
return new ResourceContainerRelativeLocationConverter(cproject.getProject());
}
+
@Override
- public void setApplicationArguments(String[] arguments) {}
+ public void setApplicationArguments(String[] arguments) {
+ }
}
- public static class TestProjectProvider4 implements IExportProjectProvider {
+ public static class TestProjectProvider4 implements IExportProjectProvider {
@Override
public ICProject createProject() throws CoreException {
- ICProject cproject= CProjectHelper.createCCProject("test" + System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER);
+ ICProject cproject = CProjectHelper.createCCProject("test" + System.currentTimeMillis(), null,
+ IPDOMManager.ID_NO_INDEXER);
projectsToDeleteOnTearDown.add(cproject);
CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ1);
return cproject;
}
+
@Override
public Map getExportProperties() {
- Map map= new HashMap();
+ Map map = new HashMap();
map.put(SDK_VERSION, "4.0.1");
map.put(IIndexFragment.PROPERTY_FRAGMENT_ID, ACME_SDK_ID);
return map;
}
+
@Override
public IIndexLocationConverter getLocationConverter(ICProject cproject) {
return new ResourceContainerRelativeLocationConverter(cproject.getProject());
}
+
@Override
- public void setApplicationArguments(String[] arguments) {}
+ public void setApplicationArguments(String[] arguments) {
+ }
}
-
- public static class TestProjectProvider5 implements IExportProjectProvider {
+
+ public static class TestProjectProvider5 implements IExportProjectProvider {
@Override
public ICProject createProject() throws CoreException {
- ICProject cproject= CProjectHelper.createCProject("test" + System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER);
+ ICProject cproject = CProjectHelper.createCProject("test" + System.currentTimeMillis(), null,
+ IPDOMManager.ID_NO_INDEXER);
projectsToDeleteOnTearDown.add(cproject);
CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ3);
return cproject;
}
+
@Override
public Map getExportProperties() {
- Map map= new HashMap();
+ Map map = new HashMap();
map.put(SDK_VERSION, "4.0.1");
map.put(IIndexFragment.PROPERTY_FRAGMENT_ID, ACME_SDK_ID);
return map;
}
+
@Override
public IIndexLocationConverter getLocationConverter(ICProject cproject) {
return new ResourceContainerRelativeLocationConverter(cproject.getProject());
}
+
@Override
- public void setApplicationArguments(String[] arguments) {}
+ public void setApplicationArguments(String[] arguments) {
+ }
}
}
class MockApplicationContext implements IApplicationContext {
Map arguments;
+
MockApplicationContext(String[] appArgs) {
- arguments= new HashMap();
+ arguments = new HashMap();
arguments.put(APPLICATION_ARGS, appArgs);
}
+
@Override
- public void applicationRunning() {}
+ public void applicationRunning() {
+ }
+
@Override
- public Map getArguments() {return arguments;}
+ public Map getArguments() {
+ return arguments;
+ }
+
@Override
- public String getBrandingApplication() {return null;}
+ public String getBrandingApplication() {
+ return null;
+ }
+
@Override
- public Bundle getBrandingBundle() {return null;}
+ public Bundle getBrandingBundle() {
+ return null;
+ }
+
@Override
- public String getBrandingDescription() {return null;}
+ public String getBrandingDescription() {
+ return null;
+ }
+
@Override
- public String getBrandingId() {return null;}
+ public String getBrandingId() {
+ return null;
+ }
+
@Override
- public String getBrandingName() {return null;}
+ public String getBrandingName() {
+ return null;
+ }
+
@Override
- public String getBrandingProperty(String key) {return null;}
+ public String getBrandingProperty(String key) {
+ return null;
+ }
+
@Override
- public void setResult(Object result, IApplication application) {}
+ public void setResult(Object result, IApplication application) {
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/IncludesTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/IncludesTests.java
index 92d1b7e7c10..72d47e2fac7 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/IncludesTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/IncludesTests.java
@@ -52,14 +52,14 @@ public class IncludesTests extends PDOMTestBase {
protected void tearDown() throws Exception {
index.releaseReadLock();
}
-
+
private IIndexFile getIndexFile(IFile file) throws CoreException {
IIndexFile[] files = index.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file));
assertTrue("Can't find " + file.getLocation(), files.length > 0);
assertEquals("Found " + files.length + " files for " + file.getLocation() + " instead of one", 1, files.length);
return files[0];
- }
-
+ }
+
public void testIncludedBy() throws Exception {
IResource loc = project.getProject().findMember("I2.h");
IIndexFile file = getIndexFile((IFile) loc);
@@ -70,10 +70,10 @@ public class IncludesTests extends PDOMTestBase {
public void testIncludes() throws Exception {
IResource loc = project.getProject().findMember("I1.cpp");
IIndexFile file = getIndexFile((IFile) loc);
- IIndexInclude[] allIncludesTo= index.findIncludes(file, -1);
+ IIndexInclude[] allIncludesTo = index.findIncludes(file, -1);
assertEquals(2, allIncludesTo.length); // i.e. I1.h, I2.h
}
-
+
public void testIncludeName() throws Exception {
IResource loc = project.getProject().findMember("a/b/I6.h");
IIndexFile file = getIndexFile((IFile) loc);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/MethodTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/MethodTests.java
index c92647dc235..bc53b25eb25 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/MethodTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/MethodTests.java
@@ -54,7 +54,7 @@ public class MethodTests extends PDOMTestBase {
pdom.releaseReadLock();
if (project != null) {
CProjectHelper.delete(project);
- project= null;
+ project = null;
}
}
@@ -70,14 +70,14 @@ public class MethodTests extends PDOMTestBase {
assertEquals(IBasicType.t_float, ((ICPPBasicType) parameters[2].getType()).getType());
assertEquals("p3", parameters[2].getName());
}
-
+
public void testVirtualMethod() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "Class1::inheritedMethod");
assertEquals(1, bindings.length);
ICPPMethod method = (ICPPMethod) bindings[0];
assertTrue(method.isVirtual());
}
-
+
public void testVirtualMethodType() throws Exception {
assertType(pdom, "Class1::inheritedMethod", ICPPFunction.class);
}
@@ -117,7 +117,7 @@ public class MethodTests extends PDOMTestBase {
assertTrue(method.isVirtual());
assertTrue(method.isPureVirtual());
}
-
+
public void testPureVirtualMethodType() throws Exception {
assertType(pdom, "Class1::pureVirtualMethod", ICPPFunction.class);
assertType(pdom, "Class2::pureVirtualMethod", ICPPFunction.class);
@@ -164,44 +164,44 @@ public class MethodTests extends PDOMTestBase {
ICPPMethod method = (ICPPMethod) bindings[0];
assertTrue(method.isDestructor());
}
-
+
public void testDefaultPrivateMethod() throws Exception {
assertCPPMemberVisibility(pdom, "Class3::defaultMethod", ICPPMember.v_private);
}
-
+
public void testPrivateMethod() throws Exception {
assertCPPMemberVisibility(pdom, "Class3::privateMethod", ICPPMember.v_private);
}
-
+
public void testProtectedMethod() throws Exception {
assertCPPMemberVisibility(pdom, "Class3::protectedMethod", ICPPMember.v_protected);
}
-
+
public void testPublicMethod() throws Exception {
assertCPPMemberVisibility(pdom, "Class3::publicMethod", ICPPMember.v_public);
}
-
+
public void testInlineMethod() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "Class1::inlineMethod");
assertEquals(1, bindings.length);
ICPPMethod method = (ICPPMethod) bindings[0];
assertTrue(method.isInline());
}
-
+
public void testStaticMethod() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "Class1::staticMethod");
assertEquals(1, bindings.length);
ICPPMethod method = (ICPPMethod) bindings[0];
assertTrue(method.isStatic());
}
-
+
public void testVarArgsMethod() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "Class1::varArgsMethod");
assertEquals(1, bindings.length);
ICPPMethod method = (ICPPMethod) bindings[0];
assertTrue(method.takesVarArgs());
}
-
+
public void testConstMethod() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "Class1::constMethod");
assertEquals(1, bindings.length);
@@ -209,7 +209,7 @@ public class MethodTests extends PDOMTestBase {
ICPPFunctionType type = method.getType();
assertTrue(type.isConst());
}
-
+
public void testVolatileMethod() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "Class1::volatileMethod");
assertEquals(1, bindings.length);
@@ -217,7 +217,7 @@ public class MethodTests extends PDOMTestBase {
ICPPFunctionType type = method.getType();
assertTrue(type.isVolatile());
}
-
+
public void testConstVolatileMethod() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "Class1::constVolatileMethod");
assertEquals(1, bindings.length);
@@ -226,7 +226,7 @@ public class MethodTests extends PDOMTestBase {
assertTrue(type.isConst());
assertTrue(type.isVolatile());
}
-
+
public void testNotConstMethod() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "Class1::notConstMethod");
assertEquals(1, bindings.length);
@@ -234,7 +234,7 @@ public class MethodTests extends PDOMTestBase {
ICPPFunctionType type = method.getType();
assertFalse(type.isConst());
}
-
+
public void testNotVolatileMethod() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "Class1::notVolatileMethod");
assertEquals(1, bindings.length);
@@ -242,7 +242,7 @@ public class MethodTests extends PDOMTestBase {
ICPPFunctionType type = method.getType();
assertFalse(type.isVolatile());
}
-
+
public void testNotConstVolatileMethod() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "Class1::notConstVolatileMethod");
assertEquals(1, bindings.length);
@@ -251,7 +251,7 @@ public class MethodTests extends PDOMTestBase {
assertFalse(type.isConst());
assertFalse(type.isVolatile());
}
-
+
public void testNoExceptionSpecification() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "Class1::noExceptionSpecMethod");
assertEquals(1, bindings.length);
@@ -259,7 +259,7 @@ public class MethodTests extends PDOMTestBase {
IType[] exceptionSpec = method.getExceptionSpecification();
assertNull(exceptionSpec);
}
-
+
public void testEmptyExceptionSpecification() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "Class1::emptyExceptionSpecMethod");
assertEquals(1, bindings.length);
@@ -267,7 +267,7 @@ public class MethodTests extends PDOMTestBase {
IType[] exceptionSpec = method.getExceptionSpecification();
assertEquals(0, exceptionSpec.length);
}
-
+
public void testNonEmptyExceptionSpecification() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "Class1::nonEmptyExceptionSpecMethod");
assertEquals(1, bindings.length);
@@ -301,8 +301,8 @@ public class MethodTests extends PDOMTestBase {
ICPPMethod method = (ICPPMethod) bindings[0];
IType[] exceptionSpec = method.getExceptionSpecification();
assertEquals(2, exceptionSpec.length);
- int t1= ((ICPPBasicType) exceptionSpec[0]).getType();
- int t2= ((ICPPBasicType) exceptionSpec[1]).getType();
+ int t1 = ((ICPPBasicType) exceptionSpec[0]).getType();
+ int t2 = ((ICPPBasicType) exceptionSpec[1]).getType();
assertEquals(IBasicType.t_int, Math.min(t1, t2));
assertEquals(IBasicType.t_double, Math.max(t1, t2));
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/NamespaceTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/NamespaceTests.java
index 51d1cc0f342..1e247302e73 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/NamespaceTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/NamespaceTests.java
@@ -61,7 +61,8 @@ public class NamespaceTests extends PDOMTestBase {
protected void tearDown() throws Exception {
pdom.releaseReadLock();
if (project != null) {
- project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
@@ -90,7 +91,8 @@ public class NamespaceTests extends PDOMTestBase {
public void testNested() throws Exception {
// Find deeply nested namespace
- Pattern[] patterns = {Pattern.compile("namespace1"), Pattern.compile("namespace2"), Pattern.compile("namespace3")};
+ Pattern[] patterns = { Pattern.compile("namespace1"), Pattern.compile("namespace2"),
+ Pattern.compile("namespace3") };
IBinding[] namespaces = pdom.findBindings(patterns, false, INDEX_FILTER, NULL_MONITOR);
assertEquals(1, namespaces.length);
assertTrue(namespaces[0] instanceof ICPPNamespace);
@@ -98,7 +100,7 @@ public class NamespaceTests extends PDOMTestBase {
public void testMemberDefinition() throws Exception {
// Find the definition of a member declared in a namespace
- Pattern[] patterns = {Pattern.compile("namespace1"), Pattern.compile("namespace2"), Pattern.compile("foo")};
+ Pattern[] patterns = { Pattern.compile("namespace1"), Pattern.compile("namespace2"), Pattern.compile("foo") };
IBinding[] members = pdom.findBindings(patterns, false, INDEX_FILTER, NULL_MONITOR);
assertEquals(1, members.length);
assertTrue(members[0] instanceof ICPPFunction);
@@ -120,14 +122,14 @@ public class NamespaceTests extends PDOMTestBase {
assertEquals(1, namespaces.length);
assertTrue(namespaces[0] instanceof ICPPNamespace);
ICPPNamespace namespace1 = (ICPPNamespace) namespaces[0];
- Pattern[] patterns = {Pattern.compile("ns1"), Pattern.compile("c")};
+ Pattern[] patterns = { Pattern.compile("ns1"), Pattern.compile("c") };
IBinding[] members = pdom.findBindings(patterns, false, INDEX_FILTER, NULL_MONITOR);
assertEquals(1, members.length); // c was added by extending the namespace
}
public void testOverload() throws Exception {
// Function overloading in namespace
- Pattern[] patterns = {Pattern.compile("ns3"), Pattern.compile("blah")};
+ Pattern[] patterns = { Pattern.compile("ns3"), Pattern.compile("blah") };
IBinding[] functions = pdom.findBindings(patterns, false, INDEX_FILTER, NULL_MONITOR);
assertEquals(1, functions.length);
assertTrue(functions[0] instanceof ICPPFunction);
@@ -197,7 +199,7 @@ public class NamespaceTests extends PDOMTestBase {
public void testUsingDirective() throws Exception {
// TODO need to test for PDOM? or is it more for compiler?
- Pattern[] patterns = {Pattern.compile("ns4"), Pattern.compile("element")};
+ Pattern[] patterns = { Pattern.compile("ns4"), Pattern.compile("element") };
IBinding[] variables = pdom.findBindings(patterns, false, INDEX_FILTER, NULL_MONITOR);
assertEquals(1, variables.length);
assertTrue(variables[0] instanceof ICPPVariable);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/OverloadsWithinCommonHeaderTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/OverloadsWithinCommonHeaderTests.java
index 26d529120d8..d3dd0b713b5 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/OverloadsWithinCommonHeaderTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/OverloadsWithinCommonHeaderTests.java
@@ -40,12 +40,12 @@ public class OverloadsWithinCommonHeaderTests extends PDOMTestBase {
public static TestSuite suite() {
return suite(OverloadsWithinCommonHeaderTests.class);
}
-
+
@Override
protected void setUp() throws Exception {
if (pdom == null) {
ICProject project = createProject("overloadsWithinCommonHeader", true);
- pdom = (PDOM)CCoreInternals.getPDOMManager().getPDOM(project);
+ pdom = (PDOM) CCoreInternals.getPDOMManager().getPDOM(project);
}
pdom.acquireReadLock();
}
@@ -54,92 +54,96 @@ public class OverloadsWithinCommonHeaderTests extends PDOMTestBase {
protected void tearDown() throws Exception {
pdom.releaseReadLock();
}
-
+
public void testOverloadedInCommonHeader_ClassScope() throws CoreException {
- Pattern[] ManyOverloadedQuxPath = makePatternArray(new String[] {"ManyOverloaded","qux"});
- IBinding[] ManyOverloadedQux = pdom.findBindings(ManyOverloadedQuxPath, true, IndexFilter.ALL, new NullProgressMonitor());
- assertEquals(5,ManyOverloadedQux.length);
-
+ Pattern[] ManyOverloadedQuxPath = makePatternArray(new String[] { "ManyOverloaded", "qux" });
+ IBinding[] ManyOverloadedQux = pdom.findBindings(ManyOverloadedQuxPath, true, IndexFilter.ALL,
+ new NullProgressMonitor());
+ assertEquals(5, ManyOverloadedQux.length);
+
// ManyOverloaded.qux()
assertFunctionRefCount(new Class[0], ManyOverloadedQux, 2);
-
+
// ManyOverloaded.qux(int)
- assertFunctionRefCount(new Class[]{IBasicType.class}, ManyOverloadedQux, 4);
-
+ assertFunctionRefCount(new Class[] { IBasicType.class }, ManyOverloadedQux, 4);
+
// ManyOverloaded.qux(int,char)
- assertFunctionRefCount(new Class[]{IBasicType.class,IBasicType.class}, ManyOverloadedQux, 6);
-
+ assertFunctionRefCount(new Class[] { IBasicType.class, IBasicType.class }, ManyOverloadedQux, 6);
+
// ManyOverloaded.qux(ManyOverloaded*)
- assertFunctionRefCount(new Class[]{IPointerType.class}, ManyOverloadedQux, 8);
-
+ assertFunctionRefCount(new Class[] { IPointerType.class }, ManyOverloadedQux, 8);
+
// ManyOverloaded.qux(ManyOverloaded)
- assertFunctionRefCount(new Class[]{ICPPClassType.class}, ManyOverloadedQux, 10);
+ assertFunctionRefCount(new Class[] { ICPPClassType.class }, ManyOverloadedQux, 10);
}
-
+
public void testOverloadedInCommonHeader_FileScope() throws CoreException {
- Pattern[] QuuxPath = makePatternArray(new String[] {"quux"});
- IBinding[] Quux = pdom.findBindings(QuuxPath, true, IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), new NullProgressMonitor());
-
- assertEquals(5,Quux.length);
-
+ Pattern[] QuuxPath = makePatternArray(new String[] { "quux" });
+ IBinding[] Quux = pdom.findBindings(QuuxPath, true, IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID),
+ new NullProgressMonitor());
+
+ assertEquals(5, Quux.length);
+
// (file scope) quux()
assertFunctionRefCount(new Class[0], Quux, 4);
-
+
// (file scope) quux(int,char)
- assertFunctionRefCount(new Class[] {IBasicType.class}, Quux, 6);
-
+ assertFunctionRefCount(new Class[] { IBasicType.class }, Quux, 6);
+
// (file scope) quux(int,char)
- assertFunctionRefCount(new Class[] {IBasicType.class, IBasicType.class}, Quux, 8);
-
+ assertFunctionRefCount(new Class[] { IBasicType.class, IBasicType.class }, Quux, 8);
+
// (file scope) quux(ManyOverloaded*)
- assertFunctionRefCount(new Class[] {IPointerType.class}, Quux, 10);
-
+ assertFunctionRefCount(new Class[] { IPointerType.class }, Quux, 10);
+
// (file scope) quux(ManyOverloaded)
- assertFunctionRefCount(new Class[] {ICPPClassType.class}, Quux, 12);
+ assertFunctionRefCount(new Class[] { ICPPClassType.class }, Quux, 12);
}
-
+
public void testOverloadedInCommonHeader_NamespaceScope() throws CoreException {
- Pattern[] GraultPath = makePatternArray(new String[] {"corge","grault"});
- IBinding[] Grault = pdom.findBindings(GraultPath, true, IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), new NullProgressMonitor());
- assertEquals(5,Grault.length);
-
+ Pattern[] GraultPath = makePatternArray(new String[] { "corge", "grault" });
+ IBinding[] Grault = pdom.findBindings(GraultPath, true, IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID),
+ new NullProgressMonitor());
+ assertEquals(5, Grault.length);
+
// corge::grault()
assertFunctionRefCount(new Class[0], Grault, 6);
-
+
// corge::grault(int,char)
- assertFunctionRefCount(new Class[] {IBasicType.class}, Grault, 8);
-
+ assertFunctionRefCount(new Class[] { IBasicType.class }, Grault, 8);
+
// corge::grault(int,char)
- assertFunctionRefCount(new Class[] {IBasicType.class, IBasicType.class}, Grault, 10);
-
+ assertFunctionRefCount(new Class[] { IBasicType.class, IBasicType.class }, Grault, 10);
+
// corge::grault(ManyOverloaded*)
- assertFunctionRefCount(new Class[] {IPointerType.class}, Grault, 12);
-
+ assertFunctionRefCount(new Class[] { IPointerType.class }, Grault, 12);
+
// corge::grault(ManyOverloaded)
- assertFunctionRefCount(new Class[] {ICPPClassType.class}, Grault, 14);
+ assertFunctionRefCount(new Class[] { ICPPClassType.class }, Grault, 14);
}
-
+
public void testOverloadedInCommonHeader_NamespaceScope_Collides_With_Filescope() throws CoreException {
- Pattern[] ns2Path = makePatternArray(new String[] {"ns2","quux"});
- IBinding[] ns2 = pdom.findBindings(ns2Path, true, IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), new NullProgressMonitor());
- assertEquals(5,ns2.length);
-
+ Pattern[] ns2Path = makePatternArray(new String[] { "ns2", "quux" });
+ IBinding[] ns2 = pdom.findBindings(ns2Path, true, IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID),
+ new NullProgressMonitor());
+ assertEquals(5, ns2.length);
+
// ns2::quux()
assertFunctionRefCount(new Class[0], ns2, 16);
-
+
// ns2::quux(int,char)
- assertFunctionRefCount(new Class[] {IBasicType.class}, ns2, 20);
-
+ assertFunctionRefCount(new Class[] { IBasicType.class }, ns2, 20);
+
// ns2::quux(int,char)
- assertFunctionRefCount(new Class[] {IBasicType.class, IBasicType.class}, ns2, 24);
-
+ assertFunctionRefCount(new Class[] { IBasicType.class, IBasicType.class }, ns2, 24);
+
// ns2::quux(ManyOverloaded*)
- assertFunctionRefCount(new Class[] {IPointerType.class}, ns2, 28);
-
+ assertFunctionRefCount(new Class[] { IPointerType.class }, ns2, 28);
+
// ns2::quux(ManyOverloaded)
- assertFunctionRefCount(new Class[] {ICPPClassType.class}, ns2, 32);
+ assertFunctionRefCount(new Class[] { ICPPClassType.class }, ns2, 32);
}
-
+
protected void assertFunctionRefCount(Class[] args, IBinding[] bindingPool, int refCount) throws CoreException {
assertFunctionRefCount(pdom, args, bindingPool, refCount);
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/OverloadsWithinSingleTUTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/OverloadsWithinSingleTUTests.java
index 4b30cd3c6e4..1e1f842957a 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/OverloadsWithinSingleTUTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/OverloadsWithinSingleTUTests.java
@@ -26,7 +26,7 @@ import org.eclipse.cdt.internal.core.CCoreInternals;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
-
+
/**
* Test overloaded symbols are correctly resolved when within a single translation
* unit. This covers the case of adapting non-PDOM bindings to PDOM bindings by
@@ -38,12 +38,12 @@ public class OverloadsWithinSingleTUTests extends PDOMTestBase {
public static TestSuite suite() {
return suite(OverloadsWithinSingleTUTests.class);
}
-
+
@Override
protected void setUp() throws Exception {
if (pdom == null) {
ICProject project = createProject("overloadsWithinSingleTU");
- pdom = (PDOM)CCoreInternals.getPDOMManager().getPDOM(project);
+ pdom = (PDOM) CCoreInternals.getPDOMManager().getPDOM(project);
}
pdom.acquireReadLock();
}
@@ -52,7 +52,7 @@ public class OverloadsWithinSingleTUTests extends PDOMTestBase {
protected void tearDown() throws Exception {
pdom.releaseReadLock();
}
-
+
public void testDistinctBindingsPresent() throws Exception {
IBinding[] fooBs = pdom.findBindings(Pattern.compile("foo"), false, IndexFilter.ALL, new NullProgressMonitor());
assertEquals(3, fooBs.length);
@@ -60,14 +60,15 @@ public class OverloadsWithinSingleTUTests extends PDOMTestBase {
IBinding[] barBs = pdom.findBindings(Pattern.compile("bar"), false, IndexFilter.ALL, new NullProgressMonitor());
assertEquals(8, barBs.length);
- IBinding[] FooBs = pdom.findBindings(Pattern.compile("Foo"), false, IndexFilter.ALL_DECLARED, new NullProgressMonitor());
+ IBinding[] FooBs = pdom.findBindings(Pattern.compile("Foo"), false, IndexFilter.ALL_DECLARED,
+ new NullProgressMonitor());
assertEquals(4, FooBs.length);
- Pattern[] XBarAbsPath = makePatternArray(new String[] {"X","bar"});
+ Pattern[] XBarAbsPath = makePatternArray(new String[] { "X", "bar" });
IBinding[] XBarBs = pdom.findBindings(XBarAbsPath, true, IndexFilter.ALL, new NullProgressMonitor());
assertEquals(4, XBarBs.length);
- Pattern[] XFooPath = makePatternArray(new String[] {"X","Foo"});
+ Pattern[] XFooPath = makePatternArray(new String[] { "X", "Foo" });
IBinding[] XFooPathBs = pdom.findBindings(XFooPath, true, IndexFilter.ALL, new NullProgressMonitor());
assertEquals(1, XFooPathBs.length);
}
@@ -78,34 +79,34 @@ public class OverloadsWithinSingleTUTests extends PDOMTestBase {
// bar()
assertFunctionRefCount(new Class[] {}, BarBs, 4);
-
+
// bar(int)
- assertFunctionRefCount(new Class[] {IBasicType.class}, BarBs, 3);
+ assertFunctionRefCount(new Class[] { IBasicType.class }, BarBs, 3);
// bar(int,int)
- assertFunctionRefCount(new Class[] {IBasicType.class, IBasicType.class}, BarBs, 2);
+ assertFunctionRefCount(new Class[] { IBasicType.class, IBasicType.class }, BarBs, 2);
// bar(Foo,int)
- assertFunctionRefCount(new Class[] {ICPPClassType.class, IBasicType.class}, BarBs, 1);
+ assertFunctionRefCount(new Class[] { ICPPClassType.class, IBasicType.class }, BarBs, 1);
}
public void testReferencesToNamespacedBindings() throws Exception {
- Pattern[] XBarAbsPath = makePatternArray(new String[] {"X","bar"});
+ Pattern[] XBarAbsPath = makePatternArray(new String[] { "X", "bar" });
IBinding[] XBarBs = pdom.findBindings(XBarAbsPath, false, IndexFilter.ALL, new NullProgressMonitor());
// X::bar()
assertFunctionRefCount(new Class[] {}, XBarBs, 2);
// X::bar(int)
- assertFunctionRefCount(new Class[] {IBasicType.class}, XBarBs, 3);
+ assertFunctionRefCount(new Class[] { IBasicType.class }, XBarBs, 3);
// X::bar(int,int)
- assertFunctionRefCount(new Class[] {IBasicType.class,IBasicType.class}, XBarBs, 4);
+ assertFunctionRefCount(new Class[] { IBasicType.class, IBasicType.class }, XBarBs, 4);
// X::bar(X::Foo,int)
- assertFunctionRefCount(new Class[] {ICPPClassType.class,IBasicType.class}, XBarBs, 5);
+ assertFunctionRefCount(new Class[] { ICPPClassType.class, IBasicType.class }, XBarBs, 5);
}
-
+
public void assertFunctionRefCount(Class[] args, IBinding[] bindingPool, int refCount) throws CoreException {
assertFunctionRefCount(pdom, args, bindingPool, refCount);
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCBugsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCBugsTest.java
index 83b97d80d87..07b5c0baed3 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCBugsTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCBugsTest.java
@@ -47,34 +47,36 @@ import org.osgi.framework.Bundle;
public class PDOMCBugsTest extends BaseTestCase {
ICProject cproject;
PDOM pdom;
-
+
public static Test suite() {
return suite(PDOMCBugsTest.class);
}
-
+
@Override
protected void setUp() throws Exception {
- cproject= CProjectHelper.createCProject("PDOMCBugsTest"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
+ cproject = CProjectHelper.createCProject("PDOMCBugsTest" + System.currentTimeMillis(), "bin",
+ IPDOMManager.ID_NO_INDEXER);
Bundle b = CTestPlugin.getDefault().getBundle();
- CharSequence[] testData = TestSourceReader.getContentsForTest(b, "parser",
- PDOMCBugsTest.this.getClass(), getName(), 1);
+ CharSequence[] testData = TestSourceReader.getContentsForTest(b, "parser", PDOMCBugsTest.this.getClass(),
+ getName(), 1);
IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), testData[0].toString());
CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
waitForIndexer(cproject);
- pdom= (PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject);
+ pdom = (PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject);
super.setUp();
}
@Override
protected void tearDown() throws Exception {
if (cproject != null) {
- cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
super.tearDown();
}
-
+
// // check we get the right IProblemBinding objects
// typedef A B;
// typedef C D;
@@ -85,27 +87,27 @@ public class PDOMCBugsTest extends BaseTestCase {
// typedef int (*J)(J);
public void test192165() throws Exception {
pdom.acquireReadLock();
- IBinding[] bindings= pdom.findBindings(Pattern.compile(".*"), false, IndexFilter.ALL, npm());
+ IBinding[] bindings = pdom.findBindings(Pattern.compile(".*"), false, IndexFilter.ALL, npm());
assertEquals(7, bindings.length);
- Set bnames= new HashSet();
+ Set bnames = new HashSet();
for (IBinding binding : bindings) {
final String name = binding.getName();
bnames.add(name);
- assertTrue("expected typedef, got "+binding, binding instanceof ITypedef);
- IType type= SemanticUtil.getUltimateType((IType)binding, false);
+ assertTrue("expected typedef, got " + binding, binding instanceof ITypedef);
+ IType type = SemanticUtil.getUltimateType((IType) binding, false);
if (name.equals("J")) {
// for plain C the second J has to be interpreted as a (useless) parameter name.
assertTrue(type instanceof IFunctionType);
- IFunctionType ft= (IFunctionType) type;
+ IFunctionType ft = (IFunctionType) type;
assertEquals("int (int)", ASTTypeUtil.getType(ft));
} else {
assertTrue(type instanceof IProblemType);
}
}
-
- Set expected= new HashSet(Arrays.asList(new String[]{"B","D","E","G","H","I","J"}));
+
+ Set expected = new HashSet(Arrays.asList(new String[] { "B", "D", "E", "G", "H", "I", "J" }));
assertEquals(expected, bnames);
-
+
pdom.releaseReadLock();
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCPPBugsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCPPBugsTest.java
index 7c9453ef165..630c423260b 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCPPBugsTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCPPBugsTest.java
@@ -62,14 +62,16 @@ public class PDOMCPPBugsTest extends BaseTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- cproject= CProjectHelper.createCCProject("PDOMBugsTest" + System.currentTimeMillis(), "bin", IPDOMManager.ID_FAST_INDEXER);
+ cproject = CProjectHelper.createCCProject("PDOMBugsTest" + System.currentTimeMillis(), "bin",
+ IPDOMManager.ID_FAST_INDEXER);
waitForIndexer(cproject);
}
@Override
protected void tearDown() throws Exception {
if (cproject != null) {
- cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
super.tearDown();
}
@@ -95,12 +97,12 @@ public class PDOMCPPBugsTest extends BaseTestCase {
PDOM pdom = (PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject);
pdom.acquireReadLock();
try {
- String id= pdom.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID);
+ String id = pdom.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID);
assertNotNull(id);
CCoreInternals.getPDOMManager().reindex(cproject);
- String id2= pdom.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID);
+ String id2 = pdom.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID);
assertNotNull(id2);
assertEquals(id, id2);
} finally {
@@ -113,14 +115,15 @@ public class PDOMCPPBugsTest extends BaseTestCase {
// not on my local linux or windows boxes.
File tmp = nonExistentTempFile("temp", ".pdom");
- IIndexLocationConverter cvr= new ResourceContainerRelativeLocationConverter(cproject.getProject());
+ IIndexLocationConverter cvr = new ResourceContainerRelativeLocationConverter(cproject.getProject());
final PDOMManager pdomManager = CCoreInternals.getPDOMManager();
pdomManager.exportProjectPDOM(cproject, tmp, cvr, null);
- IWritableIndexFragment pdom = new WritablePDOM(tmp, cvr, new ChunkCache(), LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
+ IWritableIndexFragment pdom = new WritablePDOM(tmp, cvr, new ChunkCache(),
+ LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
pdom.acquireReadLock();
try {
- String id= pdom.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID);
+ String id = pdom.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID);
assertNotNull("Exported pdom ID is null", id);
String id2 = getFragmentID(cproject);
@@ -130,11 +133,11 @@ public class PDOMCPPBugsTest extends BaseTestCase {
pdomManager.reindex(cproject);
waitForIndexer(cproject);
- String id3= pdom.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID);
+ String id3 = pdom.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID);
assertNotNull("Exported pdom ID is null after project reindex", id3);
assertEquals("Exported pdom ID hasChanged during reindex", id, id3);
- String id4= getFragmentID(cproject);
+ String id4 = getFragmentID(cproject);
assertNotNull("Reindexed project pdom ID is null", id4);
assertFalse("Reindexex project pdom ID equals exported pdom ID", id4.equals(id));
} finally {
@@ -143,31 +146,30 @@ public class PDOMCPPBugsTest extends BaseTestCase {
}
private String getFragmentID(final ICProject cproject) throws CoreException, InterruptedException {
- PDOMManager pdomManager= CCoreInternals.getPDOMManager();
- final PDOM projectPDOM = (PDOM)pdomManager.getPDOM(cproject);
+ PDOMManager pdomManager = CCoreInternals.getPDOMManager();
+ final PDOM projectPDOM = (PDOM) pdomManager.getPDOM(cproject);
String id2;
projectPDOM.acquireReadLock();
try {
- id2= (projectPDOM).getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID);
- }
- finally {
+ id2 = (projectPDOM).getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID);
+ } finally {
projectPDOM.releaseReadLock();
}
return id2;
}
public void testInterruptingAcquireReadLock() throws Exception {
- final PDOM pdom= (PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject);
- final boolean[] ok= {false};
+ final PDOM pdom = (PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject);
+ final boolean[] ok = { false };
pdom.acquireWriteLock(null);
try {
- Thread other= new Thread() {
+ Thread other = new Thread() {
@Override
public void run() {
try {
pdom.acquireReadLock();
} catch (InterruptedException e) {
- ok[0]= true;
+ ok[0] = true;
}
}
};
@@ -175,8 +177,7 @@ public class PDOMCPPBugsTest extends BaseTestCase {
other.interrupt();
other.join();
assertTrue("thread was not interrupted", ok[0]);
- }
- finally {
+ } finally {
pdom.releaseWriteLock();
}
pdom.acquireWriteLock(null);
@@ -184,18 +185,18 @@ public class PDOMCPPBugsTest extends BaseTestCase {
}
public void testInterruptingAcquireWriteLock() throws Exception {
- final WritablePDOM pdom= (WritablePDOM) CCoreInternals.getPDOMManager().getPDOM(cproject);
- final boolean[] ok= {false};
+ final WritablePDOM pdom = (WritablePDOM) CCoreInternals.getPDOMManager().getPDOM(cproject);
+ final boolean[] ok = { false };
pdom.acquireReadLock();
try {
- Thread other= new Thread() {
+ Thread other = new Thread() {
@Override
public void run() {
try {
pdom.acquireReadLock();
pdom.acquireWriteLock(1, null);
} catch (InterruptedException e) {
- ok[0]= true;
+ ok[0] = true;
pdom.releaseReadLock();
}
}
@@ -204,8 +205,7 @@ public class PDOMCPPBugsTest extends BaseTestCase {
other.interrupt();
other.join();
assertTrue("thread was not interrupted", ok[0]);
- }
- finally {
+ } finally {
pdom.releaseReadLock();
}
pdom.acquireWriteLock(null);
@@ -213,26 +213,29 @@ public class PDOMCPPBugsTest extends BaseTestCase {
}
public void test191679() throws Exception {
- IProject project= cproject.getProject();
- IFolder cHeaders= cproject.getProject().getFolder("cHeaders");
+ IProject project = cproject.getProject();
+ IFolder cHeaders = cproject.getProject().getFolder("cHeaders");
cHeaders.create(true, true, npm());
- LanguageManager lm= LanguageManager.getInstance();
+ LanguageManager lm = LanguageManager.getInstance();
- IFile cHeader= TestSourceReader.createFile(cHeaders, "cSource.c", "void foo(int i){}");
- IFile cppSource= TestSourceReader.createFile(cHeaders, "cppSource.cpp", "extern \"C\" void foo(int i); void ref() {foo(1);}");
+ IFile cHeader = TestSourceReader.createFile(cHeaders, "cSource.c", "void foo(int i){}");
+ IFile cppSource = TestSourceReader.createFile(cHeaders, "cppSource.cpp",
+ "extern \"C\" void foo(int i); void ref() {foo(1);}");
IndexerPreferences.set(project, IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
CCorePlugin.getIndexManager().reindex(cproject);
waitForIndexer(cproject);
- final PDOM pdom= (PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject);
+ final PDOM pdom = (PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject);
pdom.acquireReadLock();
try {
{ // test reference to 'foo' was resolved correctly
- IIndexBinding[] ib= pdom.findBindings(new char[][]{"foo".toCharArray()}, IndexFilter.ALL, npm());
+ IIndexBinding[] ib = pdom.findBindings(new char[][] { "foo".toCharArray() }, IndexFilter.ALL, npm());
assertEquals(2, ib.length);
if (ib[0] instanceof ICPPBinding) {
- IIndexBinding h= ib[0]; ib[0]= ib[1]; ib[1]= h;
+ IIndexBinding h = ib[0];
+ ib[0] = ib[1];
+ ib[1] = h;
}
assertTrue(ib[0] instanceof IFunction);
assertFalse(ib[0] instanceof ICPPBinding);
@@ -240,18 +243,20 @@ public class PDOMCPPBugsTest extends BaseTestCase {
assertTrue(ib[1] instanceof IFunction);
assertTrue(ib[1] instanceof ICPPBinding);
- IName[] nms= pdom.findNames(ib[0], IIndexFragment.FIND_REFERENCES | IIndexFragment.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+ IName[] nms = pdom.findNames(ib[0],
+ IIndexFragment.FIND_REFERENCES | IIndexFragment.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
assertEquals(1, nms.length);
assertTrue(nms[0].getFileLocation().getFileName().endsWith(".cpp"));
- nms= pdom.findNames(ib[0], IIndexFragment.FIND_REFERENCES);
+ nms = pdom.findNames(ib[0], IIndexFragment.FIND_REFERENCES);
assertEquals(0, nms.length);
- nms= pdom.findNames(ib[1], IIndexFragment.FIND_DEFINITIONS | IIndexFragment.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+ nms = pdom.findNames(ib[1],
+ IIndexFragment.FIND_DEFINITIONS | IIndexFragment.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
assertEquals(1, nms.length);
assertTrue(nms[0].getFileLocation().getFileName().endsWith(".c"));
- nms= pdom.findNames(ib[1], IIndexFragment.FIND_DEFINITIONS);
+ nms = pdom.findNames(ib[1], IIndexFragment.FIND_DEFINITIONS);
assertEquals(0, nms.length);
}
} finally {
@@ -259,4 +264,3 @@ public class PDOMCPPBugsTest extends BaseTestCase {
}
}
}
-
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMInlineCodeTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMInlineCodeTestBase.java
index e555cc8ec50..3cefbc2835d 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMInlineCodeTestBase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMInlineCodeTestBase.java
@@ -36,20 +36,17 @@ public class PDOMInlineCodeTestBase extends PDOMTestBase {
protected ICProject cproject;
public void setUp() throws Exception {
- cproject = CProjectHelper.createCCProject("classTemplateTests" + System.currentTimeMillis(),
- "bin", IPDOMManager.ID_NO_INDEXER);
+ cproject = CProjectHelper.createCCProject("classTemplateTests" + System.currentTimeMillis(), "bin",
+ IPDOMManager.ID_NO_INDEXER);
}
protected void setUpSections(int sections) throws Exception {
- CharSequence[] contents = TestSourceReader.getContentsForTest(
- CTestPlugin.getDefault().getBundle(), "parser", getClass(),
- getName(), sections);
+ CharSequence[] contents = TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "parser",
+ getClass(), getName(), sections);
for (CharSequence content : contents) {
- IFile file = TestSourceReader.createFile(cproject.getProject(),
- new Path("refs.cpp"), content.toString());
+ IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("refs.cpp"), content.toString());
}
- IndexerPreferences
- .set(cproject.getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
+ IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
waitForIndexer(cproject);
pdom = (PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject);
pdom.acquireReadLock();
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMLocationTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMLocationTests.java
index ccfc11c9299..cc70fc1037f 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMLocationTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMLocationTests.java
@@ -35,49 +35,45 @@ import org.eclipse.core.runtime.Platform;
*/
public class PDOMLocationTests extends BaseTestCase {
ICProject cproject;
-
+
public static Test suite() {
return suite(PDOMLocationTests.class);
}
-
+
@Override
protected void setUp() throws Exception {
- cproject= CProjectHelper.createCCProject("PDOMLocationTests" + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
+ cproject = CProjectHelper.createCCProject("PDOMLocationTests" + System.currentTimeMillis(), "bin",
+ IPDOMManager.ID_NO_INDEXER);
super.setUp();
}
@Override
protected void tearDown() throws Exception {
if (cproject != null) {
- cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
super.tearDown();
}
public void testLocationConverter() {
PDOMProjectIndexLocationConverter converter = new PDOMProjectIndexLocationConverter(cproject.getProject());
- String[] winExternals= new String[] {
- "c:/a/b/c/d.foo",
- "c:\\a\\b\\c\\d\\e.foo",
- "d:/foo.bar",
- "d:\\Documents and Settings\\JDoe\\Eclipse Workspaces\\ProjectX\\foo.bar"
- };
- String[] linuxExternals = new String[] {
- "/home/jdoe/workspaces/projectx/foo",
- "/home/jdoe/eclipse workspaces/projectx/foo.bar"
- };
-
- Set<String> externals= new HashSet();
+ String[] winExternals = new String[] { "c:/a/b/c/d.foo", "c:\\a\\b\\c\\d\\e.foo", "d:/foo.bar",
+ "d:\\Documents and Settings\\JDoe\\Eclipse Workspaces\\ProjectX\\foo.bar" };
+ String[] linuxExternals = new String[] { "/home/jdoe/workspaces/projectx/foo",
+ "/home/jdoe/eclipse workspaces/projectx/foo.bar" };
+
+ Set<String> externals = new HashSet();
externals.addAll(Arrays.asList(linuxExternals));
if (Platform.getOS().equals("win32")) {
externals.addAll(Arrays.asList(winExternals));
}
-
+
for (String ext : externals) {
IIndexFileLocation loc = IndexLocationFactory.getExternalIFL(ext);
String raw = converter.toInternalFormat(loc);
IIndexFileLocation roundtrip = converter.fromInternalFormat(raw);
- assertTrue(roundtrip!=null);
+ assertTrue(roundtrip != null);
assertEquals(roundtrip.getFullPath(), loc.getFullPath());
assertEquals(roundtrip.getURI(), loc.getURI());
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMNameTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMNameTests.java
index e42cf3591a9..01982852ea2 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMNameTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMNameTests.java
@@ -43,14 +43,16 @@ public class PDOMNameTests extends BaseTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- cproject= CProjectHelper.createCCProject("PDOMNameTest" + System.currentTimeMillis(), "bin", IPDOMManager.ID_FAST_INDEXER);
+ cproject = CProjectHelper.createCCProject("PDOMNameTest" + System.currentTimeMillis(), "bin",
+ IPDOMManager.ID_FAST_INDEXER);
waitForIndexer(cproject);
}
@Override
protected void tearDown() throws Exception {
if (cproject != null) {
- cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
super.tearDown();
}
@@ -58,8 +60,10 @@ public class PDOMNameTests extends BaseTestCase {
public void testExternalReferences() throws Exception {
IProject project = cproject.getProject();
// Use enum because this uses a different NodeType in C++ and C.
- TestSourceReader.createFile(project, "file.cpp", "enum E_cpp { e_cpp }; extern E_cpp func_cpp() { func_cpp(); return e_cpp; }");
- TestSourceReader.createFile(project, "file.c", "enum E_c { e_c }; extern enum E_c func_c() { func_c(); return e_c; }");
+ TestSourceReader.createFile(project, "file.cpp",
+ "enum E_cpp { e_cpp }; extern E_cpp func_cpp() { func_cpp(); return e_cpp; }");
+ TestSourceReader.createFile(project, "file.c",
+ "enum E_c { e_c }; extern enum E_c func_c() { func_c(); return e_c; }");
IndexerPreferences.set(project, IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
CCorePlugin.getIndexManager().reindex(cproject);
@@ -68,7 +72,8 @@ public class PDOMNameTests extends BaseTestCase {
PDOM pdom = (PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject);
pdom.acquireWriteLock(null);
try {
- IIndexBinding[] bindings = pdom.findBindings(new char[][]{"E_cpp".toCharArray()}, IndexFilter.ALL, npm());
+ IIndexBinding[] bindings = pdom.findBindings(new char[][] { "E_cpp".toCharArray() }, IndexFilter.ALL,
+ npm());
assertEquals(1, bindings.length);
assertTrue(bindings[0] instanceof PDOMBinding);
@@ -77,7 +82,7 @@ public class PDOMNameTests extends BaseTestCase {
assertNotNull(name_cpp);
assertSame(binding_cpp.getLinkage(), name_cpp.getLinkage());
- bindings = pdom.findBindings(new char[][]{"E_c".toCharArray()}, IndexFilter.ALL, npm());
+ bindings = pdom.findBindings(new char[][] { "E_c".toCharArray() }, IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
assertTrue(bindings[0] instanceof PDOMBinding);
@@ -180,7 +185,7 @@ public class PDOMNameTests extends BaseTestCase {
IPDOMIterator<PDOMName> extRefs = binding.getExternalReferences();
assertNotNull(extRefs);
int count = 0;
- for( ; extRefs.hasNext(); extRefs.next())
+ for (; extRefs.hasNext(); extRefs.next())
++count;
return count;
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMPrettyPrinter.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMPrettyPrinter.java
index 4e88fbbbb6e..88c73bf1720 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMPrettyPrinter.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMPrettyPrinter.java
@@ -36,9 +36,9 @@ public class PDOMPrettyPrinter implements IPDOMVisitor {
@Override
public void leave(IPDOMNode node) throws CoreException {
-// if (node instanceof PDOMCPPClassTemplate) {
-// ((PDOMCPPClassTemplate) node).specializationsAccept(this);
-// }
+ // if (node instanceof PDOMCPPClassTemplate) {
+ // ((PDOMCPPClassTemplate) node).specializationsAccept(this);
+ // }
if (indent.length() >= step.length())
indent.setLength(indent.length() - step.length());
}
@@ -46,12 +46,12 @@ public class PDOMPrettyPrinter implements IPDOMVisitor {
@Override
public boolean visit(IPDOMNode node) throws CoreException {
indent.append(step);
- StringBuilder sb= new StringBuilder();
+ StringBuilder sb = new StringBuilder();
sb.append(indent);
sb.append(node);
if (node instanceof PDOMBinding) {
sb.append(" ");
- PDOMBinding binding= (PDOMBinding) node;
+ PDOMBinding binding = (PDOMBinding) node;
sb.append(' ').append(binding.getRecord());
}
System.out.println(sb);
@@ -65,8 +65,8 @@ public class PDOMPrettyPrinter implements IPDOMVisitor {
* @param linkageID
*/
public static void dumpLinkage(IIndex index, final int linkageID) {
- final IPDOMVisitor v= new PDOMPrettyPrinter();
- IIndexFragment[] frg= ((CIndex) index).getFragments();
+ final IPDOMVisitor v = new PDOMPrettyPrinter();
+ IIndexFragment[] frg = ((CIndex) index).getFragments();
for (IIndexFragment element : frg) {
final PDOM pdom = (PDOM) element;
dumpLinkage(pdom, linkageID, v);
@@ -74,7 +74,7 @@ public class PDOMPrettyPrinter implements IPDOMVisitor {
}
public static void dumpLinkage(PDOM pdom, final int linkageID) {
- final IPDOMVisitor v= new PDOMPrettyPrinter();
+ final IPDOMVisitor v = new PDOMPrettyPrinter();
dumpLinkage(pdom, linkageID, v);
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMProviderTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMProviderTests.java
index d01ef3de18e..d61620e97a5 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMProviderTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMProviderTests.java
@@ -58,66 +58,65 @@ public class PDOMProviderTests extends PDOMTestBase {
}
public void testLifeCycle() throws Exception {
- final File tempPDOM= createTempFile("temp", ".pdom");
+ final File tempPDOM = createTempFile("temp", ".pdom");
{
- ICProject cproject= createCCProject("foo" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
+ ICProject cproject = createCCProject("foo" + System.currentTimeMillis(), null,
+ IPDOMManager.ID_FAST_INDEXER);
TestSourceReader.createFile(cproject.getProject(), new Path("/this.h"), "class A {};\n\n");
waitForIndexer(cproject);
- IIndex index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTIONS);
+ IIndex index = CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTIONS);
index.acquireReadLock();
try {
- IBinding[] bindings= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
+ IBinding[] bindings = index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
} finally {
index.releaseReadLock();
}
- ResourceContainerRelativeLocationConverter cvr= new ResourceContainerRelativeLocationConverter(cproject.getProject());
+ ResourceContainerRelativeLocationConverter cvr = new ResourceContainerRelativeLocationConverter(
+ cproject.getProject());
CCoreInternals.getPDOMManager().exportProjectPDOM(cproject, tempPDOM, cvr, null);
assertTrue(tempPDOM.exists());
CProjectHelper.delete(cproject);
}
- final URI baseURI= new File("c:/ExternalSDK/").toURI();
- final ICProject cproject2= createCCProject("bar" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
+ final URI baseURI = new File("c:/ExternalSDK/").toURI();
+ final ICProject cproject2 = createCCProject("bar" + System.currentTimeMillis(), null,
+ IPDOMManager.ID_FAST_INDEXER);
TestSourceReader.createFile(cproject2.getProject(), new Path("/source.cpp"), "namespace X { class A {}; }\n\n");
waitForIndexer(cproject2);
- IndexProviderManager ipm= CCoreInternals.getPDOMManager().getIndexProviderManager();
- ipm.addIndexProvider(new ReadOnlyPDOMProviderBridge(
- new IReadOnlyPDOMProvider() {
+ IndexProviderManager ipm = CCoreInternals.getPDOMManager().getIndexProviderManager();
+ ipm.addIndexProvider(new ReadOnlyPDOMProviderBridge(new IReadOnlyPDOMProvider() {
+ @Override
+ public IPDOMDescriptor[] getDescriptors(ICConfigurationDescription config) {
+ return new IPDOMDescriptor[] { new IPDOMDescriptor() {
@Override
- public IPDOMDescriptor[] getDescriptors(ICConfigurationDescription config) {
- return new IPDOMDescriptor[] {
- new IPDOMDescriptor() {
- @Override
- public IIndexLocationConverter getIndexLocationConverter() {
- return new URIRelativeLocationConverter(baseURI);
- }
-
- @Override
- public IPath getLocation() {
- return new Path(tempPDOM.getAbsolutePath());
- }
- }
- };
+ public IIndexLocationConverter getIndexLocationConverter() {
+ return new URIRelativeLocationConverter(baseURI);
}
@Override
- public boolean providesFor(ICProject project) throws CoreException {
- return cproject2.equals(project);
+ public IPath getLocation() {
+ return new Path(tempPDOM.getAbsolutePath());
}
- }
- ));
- IIndex index= CCorePlugin.getIndexManager().getIndex(cproject2, A_FRAGMENT_OPTIONS);
+ } };
+ }
+
+ @Override
+ public boolean providesFor(ICProject project) throws CoreException {
+ return cproject2.equals(project);
+ }
+ }));
+ IIndex index = CCorePlugin.getIndexManager().getIndex(cproject2, A_FRAGMENT_OPTIONS);
index.acquireReadLock();
try {
- IBinding[] bindings= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
+ IBinding[] bindings = index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
- bindings= index.findBindingsForPrefix("A".toCharArray(), false, new IndexFilter() {
+ bindings = index.findBindingsForPrefix("A".toCharArray(), false, new IndexFilter() {
@Override
public boolean acceptBinding(IBinding binding) {
return binding instanceof ICPPClassType;
@@ -130,73 +129,73 @@ public class PDOMProviderTests extends PDOMTestBase {
}
public void testCommonSDK() throws Exception {
- final File tempPDOM= createTempFile("temp", ".pdom");
+ final File tempPDOM = createTempFile("temp", ".pdom");
{
- ICProject cproject= createCCProject("foo" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
+ ICProject cproject = createCCProject("foo" + System.currentTimeMillis(), null,
+ IPDOMManager.ID_FAST_INDEXER);
TestSourceReader.createFile(cproject.getProject(), new Path("/this.h"), "class A {};\n\n");
waitForIndexer(cproject);
- IIndex index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTIONS);
+ IIndex index = CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTIONS);
index.acquireReadLock();
try {
- IBinding[] bindings= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
+ IBinding[] bindings = index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
} finally {
index.releaseReadLock();
}
- ResourceContainerRelativeLocationConverter cvr= new ResourceContainerRelativeLocationConverter(cproject.getProject());
+ ResourceContainerRelativeLocationConverter cvr = new ResourceContainerRelativeLocationConverter(
+ cproject.getProject());
CCoreInternals.getPDOMManager().exportProjectPDOM(cproject, tempPDOM, cvr, null);
assertTrue(tempPDOM.exists());
CProjectHelper.delete(cproject);
}
- final ICProject cproject3= createCCProject("bar" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
+ final ICProject cproject3 = createCCProject("bar" + System.currentTimeMillis(), null,
+ IPDOMManager.ID_FAST_INDEXER);
TestSourceReader.createFile(cproject3.getProject(), new Path("/source.cpp"), "namespace Y { class A {}; }\n\n");
waitForIndexer(cproject3);
- final URI baseURI= new File("c:/ExternalSDK/").toURI();
- final ICProject cproject2= createCCProject("baz" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
+ final URI baseURI = new File("c:/ExternalSDK/").toURI();
+ final ICProject cproject2 = createCCProject("baz" + System.currentTimeMillis(), null,
+ IPDOMManager.ID_FAST_INDEXER);
TestSourceReader.createFile(cproject2.getProject(), new Path("/source.cpp"), "namespace X { class A {}; }\n\n");
waitForIndexer(cproject2);
- IndexProviderManager ipm= CCoreInternals.getPDOMManager().getIndexProviderManager();
- ipm.addIndexProvider(new ReadOnlyPDOMProviderBridge(
- new IReadOnlyPDOMProvider() {
+ IndexProviderManager ipm = CCoreInternals.getPDOMManager().getIndexProviderManager();
+ ipm.addIndexProvider(new ReadOnlyPDOMProviderBridge(new IReadOnlyPDOMProvider() {
+ @Override
+ public IPDOMDescriptor[] getDescriptors(ICConfigurationDescription config) {
+ return new IPDOMDescriptor[] { new IPDOMDescriptor() {
@Override
- public IPDOMDescriptor[] getDescriptors(ICConfigurationDescription config) {
- return new IPDOMDescriptor[] {
- new IPDOMDescriptor() {
- @Override
- public IIndexLocationConverter getIndexLocationConverter() {
- return new URIRelativeLocationConverter(baseURI);
- }
-
- @Override
- public IPath getLocation() {
- return new Path(tempPDOM.getAbsolutePath());
- }
- }
- };
+ public IIndexLocationConverter getIndexLocationConverter() {
+ return new URIRelativeLocationConverter(baseURI);
}
@Override
- public boolean providesFor(ICProject project) throws CoreException {
- return cproject2.equals(project) || cproject3.equals(project);
+ public IPath getLocation() {
+ return new Path(tempPDOM.getAbsolutePath());
}
- }
- ));
+ } };
+ }
+
+ @Override
+ public boolean providesFor(ICProject project) throws CoreException {
+ return cproject2.equals(project) || cproject3.equals(project);
+ }
+ }));
{
- IIndex index= CCorePlugin.getIndexManager().getIndex(cproject2, A_FRAGMENT_OPTIONS);
+ IIndex index = CCorePlugin.getIndexManager().getIndex(cproject2, A_FRAGMENT_OPTIONS);
index.acquireReadLock();
try {
- IBinding[] bindings= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
+ IBinding[] bindings = index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
assertEquals(1, index.findDefinitions(bindings[0]).length);
- bindings= index.findBindingsForPrefix("A".toCharArray(), false, new IndexFilter() {
+ bindings = index.findBindingsForPrefix("A".toCharArray(), false, new IndexFilter() {
@Override
public boolean acceptBinding(IBinding binding) {
return binding instanceof ICPPClassType;
@@ -209,13 +208,13 @@ public class PDOMProviderTests extends PDOMTestBase {
}
{
- IIndex index= CCorePlugin.getIndexManager().getIndex(cproject3, A_FRAGMENT_OPTIONS);
+ IIndex index = CCorePlugin.getIndexManager().getIndex(cproject3, A_FRAGMENT_OPTIONS);
index.acquireReadLock();
try {
- IBinding[] bindings= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
+ IBinding[] bindings = index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
assertEquals(1, index.findDefinitions(bindings[0]).length);
- bindings= index.findBindingsForPrefix("A".toCharArray(), false, new IndexFilter() {
+ bindings = index.findBindingsForPrefix("A".toCharArray(), false, new IndexFilter() {
@Override
public boolean acceptBinding(IBinding binding) {
return binding instanceof ICPPClassType;
@@ -226,15 +225,16 @@ public class PDOMProviderTests extends PDOMTestBase {
index.releaseReadLock();
}
}
-
+
{
- IIndex index= CCorePlugin.getIndexManager().getIndex(new ICProject[]{cproject2, cproject3}, A_FRAGMENT_OPTIONS);
+ IIndex index = CCorePlugin.getIndexManager().getIndex(new ICProject[] { cproject2, cproject3 },
+ A_FRAGMENT_OPTIONS);
index.acquireReadLock();
try {
- IBinding[] bindings= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
+ IBinding[] bindings = index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
assertEquals(1, index.findDefinitions(bindings[0]).length);
- bindings= index.findBindingsForPrefix("A".toCharArray(), false, new IndexFilter() {
+ bindings = index.findBindingsForPrefix("A".toCharArray(), false, new IndexFilter() {
@Override
public boolean acceptBinding(IBinding binding) {
return binding instanceof ICPPClassType;
@@ -243,71 +243,70 @@ public class PDOMProviderTests extends PDOMTestBase {
assertEquals(3, bindings.length);
} finally {
index.releaseReadLock();
- }
+ }
}
}
-
+
public void testVersionMismatchOfExternalPDOM_178998() throws Exception {
- final File tempPDOM= createTempFile("temp", ".pdom");
+ final File tempPDOM = createTempFile("temp", ".pdom");
{
- ICProject cproject= createCCProject("foo" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
+ ICProject cproject = createCCProject("foo" + System.currentTimeMillis(), null,
+ IPDOMManager.ID_FAST_INDEXER);
TestSourceReader.createFile(cproject.getProject(), new Path("/this.h"), "class A {};\n\n");
waitForIndexer(cproject);
- ResourceContainerRelativeLocationConverter cvr= new ResourceContainerRelativeLocationConverter(cproject.getProject());
+ ResourceContainerRelativeLocationConverter cvr = new ResourceContainerRelativeLocationConverter(
+ cproject.getProject());
CCoreInternals.getPDOMManager().exportProjectPDOM(cproject, tempPDOM, cvr, null);
CProjectHelper.delete(cproject);
-
+
// Mimic a PDOM with superseded version.
- WritablePDOM wpdom= new WritablePDOM(tempPDOM, cvr, LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
+ WritablePDOM wpdom = new WritablePDOM(tempPDOM, cvr,
+ LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
wpdom.acquireWriteLock(null);
try {
- wpdom.getDB().setVersion(1);
+ wpdom.getDB().setVersion(1);
wpdom.close();
} finally {
wpdom.releaseWriteLock();
}
}
- final URI baseURI= new File("c:/ExternalSDK/").toURI();
- final ICProject cproject2=
- createCCProject("baz" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
+ final URI baseURI = new File("c:/ExternalSDK/").toURI();
+ final ICProject cproject2 = createCCProject("baz" + System.currentTimeMillis(), null,
+ IPDOMManager.ID_FAST_INDEXER);
TestSourceReader.createFile(cproject2.getProject(), new Path("/source.cpp"), "namespace X { class A {}; }\n\n");
waitForIndexer(cproject2);
- IndexProviderManager ipm= CCoreInternals.getPDOMManager().getIndexProviderManager();
- ipm.addIndexProvider(new ReadOnlyPDOMProviderBridge(
- new IReadOnlyPDOMProvider() {
+ IndexProviderManager ipm = CCoreInternals.getPDOMManager().getIndexProviderManager();
+ ipm.addIndexProvider(new ReadOnlyPDOMProviderBridge(new IReadOnlyPDOMProvider() {
+ @Override
+ public IPDOMDescriptor[] getDescriptors(ICConfigurationDescription config) {
+ return new IPDOMDescriptor[] { new IPDOMDescriptor() {
@Override
- public IPDOMDescriptor[] getDescriptors(ICConfigurationDescription config) {
- return new IPDOMDescriptor[] {
- new IPDOMDescriptor() {
- @Override
- public IIndexLocationConverter getIndexLocationConverter() {
- return new URIRelativeLocationConverter(baseURI);
- }
-
- @Override
- public IPath getLocation() {
- return new Path(tempPDOM.getAbsolutePath());
- }
-
- }
- };
+ public IIndexLocationConverter getIndexLocationConverter() {
+ return new URIRelativeLocationConverter(baseURI);
}
@Override
- public boolean providesFor(ICProject project) throws CoreException {
- return cproject2.equals(project);
+ public IPath getLocation() {
+ return new Path(tempPDOM.getAbsolutePath());
}
- }
- ));
-
+
+ } };
+ }
+
+ @Override
+ public boolean providesFor(ICProject project) throws CoreException {
+ return cproject2.equals(project);
+ }
+ }));
+
setExpectedNumberOfLoggedNonOKStatusObjects(1); // (this applies to the entire test duration)
-
- for (int i= 0; i < 3; i++) {
+
+ for (int i = 0; i < 3; i++) {
// Try several times in order to test the status is logged only once.
- ICProjectDescription pd= CCorePlugin.getDefault().getProjectDescription(cproject2.getProject(), false);
+ ICProjectDescription pd = CCorePlugin.getDefault().getProjectDescription(cproject2.getProject(), false);
assertEquals(0, ipm.getProvidedIndexFragments(pd.getActiveConfiguration(), -1).length);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMSearchTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMSearchTest.java
index 60db6a018d7..46480e34469 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMSearchTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMSearchTest.java
@@ -75,7 +75,8 @@ public class PDOMSearchTest extends PDOMTestBase {
protected void tearDown() throws Exception {
pdom.releaseReadLock();
if (project != null) {
- project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
@@ -105,7 +106,7 @@ public class PDOMSearchTest extends PDOMTestBase {
assertEquals(namespace2, namespaces[0]);
/* Namespace references */
- IName[] refs = pdom.findNames(namespace1,IIndex.FIND_REFERENCES);
+ IName[] refs = pdom.findNames(namespace1, IIndex.FIND_REFERENCES);
assertEquals(3, refs.length);
IASTFileLocation loc = refs[0].getFileLocation();
assertEquals(offset("main.cpp", "namespace1::Class1"), loc.getNodeOffset()); //character offset
@@ -160,7 +161,9 @@ public class PDOMSearchTest extends PDOMTestBase {
methods = class2.getDeclaredMethods();
assertEquals(2, methods.length);
if (methods[0].getName().equals("~Class1")) {
- IBinding h= methods[1]; methods[1]= methods[0]; methods[0]= h;
+ IBinding h = methods[1];
+ methods[1] = methods[0];
+ methods[0] = h;
}
assertEquals("Class1", methods[0].getName());
assertEquals("~Class1", methods[1].getName());
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTagIndexTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTagIndexTests.java
index 8c673d8a3c9..fcf6f9e3342 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTagIndexTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTagIndexTests.java
@@ -38,8 +38,7 @@ public class PDOMTagIndexTests extends BaseTestCase {
return suite(PDOMTagIndexTests.class);
}
- private static class MockIndexLocationConverter implements
- IIndexLocationConverter {
+ private static class MockIndexLocationConverter implements IIndexLocationConverter {
@Override
public IIndexFileLocation fromInternalFormat(String raw) {
return null;
@@ -55,8 +54,8 @@ public class PDOMTagIndexTests extends BaseTestCase {
protected void setUp() throws Exception {
super.setUp();
- pdomFile = File.createTempFile(getClass().getSimpleName() + '.'
- + Double.toString(Math.random()).substring(2), null);
+ pdomFile = File.createTempFile(getClass().getSimpleName() + '.' + Double.toString(Math.random()).substring(2),
+ null);
pdom = new WritablePDOM(pdomFile, new MockIndexLocationConverter(),
LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
pdom.acquireWriteLock(null);
@@ -107,8 +106,7 @@ public class PDOMTagIndexTests extends BaseTestCase {
int tag_count = 0;
for (ITag tag : tags1) {
++tag_count;
- assertTrue(tag.getTaggerId().equals(tagger_a)
- || tag.getTaggerId().equals(tagger_b));
+ assertTrue(tag.getTaggerId().equals(tagger_a) || tag.getTaggerId().equals(tagger_b));
assertEquals(1, tag.getDataLen());
}
assertEquals(2, tag_count);
@@ -129,8 +127,7 @@ public class PDOMTagIndexTests extends BaseTestCase {
// replacement should delete tags for taggers that are no longer present
// and shorter tags
// should be modified in place
- PDOMTagIndex.setTags(pdom, rec,
- Arrays.<ITag> asList(new Tag(tagger_a, 1)));
+ PDOMTagIndex.setTags(pdom, rec, Arrays.<ITag>asList(new Tag(tagger_a, 1)));
assertNull(PDOMTagIndex.getTag(pdom, rec, tagger_b));
ITag shorter_ = PDOMTagIndex.getTag(pdom, rec, tagger_a);
assertNotNull(shorter_);
@@ -139,8 +136,7 @@ public class PDOMTagIndexTests extends BaseTestCase {
assertEquals(taga_pdom.getRecord(), shorter_pdom.getRecord());
// longer tags should create a new record
- PDOMTagIndex.setTags(pdom, rec,
- Arrays.<ITag> asList(new Tag(tagger_a, 4)));
+ PDOMTagIndex.setTags(pdom, rec, Arrays.<ITag>asList(new Tag(tagger_a, 4)));
ITag longer_ = PDOMTagIndex.getTag(pdom, rec, tagger_a);
assertNotNull(longer_);
assertTrue(longer_ instanceof PDOMTag);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTestBase.java
index 3280f567ed7..9bb0fe1f6d7 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTestBase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTestBase.java
@@ -55,7 +55,7 @@ import org.eclipse.ui.dialogs.IOverwriteQuery;
import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
import org.eclipse.ui.wizards.datatransfer.ImportOperation;
-/**
+/**
* @author Doug Schaefer
*/
public class PDOMTestBase extends BaseTestCase {
@@ -66,10 +66,10 @@ public class PDOMTestBase extends BaseTestCase {
protected ICProject createProject(String folderName) throws CoreException {
return createProject(folderName, false);
}
-
+
protected ICProject createProject(String folderName, final boolean cpp) throws CoreException {
final ICProject cprojects[] = new ICProject[1];
- ModelJoiner mj= new ModelJoiner();
+ ModelJoiner mj = new ModelJoiner();
try {
// Create the project
projectName = "ProjTest_" + System.currentTimeMillis();
@@ -79,22 +79,24 @@ public class PDOMTestBase extends BaseTestCase {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
// Create the project
- ICProject cproject= cpp ? CProjectHelper.createCCProject(projectName, null, IPDOMManager.ID_NO_INDEXER)
+ ICProject cproject = cpp
+ ? CProjectHelper.createCCProject(projectName, null, IPDOMManager.ID_NO_INDEXER)
: CProjectHelper.createCProject(projectName, null, IPDOMManager.ID_NO_INDEXER);
// Import the files at the root
- ImportOperation importOp = new ImportOperation(cproject.getProject().getFullPath(),
- rootDir, FileSystemStructureProvider.INSTANCE, new IOverwriteQuery() {
- @Override
- public String queryOverwrite(String pathString) {
- return IOverwriteQuery.ALL;
- }
- });
+ ImportOperation importOp = new ImportOperation(cproject.getProject().getFullPath(), rootDir,
+ FileSystemStructureProvider.INSTANCE, new IOverwriteQuery() {
+ @Override
+ public String queryOverwrite(String pathString) {
+ return IOverwriteQuery.ALL;
+ }
+ });
importOp.setCreateContainerStructure(false);
try {
importOp.run(monitor);
} catch (Exception e) {
- throw new CoreException(new Status(IStatus.ERROR, CTestPlugin.PLUGIN_ID, 0, "Import interrupted", e));
+ throw new CoreException(
+ new Status(IStatus.ERROR, CTestPlugin.PLUGIN_ID, 0, "Import interrupted", e));
}
cprojects[0] = cproject;
@@ -115,7 +117,7 @@ public class PDOMTestBase extends BaseTestCase {
}
protected int offset(String projectRelativePath, String lookfor) throws Exception, CoreException {
- Path path= new Path(projectName + "/" + projectRelativePath);
+ Path path = new Path(projectName + "/" + projectRelativePath);
return TestSourceReader.indexOfInFile(lookfor, path);
}
@@ -127,7 +129,7 @@ public class PDOMTestBase extends BaseTestCase {
}
return pdom.findBindings(pattern, true, IndexFilter.ALL_DECLARED, PROGRESS);
}
-
+
protected IBinding[] findQualifiedPossiblyImplicit(PDOM pdom, String name) throws CoreException {
String[] segments = name.split("::");
Pattern[] pattern = new Pattern[segments.length];
@@ -182,7 +184,7 @@ public class PDOMTestBase extends BaseTestCase {
assertEquals(0, count);
}
}
-
+
protected void assertNameCount(PDOM pdom, IBinding binding, int options, int count) throws CoreException {
IName[] names = pdom.findNames(binding, options);
assertUniqueNameCount(names, count);
@@ -206,14 +208,16 @@ public class PDOMTestBase extends BaseTestCase {
assertTrue(c.isAssignableFrom(bindings[0].getClass()));
}
- protected void assertCPPMemberVisibility(PDOM pdom, String name, int visibility) throws CoreException, DOMException {
+ protected void assertCPPMemberVisibility(PDOM pdom, String name, int visibility)
+ throws CoreException, DOMException {
IBinding[] bindings = findQualifiedName(pdom, name);
assertEquals(1, bindings.length);
ICPPMember member = (ICPPMember) bindings[0];
VisibilityAsserts.assertVisibility(visibility, member.getVisibility());
}
- public static final void assertFunctionRefCount(PDOM pdom, Class[] args, IBinding[] bindingPool, int refCount) throws CoreException {
+ public static final void assertFunctionRefCount(PDOM pdom, Class[] args, IBinding[] bindingPool, int refCount)
+ throws CoreException {
IBinding[] bindings = findIFunctions(args, bindingPool);
assertEquals(1, bindings.length);
IName[] refs = pdom.findNames(bindings[0], IIndex.FIND_REFERENCES);
@@ -228,7 +232,7 @@ public class PDOMTestBase extends BaseTestCase {
IFunction function = (IFunction) binding;
IType[] candidate = function.getType().getParameterTypes();
boolean areEqual = candidate.length == paramTypes.length;
- for (int j= 0; areEqual && j < paramTypes.length; j++) {
+ for (int j = 0; areEqual && j < paramTypes.length; j++) {
if (!paramTypes[j].isAssignableFrom(candidate[j].getClass())) {
areEqual = false;
}
@@ -245,7 +249,7 @@ public class PDOMTestBase extends BaseTestCase {
assertNotNull(o);
assertTrue("Expected " + c.getName() + " but got " + o.getClass().getName(), c.isInstance(o));
}
-
+
public static Pattern[] makePatternArray(String[] args) {
List preresult = new ArrayList();
for (String arg : args) {
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/RaceCondition157992Test.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/RaceCondition157992Test.java
index 3fa8939ddd9..049b1f0a84e 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/RaceCondition157992Test.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/RaceCondition157992Test.java
@@ -27,34 +27,33 @@ import org.eclipse.cdt.internal.core.CCoreInternals;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.core.runtime.NullProgressMonitor;
-
/**
* Test case for a race condition from Bugzilla#157992
*/
public class RaceCondition157992Test extends PDOMTestBase {
-
+
public static Test suite() {
return suite(RaceCondition157992Test.class);
}
-
+
public void testRepeatedly() throws Exception {
int successes = 0, noTrials = 100;
-
- for(int i=0; i<noTrials; i++) {
+
+ for (int i = 0; i < noTrials; i++) {
ICProject project = createProject("classTests");
- PDOM pdom = (PDOM)CCoreInternals.getPDOMManager().getPDOM(project);
- pdom.acquireReadLock();
+ PDOM pdom = (PDOM) CCoreInternals.getPDOMManager().getPDOM(project);
+ pdom.acquireReadLock();
IBinding[] Bs = pdom.findBindings(Pattern.compile("B"), true, IndexFilter.ALL, new NullProgressMonitor());
- if(Bs.length==1)
+ if (Bs.length == 1)
successes++;
pdom.releaseReadLock();
}
-
- String msg = "Same indexer on same project produces different results."
- + "Failure rate of "+(noTrials-successes)+" failures in "+noTrials+" tests";
- assertTrue("Non-race-condition failure", successes!=0);
+
+ String msg = "Same indexer on same project produces different results." + "Failure rate of "
+ + (noTrials - successes) + " failures in " + noTrials + " tests";
+ assertTrue("Non-race-condition failure", successes != 0);
assertTrue(msg, successes == noTrials);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/TypesTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/TypesTests.java
index 2cb1dbe2ee3..52d837ed592 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/TypesTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/TypesTests.java
@@ -49,7 +49,7 @@ public class TypesTests extends PDOMTestBase {
protected void setUp() throws Exception {
if (pdom == null) {
ICProject project = createProject("types");
- pdom = (PDOM)CCoreInternals.getPDOMManager().getPDOM(project);
+ pdom = (PDOM) CCoreInternals.getPDOMManager().getPDOM(project);
}
pdom.acquireReadLock();
}
@@ -58,17 +58,17 @@ public class TypesTests extends PDOMTestBase {
protected void tearDown() throws Exception {
pdom.releaseReadLock();
}
-
+
public void testC() throws Exception {
// Get the binding for A::f
- IBinding [] CAs = pdom.findBindings(Pattern.compile("CA"), false, IndexFilter.ALL, new NullProgressMonitor());
+ IBinding[] CAs = pdom.findBindings(Pattern.compile("CA"), false, IndexFilter.ALL, new NullProgressMonitor());
assertEquals(1, CAs.length);
- ICompositeType CA = (ICompositeType)CAs[0];
- IField [] CAfields = CA.getFields();
+ ICompositeType CA = (ICompositeType) CAs[0];
+ IField[] CAfields = CA.getFields();
assertEquals(1, CAfields.length);
IField x = CAfields[0];
assertEquals("x", x.getName());
-
+
// Make sure that there is a reference in g();
IName[] xRefs = pdom.findNames(x, IIndex.FIND_REFERENCES);
assertEquals(1, xRefs.length);
@@ -78,29 +78,30 @@ public class TypesTests extends PDOMTestBase {
public void testCPP() throws Exception {
// Get the binding for A::f
- IBinding [] As = pdom.findBindings(Pattern.compile("A"), true, IndexFilter.ALL, new NullProgressMonitor());
+ IBinding[] As = pdom.findBindings(Pattern.compile("A"), true, IndexFilter.ALL, new NullProgressMonitor());
assertEquals(1, As.length);
- ICPPClassType A = (ICPPClassType)As[0];
+ ICPPClassType A = (ICPPClassType) As[0];
ICPPMethod[] Amethods = A.getDeclaredMethods();
assertEquals(1, Amethods.length);
ICPPMethod f = Amethods[0];
assertEquals("f", f.getName());
-
+
// Make sure that there is a reference in g();
IName[] fRefs = pdom.findNames(f, IIndex.FIND_REFERENCES);
assertEquals(1, fRefs.length);
IASTFileLocation loc = fRefs[0].getFileLocation();
assertEquals(offset("typedef.cpp", "x->f") + 3, loc.getNodeOffset());
}
-
+
public void test145351() throws Exception {
- IBinding [] bindings = pdom.findBindings(Pattern.compile("spinlock_t"), false, IndexFilter.ALL, new NullProgressMonitor());
+ IBinding[] bindings = pdom.findBindings(Pattern.compile("spinlock_t"), false, IndexFilter.ALL,
+ new NullProgressMonitor());
assertEquals(1, bindings.length);
- ITypedef spinlock_t = (ITypedef)bindings[0];
- IName [] refs = pdom.findNames(spinlock_t, IIndex.FIND_REFERENCES);
+ ITypedef spinlock_t = (ITypedef) bindings[0];
+ IName[] refs = pdom.findNames(spinlock_t, IIndex.FIND_REFERENCES);
assertEquals(1, refs.length);
IASTFileLocation loc = refs[0].getFileLocation();
assertEquals(offset("bug145351.c", "spinlock_t global_bh_lock"), loc.getNodeOffset());
}
-
+
}
diff --git a/core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/BaseTestFramework.java b/core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/BaseTestFramework.java
index 622fe866f21..546b5c169a4 100644
--- a/core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/BaseTestFramework.java
+++ b/core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/BaseTestFramework.java
@@ -41,64 +41,64 @@ import org.eclipse.core.runtime.NullProgressMonitor;
* @author aniefer
*/
abstract public class BaseTestFramework extends BaseTestCase {
- static protected NullProgressMonitor monitor;
- static protected IWorkspace workspace;
- static protected IProject project;
- static protected ICProject cproject;
- static protected FileManager fileManager;
- static protected boolean indexDisabled= false;
+ static protected NullProgressMonitor monitor;
+ static protected IWorkspace workspace;
+ static protected IProject project;
+ static protected ICProject cproject;
+ static protected FileManager fileManager;
+ static protected boolean indexDisabled = false;
static void initProject() {
if (project != null) {
return;
}
- if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null) {
+ if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null) {
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
monitor = new NullProgressMonitor();
-
+
workspace = ResourcesPlugin.getWorkspace();
-
- try {
- cproject = CProjectHelper.createCCProject("RegressionTestProject", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
-
- project = cproject.getProject();
-
- /*project.setSessionProperty(SourceIndexer.activationKey, Boolean.FALSE);
- //Set the id of the source indexer extension point as a session property to allow
- //index manager to instantiate it
- project.setSessionProperty(IndexManager.indexerIDKey, sourceIndexerID);*/
- } catch (CoreException e) {
- /*boo*/
- }
+
+ try {
+ cproject = CProjectHelper.createCCProject("RegressionTestProject", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
+
+ project = cproject.getProject();
+
+ /*project.setSessionProperty(SourceIndexer.activationKey, Boolean.FALSE);
+ //Set the id of the source indexer extension point as a session property to allow
+ //index manager to instantiate it
+ project.setSessionProperty(IndexManager.indexerIDKey, sourceIndexerID);*/
+ } catch (CoreException e) {
+ /*boo*/
+ }
if (project == null)
fail("Unable to create project"); //$NON-NLS-1$
-
+
//Create file manager
fileManager = new FileManager();
- }
+ }
+ }
+
+ public BaseTestFramework() {
+ super();
}
-
- public BaseTestFramework() {
- super();
- }
-
- /**
- * @param name
- */
- public BaseTestFramework(String name) {
- super(name);
- }
-
- public void cleanupProject() throws Exception {
- try{
- project.delete(true, false, monitor);
- } catch (Throwable e) {
- /*boo*/
- } finally {
- project= null;
- }
- }
-
+
+ /**
+ * @param name
+ */
+ public BaseTestFramework(String name) {
+ super(name);
+ }
+
+ public void cleanupProject() throws Exception {
+ try {
+ project.delete(true, false, monitor);
+ } catch (Throwable e) {
+ /*boo*/
+ } finally {
+ project = null;
+ }
+ }
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -107,37 +107,37 @@ abstract public class BaseTestFramework extends BaseTestCase {
@Override
protected void tearDown() throws Exception {
- if (project == null || !project.exists())
- return;
-
- IResource [] members = project.members();
- for (IResource member : members) {
- if (member.getName().equals(".project") || member.getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
- continue;
- if (member.getName().equals(".settings"))
- continue;
- try {
- member.delete(false, monitor);
- } catch (Throwable e) {
- /*boo*/
- }
- }
+ if (project == null || !project.exists())
+ return;
+
+ IResource[] members = project.members();
+ for (IResource member : members) {
+ if (member.getName().equals(".project") || member.getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
+ continue;
+ if (member.getName().equals(".settings"))
+ continue;
+ try {
+ member.delete(false, monitor);
+ } catch (Throwable e) {
+ /*boo*/
+ }
+ }
}
- protected IFile importFile(String fileName, String contents) throws Exception {
+ protected IFile importFile(String fileName, String contents) throws Exception {
// Obtain file handle
IFile file = project.getProject().getFile(fileName);
-
+
InputStream stream = new ByteArrayInputStream(contents.getBytes());
// Create file input stream
if (file.exists()) {
- file.setContents(stream, false, false, monitor);
+ file.setContents(stream, false, false, monitor);
} else {
IPath path = file.getLocation();
path = path.makeRelativeTo(project.getLocation());
if (path.segmentCount() > 1) {
path = path.removeLastSegments(1);
-
+
for (int i = path.segmentCount() - 1; i >= 0; i--) {
IPath currentPath = path.removeLastSegments(i);
IFolder folder = project.getFolder(currentPath);
@@ -146,11 +146,11 @@ abstract public class BaseTestFramework extends BaseTestCase {
}
}
}
- file.create(stream, false, monitor);
+ file.create(stream, false, monitor);
}
-
+
fileManager.addFile(file);
-
+
return file;
}
}
diff --git a/core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/FailingTest.java b/core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/FailingTest.java
index 1f899c91451..0273378aa07 100644
--- a/core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/FailingTest.java
+++ b/core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/FailingTest.java
@@ -23,52 +23,50 @@ import junit.framework.TestCase;
import junit.framework.TestFailure;
import junit.framework.TestResult;
-
/**
* Wraps a test case to check for its failure.
* @author aniefer
*/
public class FailingTest extends TestCase {
- private TestCase test = null;
- private int bugNum = -1;
-
- public FailingTest( TestCase test, int bugNumber ){
- this.test = test;
- this.bugNum = bugNumber;
- String name= "Failing " + test.getName();
- if (bugNum > 0) {
- name += " [bug " + bugNum + "]";
- }
- setName(name);
- }
-
- public FailingTest( TestCase test ){
- this(test, -1);
- }
- /* (non-Javadoc)
- * @see junit.framework.Test#run(junit.framework.TestResult)
- */
- @Override
- public void run( TestResult result ) {
- result.startTest( this );
-
- TestResult r = new TestResult();
- test.run( r );
- if (r.failureCount() == 1) {
- TestFailure failure= r.failures().nextElement();
- String msg= failure.exceptionMessage();
- if (msg != null && msg.startsWith("Method \"" + test.getName() + "\"")) {
- result.addFailure(this, new AssertionFailedError(msg));
- }
- }
- else if( r.errorCount() == 0 && r.failureCount() == 0 )
- {
- String err = "Unexpected success"; //$NON-NLS-1$
- if( bugNum != -1 )
- err += ", bug #" + bugNum; //$NON-NLS-1$
- result.addFailure( this, new AssertionFailedError( err ) );
- }
-
- result.endTest( this );
- }
+ private TestCase test = null;
+ private int bugNum = -1;
+
+ public FailingTest(TestCase test, int bugNumber) {
+ this.test = test;
+ this.bugNum = bugNumber;
+ String name = "Failing " + test.getName();
+ if (bugNum > 0) {
+ name += " [bug " + bugNum + "]";
+ }
+ setName(name);
+ }
+
+ public FailingTest(TestCase test) {
+ this(test, -1);
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.Test#run(junit.framework.TestResult)
+ */
+ @Override
+ public void run(TestResult result) {
+ result.startTest(this);
+
+ TestResult r = new TestResult();
+ test.run(r);
+ if (r.failureCount() == 1) {
+ TestFailure failure = r.failures().nextElement();
+ String msg = failure.exceptionMessage();
+ if (msg != null && msg.startsWith("Method \"" + test.getName() + "\"")) {
+ result.addFailure(this, new AssertionFailedError(msg));
+ }
+ } else if (r.errorCount() == 0 && r.failureCount() == 0) {
+ String err = "Unexpected success"; //$NON-NLS-1$
+ if (bugNum != -1)
+ err += ", bug #" + bugNum; //$NON-NLS-1$
+ result.addFailure(this, new AssertionFailedError(err));
+ }
+
+ result.endTest(this);
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java
index 1a759e7b87a..6babc089cbd 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java
@@ -71,7 +71,7 @@ public class AutomatedIntegrationSuite extends TestSuite {
final AutomatedIntegrationSuite suite = new AutomatedIntegrationSuite();
// Has intermittent failures
- if (System.getProperty("cdt.skip.known.test.failures") == null) {
+ if (System.getProperty("cdt.skip.known.test.failures") == null) {
suite.addTest(CDescriptorTests.suite());
}
suite.addTest(AllConstexprEvalTests.suite());
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/ProjectCreator.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/ProjectCreator.java
index 8fcd83ffef2..5036344e910 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/ProjectCreator.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/ProjectCreator.java
@@ -38,7 +38,7 @@ import org.eclipse.core.runtime.Path;
* core features. Projects are created from a template stored in a zip file
* These templates are created using the CDT and have the proper natures
* and build settings set up.
- *
+ *
* @author Doug Schaefer
*/
public class ProjectCreator extends TestCase {
@@ -46,7 +46,7 @@ public class ProjectCreator extends TestCase {
private static final byte[] buffer = new byte[512];
private static final IProgressMonitor monitor = new NullProgressMonitor();
- public static IProject createProject(IPath zipPath, String projectName) throws Exception {
+ public static IProject createProject(IPath zipPath, String projectName) throws Exception {
try (ZipFile zipFile = new ZipFile(CTestPlugin.getDefault().getFileInPlugin(zipPath))) {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
@@ -87,22 +87,22 @@ public class ProjectCreator extends TestCase {
public static IProject createCManagedProject(String projectName) throws Exception {
return createProject(new Path("resources/zips/CManaged.zip"), projectName);
}
-
+
public static IProject createCPPManagedProject(String projectName) throws Exception {
return createProject(new Path("resources/zips/CPPManaged.zip"), projectName);
}
-
+
public static IProject createCStandardProject(String projectName) throws Exception {
return createProject(new Path("resources/zips/CStandard.zip"), projectName);
}
-
+
public static IProject createCPPStandardProject(String projectName) throws Exception {
return createProject(new Path("resources/zips/CPPStandard.zip"), projectName);
}
-
+
public void test() throws Exception {
IProject project = createCPPManagedProject("TestProject");
assertNotNull(project);
}
-
+
}
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java
index 74808fc2688..0bea2142883 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java
@@ -91,8 +91,7 @@ public class CModelMock {
}
@Override
- public ICStorageElement getStorage(String id, boolean create)
- throws CoreException {
+ public ICStorageElement getStorage(String id, boolean create) throws CoreException {
return null;
}
@@ -139,20 +138,17 @@ public class CModelMock {
}
@Override
- public void setActiveConfiguration(ICConfigurationDescription cfg)
- throws WriteAccessException {
+ public void setActiveConfiguration(ICConfigurationDescription cfg) throws WriteAccessException {
}
@Override
- public ICConfigurationDescription createConfiguration(String id,
- String name, ICConfigurationDescription base)
+ public ICConfigurationDescription createConfiguration(String id, String name, ICConfigurationDescription base)
throws CoreException, WriteAccessException {
return null;
}
@Override
- public ICConfigurationDescription createConfiguration(
- String buildSystemId, CConfigurationData data)
+ public ICConfigurationDescription createConfiguration(String buildSystemId, CConfigurationData data)
throws CoreException, WriteAccessException {
return null;
}
@@ -168,13 +164,11 @@ public class CModelMock {
}
@Override
- public void removeConfiguration(String name)
- throws WriteAccessException {
+ public void removeConfiguration(String name) throws WriteAccessException {
}
@Override
- public void removeConfiguration(ICConfigurationDescription cfg)
- throws WriteAccessException {
+ public void removeConfiguration(ICConfigurationDescription cfg) throws WriteAccessException {
}
@Override
@@ -203,8 +197,7 @@ public class CModelMock {
}
@Override
- public void setDefaultSettingConfiguration(
- ICConfigurationDescription cfg) {
+ public void setDefaultSettingConfiguration(ICConfigurationDescription cfg) {
}
@Override
@@ -272,8 +265,7 @@ public class CModelMock {
}
@Override
- public ICStorageElement getStorage(String id, boolean create)
- throws CoreException {
+ public ICStorageElement getStorage(String id, boolean create) throws CoreException {
return null;
}
@@ -331,27 +323,23 @@ public class CModelMock {
}
@Override
- public ICResourceDescription getResourceDescription(IPath path,
- boolean exactPath) {
+ public ICResourceDescription getResourceDescription(IPath path, boolean exactPath) {
return null;
}
@Override
- public void removeResourceDescription(ICResourceDescription des)
- throws CoreException, WriteAccessException {
+ public void removeResourceDescription(ICResourceDescription des) throws CoreException, WriteAccessException {
}
@Override
- public ICFileDescription createFileDescription(IPath path,
- ICResourceDescription base) throws CoreException,
- WriteAccessException {
+ public ICFileDescription createFileDescription(IPath path, ICResourceDescription base)
+ throws CoreException, WriteAccessException {
return null;
}
@Override
- public ICFolderDescription createFolderDescription(IPath path,
- ICFolderDescription base) throws CoreException,
- WriteAccessException {
+ public ICFolderDescription createFolderDescription(IPath path, ICFolderDescription base)
+ throws CoreException, WriteAccessException {
return null;
}
@@ -412,9 +400,8 @@ public class CModelMock {
}
@Override
- public ICExternalSetting createExternalSetting(String[] languageIDs,
- String[] contentTypeIds, String[] extensions,
- ICSettingEntry[] entries) throws WriteAccessException {
+ public ICExternalSetting createExternalSetting(String[] languageIDs, String[] contentTypeIds,
+ String[] extensions, ICSettingEntry[] entries) throws WriteAccessException {
return null;
}
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CProjectHelper.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CProjectHelper.java
index 377020fd535..84b74deb905 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CProjectHelper.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CProjectHelper.java
@@ -76,7 +76,7 @@ import org.osgi.framework.Bundle;
*/
public class CProjectHelper {
- private final static IOverwriteQuery OVERWRITE_QUERY= new IOverwriteQuery() {
+ private final static IOverwriteQuery OVERWRITE_QUERY = new IOverwriteQuery() {
@Override
public String queryOverwrite(String file) {
return ALL;
@@ -86,11 +86,12 @@ public class CProjectHelper {
public static ICProject createCProject(final String projectName, String binFolderName) throws CoreException {
return createCCProject(projectName, binFolderName, null);
}
-
+
/**
* Creates a ICProject.
*/
- public static ICProject createCProject(final String projectName, String binFolderName, final String indexerID) throws CoreException {
+ public static ICProject createCProject(final String projectName, String binFolderName, final String indexerID)
+ throws CoreException {
final IWorkspace ws = ResourcesPlugin.getWorkspace();
final ICProject newProject[] = new ICProject[1];
ws.run(new IWorkspaceRunnable() {
@@ -99,7 +100,8 @@ public class CProjectHelper {
IWorkspaceRoot root = ws.getRoot();
IProject project = root.getProject(projectName);
if (indexerID != null) {
- IndexerPreferences.set(project, IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "true");
+ IndexerPreferences.set(project, IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG,
+ "true");
IndexerPreferences.set(project, IndexerPreferences.KEY_INDEXER_ID, indexerID);
}
if (!project.exists()) {
@@ -125,19 +127,20 @@ public class CProjectHelper {
/**
* Adds the default binary parser if no binary parser configured.
- *
+ *
* @param project
- * @throws CoreException
+ * @throws CoreException
*/
public static boolean addDefaultBinaryParser(IProject project) throws CoreException {
- ICConfigExtensionReference[] binaryParsers= CCorePlugin.getDefault().getDefaultBinaryParserExtensions(project);
+ ICConfigExtensionReference[] binaryParsers = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(project);
if (binaryParsers == null || binaryParsers.length == 0) {
- ICProjectDescription desc= CCorePlugin.getDefault().getProjectDescription(project);
+ ICProjectDescription desc = CCorePlugin.getDefault().getProjectDescription(project);
if (desc == null) {
return false;
}
-
- desc.getDefaultSettingConfiguration().create(CCorePlugin.BINARY_PARSER_UNIQ_ID, CCorePlugin.DEFAULT_BINARY_PARSER_UNIQ_ID);
+
+ desc.getDefaultSettingConfiguration().create(CCorePlugin.BINARY_PARSER_UNIQ_ID,
+ CCorePlugin.DEFAULT_BINARY_PARSER_UNIQ_ID);
CCorePlugin.getDefault().setProjectDescription(project, desc);
}
return true;
@@ -146,33 +149,37 @@ public class CProjectHelper {
/**
* Creates a ICProject.
*/
- public static ICProject createNewStyleCProject(final String projectName, final String indexerID) throws CoreException {
+ public static ICProject createNewStyleCProject(final String projectName, final String indexerID)
+ throws CoreException {
return createNewStyleCProject(projectName, indexerID, false);
}
/**
* Creates a ICProject.
*/
- public static ICProject createNewStyleCProject(final String projectName, String providerId, final String indexerID) throws CoreException {
+ public static ICProject createNewStyleCProject(final String projectName, String providerId, final String indexerID)
+ throws CoreException {
return createNewStyleCProject(projectName, providerId, indexerID, false);
}
/**
* Creates a ICProject.
*/
- public static ICProject createNewStyleCProject(final String projectName, final String indexerID, boolean markCreating) throws CoreException {
+ public static ICProject createNewStyleCProject(final String projectName, final String indexerID,
+ boolean markCreating) throws CoreException {
return createNewStyleCProject(projectName, null, indexerID, markCreating);
}
/**
* Creates a ICProject.
*/
- public static ICProject createNewStyleCProject(final String projectName, String cfgProviderId, final String indexerID, final boolean markCreating) throws CoreException {
+ public static ICProject createNewStyleCProject(final String projectName, String cfgProviderId,
+ final String indexerID, final boolean markCreating) throws CoreException {
final IWorkspace ws = ResourcesPlugin.getWorkspace();
final ICProject newProject[] = new ICProject[1];
- if(cfgProviderId == null)
+ if (cfgProviderId == null)
cfgProviderId = TestCfgDataProvider.PROVIDER_ID;
-
+
final String finalCfgProviderId = cfgProviderId;
ws.run(new IWorkspaceRunnable() {
@Override
@@ -192,12 +199,13 @@ public class CProjectHelper {
}
if (!project.hasNature(CProjectNature.C_NATURE_ID)) {
addNatureToProject(project, CProjectNature.C_NATURE_ID, null);
- ICConfigurationDescription prefCfg = CCorePlugin.getDefault().getPreferenceConfiguration(finalCfgProviderId);
+ ICConfigurationDescription prefCfg = CCorePlugin.getDefault()
+ .getPreferenceConfiguration(finalCfgProviderId);
ICProjectDescriptionManager mngr = CCorePlugin.getDefault().getProjectDescriptionManager();
ICProjectDescription projDes = mngr.createProjectDescription(project, false, markCreating);
projDes.createConfiguration(CDataUtil.genId(null), CDataUtil.genId("test"), prefCfg);
mngr.setProjectDescription(project, projDes);
-// CCorePlugin.getDefault().mapCProjectOwner(project, projectId, false);
+ // CCorePlugin.getDefault().mapCProjectOwner(project, projectId, false);
}
addDefaultBinaryParser(project);
newProject[0] = CCorePlugin.getDefault().getCoreModel().create(project);
@@ -207,13 +215,12 @@ public class CProjectHelper {
return newProject[0];
}
-
private static String getMessage(IStatus status) {
StringBuilder message = new StringBuilder("[");
message.append(status.getMessage());
if (status.isMultiStatus()) {
IStatus children[] = status.getChildren();
- for( int i = 0; i < children.length; i++) {
+ for (int i = 0; i < children.length; i++) {
message.append(getMessage(children[i]));
}
}
@@ -225,7 +232,8 @@ public class CProjectHelper {
return createCCProject(projectName, binFolderName, null);
}
- public static ICProject createCCProject(final String projectName, final String binFolderName, final String indexerID) throws CoreException {
+ public static ICProject createCCProject(final String projectName, final String binFolderName,
+ final String indexerID) throws CoreException {
final IWorkspace ws = ResourcesPlugin.getWorkspace();
final ICProject newProject[] = new ICProject[1];
ws.run(new IWorkspaceRunnable() {
@@ -320,21 +328,21 @@ public class CProjectHelper {
InternalCoreModelUtil.addSourceEntry(project, rootFolder, false, null);
} else {
IPathEntry[] entries = cproject.getRawPathEntries();
- ArrayList<IPathEntry> newEntries= new ArrayList<>(entries.length + 1);
-
+ ArrayList<IPathEntry> newEntries = new ArrayList<>(entries.length + 1);
+
for (IPathEntry entry : entries) {
if (entry.getEntryKind() == IPathEntry.CDT_SOURCE && rootPath.equals(entry.getPath())) {
return; // The source root exists already.
}
newEntries.add(entry);
}
-
- IPathEntry newEntry= CoreModel.newSourceEntry(rootPath);
-
- Set<IPathEntry> modified= new HashSet<>();
+
+ IPathEntry newEntry = CoreModel.newSourceEntry(rootPath);
+
+ Set<IPathEntry> modified = new HashSet<>();
InternalCoreModelUtil.addExclusionPatterns(newEntry, newEntries, modified);
newEntries.add(CoreModel.newSourceEntry(rootPath));
-
+
cproject.setRawPathEntries(newEntries.toArray(new IPathEntry[newEntries.size()]), null);
}
}
@@ -416,7 +424,8 @@ public class CProjectHelper {
return null;
}
- public static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
+ public static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor)
+ throws CoreException {
IProjectDescription description = proj.getDescription();
String[] prevNatures = description.getNatureIds();
String[] newNatures = new String[prevNatures.length + 1];
@@ -440,9 +449,9 @@ public class CProjectHelper {
public static void importSourcesFromPlugin(ICProject project, Bundle bundle, String sources) throws CoreException {
try {
- String baseDir= FileLocator.toFileURL(FileLocator.find(bundle, new Path(sources), null)).getFile();
- ImportOperation importOp = new ImportOperation(project.getProject().getFullPath(),
- new File(baseDir), FileSystemStructureProvider.INSTANCE, OVERWRITE_QUERY);
+ String baseDir = FileLocator.toFileURL(FileLocator.find(bundle, new Path(sources), null)).getFile();
+ ImportOperation importOp = new ImportOperation(project.getProject().getFullPath(), new File(baseDir),
+ FileSystemStructureProvider.INSTANCE, OVERWRITE_QUERY);
importOp.setCreateContainerStructure(false);
importOp.run(new NullProgressMonitor());
} catch (Exception e) {
@@ -460,7 +469,7 @@ public class CProjectHelper {
Assert.assertTrue(folder.exists());
Assert.assertTrue(folder.isDirectory());
Assert.assertTrue(folder.canWrite());
-
+
return folder;
}
}
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CTestPlugin.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CTestPlugin.java
index f2ca7384b17..aedc2e2ff74 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CTestPlugin.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CTestPlugin.java
@@ -27,28 +27,28 @@ import org.eclipse.core.runtime.Plugin;
public class CTestPlugin extends Plugin {
public static final String PLUGIN_ID = "org.eclipse.cdt.core.tests";
private static CTestPlugin fgDefault;
-
+
public CTestPlugin() {
super();
- fgDefault= this;
+ fgDefault = this;
}
-
+
public static CTestPlugin getDefault() {
return fgDefault;
}
-
+
public static IWorkspace getWorkspace() {
return ResourcesPlugin.getWorkspace();
}
-
+
public static void enableAutobuild(boolean enable) throws CoreException {
// disable auto build
- IWorkspace workspace= CTestPlugin.getWorkspace();
- IWorkspaceDescription desc= workspace.getDescription();
+ IWorkspace workspace = CTestPlugin.getWorkspace();
+ IWorkspaceDescription desc = workspace.getDescription();
desc.setAutoBuilding(enable);
workspace.setDescription(desc);
}
-
+
public File getFileInPlugin(IPath path) {
try {
return new File(Platform.asLocalURL(find(path)).getFile());
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CTestSetup.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CTestSetup.java
index e2dc768a747..c6dabff31b2 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CTestSetup.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CTestSetup.java
@@ -16,10 +16,8 @@ package org.eclipse.cdt.core.testplugin;
import junit.extensions.TestSetup;
import junit.framework.Test;
-
-
public class CTestSetup extends TestSetup {
-
+
/**
* @deprecated
* Not needed anymore. No added value
@@ -27,8 +25,8 @@ public class CTestSetup extends TestSetup {
@Deprecated
public CTestSetup(Test test) {
super(test);
- }
-
+ }
+
@Override
protected void setUp() throws Exception {
}
@@ -36,8 +34,5 @@ public class CTestSetup extends TestSetup {
@Override
protected void tearDown() throws Exception {
}
-
-
-
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/FileManager.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/FileManager.java
index 5a4401f62b7..2eba23a7e06 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/FileManager.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/FileManager.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -34,25 +34,25 @@ import org.eclipse.core.runtime.CoreException;
*/
public class FileManager {
HashSet<IFile> fileHandles;
-
- public FileManager(){
+
+ public FileManager() {
fileHandles = new HashSet<IFile>();
}
-
- public void addFile(IFile file){
+
+ public void addFile(IFile file) {
fileHandles.add(file);
}
-
- public void closeAllFiles() throws CoreException, InterruptedException{
- int wait= 1;
+
+ public void closeAllFiles() throws CoreException, InterruptedException {
+ int wait = 1;
for (int i = 0; i < 11; i++) {
- for (Iterator iter= fileHandles.iterator(); iter.hasNext();) {
+ for (Iterator iter = fileHandles.iterator(); iter.hasNext();) {
IFile tempFile = (IFile) iter.next();
try {
- if (i==1) {
- tempFile.refreshLocal(IResource.DEPTH_INFINITE,null);
+ if (i == 1) {
+ tempFile.refreshLocal(IResource.DEPTH_INFINITE, null);
}
- tempFile.delete(true,null);
+ tempFile.delete(true, null);
iter.remove();
} catch (CoreException e) {
if (wait > 2000)
@@ -63,7 +63,7 @@ public class FileManager {
if (fileHandles.isEmpty())
return;
Thread.sleep(wait);
- wait*=2;
+ wait *= 2;
}
}
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/Main.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/Main.java
index 384de5b2951..b91171cfd75 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/Main.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/Main.java
@@ -15,7 +15,6 @@ package org.eclipse.cdt.core.testplugin;
// copied from startup.jar. planned to be removed soon
-
import java.io.File;
import java.io.FileFilter;
import java.lang.reflect.InvocationTargetException;
@@ -26,6 +25,7 @@ import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
+
/**
* Startup class for Eclipse. Creates a class loader using
* supplied URL of platform installation, loads and calls
@@ -61,9 +61,9 @@ import java.util.StringTokenizer;
* -password &lt;passwd&gt;: the password for the authorization database
* </dd>
* <dd>
- * -plugins &lt;location&gt;: The arg is a URL pointing to a file which specs the plugin
- * path for the platform. The file is in property file format where the keys are user-defined
- * names and the values are comma separated lists of either explicit paths to plugin.xml
+ * -plugins &lt;location&gt;: The arg is a URL pointing to a file which specs the plugin
+ * path for the platform. The file is in property file format where the keys are user-defined
+ * names and the values are comma separated lists of either explicit paths to plugin.xml
* files or directories containing plugins. (e.g., .../eclipse/plugins).
* </dd>
* <dd>
@@ -156,14 +156,15 @@ public class Main {
/**
* Executes the launch.
- *
+ *
* @return the result of performing the launch
* @param args command-line arguments
* @exception Exception thrown if a problem occurs during the launch
*/
protected Object basicRun(String[] args) throws Exception {
Class clazz = getBootLoader(bootLocation);
- Method method = clazz.getDeclaredMethod("run", new Class[] { String.class, URL.class, String.class, String[].class });
+ Method method = clazz.getDeclaredMethod("run",
+ new Class[] { String.class, URL.class, String.class, String[].class });
try {
return method.invoke(clazz, new Object[] { application, pluginPathLocation, location, args });
} catch (InvocationTargetException e) {
@@ -176,7 +177,7 @@ public class Main {
/**
* Returns the result of converting a list of comma-separated tokens into an array
- *
+ *
* @return the array of string tokens
* @param prop the initial comma-separated string
*/
@@ -198,7 +199,7 @@ public class Main {
* up and run the platform. The given base, if not <code>null</code>,
* is the location of the boot loader code. If the value is <code>null</code>
* then the boot loader is located relative to this class.
- *
+ *
* @return the new boot loader
* @param base the location of the boot loader
*/
@@ -211,7 +212,7 @@ public class Main {
/**
* Returns the <code>URL</code>-based class path describing where the boot classes
* are located when running in development mode.
- *
+ *
* @return the url-based class path
* @param base the base location
* @exception MalformedURLException if a problem occurs computing the class path
@@ -221,7 +222,7 @@ public class Main {
String devBase = base.toExternalForm();
if (!inDevelopmentMode) {
url = new URL(devBase + "boot.jar");
- return new URL[] {url};
+ return new URL[] { url };
}
String[] locations = getArrayFromList(devClassPath);
ArrayList result = new ArrayList(locations.length);
@@ -229,7 +230,7 @@ public class Main {
String spec = devBase + locations[i];
char lastChar = spec.charAt(spec.length() - 1);
if ((spec.endsWith(".jar") || (lastChar == '/' || lastChar == '\\')))
- url = new URL (spec);
+ url = new URL(spec);
else
url = new URL(spec + "/");
//make sure URL exists before adding to path
@@ -239,42 +240,41 @@ public class Main {
url = new URL(devBase + "boot.jar");
if (new java.io.File(url.getFile()).exists())
result.add(url);
- return (URL[])result.toArray(new URL[result.size()]);
+ return (URL[]) result.toArray(new URL[result.size()]);
}
/**
* Returns the <code>URL</code>-based class path describing where the boot classes are located.
- *
+ *
* @return the url-based class path
* @param base the base location
* @exception MalformedURLException if a problem occurs computing the class path
*/
protected URL[] getBootPath(String base) throws MalformedURLException {
URL url = null;
- // if the given location is not null, assume it is correct and use it.
+ // if the given location is not null, assume it is correct and use it.
if (base != null) {
url = new URL(base);
if (debug)
System.out.println("Boot URL: " + url.toExternalForm());
- return new URL[] {url};
+ return new URL[] { url };
}
// Create a URL based on the location of this class' code.
- // strip off jar file and/or last directory to get
+ // strip off jar file and/or last directory to get
// to the directory containing projects.
URL[] result = null;
url = getClass().getProtectionDomain().getCodeSource().getLocation();
String path = url.getFile();
if (path.endsWith(".jar"))
path = path.substring(0, path.lastIndexOf("/"));
- else
- if (path.endsWith("/"))
- path = path.substring(0, path.length() - 1);
+ else if (path.endsWith("/"))
+ path = path.substring(0, path.length() - 1);
if (inVAJ || inVAME) {
int ix = path.lastIndexOf("/");
path = path.substring(0, ix + 1);
path = path + PROJECT_NAME + "/";
url = new URL(url.getProtocol(), url.getHost(), url.getPort(), path);
- result = new URL[] {url};
+ result = new URL[] { url };
} else {
path = searchForPlugins(path);
path = searchForBoot(path);
@@ -285,7 +285,7 @@ public class Main {
if (debug) {
System.out.println("Boot URL:");
for (int i = 0; i < result.length; i++)
- System.out.println(" " + result[i].toExternalForm());
+ System.out.println(" " + result[i].toExternalForm());
}
return result;
}
@@ -294,7 +294,7 @@ public class Main {
* Searches for a plugins root starting at a given location. If one is
* found then this location is returned; otherwise an empty string is
* returned.
- *
+ *
* @return the location where plugins were found, or an empty string
* @param start the location to begin searching at
*/
@@ -305,15 +305,16 @@ public class Main {
if (test.exists())
return test.toString();
path = path.getParentFile();
- path = (path == null || path.length() == 1) ? null : path;
+ path = (path == null || path.length() == 1) ? null : path;
}
return "";
}
+
/**
* Searches for a boot directory starting at a given location. If one
* is found then this location is returned; otherwise an empty string
* is returned.
- *
+ *
* @return the location where plugins were found, or an empty string
* @param start the location to begin searching at
*/
@@ -339,22 +340,22 @@ public class Main {
if (maxVersion == null) {
result = boots[i].getAbsolutePath();
maxVersion = version;
- } else
- if (maxVersion.compareTo(version) == -1) {
- result = boots[i].getAbsolutePath();
- maxVersion = version;
- }
+ } else if (maxVersion.compareTo(version) == -1) {
+ result = boots[i].getAbsolutePath();
+ maxVersion = version;
+ }
}
}
}
if (result == null)
- throw new RuntimeException("Could not find bootstrap code. Check location of boot plug-in or specify -boot.");
+ throw new RuntimeException(
+ "Could not find bootstrap code. Check location of boot plug-in or specify -boot.");
return result.replace(File.separatorChar, '/') + "/";
}
/**
* Returns the update loader for the given boot path.
- *
+ *
* @return the update loader
* @param base the boot path base
* @exception Exception thrown is a problem occurs determining this loader
@@ -377,7 +378,7 @@ public class Main {
* call should use <code>run()</code>.
*
* @see #run
- *
+ *
* @param args the command line arguments
*/
public static void main(String[] args) {
@@ -393,6 +394,7 @@ public class Main {
int exitCode = result instanceof Integer ? ((Integer) result).intValue() : 0;
System.exit(exitCode);
}
+
/**
* Tears down the currently-displayed splash screen.
*/
@@ -407,7 +409,7 @@ public class Main {
/**
* Runs this launcher with the arguments specified in the given string.
- *
+ *
* @param argString the arguments string
* @exception Exception thrown if a problem occurs during launching
*/
@@ -420,7 +422,7 @@ public class Main {
/**
* Processes the command line arguments
- *
+ *
* @return the arguments to pass through to the launched application
* @param args the command line arguments
*/
@@ -439,23 +441,24 @@ public class Main {
}
// check if development mode should be enabled for the entire platform
- // If this is the last arg or there is a following arg (i.e., arg+1 has a leading -),
+ // If this is the last arg or there is a following arg (i.e., arg+1 has a leading -),
// simply enable development mode. Otherwise, assume that that the following arg is
// actually some additional development time class path entries. This will be processed below.
- if (args[i].equalsIgnoreCase(DEV) && ((i + 1 == args.length) || ((i + 1 < args.length) && (args[i + 1].startsWith("-"))))) {
+ if (args[i].equalsIgnoreCase(DEV)
+ && ((i + 1 == args.length) || ((i + 1 < args.length) && (args[i + 1].startsWith("-"))))) {
inDevelopmentMode = true;
// do not mark the arg as found so it will be passed through
continue;
}
- // done checking for args. Remember where an arg was found
+ // done checking for args. Remember where an arg was found
if (found) {
configArgs[configArgIndex++] = i;
continue;
}
// check for args with parameters. If we are at the last argument or if the next one
// has a '-' as the first character, then we can't have an arg with a parm so continue.
- if (i == args.length - 1 || args[i + 1].startsWith("-"))
+ if (i == args.length - 1 || args[i + 1].startsWith("-"))
continue;
String arg = args[++i];
@@ -465,7 +468,7 @@ public class Main {
found = true;
}
- // look for the development mode and class path entries.
+ // look for the development mode and class path entries.
if (args[i - 1].equalsIgnoreCase(DEV)) {
inDevelopmentMode = true;
devClassPath = arg;
@@ -491,7 +494,7 @@ public class Main {
found = true;
}
- // done checking for args. Remember where an arg was found
+ // done checking for args. Remember where an arg was found
if (found) {
configArgs[configArgIndex++] = i - 1;
configArgs[configArgIndex++] = i;
@@ -514,7 +517,7 @@ public class Main {
/**
* Runs the application to be launched.
- *
+ *
* @return the return value from the launched application
* @param args the arguments to pass to the application
* @exception thrown if a problem occurs during launching
@@ -529,7 +532,7 @@ public class Main {
/**
* Performs an update run.
- *
+ *
* @return the return value from the update loader
* @param flag flag to give to the update loader
* @param value value to give to the update loader
@@ -538,7 +541,8 @@ public class Main {
*/
protected Object updateRun(String flag, String value, String[] args) throws Exception {
Class clazz = getUpdateLoader(bootLocation);
- Method method = clazz.getDeclaredMethod("run", new Class[] { String.class, String.class, String.class, String[].class });
+ Method method = clazz.getDeclaredMethod("run",
+ new Class[] { String.class, String.class, String.class, String[].class });
try {
return method.invoke(clazz, new Object[] { flag, value, location, args });
} catch (InvocationTargetException e) {
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/NewMain.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/NewMain.java
index b461d2f475d..18e90e520f2 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/NewMain.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/NewMain.java
@@ -22,22 +22,23 @@ import java.util.List;
import java.util.Properties;
import java.util.StringTokenizer;
-/**
+/**
* Application is responsible for calling core launch api
*/
public class NewMain extends Main {
- private static final String DEFAULT_APPLICATION= "org.eclipse.ui.workbench";
-
- public NewMain(String application, String location, URL pluginPathLocation, String bootLocation, boolean debug) throws IOException {
- this.application= application;
- this.location= location;
- this.pluginPathLocation= pluginPathLocation;
- this.bootLocation= bootLocation;
+ private static final String DEFAULT_APPLICATION = "org.eclipse.ui.workbench";
+
+ public NewMain(String application, String location, URL pluginPathLocation, String bootLocation, boolean debug)
+ throws IOException {
+ this.application = application;
+ this.location = location;
+ this.pluginPathLocation = pluginPathLocation;
+ this.bootLocation = bootLocation;
}
-
+
public static void main(String[] args) {
try {
- String location= getLocationFromProperties("platform");
+ String location = getLocationFromProperties("platform");
new NewMain(DEFAULT_APPLICATION, location, null, null, true).run(args);
} catch (Throwable e) {
System.out.println("Exception launching the Eclipse Platform UI:");
@@ -45,36 +46,36 @@ public class NewMain extends Main {
}
System.exit(0);
}
-
+
/**
* Run this launcher with the arguments specified in the given string.
* This is a short cut method for people running the launcher from
* a scrapbook (i.e., swip-and-doit facility).
*/
public static void main(String argString) throws Exception {
- List<String> list= new ArrayList<String>(5);
- for (StringTokenizer tokens= new StringTokenizer(argString, " "); tokens.hasMoreElements();)
+ List<String> list = new ArrayList<String>(5);
+ for (StringTokenizer tokens = new StringTokenizer(argString, " "); tokens.hasMoreElements();)
list.add((String) tokens.nextElement());
main(list.toArray(new String[list.size()]));
}
-
+
public static String getLocationFromProperties(String key) {
- Properties properties= new Properties();
+ Properties properties = new Properties();
try {
- FileInputStream fis= new FileInputStream(getSettingsFile());
+ FileInputStream fis = new FileInputStream(getSettingsFile());
properties.load(fis);
return properties.getProperty(key);
} catch (IOException e) {
}
return null;
- }
-
+ }
+
private static File getSettingsFile() {
- String home= System.getProperty("user.home");
+ String home = System.getProperty("user.home");
if (home == null) {
System.out.println("Home dir not defined");
return null;
}
- return new File(home, "eclipse-workspaces.properties");
- }
+ return new File(home, "eclipse-workspaces.properties");
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java
index ce47d37316a..f48baeeeae4 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java
@@ -70,7 +70,7 @@ import org.junit.Assert;
*/
public class ResourceHelper {
private final static IProgressMonitor NULL_MONITOR = new NullProgressMonitor();
- private static final int MAX_RETRY= 5;
+ private static final int MAX_RETRY = 5;
private final static Set<String> externalFilesCreated = new HashSet<String>();
private final static Set<IResource> resourcesCreated = new HashSet<IResource>();
@@ -84,7 +84,8 @@ public class ResourceHelper {
* @throws CoreException - if the project can't be created.
* @throws OperationCanceledException...
*/
- public static IProject createCDTProject(String projectName, String pathInWorkspace) throws OperationCanceledException, CoreException {
+ public static IProject createCDTProject(String projectName, String pathInWorkspace)
+ throws OperationCanceledException, CoreException {
return createCDTProject(projectName, pathInWorkspace, null);
}
@@ -98,7 +99,8 @@ public class ResourceHelper {
* @throws CoreException - if the project can't be created.
* @throws OperationCanceledException...
*/
- public static IProject createCDTProject(String projectName, String pathInWorkspace, String[] configurationIds) throws OperationCanceledException, CoreException {
+ public static IProject createCDTProject(String projectName, String pathInWorkspace, String[] configurationIds)
+ throws OperationCanceledException, CoreException {
CCorePlugin cdtCorePlugin = CCorePlugin.getDefault();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
@@ -108,7 +110,7 @@ public class ResourceHelper {
resourcesCreated.add(project);
IProjectDescription prjDescription = workspace.newProjectDescription(projectName);
- if(pathInWorkspace != null) {
+ if (pathInWorkspace != null) {
IPath absoluteLocation = root.getLocation().append(pathInWorkspace);
prjDescription.setLocation(absoluteLocation);
}
@@ -120,7 +122,8 @@ public class ResourceHelper {
project.open(NULL_MONITOR);
ICProjectDescription icPrjDescription = prjDescManager.createProjectDescription(project, false);
- ICConfigurationDescription baseConfiguration = cdtCorePlugin.getPreferenceConfiguration(TestCfgDataProvider.PROVIDER_ID);
+ ICConfigurationDescription baseConfiguration = cdtCorePlugin
+ .getPreferenceConfiguration(TestCfgDataProvider.PROVIDER_ID);
for (String cfgId : configurationIds) {
icPrjDescription.createConfiguration(cfgId, cfgId + " Name", baseConfiguration);
@@ -146,7 +149,8 @@ public class ResourceHelper {
* @throws CoreException - if the project can't be created.
* @throws OperationCanceledException...
*/
- public static IProject createCDTProject(String projectName, URI locationURI) throws OperationCanceledException, CoreException {
+ public static IProject createCDTProject(String projectName, URI locationURI)
+ throws OperationCanceledException, CoreException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
@@ -188,7 +192,7 @@ public class ResourceHelper {
*/
public static IProject createCDTProjectWithConfig(String projectName) throws Exception {
IProject project = createCDTProject(projectName, null,
- new String[] {"org.eclipse.cdt.core.tests.configuration"});
+ new String[] { "org.eclipse.cdt.core.tests.configuration" });
resourcesCreated.add(project);
return project;
}
@@ -201,8 +205,8 @@ public class ResourceHelper {
* @throws CoreException if project could not be created
*/
public static IProject createProject(String projectName) throws CoreException {
- IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
- IProject project= root.getProject(projectName);
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject project = root.getProject(projectName);
if (!project.exists()) {
project.create(NULL_MONITOR);
} else {
@@ -223,8 +227,8 @@ public class ResourceHelper {
* @throws CoreException
*/
public static void deleteProject(String projectName) throws CoreException {
- IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
- IProject project= root.getProject(projectName);
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject project = root.getProject(projectName);
if (project.exists())
delete(project);
}
@@ -247,10 +251,10 @@ public class ResourceHelper {
* @throws CoreException
*/
public static void delete(final IProject project, boolean deleteContent) throws CoreException {
- for (int i= 0; i < MAX_RETRY; i++) {
+ for (int i = 0; i < MAX_RETRY; i++) {
try {
project.delete(deleteContent, true, NULL_MONITOR);
- i= MAX_RETRY;
+ i = MAX_RETRY;
} catch (CoreException x) {
if (i == MAX_RETRY - 1) {
CTestPlugin.getDefault().getLog().log(x.getStatus());
@@ -273,7 +277,7 @@ public class ResourceHelper {
*/
public static IFile createFile(IFile file, String contents) throws CoreException {
if (contents == null) {
- contents= "";
+ contents = "";
}
InputStream inputStream = new ByteArrayInputStream(contents.getBytes());
@@ -341,10 +345,10 @@ public class ResourceHelper {
for (String seg : p.segments()) {
folder = folder.getFolder(new Path(seg));
if (!folder.exists())
- ((IFolder)folder).create(true, true, NULL_MONITOR);
+ ((IFolder) folder).create(true, true, NULL_MONITOR);
}
resourcesCreated.add(folder);
- return (IFolder)folder;
+ return (IFolder) folder;
}
/**
@@ -426,7 +430,7 @@ public class ResourceHelper {
* @throws CoreException if something goes wrong.
*/
public static IFile createEfsFile(IProject project, String fileLink, URI realFile) throws CoreException {
- IFile file= project.getFile(fileLink);
+ IFile file = project.getFile(fileLink);
file.createLink(realFile, IResource.ALLOW_MISSING_LOCAL, NULL_MONITOR);
resourcesCreated.add(file);
return file;
@@ -442,8 +446,9 @@ public class ResourceHelper {
* @throws CoreException if something goes wrong.
* @throws URISyntaxException if wrong URI syntax
*/
- public static IFile createEfsFile(IProject project, String fileLink, String realFile) throws CoreException, URISyntaxException {
- return createEfsFile(project,fileLink,new URI(realFile));
+ public static IFile createEfsFile(IProject project, String fileLink, String realFile)
+ throws CoreException, URISyntaxException {
+ return createEfsFile(project, fileLink, new URI(realFile));
}
/**
@@ -457,7 +462,8 @@ public class ResourceHelper {
* @return file handle.
* @throws CoreException if something goes wrong.
*/
- public static IFolder createLinkedFolder(IProject project, String folderLink, IPath realFolder) throws CoreException {
+ public static IFolder createLinkedFolder(IProject project, String folderLink, IPath realFolder)
+ throws CoreException {
IFolder folder = project.getFolder(folderLink);
folder.createLink(realFolder, IResource.REPLACE | IResource.ALLOW_MISSING_LOCAL, null);
Assert.assertTrue(folder.exists());
@@ -476,7 +482,8 @@ public class ResourceHelper {
* @return file handle.
* @throws CoreException if something goes wrong.
*/
- public static IFolder createLinkedFolder(IProject project, String folderLink, String realFolder) throws CoreException {
+ public static IFolder createLinkedFolder(IProject project, String folderLink, String realFolder)
+ throws CoreException {
return createLinkedFolder(project, folderLink, new Path(realFolder));
}
@@ -490,10 +497,10 @@ public class ResourceHelper {
* @throws CoreException if something goes wrong.
*/
public static IFolder createEfsFolder(IProject project, String folderLink, URI realFolder) throws CoreException {
- IFolder folder= project.getFolder(folderLink);
+ IFolder folder = project.getFolder(folderLink);
if (folder.exists()) {
- Assert.assertEquals("Folder with the same name but different location already exists",
- realFolder, folder.getLocationURI());
+ Assert.assertEquals("Folder with the same name but different location already exists", realFolder,
+ folder.getLocationURI());
return folder;
}
@@ -512,8 +519,9 @@ public class ResourceHelper {
* @throws CoreException if something goes wrong.
* @throws URISyntaxException if wrong URI syntax
*/
- public static IFolder createEfsFolder(IProject project, String folderLink, String realFolder) throws CoreException, URISyntaxException {
- return createEfsFolder(project,folderLink,new URI(realFolder));
+ public static IFolder createEfsFolder(IProject project, String folderLink, String realFolder)
+ throws CoreException, URISyntaxException {
+ return createEfsFolder(project, folderLink, new URI(realFolder));
}
/**
@@ -525,7 +533,7 @@ public class ResourceHelper {
* @return {@code true} if symbolic links are suppoted, {@code false} otherwise.
*/
public static boolean isSymbolicLinkSupported() {
- return ! Platform.getOS().equals(Platform.OS_WIN32);
+ return !Platform.getOS().equals(Platform.OS_WIN32);
}
/**
@@ -583,7 +591,7 @@ public class ResourceHelper {
throw new UnsupportedOperationException("Windows links .lnk are not supported.");
}
- String command[] = { "ln", "-s", realPath.toOSString(), linkPath.toOSString()};
+ String command[] = { "ln", "-s", realPath.toOSString(), linkPath.toOSString() };
Process process = Runtime.getRuntime().exec(command);
// Wait for up to 2.5s...
@@ -597,7 +605,10 @@ public class ResourceHelper {
Thread.interrupted();
}
// Wait for a 500ms before checking again.
- try { Thread.sleep(500); } catch (InterruptedException e) {/*don't care*/}
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ /*don't care*/}
}
Assert.assertTrue("Symbolic link not created, command=[" + command + "]", linkPath.toFile().exists());
}
@@ -686,7 +697,7 @@ public class ResourceHelper {
* This method removes *all* Workspace IResources and any external
* files / folders created with the #createWorkspaceFile #createWorkspaceFolder
* methods in this class
- *
+ *
* @deprecated Use {@link #cleanUp(String)} instead so test name can be printed in diagnostics
*/
public static void cleanUp() throws CoreException, IOException {
@@ -705,7 +716,6 @@ public class ResourceHelper {
joinIndexerBeforeCleanup(testName);
-
// Delete all external files & folders created using ResourceHelper
for (String loc : externalFilesCreated) {
File f = new File(loc);
@@ -764,8 +774,8 @@ public class ResourceHelper {
private static final void deleteRecursive(File f) throws IllegalArgumentException {
// Ensure that the file being deleted is a child of the workspace
// root to prevent anything nasty happening
- if (!f.getAbsolutePath().startsWith(
- ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().getAbsolutePath())) {
+ if (!f.getAbsolutePath()
+ .startsWith(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().getAbsolutePath())) {
throw new IllegalArgumentException("File must exist within the workspace!");
}
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestPluginLauncher.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestPluginLauncher.java
index 1bc21be549f..4a04244e44a 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestPluginLauncher.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestPluginLauncher.java
@@ -19,47 +19,47 @@ import java.net.URL;
* Helper class to launch a test
*/
public class TestPluginLauncher {
- public static final String APP_NAME= "org.eclipse.jdt.ui.tests.app";
-
+ public static final String APP_NAME = "org.eclipse.jdt.ui.tests.app";
+
public static void run(String location, Class<?> testCase, String[] args) {
run(APP_NAME, location, testCase, args);
}
-
+
public static void run(String application, String location, Class<?> testCase, String[] args) {
try {
- String bootLocation= getBootLocation();
- int nArgs= args.length;
- String[] newArgs= new String[4 + nArgs];
- newArgs[0]= testCase.getName();
- for (int i= 0; i < nArgs; i++) {
- newArgs[1 + i]= args[i];
+ String bootLocation = getBootLocation();
+ int nArgs = args.length;
+ String[] newArgs = new String[4 + nArgs];
+ newArgs[0] = testCase.getName();
+ for (int i = 0; i < nArgs; i++) {
+ newArgs[1 + i] = args[i];
}
- newArgs[1 + nArgs]= "-dev";
- newArgs[1 + nArgs + 1]= "bin";
- newArgs[1 + nArgs + 2]= "-debug";
- NewMain newMain= new NewMain(application, location, null, bootLocation, false);
+ newArgs[1 + nArgs] = "-dev";
+ newArgs[1 + nArgs + 1] = "bin";
+ newArgs[1 + nArgs + 2] = "-debug";
+ NewMain newMain = new NewMain(application, location, null, bootLocation, false);
newMain.run(newArgs);
} catch (Exception e) {
e.printStackTrace();
}
}
-
+
public static String getLocationFromProperties(String key) {
return NewMain.getLocationFromProperties(key);
}
-
+
public static String getLocationFromProperties() {
return NewMain.getLocationFromProperties("tests");
}
-
+
public static String getBootLocation() {
- URL url= TestPluginLauncher.class.getResource("TestPluginLauncher.class");
- String s= url.toString();
- int index= s.indexOf("/org.eclipse.jdt.ui.tests");
+ URL url = TestPluginLauncher.class.getResource("TestPluginLauncher.class");
+ String s = url.toString();
+ int index = s.indexOf("/org.eclipse.jdt.ui.tests");
if (index == -1)
throw new IllegalArgumentException();
- s= s.substring(0, index);
- s= s + "/org.eclipse.core.boot/boot.jar";
+ s = s.substring(0, index);
+ s = s + "/org.eclipse.core.boot/boot.jar";
return s;
}
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestProject.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestProject.java
index b5eb1418027..37f15ae1e65 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestProject.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestProject.java
@@ -27,7 +27,7 @@ public class TestProject implements ICOwner {
@Override
public void update(ICDescriptor cDescriptor, String extensionID) throws CoreException {
- if ( extensionID.equals(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID)) {
+ if (extensionID.equals(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID)) {
cDescriptor.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, TestScannerProvider.SCANNER_ID);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestScannerInfo.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestScannerInfo.java
index 846c09eade1..c6af5b26445 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestScannerInfo.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestScannerInfo.java
@@ -27,13 +27,13 @@ public class TestScannerInfo extends ExtendedScannerInfo {
private String[] fMacroFiles;
private Map<String, String> fDefinedSymbols;
- public TestScannerInfo(String[] includes, String[] localIncludes, String[] macroFiles,
- String[] includeFiles, Map<String, String> definedSymbols) {
- fIncludes= includes;
- fLocalIncludes= localIncludes;
- fIncludeFiles= includeFiles;
- fMacroFiles= macroFiles;
- fDefinedSymbols= definedSymbols;
+ public TestScannerInfo(String[] includes, String[] localIncludes, String[] macroFiles, String[] includeFiles,
+ Map<String, String> definedSymbols) {
+ fIncludes = includes;
+ fLocalIncludes = localIncludes;
+ fIncludeFiles = includeFiles;
+ fMacroFiles = macroFiles;
+ fDefinedSymbols = definedSymbols;
}
@Override
@@ -53,11 +53,11 @@ public class TestScannerInfo extends ExtendedScannerInfo {
@Override
public String[] getIncludeFiles() {
- return fIncludeFiles == null ? EMPTY: fIncludeFiles;
+ return fIncludeFiles == null ? EMPTY : fIncludeFiles;
}
@Override
public String[] getMacroFiles() {
- return fMacroFiles == null ? EMPTY: fMacroFiles;
+ return fMacroFiles == null ? EMPTY : fMacroFiles;
}
}
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestScannerProvider.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestScannerProvider.java
index 608f0af5c2a..a3905c9aad8 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestScannerProvider.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestScannerProvider.java
@@ -32,7 +32,7 @@ public class TestScannerProvider extends AbstractCExtension implements IScannerI
public final static String SCANNER_ID = CTestPlugin.PLUGIN_ID + ".TestScanner";
public static void clear() {
- sIncludes= sLocalIncludes= sIncludeFiles= sMacroFiles= null;
+ sIncludes = sLocalIncludes = sIncludeFiles = sMacroFiles = null;
sDefinedSymbols.clear();
}
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/AccessibilityTestPass.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/AccessibilityTestPass.java
index 6d2757676f5..c779122c245 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/AccessibilityTestPass.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/AccessibilityTestPass.java
@@ -13,13 +13,11 @@
*******************************************************************************/
package org.eclipse.cdt.core.testplugin.util;
-
import java.util.ArrayList;
-
public class AccessibilityTestPass implements IDialogTestPass {
private static final int CHECKLIST_SIZE = 5;
-
+
/**
* @see IDialogTestPass#title()
*/
@@ -27,6 +25,7 @@ public class AccessibilityTestPass implements IDialogTestPass {
public String title() {
return "Test Pass: Accessibility";
}
+
/**
* @see IDialogTestPass#description()
*/
@@ -34,13 +33,15 @@ public class AccessibilityTestPass implements IDialogTestPass {
public String description() {
return "Verify the accessibility of the dialogs.";
}
+
/**
* @see IDialogTestPass#label()
*/
@Override
public String label() {
return "&Accessibility";
- }
+ }
+
/**
* @see IDialogTestPass#checkListTexts()
*/
@@ -54,6 +55,7 @@ public class AccessibilityTestPass implements IDialogTestPass {
list.add("&5) selectable widgets can be selected using the spacebar.");
return list;
}
+
/**
* @see IDialogTestPass#failureTexts()
* Size of the return array must be the same size as the checkListTexts'
@@ -69,6 +71,7 @@ public class AccessibilityTestPass implements IDialogTestPass {
failureText[4] = "Some widgets cannot be selected using the spacebar.";
return failureText;
}
+
/**
* @see IDialogTestPass#queryText()
*/
@@ -76,6 +79,7 @@ public class AccessibilityTestPass implements IDialogTestPass {
public String queryText() {
return "Is the accessibility of the dialog acceptable?";
}
+
/**
* @see IDialogTestPass#getID()
*/
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java
index 2b529655fb0..58dcc367bd7 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java
@@ -63,29 +63,29 @@ public class BaseTestCase extends TestCase {
private static final String INDEXER_TIMEOUT_PROPERTY = "indexer.timeout";
/**
* Indexer timeout used by tests. To avoid this timeout expiring during debugging add
- * -Dindexer.timeout=some_large_number to VM arguments of the test launch configuration.
+ * -Dindexer.timeout=some_large_number to VM arguments of the test launch configuration.
*/
- protected static final int INDEXER_TIMEOUT_SEC =
- Integer.parseInt(System.getProperty(INDEXER_TIMEOUT_PROPERTY, DEFAULT_INDEXER_TIMEOUT_SEC));
- protected static final int INDEXER_TIMEOUT_MILLISEC= INDEXER_TIMEOUT_SEC * 1000;
-
+ protected static final int INDEXER_TIMEOUT_SEC = Integer
+ .parseInt(System.getProperty(INDEXER_TIMEOUT_PROPERTY, DEFAULT_INDEXER_TIMEOUT_SEC));
+ protected static final int INDEXER_TIMEOUT_MILLISEC = INDEXER_TIMEOUT_SEC * 1000;
+
/**
* The GCC version to emulate when running tests.
* We emulate the latest version whose extensions we support.
*/
protected static final int GCC_MAJOR_VERSION_FOR_TESTS = 8;
protected static final int GCC_MINOR_VERSION_FOR_TESTS = 1;
-
+
/**
* This provides the systems new line separator. Use this if you do String comparisons in tests
* instead of hard coding '\n' or '\r\n' respectively.
*/
protected static final String NL = System.getProperty("line.separator");
-
+
private boolean fExpectFailure;
private int fBugNumber;
private int fExpectedLoggedNonOK;
- private Deque<File> filesToDeleteOnTearDown= new ArrayDeque<>();
+ private Deque<File> filesToDeleteOnTearDown = new ArrayDeque<>();
public BaseTestCase() {
super();
@@ -102,9 +102,9 @@ public class BaseTestCase extends TestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- CPPASTNameBase.sAllowRecursionBindings= false;
- CPPASTNameBase.sAllowNameComputation= false;
- CModelListener.sSuppressUpdateOfLastRecentlyUsed= true;
+ CPPASTNameBase.sAllowRecursionBindings = false;
+ CPPASTNameBase.sAllowNameComputation = false;
+ CModelListener.sSuppressUpdateOfLastRecentlyUsed = true;
}
@Override
@@ -128,8 +128,7 @@ public class BaseTestCase extends TestCase {
}
protected File nonExistentTempFile(String prefix, String suffix) {
- File file= new File(System.getProperty("java.io.tmpdir"),
- prefix + System.currentTimeMillis() + suffix);
+ File file = new File(System.getProperty("java.io.tmpdir"), prefix + System.currentTimeMillis() + suffix);
filesToDeleteOnTearDown.add(file);
return file;
}
@@ -139,8 +138,8 @@ public class BaseTestCase extends TestCase {
}
protected static TestSuite suite(Class clazz, String failingTestPrefix) {
- TestSuite suite= new TestSuite(clazz);
- Test failing= getFailingTests(clazz, failingTestPrefix);
+ TestSuite suite = new TestSuite(clazz);
+ Test failing = getFailingTests(clazz, failingTestPrefix);
if (failing != null) {
suite.addTest(failing);
}
@@ -148,15 +147,15 @@ public class BaseTestCase extends TestCase {
}
private static Test getFailingTests(Class clazz, String prefix) {
- TestSuite suite= new TestSuite("Failing Tests");
- HashSet names= new HashSet();
- Class superClass= clazz;
+ TestSuite suite = new TestSuite("Failing Tests");
+ HashSet names = new HashSet();
+ Class superClass = clazz;
while (Test.class.isAssignableFrom(superClass) && !TestCase.class.equals(superClass)) {
- Method[] methods= superClass.getDeclaredMethods();
+ Method[] methods = superClass.getDeclaredMethods();
for (Method method : methods) {
addFailingMethod(suite, method, names, clazz, prefix);
}
- superClass= superClass.getSuperclass();
+ superClass = superClass.getSuperclass();
}
if (suite.countTestCases() == 0) {
return null;
@@ -165,7 +164,7 @@ public class BaseTestCase extends TestCase {
}
private static void addFailingMethod(TestSuite suite, Method m, Set names, Class clazz, String prefix) {
- String name= m.getName();
+ String name = m.getName();
if (!names.add(name)) {
return;
}
@@ -176,10 +175,10 @@ public class BaseTestCase extends TestCase {
return;
}
if (Modifier.isPublic(m.getModifiers())) {
- Class[] parameters= m.getParameterTypes();
- Class returnType= m.getReturnType();
+ Class[] parameters = m.getParameterTypes();
+ Class returnType = m.getReturnType();
if (parameters.length == 0 && returnType.equals(Void.TYPE)) {
- Test test= TestSuite.createTest(clazz, name);
+ Test test = TestSuite.createTest(clazz, name);
((BaseTestCase) test).setExpectFailure(0);
suite.addTest(test);
}
@@ -188,8 +187,8 @@ public class BaseTestCase extends TestCase {
@Override
public void runBare() throws Throwable {
- final List<IStatus> statusLog= Collections.synchronizedList(new ArrayList());
- ILogListener logListener= new ILogListener() {
+ final List<IStatus> statusLog = Collections.synchronizedList(new ArrayList());
+ ILogListener logListener = new ILogListener() {
@Override
public void logging(IStatus status, String plugin) {
if (!status.isOK() && status.getSeverity() != IStatus.INFO) {
@@ -210,30 +209,32 @@ public class BaseTestCase extends TestCase {
corePlugin.getLog().addLogListener(logListener);
}
- Throwable testThrowable= null;
+ Throwable testThrowable = null;
try {
try {
super.runBare();
} catch (Throwable e) {
- testThrowable= e;
+ testThrowable = e;
}
if (statusLog.size() != fExpectedLoggedNonOK) {
- StringBuilder msg= new StringBuilder("Expected number (").append(fExpectedLoggedNonOK).append(") of ");
- msg.append("Non-OK status objects in log differs from actual (").append(statusLog.size()).append(").\n");
- Throwable cause= null;
+ StringBuilder msg = new StringBuilder("Expected number (").append(fExpectedLoggedNonOK).append(") of ");
+ msg.append("Non-OK status objects in log differs from actual (").append(statusLog.size())
+ .append(").\n");
+ Throwable cause = null;
if (!statusLog.isEmpty()) {
synchronized (statusLog) {
for (IStatus status : statusLog) {
- IStatus[] ss= {status};
- ss= status instanceof MultiStatus ? ((MultiStatus) status).getChildren() : ss;
+ IStatus[] ss = { status };
+ ss = status instanceof MultiStatus ? ((MultiStatus) status).getChildren() : ss;
for (IStatus s : ss) {
msg.append('\t').append(s.getMessage()).append(' ');
- Throwable t= s.getException();
- cause= cause != null ? cause : t;
+ Throwable t = s.getException();
+ cause = cause != null ? cause : t;
if (t != null) {
- msg.append(t.getMessage() != null ? t.getMessage() : t.getClass().getCanonicalName());
+ msg.append(
+ t.getMessage() != null ? t.getMessage() : t.getClass().getCanonicalName());
}
msg.append("\n");
@@ -241,8 +242,8 @@ public class BaseTestCase extends TestCase {
}
}
}
- cause= cause != null ? cause : testThrowable;
- AssertionFailedError afe= new AssertionFailedError(msg.toString());
+ cause = cause != null ? cause : testThrowable;
+ AssertionFailedError afe = new AssertionFailedError(msg.toString());
afe.initCause(cause);
throw afe;
}
@@ -256,57 +257,57 @@ public class BaseTestCase extends TestCase {
throw testThrowable;
}
- @Override
+ @Override
public void run(TestResult result) {
- if (!fExpectFailure || Boolean.parseBoolean(System.getProperty("SHOW_EXPECTED_FAILURES"))) {
- super.run(result);
- return;
- }
-
- result.startTest(this);
-
- TestResult r = new TestResult();
- super.run(r);
- if (r.failureCount() == 1) {
- TestFailure failure= r.failures().nextElement();
- String msg= failure.exceptionMessage();
- if (msg != null && msg.startsWith("Method \"" + getName() + "\"")) {
- result.addFailure(this, new AssertionFailedError(msg));
- }
- } else if (r.errorCount() == 0 && r.failureCount() == 0) {
- String err = "Unexpected success of " + getName();
- if (fBugNumber > 0) {
- err += ", bug #" + fBugNumber;
- }
- result.addFailure(this, new AssertionFailedError(err));
- }
-
- result.endTest(this);
- }
-
- public void setExpectFailure(int bugNumber) {
- fExpectFailure= true;
- fBugNumber= bugNumber;
- }
-
- /**
- * The last value passed to this method in the body of a testXXX method
- * will be used to determine whether or not the presence of non-OK status objects
- * in the log should fail the test. If the logged number of non-OK status objects
- * differs from the last value passed, the test is failed. If this method is not called
- * at all, the expected number defaults to zero.
- * @param count the expected number of logged error and warning messages
- */
- public void setExpectedNumberOfLoggedNonOKStatusObjects(int count) {
- fExpectedLoggedNonOK= count;
- }
-
- /**
- * Some test steps need synchronizing against a CModel event. This class
- * is a very basic means of doing that.
- */
- static protected class ModelJoiner implements IElementChangedListener {
- private final boolean[] changed= new boolean[1];
+ if (!fExpectFailure || Boolean.parseBoolean(System.getProperty("SHOW_EXPECTED_FAILURES"))) {
+ super.run(result);
+ return;
+ }
+
+ result.startTest(this);
+
+ TestResult r = new TestResult();
+ super.run(r);
+ if (r.failureCount() == 1) {
+ TestFailure failure = r.failures().nextElement();
+ String msg = failure.exceptionMessage();
+ if (msg != null && msg.startsWith("Method \"" + getName() + "\"")) {
+ result.addFailure(this, new AssertionFailedError(msg));
+ }
+ } else if (r.errorCount() == 0 && r.failureCount() == 0) {
+ String err = "Unexpected success of " + getName();
+ if (fBugNumber > 0) {
+ err += ", bug #" + fBugNumber;
+ }
+ result.addFailure(this, new AssertionFailedError(err));
+ }
+
+ result.endTest(this);
+ }
+
+ public void setExpectFailure(int bugNumber) {
+ fExpectFailure = true;
+ fBugNumber = bugNumber;
+ }
+
+ /**
+ * The last value passed to this method in the body of a testXXX method
+ * will be used to determine whether or not the presence of non-OK status objects
+ * in the log should fail the test. If the logged number of non-OK status objects
+ * differs from the last value passed, the test is failed. If this method is not called
+ * at all, the expected number defaults to zero.
+ * @param count the expected number of logged error and warning messages
+ */
+ public void setExpectedNumberOfLoggedNonOKStatusObjects(int count) {
+ fExpectedLoggedNonOK = count;
+ }
+
+ /**
+ * Some test steps need synchronizing against a CModel event. This class
+ * is a very basic means of doing that.
+ */
+ static protected class ModelJoiner implements IElementChangedListener {
+ private final boolean[] changed = new boolean[1];
public ModelJoiner() {
CoreModel.getDefault().addElementChangedListener(this);
@@ -314,14 +315,14 @@ public class BaseTestCase extends TestCase {
public void clear() {
synchronized (changed) {
- changed[0]= false;
+ changed[0] = false;
changed.notifyAll();
}
}
public void join() throws CoreException {
try {
- synchronized(changed) {
+ synchronized (changed) {
while (!changed[0]) {
changed.wait();
}
@@ -342,13 +343,13 @@ public class BaseTestCase extends TestCase {
return;
synchronized (changed) {
- changed[0]= true;
+ changed[0] = true;
changed.notifyAll();
}
}
}
- public static void waitForIndexer(ICProject project) throws InterruptedException {
+ public static void waitForIndexer(ICProject project) throws InterruptedException {
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_REFRESH, null);
assertTrue(CCoreInternals.getPDOMManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm()));
}
@@ -358,7 +359,7 @@ public class BaseTestCase extends TestCase {
}
// Assertion helpers
-
+
protected static <T> T assertInstance(Object o, Class<T> clazz, Class... cs) {
assertNotNull("Expected object of " + clazz.getName() + " but got a null value", o);
assertTrue("Expected " + clazz.getName() + " but got " + o.getClass().getName(), clazz.isInstance(o));
@@ -368,13 +369,13 @@ public class BaseTestCase extends TestCase {
}
return clazz.cast(o);
}
-
+
protected static void assertValue(IValue value, long expectedValue) {
assertNotNull(value);
assertTrue(value.numberValue() instanceof Long);
assertEquals(expectedValue, value.numberValue().longValue());
}
-
+
protected static void assertVariableValue(IVariable var, long expectedValue) {
assertValue(var.getInitialValue(), expectedValue);
}
@@ -382,7 +383,7 @@ public class BaseTestCase extends TestCase {
protected static String formatForPrinting(IASTName name) {
String signature = name.getRawSignature();
boolean saved = CPPASTNameBase.sAllowNameComputation;
- CPPASTNameBase.sAllowNameComputation = true;
+ CPPASTNameBase.sAllowNameComputation = true;
try {
String nameStr = name.toString();
if (signature.replace(" ", "").equals(nameStr.replace(" ", "")))
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/ExpectedStrings.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/ExpectedStrings.java
index 088a8d94443..3e04b82265a 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/ExpectedStrings.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/ExpectedStrings.java
@@ -13,8 +13,8 @@
*******************************************************************************/
package org.eclipse.cdt.core.testplugin.util;
-
import java.util.Stack;
+
/**
* @author Peter Graves
*
@@ -23,11 +23,11 @@ import java.util.Stack;
*/
public class ExpectedStrings {
- public String [] expStrings;
- private boolean[] foundStrings;
- private Stack extraStrings; /* A stack of the unecpected strings we
- * recieved
- */
+ public String[] expStrings;
+ private boolean[] foundStrings;
+ private Stack extraStrings; /* A stack of the unecpected strings we
+ * recieved
+ */
private boolean extra;
/**
@@ -35,75 +35,81 @@ public class ExpectedStrings {
*/
public ExpectedStrings() {
}
+
/**
* Constructor for ExpectedStrings that accepts a list of strings that
* we expect to get.
*/
public ExpectedStrings(String[] values) {
int x;
- expStrings=new String[values.length];
- for (x=0;x<values.length;x++) {
- expStrings[x]=values[x];
+ expStrings = new String[values.length];
+ for (x = 0; x < values.length; x++) {
+ expStrings[x] = values[x];
}
- foundStrings=new boolean[values.length];
- for (x=0;x<values.length;x++) {
- foundStrings[x]=false;
+ foundStrings = new boolean[values.length];
+ for (x = 0; x < values.length; x++) {
+ foundStrings[x] = false;
}
- extraStrings=new Stack();
- extra=false;
+ extraStrings = new Stack();
+ extra = false;
}
-
+
public int foundString(String current) {
int x;
- for (x=0;x<expStrings.length;x++) {
+ for (x = 0; x < expStrings.length; x++) {
if (current.equals(expStrings[x])) {
- foundStrings[x]=true;
- return(0);
+ foundStrings[x] = true;
+ return (0);
}
}
/* If we arrive here, the strings was not found, so this is
* and extra string
*/
- extraStrings.push(current);
- extra=true;
- return(1);
+ extraStrings.push(current);
+ extra = true;
+ return (1);
}
+
public int getNum(String name) {
int x;
- for (x=0;x<expStrings.length;x++) {
+ for (x = 0; x < expStrings.length; x++) {
if (name.equals(expStrings[x]))
- return(x);
+ return (x);
}
- return(-1);
+ return (-1);
}
+
public boolean gotAll() {
int x;
- for (x=0;x<expStrings.length;x++) {
- if (foundStrings[x]==false)
- return(false);
+ for (x = 0; x < expStrings.length; x++) {
+ if (foundStrings[x] == false)
+ return (false);
}
- return(true);
+ return (true);
}
+
public boolean gotExtra() {
- return(extra);
+ return (extra);
}
+
public String getMissingString() {
int x;
String missing = "Missing elements: ";
- for (x=0;x<expStrings.length;x++) {
- if (foundStrings[x]==false)
- missing+=expStrings[x];
- missing+=" ";
+ for (x = 0; x < expStrings.length; x++) {
+ if (foundStrings[x] == false)
+ missing += expStrings[x];
+ missing += " ";
}
- return(missing);
+ return (missing);
}
+
public String getExtraString() {
- String extra= "Extra elements: ";
+ String extra = "Extra elements: ";
while (!extraStrings.empty()) {
- extra+=extraStrings.pop();
- extra+=" ";
+ extra += extraStrings.pop();
+ extra += " ";
}
- return(extra);
+ return (extra);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/ExpectedStringsTests.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/ExpectedStringsTests.java
index a79115b09ed..7297d2cb807 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/ExpectedStringsTests.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/ExpectedStringsTests.java
@@ -30,43 +30,43 @@ public class ExpectedStringsTests extends TestCase {
public ExpectedStringsTests(String name) {
super(name);
}
- /**
- * Sets up the test fixture.
- *
- * Called before every test case method.
- *
- * Example code test the packages in the project
- * "com.qnx.tools.ide.cdt.core"
- */
- @Override
+
+ /**
+ * Sets up the test fixture.
+ *
+ * Called before every test case method.
+ *
+ * Example code test the packages in the project
+ * "com.qnx.tools.ide.cdt.core"
+ */
+ @Override
protected void setUp() {
+ }
- }
-
- /**
- * Tears down the test fixture.
- *
- * Called after every test case method.
- */
- @Override
+ /**
+ * Tears down the test fixture.
+ *
+ * Called after every test case method.
+ */
+ @Override
protected void tearDown() {
- // release resources here and clean-up
- }
-
- public static TestSuite suite() {
- return new TestSuite(ExpectedStringsTests.class);
- }
-
- public static void main (String[] args){
- junit.textui.TestRunner.run(suite());
- }
+ // release resources here and clean-up
+ }
+
+ public static TestSuite suite() {
+ return new TestSuite(ExpectedStringsTests.class);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
public void testGotAll() {
ExpectedStrings myExp;
- String[] strings= {"stringOne", "stringTwo", "stringThree" };
-
- myExp=new ExpectedStrings(strings);
+ String[] strings = { "stringOne", "stringTwo", "stringThree" };
+
+ myExp = new ExpectedStrings(strings);
assertTrue("No found strings", !myExp.gotAll());
myExp.foundString("stringOne");
assertTrue("1 found strings", !myExp.gotAll());
@@ -74,14 +74,14 @@ public class ExpectedStringsTests extends TestCase {
assertTrue("2 found strings", !myExp.gotAll());
myExp.foundString("stringThree");
assertTrue("All found strings", myExp.gotAll());
-
-
+
}
- public void testGotExtra () {
+
+ public void testGotExtra() {
ExpectedStrings myExp;
- String[] strings= {"stringOne", "stringTwo", "stringThree" };
-
- myExp=new ExpectedStrings(strings);
+ String[] strings = { "stringOne", "stringTwo", "stringThree" };
+
+ myExp = new ExpectedStrings(strings);
assertTrue("No found strings", !myExp.gotExtra());
myExp.foundString("stringOne");
assertTrue("1 found strings", !myExp.gotExtra());
@@ -91,15 +91,14 @@ public class ExpectedStringsTests extends TestCase {
assertTrue("All found strings", !myExp.gotExtra());
myExp.foundString("Somerandomestring");
assertTrue("Extra String", myExp.gotExtra());
-
+
}
-
- public void testGetMissingString()
- {
+
+ public void testGetMissingString() {
ExpectedStrings myExp;
- String[] strings= {"stringOne", "stringTwo", "stringThree" };
-
- myExp=new ExpectedStrings(strings);
+ String[] strings = { "stringOne", "stringTwo", "stringThree" };
+
+ myExp = new ExpectedStrings(strings);
assertNotNull(myExp.getMissingString());
myExp.foundString("stringOne");
assertNotNull(myExp.getMissingString());
@@ -109,13 +108,12 @@ public class ExpectedStringsTests extends TestCase {
assertNotNull(myExp.getMissingString());
}
-
- public void testGetExtraString()
- {
+
+ public void testGetExtraString() {
ExpectedStrings myExp;
- String[] strings= {"stringOne", "stringTwo", "stringThree" };
-
- myExp=new ExpectedStrings(strings);
+ String[] strings = { "stringOne", "stringTwo", "stringThree" };
+
+ myExp = new ExpectedStrings(strings);
assertNotNull(myExp.getExtraString());
myExp.foundString("stringOnenot");
assertNotNull(myExp.getMissingString());
@@ -124,6 +122,4 @@ public class ExpectedStringsTests extends TestCase {
}
-
-
}
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/FailureDialog.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/FailureDialog.java
index 27ebc7942f1..c89c37e4257 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/FailureDialog.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/FailureDialog.java
@@ -12,7 +12,7 @@
* IBM - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.testplugin.util;
-
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
@@ -34,13 +34,14 @@ public class FailureDialog extends Dialog {
private String _log;
private int SIZING_TEXT_WIDTH = 400;
private int SIZING_TEXT_HEIGHT = 200;
-
+
/**
* Constructor for FailureDialog
*/
public FailureDialog(Shell parentShell) {
super(parentShell);
}
+
/* (non-Javadoc)
* Method declared on Window.
*/
@@ -49,6 +50,7 @@ public class FailureDialog extends Dialog {
super.configureShell(newShell);
newShell.setText("Dialog Test Failed");
}
+
/* (non-Javadoc)
* Method declared on Dialog.
*/
@@ -57,35 +59,38 @@ public class FailureDialog extends Dialog {
createButton(parent, IDialogConstants.OK_ID, "&OK", true);
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}
+
/* (non-Javadoc)
* Method declared on Dialog.
*/
@Override
protected Control createDialogArea(Composite parent) {
// page group
- Composite composite = (Composite)super.createDialogArea(parent);
- composite.setSize( composite.computeSize(SWT.DEFAULT, SWT.DEFAULT) );
-
+ Composite composite = (Composite) super.createDialogArea(parent);
+ composite.setSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+
Label label = new Label(composite, SWT.WRAP);
label.setText("&Enter a note regarding the failure:");
-
+
_text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
- _text.setFont( JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT) );
+ _text.setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
GridData data = new GridData(GridData.FILL_BOTH);
data.widthHint = SIZING_TEXT_WIDTH;
data.heightHint = SIZING_TEXT_HEIGHT;
_text.setLayoutData(data);
-
+
return composite;
}
+
/* (non-Javadoc)
* Method declared on Dialog.
*/
@Override
- protected void okPressed() {
+ protected void okPressed() {
_log = _text.getText();
super.okPressed();
}
+
/*
* @return String the text contained in the input area of
* the dialog.
@@ -97,6 +102,7 @@ public class FailureDialog extends Dialog {
return _log;
}
}
+
/*
* Sets the text of the input area. This should only be
* called to set the initial text so only call before invoking
@@ -105,6 +111,7 @@ public class FailureDialog extends Dialog {
void setText(String text) {
_text.setText(text);
}
+
/*
* Returns a string representation of this class which
* the text contained in the input area of the dialog.
@@ -114,5 +121,3 @@ public class FailureDialog extends Dialog {
return getText();
}
}
-
-
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/FocusTestPass.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/FocusTestPass.java
index 5562cba5f35..c3d0743088d 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/FocusTestPass.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/FocusTestPass.java
@@ -29,6 +29,7 @@ public class FocusTestPass implements IDialogTestPass {
public String title() {
return "Test Pass: Initial Focus";
}
+
/**
* @see IDialogTestPass#description()
*/
@@ -36,13 +37,15 @@ public class FocusTestPass implements IDialogTestPass {
public String description() {
return "Verify the initial focus of the dialogs.";
}
+
/**
* @see IDialogTestPass#label()
*/
@Override
public String label() {
return "&Initial Focus";
- }
+ }
+
/**
* @see IDialogTestPass#checkListTexts()
*/
@@ -52,6 +55,7 @@ public class FocusTestPass implements IDialogTestPass {
list.add("&1) the initial focus is appropriate.");
return list;
}
+
/**
* @see IDialogTestPass#failureTexts()
* Size of the return array must be the same size as the checkListTexts'
@@ -63,6 +67,7 @@ public class FocusTestPass implements IDialogTestPass {
failureText[0] = "The initial focus is inappropriate.";
return failureText;
}
+
/**
* @see IDialogTestPass#queryText()
*/
@@ -70,6 +75,7 @@ public class FocusTestPass implements IDialogTestPass {
public String queryText() {
return "Is the initial focus of the dialog correct?";
}
+
/**
* @see IDialogTestPass#getID()
*/
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/IDialogTestPass.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/IDialogTestPass.java
index 278c8045b3d..e97b25e5491 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/IDialogTestPass.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/IDialogTestPass.java
@@ -61,5 +61,3 @@ public interface IDialogTestPass {
*/
public int getID();
}
-
-
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/OneSourceMultipleHeadersTestCase.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/OneSourceMultipleHeadersTestCase.java
index 53fa8c2f500..75d45a4e5af 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/OneSourceMultipleHeadersTestCase.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/OneSourceMultipleHeadersTestCase.java
@@ -48,8 +48,7 @@ public class OneSourceMultipleHeadersTestCase extends BaseTestCase {
this(null, testSourceReader, cpp);
}
- public OneSourceMultipleHeadersTestCase(String name, TestSourceReader testSourceReader,
- boolean cpp) {
+ public OneSourceMultipleHeadersTestCase(String name, TestSourceReader testSourceReader, boolean cpp) {
super(name);
this.testSourceReader = testSourceReader;
this.cpp = cpp;
@@ -81,15 +80,18 @@ public class OneSourceMultipleHeadersTestCase extends BaseTestCase {
}
protected void setUp(boolean generateIncludeStatements) throws Exception {
- cproject = cpp ?
- CProjectHelper.createCCProject(getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER) :
- CProjectHelper.createCProject(getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
+ cproject = cpp
+ ? CProjectHelper.createCCProject(getName() + System.currentTimeMillis(), "bin",
+ IPDOMManager.ID_NO_INDEXER)
+ : CProjectHelper.createCProject(getName() + System.currentTimeMillis(), "bin",
+ IPDOMManager.ID_NO_INDEXER);
testData = testSourceReader.getContentsForTest(getName());
if (testData.length > 0) {
for (int i = 0; i < testData.length - 1; i++) {
String filename = String.format("header%d.h", i + 1);
- IFile file = TestSourceReader.createFile(cproject.getProject(), new Path(filename), testData[i].toString());
+ IFile file = TestSourceReader.createFile(cproject.getProject(), new Path(filename),
+ testData[i].toString());
CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
}
}
@@ -103,15 +105,16 @@ public class OneSourceMultipleHeadersTestCase extends BaseTestCase {
testData[testData.length - 1].insert(0, buf);
}
- IFile cppfile= TestSourceReader.createFile(cproject.getProject(), new Path("source.c" + (cpp ? "pp" : "")), getAstSource());
- waitForIndexer(cproject);
+ IFile cppfile = TestSourceReader.createFile(cproject.getProject(), new Path("source.c" + (cpp ? "pp" : "")),
+ getAstSource());
+ waitForIndexer(cproject);
if (DEBUG) {
System.out.println("Project PDOM: " + getName());
((PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject)).accept(new PDOMPrettyPrinter());
}
- index= CCorePlugin.getIndexManager().getIndex(cproject);
+ index = CCorePlugin.getIndexManager().getIndex(cproject);
index.acquireReadLock();
ast = TestSourceReader.createIndexBasedAST(index, cproject, cppfile);
@@ -123,7 +126,8 @@ public class OneSourceMultipleHeadersTestCase extends BaseTestCase {
index.releaseReadLock();
}
if (cproject != null) {
- cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
+ cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
}
}
}
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java
index d7859af4fa7..4111030de09 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java
@@ -113,8 +113,8 @@ public class TestSourceReader {
* test in the source code.
* @throws IOException
*/
- public static StringBuilder[] getContentsForTest(Bundle bundle, String srcRoot, Class clazz,
- final String testName, int numSections) throws IOException {
+ public static StringBuilder[] getContentsForTest(Bundle bundle, String srcRoot, Class clazz, final String testName,
+ int numSections) throws IOException {
// Walk up the class inheritance chain until we find the test method.
try {
while (clazz.getMethod(testName).getDeclaringClass() != clazz) {
@@ -131,7 +131,7 @@ public class TestSourceReader {
String fqn = clazz.getName().replace('.', '/');
fqn = fqn.indexOf("$") == -1 ? fqn : fqn.substring(0, fqn.indexOf("$"));
String classFile = fqn + ".java";
- IPath filePath= new Path(srcRoot + '/' + classFile);
+ IPath filePath = new Path(srcRoot + '/' + classFile);
InputStream in;
Class superclass = clazz.getSuperclass();
@@ -149,43 +149,43 @@ public class TestSourceReader {
continue;
}
- BufferedReader br = new BufferedReader(new InputStreamReader(in));
- try {
- // Read the java file collecting comments until we encounter the test method.
- List<StringBuilder> contents = new ArrayList<StringBuilder>();
- StringBuilder content = new StringBuilder();
- for (String line = br.readLine(); line != null; line = br.readLine()) {
- line = line.replaceFirst("^\\s*", ""); // Replace leading whitespace, preserve trailing
- // Trailing whitespace can be removed by editor/clean-up actions. To enforce whitespace
- // at end of line, use ${whitspace_eol}, which will be removed, but cause the
- // whitespace to the left of it to be preserved.
- line = line.replace("${whitespace_eol}", "");
- if (line.startsWith("//")) {
- content.append(line.substring(2)).append('\n');
- } else {
- if (!line.startsWith("@") && content.length() > 0) {
- contents.add(content);
- if (numSections > 0 && contents.size() == numSections + 1)
- contents.remove(0);
- content = new StringBuilder();
- }
- if (line.length() > 0 && !contents.isEmpty()) {
- int idx= line.indexOf(testName);
- if (idx != -1 && !Character.isJavaIdentifierPart(line.charAt(idx + testName.length()))) {
- return contents.toArray(new StringBuilder[contents.size()]);
- }
- if (!line.startsWith("@")) {
- contents.clear();
- }
- }
- }
- }
- } finally {
- br.close();
- }
+ BufferedReader br = new BufferedReader(new InputStreamReader(in));
+ try {
+ // Read the java file collecting comments until we encounter the test method.
+ List<StringBuilder> contents = new ArrayList<StringBuilder>();
+ StringBuilder content = new StringBuilder();
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
+ line = line.replaceFirst("^\\s*", ""); // Replace leading whitespace, preserve trailing
+ // Trailing whitespace can be removed by editor/clean-up actions. To enforce whitespace
+ // at end of line, use ${whitspace_eol}, which will be removed, but cause the
+ // whitespace to the left of it to be preserved.
+ line = line.replace("${whitespace_eol}", "");
+ if (line.startsWith("//")) {
+ content.append(line.substring(2)).append('\n');
+ } else {
+ if (!line.startsWith("@") && content.length() > 0) {
+ contents.add(content);
+ if (numSections > 0 && contents.size() == numSections + 1)
+ contents.remove(0);
+ content = new StringBuilder();
+ }
+ if (line.length() > 0 && !contents.isEmpty()) {
+ int idx = line.indexOf(testName);
+ if (idx != -1 && !Character.isJavaIdentifierPart(line.charAt(idx + testName.length()))) {
+ return contents.toArray(new StringBuilder[contents.size()]);
+ }
+ if (!line.startsWith("@")) {
+ contents.clear();
+ }
+ }
+ }
+ }
+ } finally {
+ br.close();
+ }
if (superclass == null || !superclass.getPackage().equals(clazz.getPackage())) {
- throw new IOException("Test data not found for " + clazz.getName() + "." + testName);
+ throw new IOException("Test data not found for " + clazz.getName() + "." + testName);
}
clazz = superclass;
}
@@ -201,17 +201,17 @@ public class TestSourceReader {
* @since 4.0
*/
public static int indexOfInFile(String lookfor, Path fullPath) throws Exception {
- IFile file= ResourcesPlugin.getWorkspace().getRoot().getFile(fullPath);
- Reader reader= new BufferedReader(new InputStreamReader(file.getContents(), file.getCharset()));
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(fullPath);
+ Reader reader = new BufferedReader(new InputStreamReader(file.getContents(), file.getCharset()));
Assert.assertTrue(lookfor.indexOf('\n') == -1);
try {
- int c= 0;
- int offset= 0;
- StringBuilder buf= new StringBuilder();
+ int c = 0;
+ int offset = 0;
+ StringBuilder buf = new StringBuilder();
while ((c = reader.read()) >= 0) {
buf.append((char) c);
if (c == '\n') {
- int idx= buf.indexOf(lookfor);
+ int idx = buf.indexOf(lookfor);
if (idx >= 0) {
return idx + offset;
}
@@ -219,7 +219,7 @@ public class TestSourceReader {
buf.setLength(0);
}
}
- int idx= buf.indexOf(lookfor);
+ int idx = buf.indexOf(lookfor);
if (idx >= 0) {
return idx + offset;
}
@@ -230,12 +230,12 @@ public class TestSourceReader {
}
public static int getLineNumber(int offset, Path fullPath) throws Exception {
- IFile file= ResourcesPlugin.getWorkspace().getRoot().getFile(fullPath);
- Reader reader= new BufferedReader(new InputStreamReader(file.getContents(), file.getCharset()));
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(fullPath);
+ Reader reader = new BufferedReader(new InputStreamReader(file.getContents(), file.getCharset()));
try {
int line = 1;
for (int i = 0; i < offset; i++) {
- int c= reader.read();
+ int c = reader.read();
Assert.assertTrue(c >= 0);
if (c == '\n')
line++;
@@ -251,41 +251,42 @@ public class TestSourceReader {
* is started with '// {tag}' and ends with the first line not started by '//'
* @since 4.0
*/
- public static String readTaggedComment(Bundle bundle, String srcRoot, Class clazz, final String tag) throws IOException {
- IPath filePath= new Path(srcRoot + '/' + clazz.getName().replace('.', '/') + ".java");
+ public static String readTaggedComment(Bundle bundle, String srcRoot, Class clazz, final String tag)
+ throws IOException {
+ IPath filePath = new Path(srcRoot + '/' + clazz.getName().replace('.', '/') + ".java");
- InputStream in= FileLocator.openStream(bundle, filePath, false);
- LineNumberReader reader= new LineNumberReader(new InputStreamReader(in));
- boolean found= false;
- final StringBuilder content= new StringBuilder();
- try {
- String line= reader.readLine();
- while (line != null) {
- line= line.trim();
- if (line.startsWith("//")) {
- line= line.substring(2);
- if (found) {
- content.append(line);
- content.append('\n');
- } else {
- line= line.trim();
- if (line.startsWith("{" + tag)) {
- if (line.length() == tag.length() + 1 ||
- !Character.isJavaIdentifierPart(line.charAt(tag.length() + 1))) {
- found= true;
- }
- }
- }
- } else if (found) {
- break;
- }
- line= reader.readLine();
- }
- } finally {
- reader.close();
- }
- Assert.assertTrue("Tag '" + tag + "' is not defined inside of '" + filePath + "'.", found);
- return content.toString();
+ InputStream in = FileLocator.openStream(bundle, filePath, false);
+ LineNumberReader reader = new LineNumberReader(new InputStreamReader(in));
+ boolean found = false;
+ final StringBuilder content = new StringBuilder();
+ try {
+ String line = reader.readLine();
+ while (line != null) {
+ line = line.trim();
+ if (line.startsWith("//")) {
+ line = line.substring(2);
+ if (found) {
+ content.append(line);
+ content.append('\n');
+ } else {
+ line = line.trim();
+ if (line.startsWith("{" + tag)) {
+ if (line.length() == tag.length() + 1
+ || !Character.isJavaIdentifierPart(line.charAt(tag.length() + 1))) {
+ found = true;
+ }
+ }
+ }
+ } else if (found) {
+ break;
+ }
+ line = reader.readLine();
+ }
+ } finally {
+ reader.close();
+ }
+ Assert.assertTrue("Tag '" + tag + "' is not defined inside of '" + filePath + "'.", found);
+ return content.toString();
}
/**
@@ -298,8 +299,8 @@ public class TestSourceReader {
* @throws CoreException
* @since 4.0
*/
- public static IFile createFile(final IContainer container, final IPath filePath,
- final CharSequence contents) throws CoreException {
+ public static IFile createFile(final IContainer container, final IPath filePath, final CharSequence contents)
+ throws CoreException {
final IWorkspace ws = ResourcesPlugin.getWorkspace();
final IFile result[] = new IFile[1];
ws.run(new IWorkspaceRunnable() {
@@ -316,7 +317,7 @@ public class TestSourceReader {
}
// Create file input stream
if (file.exists()) {
- long timestamp= file.getLocalTimeStamp();
+ long timestamp = file.getLocalTimeStamp();
file.setContents(stream, false, false, new NullProgressMonitor());
if (file.getLocalTimeStamp() == timestamp) {
file.setLocalTimeStamp(timestamp + 1000);
@@ -325,11 +326,11 @@ public class TestSourceReader {
createFolders(file);
file.create(stream, true, new NullProgressMonitor());
}
- result[0]= file;
+ result[0] = file;
}
private void createFolders(IResource res) throws CoreException {
- IContainer container= res.getParent();
+ IContainer container = res.getParent();
if (!container.exists() && container instanceof IFolder) {
createFolders(container);
((IFolder) container).create(true, true, new NullProgressMonitor());
@@ -364,18 +365,18 @@ public class TestSourceReader {
long fileTimestamp = file.getLocalTimeStamp();
IIndexFileLocation indexFileLocation = IndexLocationFactory.getWorkspaceIFL(file);
- long endTime= System.currentTimeMillis() + maxmillis;
- int timeLeft= maxmillis;
+ long endTime = System.currentTimeMillis() + maxmillis;
+ int timeLeft = maxmillis;
while (timeLeft >= 0) {
Assert.assertTrue(CCorePlugin.getIndexManager().joinIndexer(timeLeft, new NullProgressMonitor()));
index.acquireReadLock();
try {
- IIndexFile[] files= index.getFiles(ILinkage.CPP_LINKAGE_ID, indexFileLocation);
+ IIndexFile[] files = index.getFiles(ILinkage.CPP_LINKAGE_ID, indexFileLocation);
if (files.length > 0 && areAllFilesNotOlderThan(files, fileTimestamp)) {
Assert.assertTrue(CCorePlugin.getIndexManager().joinIndexer(timeLeft, new NullProgressMonitor()));
return;
}
- files= index.getFiles(ILinkage.C_LINKAGE_ID, indexFileLocation);
+ files = index.getFiles(ILinkage.C_LINKAGE_ID, indexFileLocation);
if (files.length > 0 && areAllFilesNotOlderThan(files, fileTimestamp)) {
Assert.assertTrue(CCorePlugin.getIndexManager().joinIndexer(timeLeft, new NullProgressMonitor()));
return;
@@ -385,7 +386,7 @@ public class TestSourceReader {
}
Thread.sleep(50);
- timeLeft= (int) (endTime - System.currentTimeMillis());
+ timeLeft = (int) (endTime - System.currentTimeMillis());
}
Assert.fail("Indexing of " + file.getFullPath() + " did not complete in " + maxmillis / 1000. + " sec");
}
@@ -399,13 +400,14 @@ public class TestSourceReader {
return true;
}
- public static IASTTranslationUnit createIndexBasedAST(IIndex index, ICProject project, IFile file) throws CModelException, CoreException {
- ICElement elem= project.findElement(file.getFullPath());
- if (elem instanceof ITranslationUnit) {
- ITranslationUnit tu= (ITranslationUnit) elem;
- return tu.getAST(index, ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
- }
- Assert.fail("Could not create AST for " + file.getFullPath());
- return null;
- }
+ public static IASTTranslationUnit createIndexBasedAST(IIndex index, ICProject project, IFile file)
+ throws CModelException, CoreException {
+ ICElement elem = project.findElement(file.getFullPath());
+ if (elem instanceof ITranslationUnit) {
+ ITranslationUnit tu = (ITranslationUnit) elem;
+ return tu.getAST(index, ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
+ }
+ Assert.fail("Could not create AST for " + file.getFullPath());
+ return null;
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/VerifyDialog.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/VerifyDialog.java
index 72035e31be6..e34563e7c58 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/VerifyDialog.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/VerifyDialog.java
@@ -13,10 +13,8 @@
*******************************************************************************/
package org.eclipse.cdt.core.testplugin.util;
-
import java.util.Iterator;
-
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TitleAreaDialog;
@@ -35,7 +33,6 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
-
/*
* This dialog is intended to verify a dialogs in a testing
* environment. The tester can test for sizing, initial focus,
@@ -43,28 +40,27 @@ import org.eclipse.swt.widgets.Shell;
*/
public class VerifyDialog extends TitleAreaDialog {
private int SIZING_WIDTH = 400;
-
- static int TEST_TYPE;
+
+ static int TEST_TYPE;
public static final int TEST_SIZING = 0;
- public static final int TEST_FOCUS = 1;
+ public static final int TEST_FOCUS = 1;
public static final int TEST_ACCESS = 2;
private IDialogTestPass _dialogTests[] = new IDialogTestPass[3];
-
private Dialog _testDialog; //the dialog to test
- private Point _testDialogSize;
-
- private Label _queryLabel;
+ private Point _testDialogSize;
+
+ private Label _queryLabel;
Button _yesButton;
private Button _checkList[];
private String _failureText;
-
+
/*
* Create an instance of the verification dialog.
*/
public VerifyDialog(Shell parent) {
super(parent);
- if ( !(TEST_TYPE <= 2) && !(TEST_TYPE >= 0) ) {
+ if (!(TEST_TYPE <= 2) && !(TEST_TYPE >= 0)) {
TEST_TYPE = TEST_SIZING;
}
_failureText = "";
@@ -72,7 +68,7 @@ public class VerifyDialog extends TitleAreaDialog {
_dialogTests[1] = new FocusTestPass();
_dialogTests[2] = new AccessibilityTestPass();
}
-
+
/* (non-Javadoc)
* Method declared on Window.
*/
@@ -82,6 +78,7 @@ public class VerifyDialog extends TitleAreaDialog {
newShell.setText("Dialog Verification");
setShellStyle(SWT.NONE);
}
+
/* (non-Javadoc)
* Method declared on Dialog.
*/
@@ -90,6 +87,7 @@ public class VerifyDialog extends TitleAreaDialog {
_yesButton = createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true);
createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false);
}
+
/* (non-Javadoc)
* Method declared on Dialog.
*/
@@ -105,14 +103,14 @@ public class VerifyDialog extends TitleAreaDialog {
handleFailure();
}
}
+
/* (non-Javadoc)
* Method declared on Dialog.
*/
@Override
protected Control createDialogArea(Composite parent) {
// top level composite
- Composite parentComposite = (Composite)super.createDialogArea(parent);
-
+ Composite parentComposite = (Composite) super.createDialogArea(parent);
// create a composite with standard margins and spacing
Composite composite = new Composite(parentComposite, SWT.NONE);
@@ -125,30 +123,29 @@ public class VerifyDialog extends TitleAreaDialog {
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
createTestSelectionGroup(composite);
createCheckListGroup(composite);
-
_queryLabel = new Label(composite, SWT.NONE);
_queryLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
+
initializeTest();
return composite;
}
+
/*
* Group for selecting type of test.
*/
private void createTestSelectionGroup(Composite parent) {
Group group = new Group(parent, SWT.SHADOW_NONE);
group.setText("Testing:");
- group.setLayout( new GridLayout() );
+ group.setLayout(new GridLayout());
GridData data = new GridData(GridData.FILL_HORIZONTAL);
group.setLayoutData(data);
-
+
for (int i = 0; i < _dialogTests.length; i++) {
Button radio = new Button(group, SWT.RADIO);
- radio.setText( _dialogTests[i].label() );
+ radio.setText(_dialogTests[i].label());
final int testID = _dialogTests[i].getID();
radio.addSelectionListener(new SelectionAdapter() {
@Override
@@ -158,21 +155,22 @@ public class VerifyDialog extends TitleAreaDialog {
_yesButton.setEnabled(true);
}
});
- if ( TEST_TYPE == _dialogTests[i].getID() ) {
+ if (TEST_TYPE == _dialogTests[i].getID()) {
radio.setSelection(true);
}
}
}
+
/*
* Initializes the checklist with empty checks.
*/
private void createCheckListGroup(Composite parent) {
Group group = new Group(parent, SWT.SHADOW_NONE);
group.setText("Verify that:");
- group.setLayout( new GridLayout() );
+ group.setLayout(new GridLayout());
GridData data = new GridData(GridData.FILL_HORIZONTAL);
group.setLayoutData(data);
-
+
int checkListSize = 0;
for (int i = 0; i < _dialogTests.length; i++) {
int size = _dialogTests[i].checkListTexts().size();
@@ -193,8 +191,9 @@ public class VerifyDialog extends TitleAreaDialog {
data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
data.grabExcessHorizontalSpace = true;
_checkList[i].setLayoutData(data);
- }
+ }
}
+
/*
* Disables the yes button if any of the items in the checklist
* are unchecked. Enables the yes button otherwise.
@@ -202,23 +201,24 @@ public class VerifyDialog extends TitleAreaDialog {
void checkYesEnable() {
boolean enable = true;
for (int i = 0; i < _checkList.length; i++) {
- if ( !_checkList[i].getSelection() ) {
+ if (!_checkList[i].getSelection()) {
enable = false;
- }
+ }
}
_yesButton.setEnabled(enable);
}
+
/*
* Initializes the checklist, banner texts, and query label
*/
void initializeTest() {
IDialogTestPass test = _dialogTests[TEST_TYPE];
- setTitle( test.title() );
- setMessage( test.description() );
+ setTitle(test.title());
+ setMessage(test.description());
Iterator iterator = test.checkListTexts().iterator();
for (int i = 0; i < _checkList.length; i++) {
- if ( iterator.hasNext() ) {
- _checkList[i].setText( iterator.next().toString() );
+ if (iterator.hasNext()) {
+ _checkList[i].setText(iterator.next().toString());
_checkList[i].setVisible(true);
_checkList[i].update();
} else {
@@ -227,22 +227,25 @@ public class VerifyDialog extends TitleAreaDialog {
}
_checkList[i].setSelection(true);
}
- _queryLabel.setText( test.queryText() );
+ _queryLabel.setText(test.queryText());
}
+
public String getFailureText() {
return _failureText;
}
+
/*
* Can't open the verification dialog without a specified
* test dialog, this simply returns a failure and prevents
* opening. Should use open(Dialog) instead.
- *
+ *
*/
@Override
public int open() {
_failureText = "Testing dialog is required, use VerifyDialog::open(Dialog)";
return IDialogConstants.NO_ID;
}
+
/*
* Opens the verification dialog to test the specified dialog.
*/
@@ -258,9 +261,10 @@ public class VerifyDialog extends TitleAreaDialog {
}
_testDialogSize = _testDialog.getShell().getSize();
openNewTestDialog();
-
+
return super.open();
}
+
/*
* Opens the dialog to be verified.
*/
@@ -273,13 +277,14 @@ public class VerifyDialog extends TitleAreaDialog {
_testDialog.getShell().setSize(_testDialogSize);
_testDialog.getShell().addShellListener(new ShellAdapter() {
@Override
- public void shellClosed(ShellEvent e) {
+ public void shellClosed(ShellEvent e) {
e.doit = false;
}
-
- });
+
+ });
_testDialog.open();
}
+
/*
* The test dialog failed, open the failure dialog.
*/
@@ -287,23 +292,19 @@ public class VerifyDialog extends TitleAreaDialog {
IDialogTestPass test = _dialogTests[TEST_TYPE];
StringBuilder text = new StringBuilder();
String label = test.label();
- label = label.substring(0, label.indexOf("&")) +
- label.substring(label.indexOf("&") + 1);
- text.append(label).
- append(" failed on the ").
- append(SWT.getPlatform()).
- append(" platform:\n");
-
+ label = label.substring(0, label.indexOf("&")) + label.substring(label.indexOf("&") + 1);
+ text.append(label).append(" failed on the ").append(SWT.getPlatform()).append(" platform:\n");
+
String failureMessages[] = test.failureTexts();
for (int i = 0; i < test.checkListTexts().size(); i++) {
- if ( !_checkList[i].getSelection() ) {
+ if (!_checkList[i].getSelection()) {
text.append("- ").append(failureMessages[i]).append("\n");
}
}
- FailureDialog dialog = new FailureDialog( getShell() );
+ FailureDialog dialog = new FailureDialog(getShell());
dialog.create();
//String temp = text.toString();
- dialog.setText( text.toString() );
+ dialog.setText(text.toString());
if (dialog.open() == IDialogConstants.OK_ID) {
_failureText = dialog.toString();
setReturnCode(IDialogConstants.NO_ID);
@@ -313,6 +314,7 @@ public class VerifyDialog extends TitleAreaDialog {
close();
}
}
+
/*
* In case the shell was closed by a means other than
* the NO button.
@@ -322,5 +324,3 @@ public class VerifyDialog extends TitleAreaDialog {
handleFailure();
}
}
-
-

Back to the top