diff --git a/build/org.eclipse.cdt.gnu.build-feature/feature.xml b/build/org.eclipse.cdt.gnu.build-feature/feature.xml index 647c95e5e65..9fdf88098eb 100644 --- a/build/org.eclipse.cdt.gnu.build-feature/feature.xml +++ b/build/org.eclipse.cdt.gnu.build-feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/build/org.eclipse.cdt.gnu.build-feature/pom.xml b/build/org.eclipse.cdt.gnu.build-feature/pom.xml index d7cb7798566..e11ef9c82e8 100644 --- a/build/org.eclipse.cdt.gnu.build-feature/pom.xml +++ b/build/org.eclipse.cdt.gnu.build-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/build/org.eclipse.cdt.gnu.build.source-feature/feature.xml b/build/org.eclipse.cdt.gnu.build.source-feature/feature.xml index 102161310d7..ddb39676660 100644 --- a/build/org.eclipse.cdt.gnu.build.source-feature/feature.xml +++ b/build/org.eclipse.cdt.gnu.build.source-feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/build/org.eclipse.cdt.gnu.build.source-feature/pom.xml b/build/org.eclipse.cdt.gnu.build.source-feature/pom.xml index 38de6b463b4..c90595ed599 100644 --- a/build/org.eclipse.cdt.gnu.build.source-feature/pom.xml +++ b/build/org.eclipse.cdt.gnu.build.source-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/build/org.eclipse.cdt.make.core.tests/.classpath b/build/org.eclipse.cdt.make.core.tests/.classpath index 472ee29b11e..deb673668e9 100644 --- a/build/org.eclipse.cdt.make.core.tests/.classpath +++ b/build/org.eclipse.cdt.make.core.tests/.classpath @@ -2,6 +2,6 @@ - + diff --git a/build/org.eclipse.cdt.make.core.tests/.settings/org.eclipse.jdt.core.prefs b/build/org.eclipse.cdt.make.core.tests/.settings/org.eclipse.jdt.core.prefs index 4a1c019942b..598dd4e35ce 100644 --- a/build/org.eclipse.cdt.make.core.tests/.settings/org.eclipse.jdt.core.prefs +++ b/build/org.eclipse.cdt.make.core.tests/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Thu Apr 29 13:28:18 EDT 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -84,7 +84,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 diff --git a/build/org.eclipse.cdt.make.core.tests/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.make.core.tests/META-INF/MANIFEST.MF index 7b7b8f92b67..76c77948d90 100644 --- a/build/org.eclipse.cdt.make.core.tests/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.make.core.tests/META-INF/MANIFEST.MF @@ -15,5 +15,5 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.cdt.core.tests Bundle-ActivationPolicy: lazy Bundle-Vendor: Eclipse.org -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: org.eclipse.core.filesystem diff --git a/build/org.eclipse.cdt.make.core/.classpath b/build/org.eclipse.cdt.make.core/.classpath index 472ee29b11e..deb673668e9 100644 --- a/build/org.eclipse.cdt.make.core/.classpath +++ b/build/org.eclipse.cdt.make.core/.classpath @@ -2,6 +2,6 @@ - + diff --git a/build/org.eclipse.cdt.make.core/.settings/org.eclipse.jdt.core.prefs b/build/org.eclipse.cdt.make.core/.settings/org.eclipse.jdt.core.prefs index 3097bf2d037..c57477de0d4 100644 --- a/build/org.eclipse.cdt.make.core/.settings/org.eclipse.jdt.core.prefs +++ b/build/org.eclipse.cdt.make.core/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Thu Apr 29 13:15:20 EDT 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -80,7 +80,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 diff --git a/build/org.eclipse.cdt.make.core/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.make.core/META-INF/MANIFEST.MF index 73460367377..3a2cbd5d68b 100644 --- a/build/org.eclipse.cdt.make.core/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.make.core/META-INF/MANIFEST.MF @@ -25,5 +25,5 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)", org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)", org.eclipse.core.filesystem;bundle-version="1.2.0" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: com.ibm.icu.text diff --git a/build/org.eclipse.cdt.make.core/build.properties b/build/org.eclipse.cdt.make.core/build.properties index be4c400f021..1c67896b0db 100644 --- a/build/org.eclipse.cdt.make.core/build.properties +++ b/build/org.eclipse.cdt.make.core/build.properties @@ -19,6 +19,6 @@ src.includes = schema/,\ source.. = src/ -jre.compilation.profile=J2SE-1.5 -javacSource=1.5 -javacTarget=1.5 +jre.compilation.profile=JavaSE-1.6 +javacSource=1.6 +javacTarget=1.6 diff --git a/build/org.eclipse.cdt.make.core/plugin.xml b/build/org.eclipse.cdt.make.core/plugin.xml index 9b0c70400ff..ecdb0eb306f 100644 --- a/build/org.eclipse.cdt.make.core/plugin.xml +++ b/build/org.eclipse.cdt.make.core/plugin.xml @@ -122,7 +122,7 @@ diff --git a/build/org.eclipse.cdt.make.core/pom.xml b/build/org.eclipse.cdt.make.core/pom.xml index d08b032e0f2..9f4ce86c409 100644 --- a/build/org.eclipse.cdt.make.core/pom.xml +++ b/build/org.eclipse.cdt.make.core/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/build/org.eclipse.cdt.make.ui/.classpath b/build/org.eclipse.cdt.make.ui/.classpath index 64c5e31b7a2..ad32c83a788 100644 --- a/build/org.eclipse.cdt.make.ui/.classpath +++ b/build/org.eclipse.cdt.make.ui/.classpath @@ -1,6 +1,6 @@ - + diff --git a/build/org.eclipse.cdt.make.ui/.settings/org.eclipse.jdt.core.prefs b/build/org.eclipse.cdt.make.ui/.settings/org.eclipse.jdt.core.prefs index 3097bf2d037..c57477de0d4 100644 --- a/build/org.eclipse.cdt.make.ui/.settings/org.eclipse.jdt.core.prefs +++ b/build/org.eclipse.cdt.make.ui/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Thu Apr 29 13:15:20 EDT 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -80,7 +80,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 diff --git a/build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF index 22feef84ebc..1986bb3259e 100644 --- a/build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF @@ -30,7 +30,7 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)", org.eclipse.ui;bundle-version="[3.2.0,4.0.0)", org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)", org.eclipse.cdt.ui;bundle-version="[5.0.0,6.0.0)", - org.eclipse.cdt.make.core;bundle-version="[7.0.0,8.0.0)", + org.eclipse.cdt.make.core;bundle-version="[7.0.0,8.1.0)", org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", org.eclipse.debug.ui;bundle-version="[3.2.0,4.0.0)", org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)";resolution:=optional, @@ -38,5 +38,5 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)", org.eclipse.core.filesystem;bundle-version="1.2.0", org.eclipse.ui.console;bundle-version="3.5.100" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: com.ibm.icu.text diff --git a/build/org.eclipse.cdt.make.ui/pom.xml b/build/org.eclipse.cdt.make.ui/pom.xml index 0b0c6bf0e9e..670e07fd6a5 100644 --- a/build/org.eclipse.cdt.make.ui/pom.xml +++ b/build/org.eclipse.cdt.make.ui/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/.classpath b/build/org.eclipse.cdt.managedbuilder.core.tests/.classpath index adb2aa14483..8a69c793575 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/.classpath +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/.classpath @@ -2,7 +2,7 @@ - + diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/.settings/org.eclipse.jdt.core.prefs b/build/org.eclipse.cdt.managedbuilder.core.tests/.settings/org.eclipse.jdt.core.prefs index af539f24fbe..716f66132cd 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/.settings/org.eclipse.jdt.core.prefs +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Thu Oct 08 20:38:59 EDT 2009 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -84,7 +84,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.managedbuilder.core.tests/META-INF/MANIFEST.MF index 00661aa790f..e3f95fe6e79 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/META-INF/MANIFEST.MF @@ -22,4 +22,4 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.cdt.managedbuilder.gnu.ui, org.eclipse.cdt.core.tests;bundle-version="5.0.0" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/pom.xml b/build/org.eclipse.cdt.managedbuilder.core.tests/pom.xml index 9c859267933..f95d8307726 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/pom.xml +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml @@ -45,7 +45,7 @@ org.eclipse.cdt.feature.group - 8.0.0.${buildQualifier} + 8.1.0.${buildQualifier} p2-installable-unit diff --git a/build/org.eclipse.cdt.managedbuilder.core/.classpath b/build/org.eclipse.cdt.managedbuilder.core/.classpath index 472ee29b11e..deb673668e9 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/.classpath +++ b/build/org.eclipse.cdt.managedbuilder.core/.classpath @@ -2,6 +2,6 @@ - + diff --git a/build/org.eclipse.cdt.managedbuilder.core/.settings/org.eclipse.jdt.core.prefs b/build/org.eclipse.cdt.managedbuilder.core/.settings/org.eclipse.jdt.core.prefs index 3097bf2d037..c57477de0d4 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/.settings/org.eclipse.jdt.core.prefs +++ b/build/org.eclipse.cdt.managedbuilder.core/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Thu Apr 29 13:15:20 EDT 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -80,7 +80,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 diff --git a/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF index bb7b599b93c..363db3a759e 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF @@ -37,5 +37,5 @@ Require-Bundle: org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)", org.eclipse.cdt.make.core;visibility:=reexport, org.eclipse.core.filesystem;bundle-version="1.2.0" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: com.ibm.icu.text diff --git a/build/org.eclipse.cdt.managedbuilder.core/build.properties b/build/org.eclipse.cdt.managedbuilder.core/build.properties index 2873d107c5c..3f535c10e71 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/build.properties +++ b/build/org.eclipse.cdt.managedbuilder.core/build.properties @@ -17,6 +17,6 @@ src.includes = schema/,\ about.html source.. = src/ -jre.compilation.profile=J2SE-1.5 -javacSource=1.5 -javacTarget=1.5 +jre.compilation.profile=JavaSE-1.6 +javacSource=1.6 +javacTarget=1.6 diff --git a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml index be712a6d999..29e3713b30a 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml +++ b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml @@ -86,7 +86,7 @@ @@ -105,7 +105,7 @@ @@ -124,7 +124,7 @@ diff --git a/build/org.eclipse.cdt.managedbuilder.core/pom.xml b/build/org.eclipse.cdt.managedbuilder.core/pom.xml index b57ca1be5cd..1b38d610dc4 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/pom.xml +++ b/build/org.eclipse.cdt.managedbuilder.core/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java index d5d2148931f..bb9f105b626 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java @@ -1057,6 +1057,11 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider } private String addCmd(String args, String cmd){ + // Don't modify the args parameter if the cmd to add is emtpy. + // Bug 360846 + if(cmd.length() == 0) + return args; + if(getCmdIndex(args, cmd) == -1){ if(args.length() != 0){ args += ' '; diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/.classpath b/build/org.eclipse.cdt.managedbuilder.gnu.ui/.classpath index 472ee29b11e..deb673668e9 100644 --- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/.classpath +++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/.classpath @@ -2,6 +2,6 @@ - + diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/.settings/org.eclipse.jdt.core.prefs b/build/org.eclipse.cdt.managedbuilder.gnu.ui/.settings/org.eclipse.jdt.core.prefs index 3097bf2d037..c57477de0d4 100644 --- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/.settings/org.eclipse.jdt.core.prefs +++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Thu Apr 29 13:15:20 EDT 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -80,7 +80,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.managedbuilder.gnu.ui/META-INF/MANIFEST.MF index 1ef142e316c..9e504b15012 100644 --- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/META-INF/MANIFEST.MF @@ -11,8 +11,8 @@ Export-Package: org.eclipse.cdt.managedbuilder.gnu.cygwin, org.eclipse.cdt.managedbuilder.gnu.templates;x-internal:=true, org.eclipse.cdt.managedbuilder.gnu.ui Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", - org.eclipse.cdt.managedbuilder.core;bundle-version="[8.0.0,9.0.0)", + org.eclipse.cdt.managedbuilder.core;bundle-version="[8.1.0,9.0.0)", org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)", org.eclipse.core.resources Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/build.properties b/build/org.eclipse.cdt.managedbuilder.gnu.ui/build.properties index d3706bf4ee8..4f0c06c790b 100644 --- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/build.properties +++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/build.properties @@ -16,7 +16,7 @@ bin.includes = plugin.xml,\ templates/ source.. = src/ -jre.compilation.profile=J2SE-1.5 -javacSource=1.5 -javacTarget=1.5 +jre.compilation.profile=JavaSE-1.6 +javacSource=1.6 +javacTarget=1.6 src.includes = about.html diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/pom.xml b/build/org.eclipse.cdt.managedbuilder.gnu.ui/pom.xml index 60ca3e7f7af..6513419812d 100644 --- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/pom.xml +++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/build/org.eclipse.cdt.managedbuilder.ui.tests/.classpath b/build/org.eclipse.cdt.managedbuilder.ui.tests/.classpath index 64c5e31b7a2..ad32c83a788 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui.tests/.classpath +++ b/build/org.eclipse.cdt.managedbuilder.ui.tests/.classpath @@ -1,6 +1,6 @@ - + diff --git a/build/org.eclipse.cdt.managedbuilder.ui.tests/.settings/org.eclipse.jdt.core.prefs b/build/org.eclipse.cdt.managedbuilder.ui.tests/.settings/org.eclipse.jdt.core.prefs index 4a1c019942b..598dd4e35ce 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui.tests/.settings/org.eclipse.jdt.core.prefs +++ b/build/org.eclipse.cdt.managedbuilder.ui.tests/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Thu Apr 29 13:28:18 EDT 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -84,7 +84,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 diff --git a/build/org.eclipse.cdt.managedbuilder.ui.tests/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.managedbuilder.ui.tests/META-INF/MANIFEST.MF index 354829e1ab4..b4b8d946d25 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui.tests/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.managedbuilder.ui.tests/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Managed Build UI Tests Plug-in Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.ui.tests; singleton:=true -Bundle-Version: 8.0.0.qualifier +Bundle-Version: 8.1.0.qualifier Bundle-Activator: org.eclipse.cdt.managedbuilder.ui.tests.testplugin.TestsPlugin Bundle-Vendor: Eclipse CDT Bundle-Localization: plugin @@ -15,4 +15,4 @@ Require-Bundle: org.eclipse.ui, org.eclipse.cdt.core, org.eclipse.core.resources Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/build/org.eclipse.cdt.managedbuilder.ui.tests/pom.xml b/build/org.eclipse.cdt.managedbuilder.ui.tests/pom.xml index f8f3e2a8d4e..9061af893e9 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui.tests/pom.xml +++ b/build/org.eclipse.cdt.managedbuilder.ui.tests/pom.xml @@ -7,11 +7,11 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT org.eclipse.cdt.managedbuilder.ui.tests eclipse-test-plugin diff --git a/build/org.eclipse.cdt.managedbuilder.ui/.classpath b/build/org.eclipse.cdt.managedbuilder.ui/.classpath index 472ee29b11e..deb673668e9 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/.classpath +++ b/build/org.eclipse.cdt.managedbuilder.ui/.classpath @@ -2,6 +2,6 @@ - + diff --git a/build/org.eclipse.cdt.managedbuilder.ui/.settings/org.eclipse.jdt.core.prefs b/build/org.eclipse.cdt.managedbuilder.ui/.settings/org.eclipse.jdt.core.prefs index 3097bf2d037..c57477de0d4 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/.settings/org.eclipse.jdt.core.prefs +++ b/build/org.eclipse.cdt.managedbuilder.ui/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Thu Apr 29 13:15:20 EDT 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -80,7 +80,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 diff --git a/build/org.eclipse.cdt.managedbuilder.ui/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.managedbuilder.ui/META-INF/MANIFEST.MF index 09798caf7cb..beaff8e8eb2 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.managedbuilder.ui/META-INF/MANIFEST.MF @@ -16,7 +16,7 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)", org.eclipse.ui;bundle-version="[3.2.0,4.0.0)", org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)", org.eclipse.cdt.ui;bundle-version="[5.0.0,6.0.0)", - org.eclipse.cdt.managedbuilder.core;bundle-version="[8.0.0,9.0.0)", + org.eclipse.cdt.managedbuilder.core;bundle-version="[8.1.0,9.0.0)", org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)", org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)";resolution:=optional, @@ -24,5 +24,5 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)", org.eclipse.cdt.make.ui, org.eclipse.core.filesystem Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: com.ibm.icu.text diff --git a/build/org.eclipse.cdt.managedbuilder.ui/build.properties b/build/org.eclipse.cdt.managedbuilder.ui/build.properties index 855706cef61..925bccedd81 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/build.properties +++ b/build/org.eclipse.cdt.managedbuilder.ui/build.properties @@ -18,6 +18,6 @@ src.includes = schema/,\ about.html source.. = src/ -jre.compilation.profile=J2SE-1.5 -javacSource=1.5 -javacTarget=1.5 +jre.compilation.profile=JavaSE-1.6 +javacSource=1.6 +javacTarget=1.6 diff --git a/build/org.eclipse.cdt.managedbuilder.ui/pom.xml b/build/org.eclipse.cdt.managedbuilder.ui/pom.xml index 057e77905de..63ff44d6216 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/pom.xml +++ b/build/org.eclipse.cdt.managedbuilder.ui/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/.classpath b/codan/org.eclipse.cdt.codan.checkers.ui/.classpath index 64c5e31b7a2..ad32c83a788 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/.classpath +++ b/codan/org.eclipse.cdt.codan.checkers.ui/.classpath @@ -1,6 +1,6 @@ - + diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/.settings/org.eclipse.jdt.core.prefs b/codan/org.eclipse.cdt.codan.checkers.ui/.settings/org.eclipse.jdt.core.prefs index 3b035d87905..350fddcf779 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/.settings/org.eclipse.jdt.core.prefs +++ b/codan/org.eclipse.cdt.codan.checkers.ui/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Wed Feb 23 19:43:34 EST 2011 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -72,7 +72,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/META-INF/MANIFEST.MF b/codan/org.eclipse.cdt.codan.checkers.ui/META-INF/MANIFEST.MF index 00c04aa9d3b..2af6f3f12de 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/META-INF/MANIFEST.MF +++ b/codan/org.eclipse.cdt.codan.checkers.ui/META-INF/MANIFEST.MF @@ -15,7 +15,7 @@ Require-Bundle: org.eclipse.ui, org.eclipse.cdt.codan.core, org.eclipse.cdt.codan.checkers Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-Vendor: %Bundle-Vendor Export-Package: org.eclipse.cdt.codan.internal.checkers.ui;x-internal:=true, org.eclipse.cdt.codan.internal.checkers.ui.quickfix;x-internal:=true diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/pom.xml b/codan/org.eclipse.cdt.codan.checkers.ui/pom.xml index c39d39239f6..50c3b783f6a 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/pom.xml +++ b/codan/org.eclipse.cdt.codan.checkers.ui/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/codan/org.eclipse.cdt.codan.checkers/.classpath b/codan/org.eclipse.cdt.codan.checkers/.classpath index 64c5e31b7a2..ad32c83a788 100644 --- a/codan/org.eclipse.cdt.codan.checkers/.classpath +++ b/codan/org.eclipse.cdt.codan.checkers/.classpath @@ -1,6 +1,6 @@ - + diff --git a/codan/org.eclipse.cdt.codan.checkers/.settings/org.eclipse.jdt.core.prefs b/codan/org.eclipse.cdt.codan.checkers/.settings/org.eclipse.jdt.core.prefs index dbff50f1c0d..72d8fceef3f 100644 --- a/codan/org.eclipse.cdt.codan.checkers/.settings/org.eclipse.jdt.core.prefs +++ b/codan/org.eclipse.cdt.codan.checkers/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Wed Feb 23 19:43:41 EST 2011 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -72,7 +72,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 diff --git a/codan/org.eclipse.cdt.codan.checkers/META-INF/MANIFEST.MF b/codan/org.eclipse.cdt.codan.checkers/META-INF/MANIFEST.MF index b447bb01b12..927ef1364fe 100644 --- a/codan/org.eclipse.cdt.codan.checkers/META-INF/MANIFEST.MF +++ b/codan/org.eclipse.cdt.codan.checkers/META-INF/MANIFEST.MF @@ -10,7 +10,7 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.cdt.core;bundle-version="5.1.0", org.eclipse.cdt.codan.core.cxx;bundle-version="1.0.0" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-Vendor: %Bundle-Vendor Export-Package: org.eclipse.cdt.codan.checkers, org.eclipse.cdt.codan.internal.checkers;x-friends:="org.eclipse.cdt.codan.checkers.ui,org.eclipse.cdt.codan.core.test" diff --git a/codan/org.eclipse.cdt.codan.checkers/pom.xml b/codan/org.eclipse.cdt.codan.checkers/pom.xml index e2759b2274b..3bf53767e3a 100644 --- a/codan/org.eclipse.cdt.codan.checkers/pom.xml +++ b/codan/org.eclipse.cdt.codan.checkers/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/codan/org.eclipse.cdt.codan.core.cxx/.classpath b/codan/org.eclipse.cdt.codan.core.cxx/.classpath index 64c5e31b7a2..ad32c83a788 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/.classpath +++ b/codan/org.eclipse.cdt.codan.core.cxx/.classpath @@ -1,6 +1,6 @@ - + diff --git a/codan/org.eclipse.cdt.codan.core.cxx/.settings/org.eclipse.jdt.core.prefs b/codan/org.eclipse.cdt.codan.core.cxx/.settings/org.eclipse.jdt.core.prefs index bc351a2f381..cb4535a3431 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/.settings/org.eclipse.jdt.core.prefs +++ b/codan/org.eclipse.cdt.codan.core.cxx/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Wed Feb 23 19:43:49 EST 2011 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -72,7 +72,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 diff --git a/codan/org.eclipse.cdt.codan.core.cxx/META-INF/MANIFEST.MF b/codan/org.eclipse.cdt.codan.core.cxx/META-INF/MANIFEST.MF index e9b5b18bd6b..5ae26879718 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/META-INF/MANIFEST.MF +++ b/codan/org.eclipse.cdt.codan.core.cxx/META-INF/MANIFEST.MF @@ -13,5 +13,5 @@ Export-Package: org.eclipse.cdt.codan.core.cxx, org.eclipse.cdt.codan.core.cxx.internal.model;x-friends:="org.eclipse.cdt.codan.checkers.ui,org.eclipse.cdt.codan.ui,org.eclipse.cdt.codan.ui.cxx", org.eclipse.cdt.codan.core.cxx.internal.model.cfg;x-friends:="org.eclipse.cdt.codan.core.test", org.eclipse.cdt.codan.core.cxx.model -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-Vendor: %Bundle-Vendor diff --git a/codan/org.eclipse.cdt.codan.core.cxx/pom.xml b/codan/org.eclipse.cdt.codan.core.cxx/pom.xml index 25390c058ce..d023aa204df 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/pom.xml +++ b/codan/org.eclipse.cdt.codan.core.cxx/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/codan/org.eclipse.cdt.codan.core.test/.classpath b/codan/org.eclipse.cdt.codan.core.test/.classpath index 64c5e31b7a2..ad32c83a788 100644 --- a/codan/org.eclipse.cdt.codan.core.test/.classpath +++ b/codan/org.eclipse.cdt.codan.core.test/.classpath @@ -1,6 +1,6 @@ - + diff --git a/codan/org.eclipse.cdt.codan.core.test/.settings/org.eclipse.jdt.core.prefs b/codan/org.eclipse.cdt.codan.core.test/.settings/org.eclipse.jdt.core.prefs index 6cb1f62297b..00a23997e3b 100644 --- a/codan/org.eclipse.cdt.codan.core.test/.settings/org.eclipse.jdt.core.prefs +++ b/codan/org.eclipse.cdt.codan.core.test/.settings/org.eclipse.jdt.core.prefs @@ -1,8 +1,8 @@ #Wed Feb 23 19:43:55 EST 2011 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore @@ -68,7 +68,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 diff --git a/codan/org.eclipse.cdt.codan.core.test/META-INF/MANIFEST.MF b/codan/org.eclipse.cdt.codan.core.test/META-INF/MANIFEST.MF index 7afa45efff2..c7de299e4a6 100644 --- a/codan/org.eclipse.cdt.codan.core.test/META-INF/MANIFEST.MF +++ b/codan/org.eclipse.cdt.codan.core.test/META-INF/MANIFEST.MF @@ -20,7 +20,7 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.ui.ide;bundle-version="3.6.0", org.eclipse.cdt.codan.ui.cxx;bundle-version="2.0.0" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-Vendor: %Bundle-Vendor Export-Package: org.eclipse.cdt.codan.core.cfg, org.eclipse.cdt.codan.core.cxx, diff --git a/codan/org.eclipse.cdt.codan.core.test/build.properties b/codan/org.eclipse.cdt.codan.core.test/build.properties index 50bab9e99aa..c62e0c254a5 100644 --- a/codan/org.eclipse.cdt.codan.core.test/build.properties +++ b/codan/org.eclipse.cdt.codan.core.test/build.properties @@ -17,5 +17,5 @@ bin.includes = META-INF/,\ test.xml,\ OSGI-INF/,\ about.html -jre.compilation.profile = J2SE-1.5 +jre.compilation.profile = JavaSE-1.6 src.includes = about.html diff --git a/codan/org.eclipse.cdt.codan.core.test/pom.xml b/codan/org.eclipse.cdt.codan.core.test/pom.xml index d16f9260f99..f84e8acc9a2 100644 --- a/codan/org.eclipse.cdt.codan.core.test/pom.xml +++ b/codan/org.eclipse.cdt.codan.core.test/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/codan/org.eclipse.cdt.codan.core/.classpath b/codan/org.eclipse.cdt.codan.core/.classpath index 5e4c1fe99cf..4c62a8048e6 100644 --- a/codan/org.eclipse.cdt.codan.core/.classpath +++ b/codan/org.eclipse.cdt.codan.core/.classpath @@ -2,6 +2,6 @@ - + diff --git a/codan/org.eclipse.cdt.codan.core/.settings/org.eclipse.jdt.core.prefs b/codan/org.eclipse.cdt.codan.core/.settings/org.eclipse.jdt.core.prefs index dba31ee90bb..8f13f952a72 100644 --- a/codan/org.eclipse.cdt.codan.core/.settings/org.eclipse.jdt.core.prefs +++ b/codan/org.eclipse.cdt.codan.core/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Wed Feb 23 19:43:25 EST 2011 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -87,7 +87,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 diff --git a/codan/org.eclipse.cdt.codan.core/META-INF/MANIFEST.MF b/codan/org.eclipse.cdt.codan.core/META-INF/MANIFEST.MF index 8bc68ff7a5f..674cf7b6a00 100644 --- a/codan/org.eclipse.cdt.codan.core/META-INF/MANIFEST.MF +++ b/codan/org.eclipse.cdt.codan.core/META-INF/MANIFEST.MF @@ -8,7 +8,7 @@ Bundle-Vendor: %Bundle-Vendor Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.resources Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Export-Package: org.eclipse.cdt.codan.core, org.eclipse.cdt.codan.core.model, org.eclipse.cdt.codan.core.model.cfg;x-friends:="org.eclipse.cdt.codan.core.cxx,org.eclipse.cdt.codan.checkers", diff --git a/codan/org.eclipse.cdt.codan.core/pom.xml b/codan/org.eclipse.cdt.codan.core/pom.xml index 7e97533798b..487fadb81ae 100644 --- a/codan/org.eclipse.cdt.codan.core/pom.xml +++ b/codan/org.eclipse.cdt.codan.core/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/codan/org.eclipse.cdt.codan.ui.cfgview/.classpath b/codan/org.eclipse.cdt.codan.ui.cfgview/.classpath index 64c5e31b7a2..ad32c83a788 100644 --- a/codan/org.eclipse.cdt.codan.ui.cfgview/.classpath +++ b/codan/org.eclipse.cdt.codan.ui.cfgview/.classpath @@ -1,6 +1,6 @@ - + diff --git a/codan/org.eclipse.cdt.codan.ui.cfgview/.settings/org.eclipse.jdt.core.prefs b/codan/org.eclipse.cdt.codan.ui.cfgview/.settings/org.eclipse.jdt.core.prefs index b588de384cd..6978df9a2b0 100644 --- a/codan/org.eclipse.cdt.codan.ui.cfgview/.settings/org.eclipse.jdt.core.prefs +++ b/codan/org.eclipse.cdt.codan.ui.cfgview/.settings/org.eclipse.jdt.core.prefs @@ -1,11 +1,11 @@ #Wed Feb 23 19:44:14 EST 2011 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 diff --git a/codan/org.eclipse.cdt.codan.ui.cfgview/META-INF/MANIFEST.MF b/codan/org.eclipse.cdt.codan.ui.cfgview/META-INF/MANIFEST.MF index 4671df836a0..9c7a132222c 100644 --- a/codan/org.eclipse.cdt.codan.ui.cfgview/META-INF/MANIFEST.MF +++ b/codan/org.eclipse.cdt.codan.ui.cfgview/META-INF/MANIFEST.MF @@ -13,7 +13,7 @@ Require-Bundle: org.eclipse.ui, org.eclipse.cdt.ui;bundle-version="5.2.0", org.eclipse.core.resources;bundle-version="3.6.0", org.eclipse.ui.editors;bundle-version="3.6.0" -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.cdt.codan.ui.cfgview;x-internal:=true, org.eclipse.cdt.codan.ui.cfgview.views;x-internal:=true diff --git a/codan/org.eclipse.cdt.codan.ui.cxx/pom.xml b/codan/org.eclipse.cdt.codan.ui.cxx/pom.xml index 6271687f04e..0c5934630ea 100644 --- a/codan/org.eclipse.cdt.codan.ui.cxx/pom.xml +++ b/codan/org.eclipse.cdt.codan.ui.cxx/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/codan/org.eclipse.cdt.codan.ui/.classpath b/codan/org.eclipse.cdt.codan.ui/.classpath index 64c5e31b7a2..ad32c83a788 100644 --- a/codan/org.eclipse.cdt.codan.ui/.classpath +++ b/codan/org.eclipse.cdt.codan.ui/.classpath @@ -1,6 +1,6 @@ - + diff --git a/codan/org.eclipse.cdt.codan.ui/.settings/org.eclipse.jdt.core.prefs b/codan/org.eclipse.cdt.codan.ui/.settings/org.eclipse.jdt.core.prefs index 408b1fe6f3c..4657fb0782e 100644 --- a/codan/org.eclipse.cdt.codan.ui/.settings/org.eclipse.jdt.core.prefs +++ b/codan/org.eclipse.cdt.codan.ui/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Sun Feb 27 22:29:21 EST 2011 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -72,7 +72,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 diff --git a/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF b/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF index 06f3f7a0852..a294b632d94 100644 --- a/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF +++ b/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF @@ -14,7 +14,7 @@ Require-Bundle: org.eclipse.ui, org.eclipse.ui.ide, org.eclipse.cdt.ui, org.eclipse.core.filesystem -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.cdt.codan.internal.ui;x-friends:="org.eclipse.cdt.codan.ui.cxx", org.eclipse.cdt.codan.internal.ui.actions;x-friends:="org.eclipse.cdt.codan.ui.cxx", diff --git a/codan/org.eclipse.cdt.codan.ui/pom.xml b/codan/org.eclipse.cdt.codan.ui/pom.xml index c6b52af4dd3..492cdd64b84 100644 --- a/codan/org.eclipse.cdt.codan.ui/pom.xml +++ b/codan/org.eclipse.cdt.codan.ui/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java index a69563587ba..fb2396a13d5 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java @@ -13,6 +13,7 @@ package org.eclipse.cdt.codan.internal.ui.preferences; import java.text.MessageFormat; +import org.eclipse.cdt.codan.core.CodanRuntime; import org.eclipse.cdt.codan.core.PreferenceConstants; import org.eclipse.cdt.codan.core.model.CodanSeverity; import org.eclipse.cdt.codan.core.model.IProblem; @@ -332,16 +333,18 @@ public class ProblemsTreeEditor extends CheckedTreeEditor { @Override protected void doLoadDefault() { if (getTreeControl() != null) { + CodanPreferencesLoader defaultPreferences = new CodanPreferencesLoader(CodanRuntime.getInstance().getCheckersRegistry().getDefaultProfile()); IProblem[] probs = codanPreferencesLoader.getProblems(); for (int i = 0; i < probs.length; i++) { String id = probs[i].getId(); String s = getPreferenceStore().getDefaultString(id); if (s == null || s.length() == 0) { - s = codanPreferencesLoader.getProperty(id); + s = defaultPreferences.getProperty(id); } codanPreferencesLoader.setProperty(id, s); } getViewer().setInput(codanPreferencesLoader.getInput()); + setPresentsDefaultValue(true); } } diff --git a/core/org.eclipse.cdt.core.aix/pom.xml b/core/org.eclipse.cdt.core.aix/pom.xml index 9f9cefad3a8..e7ef93c92fd 100644 --- a/core/org.eclipse.cdt.core.aix/pom.xml +++ b/core/org.eclipse.cdt.core.aix/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/core/org.eclipse.cdt.core.linux.ia64/pom.xml b/core/org.eclipse.cdt.core.linux.ia64/pom.xml index c87a7453fa1..c88cee3744e 100644 --- a/core/org.eclipse.cdt.core.linux.ia64/pom.xml +++ b/core/org.eclipse.cdt.core.linux.ia64/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/core/org.eclipse.cdt.core.linux.ppc/pom.xml b/core/org.eclipse.cdt.core.linux.ppc/pom.xml index c726fc17ca6..169c4c22d54 100644 --- a/core/org.eclipse.cdt.core.linux.ppc/pom.xml +++ b/core/org.eclipse.cdt.core.linux.ppc/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/core/org.eclipse.cdt.core.linux.ppc64/pom.xml b/core/org.eclipse.cdt.core.linux.ppc64/pom.xml index 30331649e75..2613b0dda51 100644 --- a/core/org.eclipse.cdt.core.linux.ppc64/pom.xml +++ b/core/org.eclipse.cdt.core.linux.ppc64/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/core/org.eclipse.cdt.core.linux.x86/pom.xml b/core/org.eclipse.cdt.core.linux.x86/pom.xml index c656800088b..a1f878a1295 100644 --- a/core/org.eclipse.cdt.core.linux.x86/pom.xml +++ b/core/org.eclipse.cdt.core.linux.x86/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/core/org.eclipse.cdt.core.linux.x86_64/pom.xml b/core/org.eclipse.cdt.core.linux.x86_64/pom.xml index d1ad6ed7809..210e29e510c 100644 --- a/core/org.eclipse.cdt.core.linux.x86_64/pom.xml +++ b/core/org.eclipse.cdt.core.linux.x86_64/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/core/org.eclipse.cdt.core.linux/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.linux/META-INF/MANIFEST.MF index c54d2ff7eaa..80e45316a4e 100644 --- a/core/org.eclipse.cdt.core.linux/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core.linux/META-INF/MANIFEST.MF @@ -7,5 +7,5 @@ Bundle-ClassPath: cdt_linux.jar Bundle-Vendor: %providerName Fragment-Host: org.eclipse.cdt.core;bundle-version="[5.2.0,6.0.0)" Bundle-Localization: plugin -Bundle-RequiredExecutionEnvironment: J2SE-1.4 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Eclipse-PlatformFilter: (osgi.os=linux) diff --git a/core/org.eclipse.cdt.core.linux/pom.xml b/core/org.eclipse.cdt.core.linux/pom.xml index 9b10fc24d13..16bbdbbd6ef 100644 --- a/core/org.eclipse.cdt.core.linux/pom.xml +++ b/core/org.eclipse.cdt.core.linux/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/core/org.eclipse.cdt.core.macosx/pom.xml b/core/org.eclipse.cdt.core.macosx/pom.xml index bbbffa5863f..cada32ecf33 100644 --- a/core/org.eclipse.cdt.core.macosx/pom.xml +++ b/core/org.eclipse.cdt.core.macosx/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/core/org.eclipse.cdt.core.solaris/pom.xml b/core/org.eclipse.cdt.core.solaris/pom.xml index 8e2e7d124da..0bb9cd48d85 100644 --- a/core/org.eclipse.cdt.core.solaris/pom.xml +++ b/core/org.eclipse.cdt.core.solaris/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/core/org.eclipse.cdt.core.tests/.classpath b/core/org.eclipse.cdt.core.tests/.classpath index a32029e2315..71e490e81a7 100644 --- a/core/org.eclipse.cdt.core.tests/.classpath +++ b/core/org.eclipse.cdt.core.tests/.classpath @@ -6,7 +6,7 @@ - + diff --git a/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.core.prefs b/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.core.prefs index 67b45007e60..596d561f4e2 100644 --- a/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.core.prefs +++ b/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Wed Jan 02 10:16:52 EST 2008 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -59,4 +59,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=di org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF index ce74fc87eea..66699fb547f 100644 --- a/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF @@ -48,4 +48,4 @@ Require-Bundle: org.eclipse.core.resources, org.eclipse.ltk.core.refactoring;bundle-version="3.4.0" Bundle-ActivationPolicy: lazy Bundle-Vendor: Eclipse CDT -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/core/org.eclipse.cdt.core.tests/build.properties b/core/org.eclipse.cdt.core.tests/build.properties index 2fb22f41434..016d8b57403 100644 --- a/core/org.eclipse.cdt.core.tests/build.properties +++ b/core/org.eclipse.cdt.core.tests/build.properties @@ -28,9 +28,9 @@ source.. = model/,\ regression/,\ templateengine/ -jre.compilation.profile=J2SE-1.5 -javacSource=1.5 -javacTarget=1.5 +jre.compilation.profile=JavaSE-1.6 +javacSource=1.6 +javacTarget=1.6 javacProjectSettings=true src.includes = about.html \ No newline at end of file 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 afde4aaeeae..fae5b672666 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 @@ -524,7 +524,8 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // struct Base::Datum; // error: Datum undefined // struct Base::Data* pBase; // OK: refers to nested Data public void test3_4_4s3() throws Exception { - parse(getAboveComment(), ParserLanguage.CPP, true, 0); + String[] problems= {"::Glob", "Glob", "Base::Datum", "Datum"}; + parse(getAboveComment(), ParserLanguage.CPP, problems); } // static void f(); 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 23d42cca070..ea5a472b683 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 @@ -9351,6 +9351,22 @@ public class AST2CPPTests extends AST2BaseTest { parseAndCheckBindings(); } + // struct S { + // void f(); + // }; + // struct Vector { + // S* begin(); + // }; + // void test() { + // Vector v; + // for (auto e : v) { + // e.f(); + // } + // } + public void testAutoTypeInRangeBasedFor_359653() throws Exception { + parseAndCheckBindings(); + } + // typedef int T; // struct B { // int a, b; @@ -9538,4 +9554,32 @@ public class AST2CPPTests extends AST2BaseTest { public void testAmbiguityResolution_Bug359364() throws Exception { parseAndCheckBindings(); } + + // template struct C { + // C(const C& c) {} + // }; + // struct D { + // typedef const D& TD; + // D(TD c) {} + // }; + // struct E { + // E(); + // }; + // typedef E F; + // F::E(){} + public void testImplicitCtors_360223() throws Exception { + 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); + ctors = c.getConstructors(); + assertEquals(1, ctors.length); + assertFalse(ctors[0].isImplicit()); + + IBinding ctor= bh.assertNonProblem("E(){}", 1); + assertTrue(ctor instanceof ICPPConstructor); + } } 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 9f018116ef0..ca6240ec93e 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 @@ -3761,17 +3761,17 @@ public class AST2TemplateTests extends AST2BaseTest { // ~DumbPtr (); // }; // template - // DumbPtr::DumbPtr/**/ (const DumbPtr& aObj) { + // DumbPtr::DumbPtr/**/ (const DumbPtr& aObj) { // } // template - // DumbPtr::~DumbPtr/**/ () { + // DumbPtr::~DumbPtr/**/ () { // } public void testCtorWithTemplateID_259600() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); BindingAssertionHelper bh= new BindingAssertionHelper(code, true); - ICPPConstructor ctor= bh.assertNonProblem("DumbPtr/**/", 10); - ICPPMethod dtor= bh.assertNonProblem("~DumbPtr/**/", 11); + ICPPConstructor ctor= bh.assertNonProblem("DumbPtr/**/", 7); + ICPPMethod dtor= bh.assertNonProblem("~DumbPtr/**/", 8); } // template class XT { @@ -5470,7 +5470,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testTemplateTemplateParameterMatching_352859() throws Exception { parseAndCheckBindings(); } - + // template T f(); // template<> int f() { // return 0; @@ -5482,7 +5482,7 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPTemplateInstance inst= bh.assertNonProblem("f() {", 1); assertSame(template, inst.getTemplateDefinition()); } - + // template class A{}; // template class A{}; // template class A{}; @@ -5497,7 +5497,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testExplicitSpecializationOfForbiddenAsImplicit_356818() throws Exception { parseAndCheckBindings(); } - + // struct A { // void f() { } // }; @@ -5522,11 +5522,56 @@ public class AST2TemplateTests extends AST2BaseTest { public void testSpecializationOfUsingDeclaration_357293() throws Exception { parseAndCheckBindings(); } - + // template struct SS {}; // template > class Cont> // Cont f() {} public void testReferenceToParameterOfTemplateTemplateParameter_357308() throws Exception { parseAndCheckBindings(); } + + // template void f() {} + // void test() { + // f(); + // f<>(); + // } + public void testTemplateArgumentDeductionWithoutParameters_358654() throws Exception { + parseAndCheckBindings(); + } + + // template + // struct C { + // typedef int s; + // }; + // + // template + // struct C { + // typedef T s; + // }; + // + // struct B { + // typedef B u; + // }; + // + // struct C8 { char c[8]; }; + // + // typedef C r; + // typedef r::s t; + // t::u x; + public void testBoolExpressionAsTemplateArgument_361604() throws Exception { + final String code= getAboveComment(); + parseAndCheckBindings(code); + } + + // template struct B { + // void m(); + // }; + // template struct C : B { + // using B::m; + // void m(); + // }; + // template void C::m() {} + public void testDependentUsingDeclaration() throws Exception { + parseAndCheckBindings(); + } } 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 c6392ba67ef..a1744313ddb 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 @@ -138,7 +138,13 @@ public class AST2Tests extends AST2BaseTest { public AST2Tests(String name) { super(name); } - + + private void parseAndCheckBindings() throws Exception { + String code= getAboveComment(); + parseAndCheckBindings(code, ParserLanguage.C); + parseAndCheckBindings(code, ParserLanguage.CPP); + } + protected IASTTranslationUnit parseAndCheckBindings(String code) throws Exception { return parseAndCheckBindings(code, ParserLanguage.C); } @@ -7360,4 +7366,13 @@ public class AST2Tests extends AST2BaseTest { es= getStatement(a, 2); assertEquals("unsigned long int", ASTTypeUtil.getType(es.getExpression().getExpressionType())); } + + // void foo(){ + // typedef int foobar_t; + // foobar_t *a = 0, *b = a; + // } + public void testAmbiguousStatement_Bug360541() throws Exception { + parseAndCheckBindings(); + } + } 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 8e30a70c3ce..5e0277075f3 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 @@ -655,7 +655,7 @@ public class CompleteParser2Tests extends BaseTestCase { public void testNestedClassname() throws Exception { - IASTTranslationUnit tu = parse( "namespace A { } \n class A::B { };"); //$NON-NLS-1$ + IASTTranslationUnit tu = parse( "namespace A { \n class A::B { };}"); //$NON-NLS-1$ CPPNameCollector col = new CPPNameCollector(); tu.accept( col ); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationInclusionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationInclusionTests.java index ddc284ea9ba..82846d56284 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationInclusionTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationInclusionTests.java @@ -1,13 +1,13 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; @@ -35,6 +35,7 @@ import org.eclipse.cdt.core.parser.ExtendedScannerInfo; import org.eclipse.cdt.core.parser.IExtendedScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.ParserLanguage; +import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; @@ -70,9 +71,9 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest { String code = "int main() { return BEAST * sizeof( Include ); } "; //$NON-NLS-1$ for (ParserLanguage p : ParserLanguage.values()) { String filename = (p == ParserLanguage.CPP) ? "main.cc" : "main.c"; //$NON-NLS-1$ //$NON-NLS-2$ - IFile c = importFile(filename, code); //$NON-NLS-1$ //$NON-NLS-2$ + IFile c = importFile(filename, code); - IASTTranslationUnit tu = parse(c, scannerInfo); //$NON-NLS-1$ + IASTTranslationUnit tu = parse(c, scannerInfo); IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[3]; IASTFileLocation floc = fd.getFileLocation(); assertEquals(floc.getNodeOffset(), @@ -102,11 +103,11 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest { for (ParserLanguage p : ParserLanguage.values()) { String filename = (p == ParserLanguage.CPP) ? "blah.cc" : "blah.c"; //$NON-NLS-1$ //$NON-NLS-2$ - IFile source = importFile(filename, code); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(source); //$NON-NLS-1$ + IFile source = importFile(filename, code); + IASTTranslationUnit tu = parse(source); IASTSimpleDeclaration declaration = (IASTSimpleDeclaration) tu.getDeclarations()[0]; assertSoleFileLocation(declaration.getDeclarators()[0], filename, - code.indexOf("SomeStructure"), "SomeStructure".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + code.indexOf("SomeStructure"), "SomeStructure".length()); //$NON-NLS-1$ //$NON-NLS-2$ } } } @@ -206,13 +207,13 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest { for (ParserLanguage p : ParserLanguage.values()) { String filename = (p == ParserLanguage.CPP) ? "code.cc" : "code.c"; //$NON-NLS-1$ //$NON-NLS-2$ - IFile cpp = importFile(filename, code); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(cpp); //$NON-NLS-1$ + IFile cpp = importFile(filename, code); + IASTTranslationUnit tu = parse(cpp); IASTDeclaration[] declarations = tu.getDeclarations(); assertEquals(declarations.length, 2); IASTSimpleDeclaration bar = (IASTSimpleDeclaration) declarations[0]; IASTSimpleDeclaration FOO = (IASTSimpleDeclaration) declarations[1]; - assertSoleFileLocation(bar, filename, code.indexOf("int"), code.indexOf(";") + 1); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + assertSoleFileLocation(bar, filename, code.indexOf("int"), code.indexOf(";") + 1); //$NON-NLS-1$ //$NON-NLS-2$ assertSoleFileLocation(FOO, "foo.h", foo.indexOf("int"), foo.indexOf(";") + 1); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ IASTPreprocessorIncludeStatement[] incs = tu.getIncludeDirectives(); @@ -243,8 +244,8 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest { for (ParserLanguage p : ParserLanguage.values()) { String filename = (p == ParserLanguage.CPP) ? "code.cc" : "code.c"; //$NON-NLS-1$ //$NON-NLS-2$ - IFile cpp = importFile(filename, code); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(cpp); //$NON-NLS-1$ + IFile cpp = importFile(filename, code); + IASTTranslationUnit tu = parse(cpp); IASTDeclaration[] declarations = tu.getDeclarations(); assertEquals(declarations.length, 3); IASTSimpleDeclaration bar = (IASTSimpleDeclaration) declarations[0]; @@ -253,21 +254,21 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest { assertSoleFileLocation( bar, filename, - code.indexOf("int"), code.indexOf("r;") + 2 - code.indexOf("int")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + code.indexOf("int"), code.indexOf("r;") + 2 - code.indexOf("int")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertSoleFileLocation( FOO, "foo.h", foo.indexOf("int"), foo.indexOf(";") + 1 - foo.indexOf("int")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertSoleFileLocation( byob, filename, - code.indexOf("float"), code.indexOf("b;") + 2 - code.indexOf("float")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + code.indexOf("float"), code.indexOf("b;") + 2 - code.indexOf("float")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ IASTPreprocessorIncludeStatement[] incs = tu.getIncludeDirectives(); assertNotNull(incs); assertEquals(incs.length, 1); assertSoleFileLocation( incs[0], filename, - code.indexOf("#inc"), code.indexOf(".h\"\n") + ".h\"".length() - code.indexOf("#inc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + code.indexOf("#inc"), code.indexOf(".h\"\n") + ".h\"".length() - code.indexOf("#inc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } } @@ -278,8 +279,8 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest { for (ParserLanguage p : ParserLanguage.values()) { String filename = (p == ParserLanguage.CPP) ? "blah.cc" : "blah.c"; //$NON-NLS-1$ //$NON-NLS-2$ - IFile c_file = importFile(filename, c_file_code); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(c_file); //$NON-NLS-1$ + IFile c_file = importFile(filename, c_file_code); + IASTTranslationUnit tu = parse(c_file); assertEquals(tu.getDeclarations().length, 0); IASTPreprocessorMacroDefinition[] macroDefinitions = tu .getMacroDefinitions(); @@ -288,9 +289,9 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest { assertSoleFileLocation( macroDefinitions[0], filename, - c_file_code.indexOf("#define"), c_file_code.indexOf("4") + 1 - c_file_code.indexOf("#define")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + c_file_code.indexOf("#define"), c_file_code.indexOf("4") + 1 - c_file_code.indexOf("#define")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertSoleFileLocation(macroDefinitions[0].getName(), filename, - c_file_code.indexOf("X"), 1); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + c_file_code.indexOf("X"), 1); //$NON-NLS-1$ assertSoleFileLocation( macroDefinitions[1], "blarg.h", h_file_code.indexOf("#define _BLARG_H_"), "#define _BLARG_H_".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ @@ -299,17 +300,17 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest { "blarg.h", h_file_code.indexOf("e _BLARG_H_") + 2, "_BLARG_H_".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertSoleFileLocation( macroDefinitions[2], - "blarg.h", h_file_code.indexOf("#define PRINT(s,m) printf(s,m)\r"), "#define PRINT(s,m) printf(s,m)".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "blarg.h", h_file_code.indexOf("#define PRINT(s,m) printf(s,m)\r"), "#define PRINT(s,m) printf(s,m)".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertSoleFileLocation(macroDefinitions[2].getName(), - "blarg.h", h_file_code.indexOf("PRINT"), "PRINT".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "blarg.h", h_file_code.indexOf("PRINT"), "PRINT".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertSoleFileLocation( macroDefinitions[3], filename, - c_file_code.indexOf("#define POST_INCLUDE"), "#define POST_INCLUDE".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + c_file_code.indexOf("#define POST_INCLUDE"), "#define POST_INCLUDE".length()); //$NON-NLS-1$ //$NON-NLS-2$ assertSoleFileLocation( macroDefinitions[3].getName(), filename, - c_file_code.indexOf("POST_INCLUDE"), "POST_INCLUDE".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + c_file_code.indexOf("POST_INCLUDE"), "POST_INCLUDE".length()); //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -322,7 +323,7 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest { for (ParserLanguage p : ParserLanguage.values()) { String filename = (p == ParserLanguage.CPP) ? "source.cc" : "source.c"; //$NON-NLS-1$ //$NON-NLS-2$ - IFile f = importFile(filename, cpp_code); //$NON-NLS-1$ + IFile f = importFile(filename, cpp_code); IASTTranslationUnit tu = parse(f); IASTDeclaration[] declarations = tu.getDeclarations(); IASTPreprocessorIncludeStatement[] includeDirectives = tu @@ -330,7 +331,7 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest { assertSoleFileLocation( includeDirectives[0], filename, - cpp_code.indexOf("#include \"header1.h\""), "#include \"header1.h\"".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + cpp_code.indexOf("#include \"header1.h\""), "#include \"header1.h\"".length()); //$NON-NLS-1$ //$NON-NLS-2$ assertSoleFileLocation(declarations[0], "header1.h", 0, "int x;".length()); //$NON-NLS-1$ //$NON-NLS-2$ assertSoleFileLocation(declarations[1], @@ -338,9 +339,9 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest { assertSoleFileLocation( includeDirectives[1], filename, - cpp_code.indexOf("#include \"header2.h\""), "#include \"header2.h\"".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + cpp_code.indexOf("#include \"header2.h\""), "#include \"header2.h\"".length()); //$NON-NLS-1$ //$NON-NLS-2$ assertSoleFileLocation(declarations[2], filename, cpp_code - .indexOf("int z;"), "int z;".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + .indexOf("int z;"), "int z;".length()); //$NON-NLS-1$ //$NON-NLS-2$ IASTTranslationUnit.IDependencyTree tree = tu.getDependencyTree(); assertEquals(tree.getInclusions().length, 2); @@ -357,8 +358,8 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest { for (ParserLanguage p : ParserLanguage.values()) { String filename = (p == ParserLanguage.CPP) ? "blah.cc" : "blah.c"; //$NON-NLS-1$ //$NON-NLS-2$ - IFile c_file = importFile(filename, c_file_code); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(c_file); //$NON-NLS-1$ + IFile c_file = importFile(filename, c_file_code); + IASTTranslationUnit tu = parse(c_file); assertEquals(tu.getDeclarations().length, 0); IASTPreprocessorMacroDefinition[] macroDefinitions = tu.getMacroDefinitions(); assertNotNull(macroDefinitions); @@ -366,9 +367,9 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest { assertSoleFileLocation( macroDefinitions[0], filename, - c_file_code.indexOf("#define"), c_file_code.indexOf("4") + 1 - c_file_code.indexOf("#define")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + c_file_code.indexOf("#define"), c_file_code.indexOf("4") + 1 - c_file_code.indexOf("#define")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertSoleFileLocation(macroDefinitions[0].getName(), filename, - c_file_code.indexOf("X"), 1); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + c_file_code.indexOf("X"), 1); //$NON-NLS-1$ assertSoleFileLocation( macroDefinitions[1], "blarg.h", h_file_code.indexOf("#define _BLARG_H_"), "#define _BLARG_H_".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ @@ -377,24 +378,24 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest { "blarg.h", h_file_code.indexOf("e _BLARG_H_") + 2, "_BLARG_H_".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertSoleFileLocation( macroDefinitions[2], - "blarg.h", h_file_code.indexOf("#define PRINT(s,m) printf(s,m)\r"), "#define PRINT(s,m) printf(s,m)".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "blarg.h", h_file_code.indexOf("#define PRINT(s,m) printf(s,m)\r"), "#define PRINT(s,m) printf(s,m)".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertSoleFileLocation(macroDefinitions[2].getName(), - "blarg.h", h_file_code.indexOf("PRINT"), "PRINT".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "blarg.h", h_file_code.indexOf("PRINT"), "PRINT".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertSoleFileLocation( macroDefinitions[3], filename, - c_file_code.indexOf("#define POST_INCLUDE"), "#define POST_INCLUDE".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + c_file_code.indexOf("#define POST_INCLUDE"), "#define POST_INCLUDE".length()); //$NON-NLS-1$ //$NON-NLS-2$ assertSoleFileLocation( macroDefinitions[3].getName(), filename, - c_file_code.indexOf("POST_INCLUDE"), "POST_INCLUDE".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + c_file_code.indexOf("POST_INCLUDE"), "POST_INCLUDE".length()); //$NON-NLS-1$ //$NON-NLS-2$ assertSoleFileLocation( macroDefinitions[4], "second.h", h_file2_code.indexOf("#define _SECOND_H_"), "#define _SECOND_H_".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertSoleFileLocation( macroDefinitions[5], filename, - c_file_code.indexOf("#define POST_SECOND"), "#define POST_SECOND".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + c_file_code.indexOf("#define POST_SECOND"), "#define POST_SECOND".length()); //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -411,15 +412,15 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest { buffer.append("};\n"); //$NON-NLS-1$ buffer.append("#endif /*_INCLUDE_H_*/\n"); //$NON-NLS-1$ final String inc_file_code = buffer.toString(); - IFile include_file = importFile("include.h", inc_file_code); //$NON-NLS-1$ //$NON-NLS-2$ + IFile include_file = importFile("include.h", inc_file_code); //$NON-NLS-1$ String[] macros = { imacro_file.getLocation().toOSString() }; String[] includes = { include_file.getLocation().toOSString() }; IExtendedScannerInfo scannerInfo = new ExtendedScannerInfo(Collections.EMPTY_MAP, EMPTY_STRING_ARRAY, macros, includes); for (ParserLanguage p : ParserLanguage.values()) { String filename = (p == ParserLanguage.CPP) ? "main.cc" : "main.c"; //$NON-NLS-1$ //$NON-NLS-2$ - IFile code = importFile(filename, "int main() { return BEAST * sizeof( Include ); } "); //$NON-NLS-1$ //$NON-NLS-2$ - IASTTranslationUnit tu = parse(code, scannerInfo); //$NON-NLS-1$ + IFile code = importFile(filename, "int main() { return BEAST * sizeof( Include ); } "); //$NON-NLS-1$ + IASTTranslationUnit tu = parse(code, scannerInfo); IASTPreprocessorMacroDefinition[] macro_defs = tu.getMacroDefinitions(); assertEquals(macro_defs.length, 2); IASTPreprocessorMacroDefinition BEAST = macro_defs[0]; @@ -443,8 +444,8 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest { for (ParserLanguage p : ParserLanguage.values()) { String filename = (p == ParserLanguage.CPP) ? "blah.cc" : "blah.c"; //$NON-NLS-1$ //$NON-NLS-2$ - IFile f = importFile(filename, code); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(f); //$NON-NLS-1$ + IFile f = importFile(filename, code); + IASTTranslationUnit tu = parse(f); IASTProblem[] prbs = tu.getPreprocessorProblems(); assertEquals(prbs.length, 1); IASTNodeLocation[] locs = prbs[0].getNodeLocations(); @@ -474,16 +475,16 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest { buffer.append("};\n"); //$NON-NLS-1$ buffer.append("#endif /*_INCLUDE_H_*/\n"); //$NON-NLS-1$ final String inc_file_code = buffer.toString(); - IFile include_file = importFile("include.h", inc_file_code); //$NON-NLS-1$ //$NON-NLS-2$ + IFile include_file = importFile("include.h", inc_file_code); //$NON-NLS-1$ String[] macros = { imacro_file.getLocation().toOSString() }; String[] includes = { include_file.getLocation().toOSString() }; IExtendedScannerInfo scannerInfo = new ExtendedScannerInfo( Collections.EMPTY_MAP, EMPTY_STRING_ARRAY, macros, includes); for (ParserLanguage p : ParserLanguage.values()) { String filename = (p == ParserLanguage.CPP) ? "main.cc" : "main.c"; //$NON-NLS-1$ //$NON-NLS-2$ - IFile code = importFile(filename, "int main() { return BEAST * sizeof( Include ); } "); //$NON-NLS-1$ //$NON-NLS-2$ + IFile code = importFile(filename, "int main() { return BEAST * sizeof( Include ); } "); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(code, scannerInfo); //$NON-NLS-1$ + IASTTranslationUnit tu = parse(code, scannerInfo); IASTPreprocessorMacroDefinition[] macro_defs = tu.getMacroDefinitions(); assertEquals(macro_defs.length, 4); IASTPreprocessorMacroDefinition BEAST = macro_defs[0]; @@ -515,14 +516,14 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest { buffer.append("};\n"); //$NON-NLS-1$ buffer.append("#endif /*_INCLUDE_H_*/\n"); //$NON-NLS-1$ final String inc_file_code = buffer.toString(); - IFile include_file = importFile("include.h", inc_file_code); //$NON-NLS-1$ //$NON-NLS-2$ + IFile include_file = importFile("include.h", inc_file_code); //$NON-NLS-1$ String[] macros = { imacro_file1.getLocation().toOSString(), imacro_file2.getLocation().toOSString() }; String[] includes = { include_file.getLocation().toOSString() }; IExtendedScannerInfo scannerInfo = new ExtendedScannerInfo(Collections.EMPTY_MAP, EMPTY_STRING_ARRAY, macros, includes); for (ParserLanguage p : ParserLanguage.values()) { String filename = (p == ParserLanguage.CPP) ? "main.cc" : "main.c"; //$NON-NLS-1$ //$NON-NLS-2$ - IFile code = importFile(filename, "int main() { return BEAST * sizeof( Include ); } "); //$NON-NLS-1$ //$NON-NLS-2$ + IFile code = importFile(filename, "int main() { return BEAST * sizeof( Include ); } "); //$NON-NLS-1$ IASTTranslationUnit tu = parse(code, scannerInfo); IASTPreprocessorMacroDefinition[] macro_defs = tu.getMacroDefinitions(); @@ -611,4 +612,182 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest { tmpFile.getParentFile().delete(); } } + + // // comment + // + // #ifndef guard + // #define guard + // bla bla + // #if 1 + // #endif + // bla bla + // #endif + // //comment + + // // comment + // + // #if !defined(guard) + // #define guard + // bla bla + // #if 1 + // #endif + // bla bla + // #endif + // //comment + + // // comment + // + // #if ((!defined guard)) + // #define guard + // bla bla + // #if 1 + // #endif + // bla bla + // #endif + // //comment + + // // comment + // #pragma once + + // // Some comment + // + // #ifndef AN_UNIQUE_INCLUDE_GUARD_H_ + // #define AN_UNIQUE_INCLUDE_GUARD_H_ + // + // #include + // + // Some code without any macro references + // + // #endif // AN_UNIQUE_INCLUDE_GUARD_H_ + public void testPragmaOnceDetection_197989a() throws Exception { + CharSequence[] contents= getContents(5); + + int i= 0; + for (CharSequence content : contents) { + String headerName = i + ".h"; + IFile base = importFile("base" + headerName, "#include \"" + headerName + "\""); + importFile(headerName, content.toString()); + IASTTranslationUnit tu = parse(base, new ScannerInfo()); + IASTPreprocessorIncludeStatement[] incs = tu.getIncludeDirectives(); + assertTrue(incs.length > 0); + assertTrue(incs[0].hasPragmaOnceSemantics()); + } + } + + // #ifndef guard + // #define guard2 + // #endif + + // #if !defined guard + // #define guard2 + // #endif + + // #if !defined(guard) && !defined(guard2) + // #define guard + // #endif + + // #if (0) + // #pragma once + // #endif + + // leading + // #ifndef guard + // #define guard2 + // #endif + + // #ifndef guard + // #define guard2 + // #endif + // #ifdef xx + // trailing + // #endif + public void testPragmaOnceDetection_197989b() throws Exception { + CharSequence[] contents= getContents(6); + + int i= 0; + for (CharSequence content : contents) { + String headerName = i + ".h"; + IFile base = importFile("base" + headerName, "#include \"" + headerName + "\""); + importFile(headerName, content.toString()); + IASTTranslationUnit tu = parse(base, new ScannerInfo()); + IASTPreprocessorIncludeStatement[] incs = tu.getIncludeDirectives(); + assertEquals(1, incs.length); + assertFalse(incs[0].hasPragmaOnceSemantics()); + } + } + + + // // header.h + // #ifdef AH + // #endif + // #ifndef BH + // #endif + // #define h + // #if CH || DH + // #elif EH==1 + // #endif + + // #define BH + // #define DH 0 + // #define EH 1 + // #include "header.h" + // #ifdef h // defined in header + // #endif + // #ifdef A + // #ifdef a // inactive + // #endif + // #else + // #ifndef B + // #endif + // #endif + // #if defined C + // #elif ((!((defined(D))))) + // #endif + // #define A + // #define B + // #define AH + // #define h + // #undef u + // #ifdef h // locally defined + // #endif + // #ifndef u // locally undefined + // #endif + public void testSignificantMacros_197989a() throws Exception { + CharSequence[] contents= getContents(2); + + IFile h = importFile("header.h", contents[0].toString()); + IFile c = importFile("source.c", contents[1].toString()); + + IASTTranslationUnit tu = parse(c, new ScannerInfo()); + IASTPreprocessorIncludeStatement[] incs = tu.getIncludeDirectives(); + assertEquals(1, incs.length); + assertEquals("{AH=null,BH=*,CH=null,DH=0,EH=1}", + incs[0].getSignificantMacros().toString()); + assertEquals("{A=null,AH=null,B=null,C=null,CH=null,D=null}", + tu.getSignificantMacros().toString()); + } + + // // header.h + // #if EQ(A,B) + // #endif + + // #define EQ(x,y) x==y + // #define A A1 + // #define B 1 + // #include "header.h" + public void testSignificantMacros_197989b() throws Exception { + CharSequence[] contents= getContents(2); + + IFile h = importFile("header.h", contents[0].toString()); + IFile c = importFile("source.c", contents[1].toString()); + + IASTTranslationUnit tu = parse(c, new ScannerInfo()); + IASTPreprocessorIncludeStatement[] incs = tu.getIncludeDirectives(); + assertEquals(1, incs.length); + assertEquals("{A=A1,A1=null,B=1,EQ=x==y}", + incs[0].getSignificantMacros().toString()); + assertEquals("{A1=null}", + tu.getSignificantMacros().toString()); + } + } 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 3668c5dcd15..b84db415e89 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 @@ -1,29 +1,29 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation + * IBM - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.scanner; import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.parser.FileContent; +import org.eclipse.cdt.internal.core.parser.IMacroDictionary; 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 FileCodeReaderFactory() {} - @Override - public InternalFileContent getContentForInclusion(String path) { + public InternalFileContent getContentForInclusion(String path, + IMacroDictionary macroDictionary) { return (InternalFileContent) FileContent.createForExternalFileLocation(path); } 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 7b8fccea0d1..ed65bacc85c 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 @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.scanner; @@ -37,10 +37,10 @@ import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorUndefStatement; import org.eclipse.cdt.core.dom.ast.IASTProblem; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.ast.IBinding; -import org.eclipse.cdt.core.dom.ast.IMacroBinding; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit.IDependencyTree; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit.IDependencyTree.IASTInclusionNode; +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.IMacroBinding; import org.eclipse.cdt.core.testplugin.CTestPlugin; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.core.testplugin.util.TestSourceReader; @@ -49,8 +49,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit; import org.eclipse.cdt.internal.core.parser.scanner.CharArray; import org.eclipse.cdt.internal.core.parser.scanner.ILocationCtx; import org.eclipse.cdt.internal.core.parser.scanner.ImageLocationInfo; -import org.eclipse.cdt.internal.core.parser.scanner.LocationMap; import org.eclipse.cdt.internal.core.parser.scanner.Lexer.LexerOptions; +import org.eclipse.cdt.internal.core.parser.scanner.LocationMap; public class LocationMapTests extends BaseTestCase { public class Loc implements IASTFileLocation { @@ -80,6 +80,9 @@ public class LocationMapTests extends BaseTestCase { public IASTFileLocation asFileLocation() { return this; } + public IASTPreprocessorIncludeStatement getContextInclusionStatement() { + return null; + } } private static final String FN = "filename"; @@ -336,8 +339,8 @@ public class LocationMapTests extends BaseTestCase { public void testIncludes() { init(DIGITS); - fLocationMap.encounterPoundInclude(0, 0, 0, 0, "n1".toCharArray(), null, true, false, false); - fLocationMap.encounterPoundInclude(0, 1, 3, 16, "n2".toCharArray(), "f2", false , true, false); + 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(); assertEquals(2, includes.length); checkInclude(includes[0], "", "", "n1", "", true, false, FN, 0, 0, 1, 0, 0); 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 30d98de7f11..151109c0c80 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 @@ -21,6 +21,7 @@ import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.index.IIndexLinkage; import org.eclipse.cdt.core.index.IIndexMacro; import org.eclipse.cdt.core.index.IndexFilter; +import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.cdt.internal.core.index.IIndexFragment; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; import org.eclipse.cdt.internal.core.index.IIndexFragmentFile; @@ -100,13 +101,24 @@ public class EmptyIndexFragment implements IIndexFragment { return 0; } + @Deprecated public IIndexFragmentFile getFile(int linkageID, IIndexFileLocation location) throws CoreException { return null; } + public IIndexFragmentFile getFile(int linkageID, IIndexFileLocation location, + ISignificantMacros sigMacros) throws CoreException { + return null; + } + + public IIndexFragmentFile[] getFiles(int linkageID, IIndexFileLocation location) + throws CoreException { + return IIndexFragmentFile.EMPTY_ARRAY; + } + public IIndexFragmentFile[] getFiles(IIndexFileLocation location) throws CoreException { - return new IIndexFragmentFile[0]; + return IIndexFragmentFile.EMPTY_ARRAY; } public long getLastWriteAccess() { 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 54bf1201d2f..ffe5e705c22 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 @@ -6,13 +6,16 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial implementation - * IBM Corporation - * Markus Schorn (Wind River Systems) + * Andrew Ferguson (Symbian) - Initial implementation + * IBM Corporation + * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.index.tests; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMManager; @@ -81,14 +84,19 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { } protected IASTName findName(String section, int len) { - IASTTranslationUnit ast = strategy.getAst(); - final IASTNodeSelector nodeSelector = ast.getNodeSelector(null); - final int offset = strategy.getTestData()[1].indexOf(section); - IASTName name= nodeSelector.findName(offset, len); - if (name == null) - name= nodeSelector.findImplicitName(offset, len); + for (int i = 0; i < strategy.getAstCount(); i++) { + IASTTranslationUnit ast = strategy.getAst(i); + final IASTNodeSelector nodeSelector = ast.getNodeSelector(null); + final int offset = strategy.getAstSource(i).indexOf(section); + if (offset >= 0) { + IASTName name= nodeSelector.findName(offset, len); + if (name == null) + name= nodeSelector.findImplicitName(offset, len); + return name; + } + } - return name; + return null; } /** @@ -210,7 +218,9 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { IIndex getIndex(); void setUp() throws Exception; void tearDown() throws Exception; - public IASTTranslationUnit getAst(); + public int getAstCount(); + public IASTTranslationUnit getAst(int index); + public StringBuilder getAstSource(int index); public StringBuilder[] getTestData(); public ICProject getCProject(); public boolean isCompositeIndex(); @@ -258,13 +268,25 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { return testData; } - public IASTTranslationUnit getAst() { + public int getAstCount() { + return 1; + } + + public IASTTranslationUnit getAst(int index) { + if (index != 0) + throw new IllegalArgumentException(); return ast; } + public StringBuilder getAstSource(int index) { + if (index != 0) + throw new IllegalArgumentException(); + return testData[1]; + } + 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); @@ -275,7 +297,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor())); if (DEBUG) { - System.out.println("Project PDOM: "+getName()); + System.out.println("Project PDOM: " + getName()); ((PDOM)CCoreInternals.getPDOMManager().getPDOM(cproject)).accept(new PDOMPrettyPrinter()); } @@ -304,7 +326,6 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { } } - class SinglePDOMTestStrategy implements ITestStrategy { private IIndex index; private ICProject cproject; @@ -324,10 +345,22 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { return testData; } - public IASTTranslationUnit getAst() { + public int getAstCount() { + return 1; + } + + public IASTTranslationUnit getAst(int index) { + if (index != 0) + throw new IllegalArgumentException(); return ast; } + public StringBuilder getAstSource(int index) { + if (index != 0) + throw new IllegalArgumentException(); + return testData[1]; + } + 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); @@ -370,6 +403,108 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { } } + /** + * This strategy allows tests to create an arbitrary number of header and source files + * and to obtain ASTs of any subset of the created files. + * + * The first line of each comment section preceding the test contains the name of the file + * to put the contents of the section to. To request the AST of a file, put an asterisk after + * the file name. + */ + class SinglePDOMTestNamedFilesStrategy implements ITestStrategy { + private IIndex index; + private ICProject cproject; + private StringBuilder[] testData; + private final List astSources; + private final List asts; + private final boolean cpp; + + public SinglePDOMTestNamedFilesStrategy(boolean cpp) { + this.cpp = cpp; + astSources = new ArrayList(); + asts = new ArrayList(); + } + + public ICProject getCProject() { + return cproject; + } + + public StringBuilder[] getTestData() { + return testData; + } + + public int getAstCount() { + return asts.size(); + } + + public IASTTranslationUnit getAst(int index) { + return asts.get(index); + } + + public StringBuilder getAstSource(int index) { + return astSources.get(index); + } + + 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); + Bundle b = CTestPlugin.getDefault().getBundle(); + testData = TestSourceReader.getContentsForTest(b, "parser", IndexBindingResolutionTestBase.this.getClass(), getName(), 0); + + List astFiles = new ArrayList(); + for (int i = 0; i < testData.length; i++) { + StringBuilder contents = testData[i]; + int endOfLine = contents.indexOf("\n"); + if (endOfLine >= 0) + endOfLine++; + else + endOfLine = contents.length(); + String filename = contents.substring(0, endOfLine).trim(); + contents.delete(0, endOfLine); // Remove first line from the file contents + boolean astRequested = filename.endsWith("*"); + if (astRequested) { + filename = filename.substring(0, filename.length() - 1).trim(); + } + IFile file = TestSourceReader.createFile(cproject.getProject(), new Path(filename), contents.toString()); + if (astRequested || (i == testData.length - 1 && astFiles.isEmpty())) { + astSources.add(contents); + astFiles.add(file); + } + } + CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER); + assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor())); + + if (DEBUG) { + System.out.println("Project PDOM: "+getName()); + ((PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject)).accept(new PDOMPrettyPrinter()); + } + + index= CCorePlugin.getIndexManager().getIndex(cproject); + + index.acquireReadLock(); + for (IFile file : astFiles) { + asts.add(TestSourceReader.createIndexBasedAST(index, cproject, file)); + } + } + + public void tearDown() throws Exception { + if (index != null) { + index.releaseReadLock(); + } + if (cproject != null) { + cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor()); + } + } + + public IIndex getIndex() { + return index; + } + + public boolean isCompositeIndex() { + return false; + } + } + class ReferencedProject implements ITestStrategy { private IIndex index; private ICProject cproject, referenced; @@ -445,10 +580,22 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { return referenced; } - public IASTTranslationUnit getAst() { + public int getAstCount() { + return 1; + } + + public IASTTranslationUnit getAst(int index) { + if (index != 0) + throw new IllegalArgumentException(); return ast; } + public StringBuilder getAstSource(int index) { + if (index != 0) + throw new IllegalArgumentException(); + return testData[1]; + } + public IIndex getIndex() { return index; } 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 fd67979eb33..293cbc8ae73 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 @@ -289,6 +289,17 @@ public class IndexBugsTests extends BaseTestCase { return TestSourceReader.createFile(container, new Path(fileName), contents); } + private IIndexFile getIndexFile(IFile file) throws CoreException { + return getIndexFile(fIndex, file); + } + + private IIndexFile getIndexFile(IIndex index, 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]; + } + private void waitForIndexer() throws InterruptedException { final IIndexManager indexManager = CCorePlugin.getIndexManager(); assertTrue(indexManager.joinIndexer(INDEX_WAIT_TIME, npm())); @@ -459,8 +470,7 @@ public class IndexBugsTests extends BaseTestCase { fIndex.acquireReadLock(); try { - IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)); - assertNotNull(ifile); + IIndexFile ifile= getIndexFile(file); IIndexInclude[] includes= ifile.getIncludes(); assertEquals(1, includes.length); IIndexInclude i= includes[0]; @@ -484,8 +494,7 @@ public class IndexBugsTests extends BaseTestCase { fIndex.acquireReadLock(); try { - IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)); - assertNotNull(ifile); + IIndexFile ifile= getIndexFile(file); IIndexInclude[] includes= ifile.getIncludes(); assertEquals(1, includes.length); IIndexInclude i= includes[0]; @@ -561,8 +570,7 @@ public class IndexBugsTests extends BaseTestCase { fIndex.acquireReadLock(); try { - IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)); - assertNotNull(ifile); + IIndexFile ifile= getIndexFile(file); IIndexInclude[] includes= ifile.getIncludes(); assertEquals(1, includes.length); IIndexInclude i= includes[0]; @@ -585,8 +593,7 @@ public class IndexBugsTests extends BaseTestCase { fIndex.acquireReadLock(); try { - IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)); - assertNotNull(ifile); + IIndexFile ifile= getIndexFile(file); IIndexInclude[] includes= ifile.getIncludes(); assertEquals(1, includes.length); IIndexInclude i= includes[0]; @@ -612,8 +619,7 @@ public class IndexBugsTests extends BaseTestCase { fIndex.acquireReadLock(); try { - IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)); - assertNotNull(ifile); + IIndexFile ifile= getIndexFile(file); IIndexMacro[] macros= ifile.getMacros(); assertEquals(3, macros.length); IIndexMacro m= macros[0]; @@ -1116,7 +1122,7 @@ public class IndexBugsTests extends BaseTestCase { // #endif // #ifndef _h1 - // #include "header1.h" + // #include "header1.h" // is inactive, but must be resolved // #endif // #include "header1.h" @@ -1127,7 +1133,7 @@ public class IndexBugsTests extends BaseTestCase { // #include "header2.h" // #ifndef _h1 - // #include "header1.h" + // #include "header1.h" // inactive but resolved. // #endif public void testIncludeGuardsOutsideOfHeader_Bug167100() throws Exception { final IIndexManager indexManager = CCorePlugin.getIndexManager(); @@ -1152,13 +1158,15 @@ public class IndexBugsTests extends BaseTestCase { assertEquals(1, names.length); assertEquals(f4.getFullPath().toString(), names[0].getFile().getLocation().getFullPath()); - IIndexFile idxFile= index.getFile(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(); assertEquals(2, includes.length); assertTrue(includes[0].isActive()); assertTrue(includes[0].isResolved()); assertFalse(includes[1].isActive()); - assertTrue(includes[1].isResolved()); + // includes[1].isResolved()); May or may not be resolved. } finally { index.releaseReadLock(); } @@ -1658,11 +1666,11 @@ public class IndexBugsTests extends BaseTestCase { waitForIndexer(); fIndex.acquireReadLock(); try { - IIndexFile f= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(f1)); + IIndexFile f= getIndexFile(f1); IIndexInclude i= f.getIncludes()[0]; assertTrue(i.isResolvedByHeuristics()); - f= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(f2)); + f= getIndexFile(f2); i= f.getIncludes()[0]; assertFalse(i.isResolvedByHeuristics()); } finally { @@ -1683,7 +1691,7 @@ public class IndexBugsTests extends BaseTestCase { waitForIndexer(); fIndex.acquireReadLock(); try { - IIndexFile f= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(f1)); + IIndexFile f= getIndexFile(f1); IIndexInclude[] is= f.getIncludes(); assertFalse(is[0].isResolved()); assertTrue(is[1].isResolvedByHeuristics()); @@ -1702,12 +1710,12 @@ public class IndexBugsTests extends BaseTestCase { // int aOK; // #endif /* A_H_ */ + // #ifndef B_H_ + // #define B_H_ // #ifndef A_H_ // #include "a.h" // #endif // - // #ifndef B_H_ - // #define B_H_ // int bOK; // #endif @@ -2125,7 +2133,7 @@ public class IndexBugsTests extends BaseTestCase { IIndex index= indexManager.getIndex(fCProject); index.acquireReadLock(); try { - IIndexFile file= index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(f)); + IIndexFile file= getIndexFile(index, f); // check order of includes IIndexInclude[] incs = file.getIncludes(); assertEquals(2, incs.length); @@ -2157,7 +2165,7 @@ public class IndexBugsTests extends BaseTestCase { IIndex index= indexManager.getIndex(fCProject); index.acquireReadLock(); try { - IIndexFile file= index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(f)); + IIndexFile file= getIndexFile(index, f); int idx= testData.indexOf("f("); IIndexName[] names = file.findNames(idx, idx+1); assertEquals(1, names.length); @@ -2423,4 +2431,4 @@ public class IndexBugsTests extends BaseTestCase { index.releaseReadLock(); } } -} \ No newline at end of file +} 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 18dded3ab59..3b052cc546d 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 @@ -35,6 +35,7 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CTestPlugin; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.core.testplugin.util.TestSourceReader; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.runtime.CoreException; @@ -458,9 +459,10 @@ class ProjectBuilder { CProjectHelper.createCCProject(name, "bin", IPDOMManager.ID_NO_INDEXER) : CProjectHelper.createCCProject(name, "bin", IPDOMManager.ID_NO_INDEXER); + IFile lastFile= null; for (Iterator i = path2content.entrySet().iterator(); i.hasNext();) { Map.Entry entry = (Map.Entry) i.next(); - TestSourceReader.createFile(result.getProject(), new Path((String)entry.getKey()), (String) entry.getValue()); + lastFile= TestSourceReader.createFile(result.getProject(), new Path((String)entry.getKey()), (String) entry.getValue()); } IProjectDescription desc = result.getProject().getDescription(); @@ -468,6 +470,10 @@ class ProjectBuilder { result.getProject().setDescription(desc, new NullProgressMonitor()); CCorePlugin.getIndexManager().setIndexerId(result, IPDOMManager.ID_FAST_INDEXER); + if (lastFile != null) { + IIndex index= CCorePlugin.getIndexManager().getIndex(result); + TestSourceReader.waitUntilFileIsIndexed(index, lastFile, 2000); + } BaseTestCase.waitForIndexer(result); return result; } 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 2fda9e95f00..d48ce0825b2 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 @@ -7,6 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.index.tests; @@ -64,6 +65,7 @@ public class IndexIncludeTest extends IndexTestBase { 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"); } fIndex= CCorePlugin.getIndexManager().getIndex(fProject); } @@ -114,17 +116,16 @@ public class IndexIncludeTest extends IndexTestBase { ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { - file.setContents(new ByteArrayInputStream( "int included; int CONTEXT;\n".getBytes()), false, false, npm()); - file.setLocalTimeStamp(timestamp+1000); + file.setContents(new ByteArrayInputStream("int included; int CONTEXT;\n".getBytes()), false, false, npm()); + file.setLocalTimeStamp(timestamp + 1000); } }, npm()); assertTrue("Timestamp was not increased", file.getLocalTimeStamp() >= timestamp); TestSourceReader.waitUntilFileIsIndexed(fIndex, file, 4000); fIndex.acquireReadLock(); try { - IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)); - assertNotNull("Can't find " + file.getLocation(), ifile); - assertTrue("timestamp not ok", ifile.getTimestamp() >= timestamp); + IIndexFile ifile= getIndexFile(file); + assertTrue("Timestamp not ok", ifile.getTimestamp() >= timestamp); IIndexBinding[] result= fIndex.findBindings(Pattern.compile("testInclude_cpp"), true, IndexFilter.ALL, npm()); assertEquals(1, result.length); @@ -134,6 +135,13 @@ public class IndexIncludeTest extends IndexTestBase { } finally { fIndex.releaseReadLock(); } + } + + private IIndexFile getIndexFile(IFile file) throws CoreException { + IIndexFile[] files = fIndex.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]; } // {source20061107} @@ -150,8 +158,7 @@ public class IndexIncludeTest extends IndexTestBase { fIndex.acquireReadLock(); try { - IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)); - assertNotNull(ifile); + IIndexFile ifile= getIndexFile(file); IIndexInclude[] includes= ifile.getIncludes(); assertEquals(2, includes.length); @@ -174,8 +181,7 @@ public class IndexIncludeTest extends IndexTestBase { fIndex.acquireReadLock(); try { - IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)); - assertNotNull(ifile); + IIndexFile ifile= getIndexFile(file); IIndexInclude[] includes= ifile.getIncludes(); assertEquals(1, includes.length); @@ -194,8 +200,7 @@ public class IndexIncludeTest extends IndexTestBase { fIndex.acquireReadLock(); try { - IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)); - assertNotNull(ifile); + IIndexFile ifile= getIndexFile(file); IIndexInclude[] includes= ifile.getIncludes(); assertEquals(1, includes.length); @@ -215,8 +220,7 @@ public class IndexIncludeTest extends IndexTestBase { fIndex.acquireReadLock(); try { - IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)); - assertNotNull(ifile); + IIndexFile ifile= getIndexFile(file); IIndexInclude[] includes= ifile.getIncludes(); assertEquals(1, includes.length); @@ -238,7 +242,10 @@ 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); @@ -332,8 +339,7 @@ public class IndexIncludeTest extends IndexTestBase { fIndex.acquireReadLock(); try { - IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(header)); - assertNotNull(ifile); + IIndexFile ifile= getIndexFile(header); IIndexInclude[] includes= fIndex.findIncludedBy(ifile); assertEquals(2, includes.length); @@ -352,8 +358,7 @@ public class IndexIncludeTest extends IndexTestBase { fIndex.acquireReadLock(); try { assertEquals(1, fIndex.findBindings("a20070426".toCharArray(), IndexFilter.ALL_DECLARED, npm()).length); - IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(header)); - assertNotNull(ifile); + IIndexFile ifile= getIndexFile(header); IIndexInclude[] includes= fIndex.findIncludedBy(ifile); assertEquals(2, includes.length); assertEquals(s1.getFullPath().toString(), includes[0].getIncludedByLocation().getFullPath()); @@ -370,8 +375,7 @@ public class IndexIncludeTest extends IndexTestBase { fIndex.acquireReadLock(); try { assertEquals(1, fIndex.findBindings("b20070426".toCharArray(), IndexFilter.ALL_DECLARED, npm()).length); - IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(header)); - assertNotNull(ifile); + IIndexFile ifile= getIndexFile(header); IIndexInclude[] includes= fIndex.findIncludedBy(ifile); assertEquals(2, includes.length); assertEquals(s1.getFullPath().toString(), includes[0].getIncludedByLocation().getFullPath()); @@ -448,14 +452,188 @@ public class IndexIncludeTest extends IndexTestBase { standardCheckUpdateIncludes(header, s1, "h20070427"); } + // #ifdef A + // static const int a = 0; + // #endif + // #ifdef B + // static const int b = 0; + // #endif + // #ifdef C + // static const int c = 0; + // #endif + + // #define A + // #include "h1.h" + // #undef A + // #define B + // #include "h1.h" + // #undef B + + // #define C + // #include "h1.h" + + // #include "h2.h" + public void testMultiVariantHeaderUpdate() throws Exception { + waitForIndexer(); + 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()); + TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_WAIT_TIME); + TestSourceReader.waitUntilFileIsIndexed(fIndex, s2, INDEXER_WAIT_TIME); + + fIndex.acquireReadLock(); + try { + IIndexFile[] indexFiles = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(h1)); + assertEquals(3, indexFiles.length); + } finally { + fIndex.releaseReadLock(); + } + + final long timestamp= System.currentTimeMillis(); + while (true) { + int pos = h1Contents.indexOf("int"); + if (pos < 0) + break; + h1Contents.replace(pos, pos + "int".length(), "float"); + } + ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { + public void run(IProgressMonitor monitor) throws CoreException { + h1.setContents(new ByteArrayInputStream(h1Contents.toString().getBytes()), false, false, npm()); + h1.setLocalTimeStamp(timestamp + 1000); + } + }, npm()); + waitForIndexer(); + + fIndex.acquireReadLock(); + try { + 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); + } + } finally { + fIndex.releaseReadLock(); + } + } + + // #ifdef A + // static const int a = 0; + // #endif + // #ifdef B + // static const int b = 0; + // #endif + // #ifdef C + // static const int c = 0; + // #endif + + // #define A + // #include "h1.h" + // #undef A + // #define B + // #include "h1.h" + // #undef B + + // #define C + // #include "h1.h" + + // #include "h2.h" + + // #ifndef H1_H_ + // #define H1_H_ + // #ifdef A + // static const int a = 0; + // #endif + // #ifdef B + // static const int b = 0; + // #endif + // #ifdef C + // static const int c = 0; + // #endif + // #endif // H1_H_ + public void testPragmaOnceChange() throws Exception { + waitForIndexer(); + 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()); + IFile s2= TestSourceReader.createFile(fProject.getProject(), "s2.cpp", contents[3].toString()); + TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_WAIT_TIME); + TestSourceReader.waitUntilFileIsIndexed(fIndex, s2, INDEXER_WAIT_TIME); + + fIndex.acquireReadLock(); + try { + IIndexFile[] indexFiles = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(h1)); + assertEquals(3, indexFiles.length); + for (IIndexFile indexFile : indexFiles) { + assertFalse(indexFile.hasPragmaOnceSemantics()); + assertEquals(1, fIndex.findIncludedBy(indexFile).length); + } + } finally { + fIndex.releaseReadLock(); + } + + // Change h1.h so that it has the pragma-once semantics. + final long t1= System.currentTimeMillis(); + final String changedContents = contents[4].toString(); + ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { + public void run(IProgressMonitor monitor) throws CoreException { + h1.setContents(new ByteArrayInputStream(changedContents.getBytes()), false, false, npm()); + h1.setLocalTimeStamp(t1 + 1000); + } + }, npm()); + waitForIndexer(); + + fIndex.acquireReadLock(); + try { + 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); + assertTrue(indexFile.hasPragmaOnceSemantics()); + // Included twice by h2.h and once by s1.cpp + assertEquals(2, fIndex.findIncludedBy(indexFile).length); + } + } finally { + fIndex.releaseReadLock(); + } + + // Change h1.h back to the original state without the pragma-once semantics. + final long t2= System.currentTimeMillis(); + ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { + public void run(IProgressMonitor monitor) throws CoreException { + h1.setContents(new ByteArrayInputStream(h1Contents.toString().getBytes()), false, false, npm()); + h1.setLocalTimeStamp(t2 + 2000); + } + }, npm()); + waitForIndexer(); + + fIndex.acquireReadLock(); + try { + 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); + assertFalse(indexFile.hasPragmaOnceSemantics()); + assertEquals(1, fIndex.findIncludedBy(indexFile).length); + } + } finally { + fIndex.releaseReadLock(); + } + } + private void standardCheckUpdateIncludes(IFile header, IFile s1, String tag) throws Exception { fIndex.acquireReadLock(); try { assertEquals(1, fIndex.findBindings(tag.toCharArray(), IndexFilter.ALL_DECLARED, npm()).length); - IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(header)); - IIndexFile sfile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(s1)); - assertNotNull(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()); @@ -464,7 +642,6 @@ public class IndexIncludeTest extends IndexTestBase { assertTrue(includes[0].isResolved()); assertFalse(includes[0].isSystemInclude()); - assertNotNull(sfile); includes= fIndex.findIncludes(sfile); assertEquals(3, includes.length); assertEquals(header.getFullPath().toString(), includes[0].getIncludesLocation().getFullPath()); @@ -494,13 +671,11 @@ public class IndexIncludeTest extends IndexTestBase { try { assertEquals(1, fIndex.findBindings(tag.toCharArray(), IndexFilter.ALL_DECLARED, npm()).length); - IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(header)); - IIndexFile sfile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(s1)); - assertNotNull(ifile); + IIndexFile ifile= getIndexFile(header); + IIndexFile sfile= getIndexFile(s1); IIndexInclude[] includes= fIndex.findIncludedBy(ifile); assertEquals(0, includes.length); - assertNotNull(sfile); includes= fIndex.findIncludes(sfile); assertEquals(2, includes.length); @@ -525,9 +700,8 @@ public class IndexIncludeTest extends IndexTestBase { try { assertEquals(1, fIndex.findBindings(tag.toCharArray(), IndexFilter.ALL_DECLARED, npm()).length); - IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(header)); - IIndexFile sfile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(s1)); - assertNotNull(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()); @@ -536,7 +710,6 @@ public class IndexIncludeTest extends IndexTestBase { assertTrue(includes[0].isResolved()); assertTrue(includes[0].isSystemInclude()); - assertNotNull(sfile); includes= fIndex.findIncludes(sfile); assertEquals(2, includes.length); assertEquals(header.getFullPath().toString(), includes[0].getIncludesLocation().getFullPath()); @@ -560,9 +733,8 @@ public class IndexIncludeTest extends IndexTestBase { try { assertEquals(1, fIndex.findBindings(tag.toCharArray(), IndexFilter.ALL_DECLARED, npm()).length); - IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(header)); - IIndexFile sfile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(s1)); - assertNotNull(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()); @@ -571,7 +743,6 @@ public class IndexIncludeTest extends IndexTestBase { assertTrue(includes[0].isResolved()); assertFalse(includes[0].isSystemInclude()); - assertNotNull(sfile); includes= fIndex.findIncludes(sfile); assertEquals(2, includes.length); assertEquals(header.getFullPath().toString(), includes[0].getIncludesLocation().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 8be862dd17c..89fdf310f66 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 @@ -101,9 +101,11 @@ public class IndexListenerTest extends BaseTestCase { assertTrue(im.joinIndexer(10000, npm())); IIndexChangeListener listener = new IIndexChangeListener() { public void indexChanged(IIndexChangeEvent event) { - synchronized (mutex) { - projects.add(event.getAffectedProject()); - mutex.notify(); + if (!event.getFilesWritten().isEmpty()) { + synchronized (mutex) { + projects.add(event.getAffectedProject()); + mutex.notify(); + } } } }; @@ -119,7 +121,6 @@ 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;"); synchronized (mutex) { 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 new file mode 100644 index 00000000000..c798cdebc11 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiVariantHeaderTest.java @@ -0,0 +1,142 @@ +/******************************************************************************* + * Copyright (c) 2011 Google, Inc and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Sergey Prigogin (Google) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.index.tests; + +import junit.framework.TestSuite; + +import org.eclipse.cdt.core.dom.ast.IFunction; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable; + +/** + * Tests for header files included in multiple variants. + * + * The first line of each comment section preceding a test contains the name of the file + * to put the contents of the section to. To request the AST of a file, put an asterisk after + * the file name. + */ +public class IndexMultiVariantHeaderTest extends IndexBindingResolutionTestBase { + + public IndexMultiVariantHeaderTest() { + setStrategy(new SinglePDOMTestNamedFilesStrategy(true)); + } + + public static TestSuite suite() { + return suite(IndexMultiVariantHeaderTest.class); + } + + // test.h + // #ifdef func + // #undef func + // #endif + // + // #define func(x) foo ## x + + // test.c * + // #include "test.h" + // + // void func(1)() {} + // + // #undef func + // #define func(x) bar ## x + // + // void func(2)() {} + // + // #include "test.h" + // void func(3)() {} + public void testExampleFromBug197989_Comment0() throws Exception { + IFunction f1 = getBindingFromASTName("func(1)", 7, IFunction.class); + assertEquals("foo1", f1.getName()); + IFunction f2 = getBindingFromASTName("func(2)", 7, IFunction.class); + assertEquals("bar2", f2.getName()); + IFunction f3 = getBindingFromASTName("func(3)", 7, IFunction.class); + assertEquals("foo3", f3.getName()); + } + + // stddef.h + // #if !defined(_STDDEF_H) || defined(__need_NULL) + // + // #if !defined(__need_NULL) + // #define _STDDEF_H + // #endif /* !defined(__need_NULL) */ + // + // #if defined(_STDDEF_H) || defined(__need_NULL) + // #define NULL 0 + // #endif /* defined(_STDDEF_H) || defined(__need_NULL) */ + // #undef __need_NULL + // + // #if defined(_STDDEF_H) + // typedef unsigned int size_t; + // #endif /* defined(_STDDEF_H) */ + // + // #endif /* !defined(_STDDEF_H) || defined(__need_NULL) */ + + // a.h + // #ifndef A_H_ + // #define A_H_ + // #include "stddef.h" + // #endif /* A_H_ */ + + // a.cpp * + // #define __need_NULL + // #include "stddef.h" + // void f1(char* p) {} + // void test() { + // f1(NULL); + // } + + // b.cpp + // #include "stddef.h" + // #include "a.h" + + // c.cpp * + // #include "a.h" + // void f2(char* p, size_t t) {} + // void test() { + // f2(NULL, 1); + // } + public void testExampleFromBug197989_Comment73() throws Exception { + getBindingFromASTName("f1(NULL)", 2, ICPPFunction.class); + getBindingFromASTName("f2(NULL, 1)", 2, ICPPFunction.class); + } + + // a.h + // external int X; + + // b.h + // #define X y + // #include "a.h" + // #undef X + // #define X z + // #include "a.h" + + // a.cpp * + // #define X x + // #include "a.h" + // static void test() { + // x = 0; + // } + + // b.cpp * + // #include "b.h" + // static void test() { + // y = 0; + // z = 0; + // } + public void _testSignificantMacroDetection() throws Exception { + // TODO(sprigogin): For this test to work REPORT_SIGNIFICANT_MACROS flag + // should be passed to CPreprocessor.expandMacro method. See + // http://bugs.eclipse.org/bugs/show_bug.cgi?id=197989#c92 for details. + getBindingFromASTName("x = 0", 1, ICPPVariable.class); + getBindingFromASTName("y = 0", 1, ICPPVariable.class); + getBindingFromASTName("z = 0", 1, ICPPVariable.class); + } +} 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 123318398e4..69ae8c4a08d 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 @@ -88,6 +88,13 @@ public class IndexNamesTests extends BaseTestCase { return result; } + private IIndexFile getIndexFile(int linkageID, IFile file) throws CoreException { + IIndexFile[] files = fIndex.getFiles(linkageID, 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]; + } + protected void waitUntilFileIsIndexed(IFile file, int time) throws Exception { TestSourceReader.waitUntilFileIsIndexed(fIndex, file, time); } @@ -263,7 +270,7 @@ public class IndexNamesTests extends BaseTestCase { fIndex.acquireReadLock(); try { - IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)); + IIndexFile ifile= getIndexFile(ILinkage.CPP_LINKAGE_ID, file); IIndexName[] names= ifile.findNames(0, content.length()); int j= 0; for (IIndexName indexName : names) { @@ -321,7 +328,7 @@ public class IndexNamesTests extends BaseTestCase { CoreException { fIndex.acquireReadLock(); try { - IIndexFile ifile= fIndex.getFile(linkageID, IndexLocationFactory.getWorkspaceIFL(file)); + IIndexFile ifile= getIndexFile(linkageID, file); IIndexName[] names= ifile.findNames(0, Integer.MAX_VALUE); int j= 0; for (IIndexName indexName : names) { 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 de9df4893f5..e1a55874e49 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 @@ -238,7 +238,7 @@ public class IndexProviderManagerTest extends IndexTestBase { ipm.reset(VERSION_405); ipm.startup(); ipm.addIndexProvider(provider1); ipm.addIndexProvider(provider2); - IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig()); + IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true); assertEquals(1, actual.length); assertFragmentPresent("contentID.contentA", "38", actual); } finally { @@ -293,7 +293,7 @@ public class IndexProviderManagerTest extends IndexTestBase { ipm.reset(VERSION_502); ipm.startup(); ipm.addIndexProvider(provider1); ipm.addIndexProvider(provider2); - IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig()); + IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true); assertEquals(3, actual.length); assertFragmentPresent("contentID.foo", "90", actual); assertFragmentPresent("contentID.bar", "91", actual); @@ -400,29 +400,29 @@ public class IndexProviderManagerTest extends IndexTestBase { IIndexFragment[] fragments; mockState.setConfig(MockState.REL_V1_ID); - fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig()); + fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true); assertEquals(2, fragments.length); assertTrue(ArrayUtil.contains(fragments, provider1.fragments[0])); assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0])); mockState.setConfig(MockState.DBG_V2_ID); - fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig()); + fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true); assertEquals(2, fragments.length); assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3])); assertTrue(ArrayUtil.contains(fragments, provider2.fragments[3])); mockState.setConfig(MockState.DBG_V1_ID); - fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig()); + fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true); assertEquals(0, fragments.length); mockState.setConfig(MockState.REL_V2_ID); - fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig()); + fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true); assertEquals(2, fragments.length); assertTrue(ArrayUtil.contains(fragments, provider1.fragments[1])); assertTrue(ArrayUtil.contains(fragments, provider2.fragments[1])); mockState.setConfig(MockState.REL_V1_ID); - fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig()); + fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true); assertEquals(2, fragments.length); assertTrue(ArrayUtil.contains(fragments, provider1.fragments[0])); assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0])); @@ -430,29 +430,29 @@ public class IndexProviderManagerTest extends IndexTestBase { provider1.invert(); mockState.setConfig(MockState.REL_V1_ID); - fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig()); + fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true); assertEquals(2, fragments.length); assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3])); assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0])); mockState.setConfig(MockState.DBG_V2_ID); - fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig()); + fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true); assertEquals(2, fragments.length); assertTrue(ArrayUtil.contains(fragments, provider1.fragments[0])); assertTrue(ArrayUtil.contains(fragments, provider2.fragments[3])); mockState.setConfig(MockState.DBG_V1_ID); - fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig()); + fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true); assertEquals(1, fragments.length); assertTrue(ArrayUtil.contains(fragments, provider1.fragments[1])); mockState.setConfig(MockState.REL_V2_ID); - fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig()); + fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true); assertEquals(1, fragments.length); assertTrue(ArrayUtil.contains(fragments, provider2.fragments[1])); mockState.setConfig(MockState.REL_V1_ID); - fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig()); + fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true); assertEquals(2, fragments.length); assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3])); assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0])); @@ -460,29 +460,29 @@ public class IndexProviderManagerTest extends IndexTestBase { provider2.invert(); mockState.setConfig(MockState.REL_V1_ID); - fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig()); + fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true); assertEquals(2, fragments.length); assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3])); assertTrue(ArrayUtil.contains(fragments, provider2.fragments[3])); mockState.setConfig(MockState.DBG_V2_ID); - fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig()); + fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true); assertEquals(2, fragments.length); assertTrue(ArrayUtil.contains(fragments, provider1.fragments[0])); assertTrue(ArrayUtil.contains(fragments, provider2.fragments[0])); mockState.setConfig(MockState.DBG_V1_ID); - fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig()); + fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true); assertEquals(2, fragments.length); assertTrue(ArrayUtil.contains(fragments, provider1.fragments[1])); assertTrue(ArrayUtil.contains(fragments, provider2.fragments[1])); mockState.setConfig(MockState.REL_V2_ID); - fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig()); + fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true); assertEquals(0, fragments.length); mockState.setConfig(MockState.REL_V1_ID); - fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig()); + fragments = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true); assertEquals(2, fragments.length); assertTrue(ArrayUtil.contains(fragments, provider1.fragments[3])); assertTrue(ArrayUtil.contains(fragments, provider2.fragments[3])); @@ -767,4 +767,4 @@ class MockPDOM extends EmptyIndexFragment { public String toString() { 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/IndexTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexTests.java index 6b3d23b37fd..97982030531 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexTests.java @@ -30,6 +30,7 @@ public class IndexTests extends TestSuite { suite.addTest(IndexNamesTests.suite()); suite.addTest(TeamSharedIndexTest.suite()); suite.addTest(IndexProviderManagerTest.suite()); + suite.addTest(IndexMultiVariantHeaderTest.suite()); IndexCPPBindingResolutionBugs.addTests(suite); IndexCPPBindingResolutionTest.addTests(suite); 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 2f9a59e801a..6a8e8da0adc 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 @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.index.tests; @@ -59,7 +59,6 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; 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"; @@ -82,9 +81,9 @@ public class IndexUpdateTests extends IndexTestBase { return suite; } - private ICProject fCppProject= null; - private ICProject fCProject= null; - private IIndex fIndex= null; + private ICProject fCppProject; + private ICProject fCProject; + private IIndex fIndex; private CharSequence[] fContents; private IFile fFile; private IFile fHeader; @@ -1285,7 +1284,7 @@ public class IndexUpdateTests extends IndexTestBase { setupFile(2, true); long id1, id2; fIndex.acquireReadLock(); - try { + try { final IIndexBinding binding = findBinding("X"); id1= ((PDOMFile) binding.getLocalToFile()).getRecord(); } finally { @@ -1294,7 +1293,7 @@ public class IndexUpdateTests extends IndexTestBase { updateFile(); fIndex.acquireReadLock(); - try { + try { final IIndexBinding binding = findBinding("X"); id2= ((PDOMFile) binding.getLocalToFile()).getRecord(); } finally { @@ -1462,6 +1461,4 @@ public class IndexUpdateTests extends IndexTestBase { fIndex.releaseReadLock(); } } - } - 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 1a6929db213..da46316999e 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 @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * QNX - Initial API and implementation - * Markus Schorn (Wind River Systems) + * QNX - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.pdom.tests; @@ -183,6 +183,11 @@ public class DefDeclTests extends PDOMTestBase { checkReference(binding, "ref" + testNum, ref); } + private IIndexFile getSingleFile(IIndexFileLocation ifl) throws CoreException { + IIndexFile[] files= pdom.getFiles(ILinkage.C_LINKAGE_ID, ifl); + assertEquals(1, files.length); + return files[0]; + } /* ------------------ Tests Started Here ------------------------ */ public void testInit() { // will fail if setUp fails, maybe timelimit is too small for warm-up @@ -237,7 +242,7 @@ public class DefDeclTests extends PDOMTestBase { String elName = "foo" + "08"; IIndexFileLocation ifl= IndexLocationFactory.getIFL((ITranslationUnit) cproject.findElement(new Path("func.c"))); - IIndexFile file= pdom.getFile(ILinkage.C_LINKAGE_ID, ifl); + IIndexFile file= getSingleFile(ifl); int offset= TestSourceReader.indexOfInFile("foo08();", new Path(ifl.getFullPath())); IIndexName[] names= file.findNames(offset, 5); assertEquals(1, names.length); @@ -249,7 +254,7 @@ public class DefDeclTests extends PDOMTestBase { // check the other file ifl= IndexLocationFactory.getIFL((ITranslationUnit) cproject.findElement(new Path("second.c"))); - file= pdom.getFile(ILinkage.C_LINKAGE_ID, ifl); + file= getSingleFile(ifl); offset= TestSourceReader.indexOfInFile("foo08();", new Path(ifl.getFullPath())); names= file.findNames(offset, 5); assertEquals(1, names.length); 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 5f72bcb7994..be8784315ae 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 @@ -22,6 +22,7 @@ import org.eclipse.cdt.core.index.IndexLocationFactory; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Path; /** @@ -47,26 +48,30 @@ public class IncludesTests extends PDOMTestBase { 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 = index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL((IFile) loc)); - assertNotNull(file); + IIndexFile file = getIndexFile((IFile) loc); IIndexInclude[] allIncludedBy = index.findIncludedBy(file, -1); assertEquals(9, allIncludedBy.length); // i.e. all of them } - + public void testIncludes() throws Exception { IResource loc = project.getProject().findMember("I1.cpp"); - IIndexFile file = index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL((IFile) loc)); - assertNotNull(file); + IIndexFile file = getIndexFile((IFile) loc); 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 = index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL((IFile) loc)); - assertNotNull(file); + IIndexFile file = getIndexFile((IFile) loc); IIndexInclude[] allIncludedBy = index.findIncludedBy(file, -1); assertEquals(2, allIncludedBy.length); for (IIndexInclude include : allIncludedBy) { 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 eeb51dcc574..09464883c19 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 @@ -305,7 +305,7 @@ public class PDOMProviderTests extends PDOMTestBase { 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); - assertEquals(0, ipm.getProvidedIndexFragments(pd.getActiveConfiguration()).length); + assertEquals(0, ipm.getProvidedIndexFragments(pd.getActiveConfiguration(), true).length); } } diff --git a/core/org.eclipse.cdt.core.tests/pom.xml b/core/org.eclipse.cdt.core.tests/pom.xml index 6bd853b6b0d..d8b56d0ea12 100644 --- a/core/org.eclipse.cdt.core.tests/pom.xml +++ b/core/org.eclipse.cdt.core.tests/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml @@ -44,7 +44,7 @@ org.eclipse.cdt.feature.group - 8.0.0.${buildQualifier} + 8.1.0.${buildQualifier} p2-installable-unit 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 d807643ba55..c9a74d91449 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 @@ -37,6 +37,7 @@ import org.eclipse.cdt.internal.core.CCoreInternals; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase; import org.eclipse.cdt.internal.core.pdom.CModelListener; import org.eclipse.cdt.internal.core.pdom.PDOMManager; +import org.eclipse.cdt.internal.core.pdom.indexer.AbstractPDOMIndexer; import org.eclipse.core.resources.IResourceStatus; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.ILogListener; @@ -66,6 +67,7 @@ public class BaseTestCase extends TestCase { CPPASTNameBase.sAllowRecursionBindings= false; CPPASTNameBase.sAllowNameComputation= false; CModelListener.sSuppressUpdateOfLastRecentlyUsed= true; + AbstractPDOMIndexer.noFilesUpFront= true; } @Override @@ -294,4 +296,4 @@ public class BaseTestCase extends TestCase { } assertTrue(indexManager.joinIndexer(10000, npm())); } -} \ No newline at end of file +} 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 6718f076766..5c8ea899085 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 @@ -63,9 +63,10 @@ public class TestSourceReader { * @param srcRoot the directory inside the bundle containing the packages * @param clazz the name of the class containing the test * @param testName the name of the test - * @param sections the number of comment sections preceding the named test to return + * @param sections the number of comment sections preceding the named test to return. Pass zero + * to get all available sections. * @return an array of StringBuilder objects for each comment section found preceding the named - * test in the source code. + * test in the source code. * @throws IOException */ public static StringBuilder[] getContentsForTest(Bundle bundle, String srcRoot, Class clazz, @@ -100,7 +101,7 @@ public class TestSourceReader { } else { if (content.length() > 0) { contents.add(content); - if (contents.size() == sections + 1) + if (sections > 0 && contents.size() == sections + 1) contents.remove(0); content = new StringBuilder(); } @@ -285,12 +286,12 @@ public class TestSourceReader { Assert.assertTrue(CCorePlugin.getIndexManager().joinIndexer(timeLeft, new NullProgressMonitor())); index.acquireReadLock(); try { - IIndexFile pfile= index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)); - if (pfile != null && pfile.getTimestamp() >= file.getLocalTimeStamp()) { + IIndexFile[] files= index.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)); + if (files.length > 0 && areAllFilesNotOlderThan(files, file.getLocalTimeStamp())) { return; } - pfile= index.getFile(ILinkage.C_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)); - if (pfile != null && pfile.getTimestamp() >= file.getLocalTimeStamp()) { + files= index.getFiles(ILinkage.C_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)); + if (files.length > 0 && areAllFilesNotOlderThan(files, file.getLocalTimeStamp())) { return; } } finally { @@ -303,7 +304,16 @@ public class TestSourceReader { Assert.fail("Indexing " + file.getFullPath() + " did not complete in time!"); } - public static IASTTranslationUnit createIndexBasedAST(IIndex index, ICProject project, IFile file) throws CModelException, CoreException { + private static boolean areAllFilesNotOlderThan(IIndexFile[] files, long timestamp) throws CoreException { + for (IIndexFile file : files) { + if (file.getTimestamp() < timestamp) { + return false; + } + } + 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; diff --git a/core/org.eclipse.cdt.core.win32.x86/pom.xml b/core/org.eclipse.cdt.core.win32.x86/pom.xml index 5f2bebb9b25..ade54085497 100644 --- a/core/org.eclipse.cdt.core.win32.x86/pom.xml +++ b/core/org.eclipse.cdt.core.win32.x86/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/core/org.eclipse.cdt.core.win32.x86_64/pom.xml b/core/org.eclipse.cdt.core.win32.x86_64/pom.xml index 3877dad754c..d006bf32875 100644 --- a/core/org.eclipse.cdt.core.win32.x86_64/pom.xml +++ b/core/org.eclipse.cdt.core.win32.x86_64/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/core/org.eclipse.cdt.core.win32/pom.xml b/core/org.eclipse.cdt.core.win32/pom.xml index ca90b4a136d..4db9ce85789 100644 --- a/core/org.eclipse.cdt.core.win32/pom.xml +++ b/core/org.eclipse.cdt.core.win32/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/core/org.eclipse.cdt.core/.classpath b/core/org.eclipse.cdt.core/.classpath index 2288d9b1dc8..e021ab95509 100644 --- a/core/org.eclipse.cdt.core/.classpath +++ b/core/org.eclipse.cdt.core/.classpath @@ -6,7 +6,7 @@ - + diff --git a/core/org.eclipse.cdt.core/.options b/core/org.eclipse.cdt.core/.options index 9f00de4f203..7b086655c64 100644 --- a/core/org.eclipse.cdt.core/.options +++ b/core/org.eclipse.cdt.core/.options @@ -12,6 +12,9 @@ org.eclipse.cdt.core/debug/parser/exceptions=false # Reports scanner activity org.eclipse.cdt.core/debug/scanner=false +# Reports scanner activity +org.eclipse.cdt.core/debug/scanner/missingIncludeGuards=false + # Reports search activity org.eclipse.cdt.core/debug/search=false diff --git a/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.core.prefs b/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.core.prefs index 0d175aa985a..07dc692254a 100644 --- a/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.core.prefs +++ b/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ -#Thu Jan 29 16:45:28 CET 2009 +#Mon Oct 17 17:36:13 PDT 2011 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -78,7 +78,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 @@ -150,9 +150,12 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF index 1b340722f7d..c81a487398c 100644 --- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF @@ -117,5 +117,5 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)", org.eclipse.core.filesystem;bundle-version="[1.1.0,2.0.0)", org.eclipse.ltk.core.refactoring;bundle-version="3.4.0" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: com.ibm.icu.text diff --git a/core/org.eclipse.cdt.core/build.properties b/core/org.eclipse.cdt.core/build.properties index fb2c80db177..c95e695942d 100644 --- a/core/org.eclipse.cdt.core/build.properties +++ b/core/org.eclipse.cdt.core/build.properties @@ -31,6 +31,6 @@ source.. = src/,\ templateengine/,\ utils/ -jre.compilation.profile=J2SE-1.5 -javacSource=1.5 -javacTarget=1.5 +jre.compilation.profile=JavaSE-1.6 +javacSource=1.6 +javacTarget=1.6 diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/AbstractLanguage.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/AbstractLanguage.java index d49fbea15f3..3c7c9b02588 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/AbstractLanguage.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/AbstractLanguage.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - * Anton Leherbauer (Wind River Systems) + * Markus Schorn - initial API and implementation + * Anton Leherbauer (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.model; @@ -27,9 +27,7 @@ import org.eclipse.core.runtime.PlatformObject; * @since 4.0 */ public abstract class AbstractLanguage extends PlatformObject implements ILanguage { - /* - * @see org.eclipse.cdt.core.model.ILanguage#getName() - */ + @Override public String getName() { ILanguageDescriptor languageDescriptor= LanguageManager.getInstance().getLanguageDescriptor(getId()); if (languageDescriptor != null) { @@ -43,6 +41,7 @@ public abstract class AbstractLanguage extends PlatformObject implements ILangua * IncludeFileContentProvider, IIndex, int, IParserLogService)} */ @Deprecated + @Override public IASTTranslationUnit getASTTranslationUnit(org.eclipse.cdt.core.parser.CodeReader reader, IScannerInfo scanInfo, org.eclipse.cdt.core.dom.ICodeReaderFactory fileCreator, IIndex index, int options, IParserLogService log) @@ -54,6 +53,7 @@ public abstract class AbstractLanguage extends PlatformObject implements ILangua /** * @since 5.2 */ + @Override @SuppressWarnings("deprecation") public IASTTranslationUnit getASTTranslationUnit(FileContent content, IScannerInfo scanInfo, IncludeFileContentProvider fileCreator, IIndex index, int options, IParserLogService log) @@ -67,6 +67,7 @@ public abstract class AbstractLanguage extends PlatformObject implements ILangua /** * @since 5.2 */ + @Override @SuppressWarnings("deprecation") public IASTCompletionNode getCompletionNode(FileContent reader, IScannerInfo scanInfo, IncludeFileContentProvider fileCreator, IIndex index, IParserLogService log, int offset) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/AssemblyLanguage.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/AssemblyLanguage.java index e11443a07f5..f0899e56834 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/AssemblyLanguage.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/AssemblyLanguage.java @@ -60,9 +60,7 @@ public class AssemblyLanguage extends AbstractLanguage implements IAsmLanguage, return DEFAULT_INSTANCE; } - /* - * @see org.eclipse.cdt.core.model.ILanguage#createModelBuilder(org.eclipse.cdt.core.model.ITranslationUnit) - */ + @Override public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) { IContributedModelBuilder modelBuilder= null; IContributedModelBuilder.Factory modelBuilderFactory= (IContributedModelBuilder.Factory)getAdapter(IContributedModelBuilder.Factory.class); @@ -78,75 +76,57 @@ public class AssemblyLanguage extends AbstractLanguage implements IAsmLanguage, return modelBuilder; } - /* - * @see org.eclipse.cdt.core.model.ILanguage#getASTTranslationUnit(org.eclipse.cdt.core.parser.CodeReader, org.eclipse.cdt.core.parser.IScannerInfo, org.eclipse.cdt.core.dom.ICodeReaderFactory, org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.parser.IParserLogService) - */ @Deprecated + @Override public IASTTranslationUnit getASTTranslationUnit(org.eclipse.cdt.core.parser.CodeReader reader, IScannerInfo scanInfo, org.eclipse.cdt.core.dom.ICodeReaderFactory fileCreator, IIndex index, IParserLogService log) throws CoreException { return null; } - /* - * @see org.eclipse.cdt.core.model.ILanguage#getCompletionNode(org.eclipse.cdt.core.parser.CodeReader, org.eclipse.cdt.core.parser.IScannerInfo, org.eclipse.cdt.core.dom.ICodeReaderFactory, org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.parser.IParserLogService, int) - */ @Deprecated + @Override public IASTCompletionNode getCompletionNode(org.eclipse.cdt.core.parser.CodeReader reader, IScannerInfo scanInfo, org.eclipse.cdt.core.dom.ICodeReaderFactory fileCreator, IIndex index, IParserLogService log, int offset) throws CoreException { return null; } - /* - * @see org.eclipse.cdt.core.model.ILanguage#getId() - */ + @Override public String getId() { return fId; } - /* - * @see org.eclipse.cdt.core.model.ILanguage#getSelectedNames(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit, int, int) - */ + @Override public IASTName[] getSelectedNames(IASTTranslationUnit ast, int start, int length) { return null; } // IAsmLanguage - /* - * @see org.eclipse.cdt.core.model.IAsmLanguage#getLineCommentCharacters() - */ + @Override public char[] getLineCommentCharacters() { return fLineCommentCharacters; } - /* - * @see org.eclipse.cdt.core.model.IAsmLanguage#getLineSeparatorCharacter() - */ + @Override public char getLineSeparatorCharacter() { return '\0'; } - /* - * @see org.eclipse.cdt.core.model.IAsmLanguage#getDirectiveKeywords() - */ + @Override public String[] getDirectiveKeywords() { return DIRECTIVE_KEYWORDS; } - /* - * @see org.eclipse.cdt.core.model.IAsmLanguage#getPreprocessorKeywords() - */ + @Override public String[] getPreprocessorKeywords() { Set ppDirectives= ParserFactory.getKeywordSet(KeywordSetKey.PP_DIRECTIVE, ParserLanguage.C); String[] result= ppDirectives.toArray(new String[ppDirectives.size()]); return result; } - /* - * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object) - */ + @Override public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException { if (data instanceof String) { fLineCommentCharacters= ((String)data).toCharArray(); @@ -154,6 +134,7 @@ public class AssemblyLanguage extends AbstractLanguage implements IAsmLanguage, fId= CCorePlugin.PLUGIN_ID + '.' + config.getAttribute("id"); //$NON-NLS-1$ } + @Override public int getLinkageID() { return ILinkage.NO_LINKAGE_ID; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BatchOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BatchOperation.java index 5d5207e85ee..47576e5f047 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BatchOperation.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BatchOperation.java @@ -56,6 +56,4 @@ public class BatchOperation extends CModelOperation { // cannot verify user defined operation return CModelStatus.VERIFIED_OK; } - - } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java index bfda27a9c37..5e13712ffc5 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java @@ -45,6 +45,7 @@ import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; public class Binary extends Openable implements IBinary { @@ -273,20 +274,19 @@ public class Binary extends Openable implements IBinary { if (obj != null) { // First check if we can get the list of source // files used to build the binary from the symbol - // information. if not, fall back on information from the binary parser. - boolean showSourceFiles = CCorePlugin.getDefault().getPluginPreferences().getBoolean( CCorePreferenceConstants.SHOW_SOURCE_FILES_IN_BINARIES ); - if (!showSourceFiles || - !addSourceFiles(info, obj, hash)) - { + // information. If not, fall back on information from the binary parser. + boolean showSourceFiles = Platform.getPreferencesService().getBoolean(CCorePlugin.PLUGIN_ID, + CCorePreferenceConstants.SHOW_SOURCE_FILES_IN_BINARIES, false, null); + if (!showSourceFiles || !addSourceFiles(info, obj, hash)) { ISymbol[] symbols = obj.getSymbols(); for (ISymbol symbol : symbols) { switch (symbol.getType()) { - case ISymbol.FUNCTION : - addFunction(info, symbol, hash); + case ISymbol.FUNCTION: + addFunction(info, symbol, hash); break; - case ISymbol.VARIABLE : - addVariable(info, symbol, hash); + case ISymbol.VARIABLE: + addVariable(info, symbol, hash); break; } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModel.java index 499a450118c..1ea7dceea65 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModel.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModel.java @@ -10,7 +10,6 @@ * Anton Leherbauer (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.model; - import java.util.List; import java.util.Map; @@ -60,7 +59,7 @@ public class CModel extends Openable implements ICModel { * ICModel#getCProject(String) */ public ICProject getCProject(String name) { - IProject project = ((IWorkspaceRoot)getResource()).getProject(name); + IProject project = ((IWorkspaceRoot) getResource()).getProject(name); return CModelManager.getDefault().create(project); } @@ -73,15 +72,15 @@ public class CModel extends Openable implements ICModel { * is not one of an IProject, IFolder, or IFile. */ public ICProject getCProject(IResource resource) { - switch(resource.getType()){ - case IResource.FOLDER: - return new CProject(this, ((IFolder)resource).getProject()); - case IResource.FILE: - return new CProject(this, ((IFile)resource).getProject()); - case IResource.PROJECT: - return new CProject(this, (IProject)resource); - default: - throw new IllegalArgumentException("element.invalidResourceForProject"); //$NON-NLS-1$ + switch (resource.getType()) { + case IResource.FOLDER: + return new CProject(this, ((IFolder) resource).getProject()); + case IResource.FILE: + return new CProject(this, ((IFile) resource).getProject()); + case IResource.PROJECT: + return new CProject(this, (IProject) resource); + default: + throw new IllegalArgumentException("element.invalidResourceForProject"); //$NON-NLS-1$ } } @@ -110,9 +109,11 @@ public class CModel extends Openable implements ICModel { public void copy(ICElement[] elements, ICElement[] containers, ICElement[] siblings, String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException { if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT ) { - runOperation(new CopyResourceElementsOperation(elements, containers, replace), elements, siblings, renamings, monitor); + runOperation(new CopyResourceElementsOperation(elements, containers, replace), elements, + siblings, renamings, monitor); } else { - runOperation(new CopyElementsOperation(elements, containers, replace), elements, siblings, renamings, monitor); + runOperation(new CopyElementsOperation(elements, containers, replace), elements, siblings, + renamings, monitor); } } @@ -130,9 +131,11 @@ public class CModel extends Openable implements ICModel { public void move(ICElement[] elements, ICElement[] containers, ICElement[] siblings, String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException { if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT) { - runOperation(new MoveResourceElementsOperation(elements, containers, replace), elements, siblings, renamings, monitor); + runOperation(new MoveResourceElementsOperation(elements, containers, replace), elements, + siblings, renamings, monitor); } else { - runOperation(new MoveElementsOperation(elements, containers, replace), elements, siblings, renamings, monitor); + runOperation(new MoveElementsOperation(elements, containers, replace), elements, siblings, + renamings, monitor); } } @@ -150,7 +153,8 @@ public class CModel extends Openable implements ICModel { /** * Configures and runs the MultiOperation. */ - protected void runOperation(MultiOperation op, ICElement[] elements, ICElement[] siblings, String[] renamings, IProgressMonitor monitor) throws CModelException { + protected void runOperation(MultiOperation op, ICElement[] elements, ICElement[] siblings, + String[] renamings, IProgressMonitor monitor) throws CModelException { op.setRenamings(renamings); if (siblings != null) { for (int i = 0; i < elements.length; i++) { @@ -184,10 +188,11 @@ public class CModel extends Openable implements ICModel { } /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.model.Openable#buildStructure(org.eclipse.cdt.internal.core.model.OpenableInfo, org.eclipse.core.runtime.IProgressMonitor, java.util.Map, org.eclipse.core.resources.IResource) + * @see Openable#buildStructure(OpenableInfo, IProgressMonitor, Map, IResource) */ @Override - protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws CModelException { + protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws CModelException { boolean validInfo = false; try { IResource res = getResource(); @@ -206,12 +211,12 @@ public class CModel extends Openable implements ICModel { * @see org.eclipse.cdt.core.model.ICModel#getNonCResources() */ public Object[] getNonCResources() throws CModelException { - return ((CModelInfo)getElementInfo()).getNonCResources(); + return ((CModelInfo) getElementInfo()).getNonCResources(); } protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException { // determine my children - IWorkspaceRoot root = (IWorkspaceRoot)getResource(); + IWorkspaceRoot root = (IWorkspaceRoot) getResource(); IProject[] projects = root.getProjects(); for (IProject project : projects) { if (CoreModel.hasCNature(project) || CoreModel.hasCCNature(project)) { @@ -219,7 +224,7 @@ public class CModel extends Openable implements ICModel { info.addChild(cproject); } } - ((CModelInfo)getElementInfo()).setNonCResources(null); + ((CModelInfo) getElementInfo()).setNonCResources(null); return true; } @@ -229,7 +234,7 @@ public class CModel extends Openable implements ICModel { case CEM_CPROJECT: if (!memento.hasMoreTokens()) return this; String projectName = memento.nextToken(); - CElement project = (CElement)getCProject(projectName); + CElement project = (CElement) getCProject(projectName); if (project != null) { return project.getHandleFromMemento(memento); } @@ -243,9 +248,8 @@ public class CModel extends Openable implements ICModel { } @Override - protected char getHandleMementoDelimiter(){ + protected char getHandleMementoDelimiter() { Assert.isTrue(false, "Should not be called"); //$NON-NLS-1$ return 0; } - } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java index f57924b0116..908aa8fdcaa 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java @@ -12,6 +12,7 @@ * Anton Leherbauer (Wind River Systems) * Warren Paul (Nokia) - Bug 218266 * James Blackburn (Broadcom Corp.) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.model; @@ -655,18 +656,26 @@ public class TranslationUnit extends Openable implements ITranslationUnit { } public boolean isHeaderUnit() { - return CCorePlugin.CONTENT_TYPE_CHEADER.equals(contentTypeId) - || CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(contentTypeId); + return isHeaderContentType(contentTypeId); } public boolean isSourceUnit() { - if (isHeaderUnit()) + return isSourceContentType(contentTypeId); + } + + private static boolean isHeaderContentType(String contentType) { + return CCorePlugin.CONTENT_TYPE_CHEADER.equals(contentType) + || CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(contentType); + } + + private static boolean isSourceContentType(String contentType) { + if (isHeaderContentType(contentType)) return false; - return CCorePlugin.CONTENT_TYPE_CSOURCE.equals(contentTypeId) - || CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(contentTypeId) - || CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(contentTypeId) - || LanguageManager.getInstance().isContributedContentType(contentTypeId); + return CCorePlugin.CONTENT_TYPE_CSOURCE.equals(contentType) + || CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(contentType) + || CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(contentType) + || LanguageManager.getInstance().isContributedContentType(contentType); } public boolean isCLanguage() { @@ -769,7 +778,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit { } public IASTTranslationUnit getAST(IIndex index, int style, IProgressMonitor monitor) throws CoreException { - ITranslationUnit configureWith = getSourceContextTU(index, style); + IIndexFile[] contextToHeader = getContextToHeader(index, style); + ITranslationUnit configureWith = getConfigureWith(contextToHeader); + if (configureWith == this) + contextToHeader= null; IScannerInfo scanInfo= configureWith.getScannerInfo((style & AST_SKIP_IF_NO_BUILD_INFO) == 0); if (scanInfo == null) { @@ -786,7 +798,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return null; } - IncludeFileContentProvider crf= getIncludeFileContentProvider(style, index, language.getLinkageID()); + IncludeFileContentProvider crf= getIncludeFileContentProvider(style, index, language.getLinkageID(), contextToHeader); int options= 0; if ((style & AST_SKIP_FUNCTION_BODIES) != 0) { options |= ILanguage.OPTION_SKIP_FUNCTION_BODIES; @@ -812,7 +824,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return ast; } - private IncludeFileContentProvider getIncludeFileContentProvider(int style, IIndex index, int linkageID) { + private IncludeFileContentProvider getIncludeFileContentProvider(int style, IIndex index, int linkageID, IIndexFile[] contextToHeader) { final ICProject cprj= getCProject(); final ProjectIndexerInputAdapter pathResolver = new ProjectIndexerInputAdapter(cprj); IncludeFileContentProvider fileContentsProvider; @@ -825,9 +837,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { if (index != null && (style & AST_SKIP_INDEXED_HEADERS) != 0) { IndexBasedFileContentProvider ibcf= new IndexBasedFileContentProvider(index, pathResolver, linkageID, fileContentsProvider); - if ((style & AST_CONFIGURE_USING_SOURCE_CONTEXT) != 0) { - ibcf.setSupportFillGapFromContextToHeader(true); - } + ibcf.setContextToHeaderGap(contextToHeader); fileContentsProvider= ibcf; } @@ -839,52 +849,83 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return fileContentsProvider; } - private static int[] CTX_LINKAGES= {ILinkage.CPP_LINKAGE_ID, ILinkage.C_LINKAGE_ID}; - public ITranslationUnit getSourceContextTU(IIndex index, int style) { + private static final int[] CTX_LINKAGES= { ILinkage.CPP_LINKAGE_ID, ILinkage.C_LINKAGE_ID }; + public IIndexFile[] getContextToHeader(IIndex index, int style) { if (index != null && (style & AST_CONFIGURE_USING_SOURCE_CONTEXT) != 0) { try { fLanguageOfContext= null; - for (int element : CTX_LINKAGES) { - IIndexFile context= null; - final IIndexFileLocation ifl = IndexLocationFactory.getIFL(this); - if (ifl != null) { - IIndexFile indexFile= index.getFile(element, ifl); - if (indexFile != null) { - // bug 199412, when a source-file includes itself the context may recurse. - HashSet visited= new HashSet(); - visited.add(indexFile); - indexFile = getParsedInContext(indexFile); - while (indexFile != null && visited.add(indexFile)) { - context= indexFile; - indexFile= getParsedInContext(indexFile); - } - } - if (context != null) { - ITranslationUnit tu= CoreModelUtil.findTranslationUnitForLocation(context.getLocation(), getCProject()); - if (tu != null && tu.isSourceUnit()) { - return tu; + final IIndexFileLocation ifl = IndexLocationFactory.getIFL(this); + if (ifl != null) { + IIndexFile best = null; + IIndexFile contextOfBest = null; + int bestScore= -1; + // Find file variant that has the most content and preferably was parsed in + // context of a source file. + for (int linkageID : CTX_LINKAGES) { + for (IIndexFile indexFile : index.getFiles(linkageID, ifl)) { + int score= indexFile.getMacros().length * 2; + IIndexFile context= getParsedInContext(indexFile); + if (isSourceFile(context)) + score++; + if (score > bestScore) { + bestScore= score; + best= indexFile; + contextOfBest = context; } } } + + if (best != null && contextOfBest != best) { + return new IIndexFile[] { contextOfBest, best }; + } } } catch (CoreException e) { CCorePlugin.log(e); } } - return this; - } - - private IIndexFile getParsedInContext(IIndexFile indexFile) - throws CoreException { - IIndexInclude include= indexFile.getParsedInContext(); - if (include != null) { - return include.getIncludedBy(); - } return null; } + private IIndexFile getParsedInContext(IIndexFile indexFile) throws CoreException { + HashSet visited= new HashSet(); + // Bug 199412, may recurse. + while (visited.add(indexFile)) { + IIndexInclude include= indexFile.getParsedInContext(); + if (include == null) + break; + indexFile = include.getIncludedBy(); + } + return indexFile; + } + + /** + * Returns true if the given file was parsed in a context of a source file. + * @throws CoreException + */ + private boolean isSourceFile(IIndexFile indexFile) throws CoreException { + String path = indexFile.getLocation().getURI().getPath(); + IContentType cType = CCorePlugin.getContentType(getCProject().getProject(), path); + if (cType == null) + return false; + + return isSourceContentType(cType.getId()); + } + + private ITranslationUnit getConfigureWith(IIndexFile[] contextToHeader) throws CoreException { + if (contextToHeader != null) { + ITranslationUnit configureWith = CoreModelUtil.findTranslationUnitForLocation( + contextToHeader[0].getLocation(), getCProject()); + if (configureWith != null) + return configureWith; + } + return this; + } + public IASTCompletionNode getCompletionNode(IIndex index, int style, int offset) throws CoreException { - ITranslationUnit configureWith= getSourceContextTU(index, style); + IIndexFile[] contextToHeader = getContextToHeader(index, style); + ITranslationUnit configureWith = getConfigureWith(contextToHeader); + if (configureWith == this) + contextToHeader= null; IScannerInfo scanInfo = configureWith.getScannerInfo((style & ITranslationUnit.AST_SKIP_IF_NO_BUILD_INFO) == 0); if (scanInfo == null) { @@ -896,7 +937,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { ILanguage language= configureWith.getLanguage(); fLanguageOfContext= language; if (language != null) { - IncludeFileContentProvider crf= getIncludeFileContentProvider(style, index, language.getLinkageID()); + IncludeFileContentProvider crf= getIncludeFileContentProvider(style, index, language.getLinkageID(), contextToHeader); IASTCompletionNode result = language.getCompletionNode(fileContent, scanInfo, crf, index, ParserUtil.getParserLogService(), offset); if (result != null) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCastExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCastExpression.java index 111d29d2b90..6466d795e13 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCastExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCastExpression.java @@ -87,10 +87,12 @@ public interface IASTCastExpression extends IASTExpression { /** * @since 5.1 */ + @Override public IASTCastExpression copy(); /** * @since 5.3 */ + @Override public IASTCastExpression copy(CopyStyle style); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFileLocation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFileLocation.java index 7dd1462df02..f3a85ea5187 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFileLocation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFileLocation.java @@ -50,4 +50,13 @@ public interface IASTFileLocation extends IASTNodeLocation { * @return int representing line number or 0 if not applicable */ public int getEndingLineNumber(); + + /** + * Returns the inclusion statement that included this file, or null for + * a top-level file. + * Also null when the file location does not belong to an AST node, e.g. + * if it is obtained from a name in the index. + * @since 5.4 + */ + public IASTPreprocessorIncludeStatement getContextInclusionStatement(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPreprocessorIncludeStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPreprocessorIncludeStatement.java index a1c8698ba66..4cf5ca99645 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPreprocessorIncludeStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPreprocessorIncludeStatement.java @@ -6,20 +6,22 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; +import org.eclipse.cdt.core.index.IIndexFile; +import org.eclipse.cdt.core.parser.ISignificantMacros; + + /** * This interface represent a preprocessor #include statement. * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ -public interface IASTPreprocessorIncludeStatement extends - IASTPreprocessorStatement { - +public interface IASTPreprocessorIncludeStatement extends IASTPreprocessorStatement, IFileNomination { /** * INCLUDE_NAME describes the relationship between an include directive and * it's name. @@ -64,4 +66,33 @@ public interface IASTPreprocessorIncludeStatement extends * @since 5.1 */ public boolean isResolvedByHeuristics(); + + /** + * Returns the list of versions of the target file, each of which is + * identified by its significant macros, that had been included + * in this translation-unit prior to this statement. + * @noreference This method is not intended to be referenced by clients. + */ + public ISignificantMacros[] getLoadedVersions(); + + /** + * Returns a hash-code for the contents of the file included, or 0 + * if the content has not been parsed. + * @since 5.4 + */ + public long getContentsHash(); + + /** + * Returns true, if an attempt will be or has been made to create AST for the target + * of this inclusion. + * @since 5.4 + */ + public boolean createsAST(); + + /** + * Returns the file from the index that this include statement has pulled in, or null + * if the include creates AST or is unresolved or skipped. + * @since 5.4 + */ + public IIndexFile getImportedIndexFile(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java index 3f467c197dd..3a7dfea8172 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.IName; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexFileSet; import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.core.runtime.IAdaptable; @@ -28,7 +29,7 @@ import org.eclipse.core.runtime.IAdaptable; * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ -public interface IASTTranslationUnit extends IASTDeclarationListOwner, IAdaptable { +public interface IASTTranslationUnit extends IASTDeclarationListOwner, IFileNomination, IAdaptable { /** * OWNED_DECLARATION represents the relationship between an IASTTranslationUnit and @@ -343,4 +344,16 @@ public interface IASTTranslationUnit extends IASTDeclarationListOwner, IAdaptabl * @since 5.3 */ public ITranslationUnit getOriginatingTranslationUnit(); + + /** + * @since 5.4 + * @noreference This method is not intended to be referenced by clients. + */ + public void setSignificantMacros(ISignificantMacros sigMacros); + + /** + * @since 5.4 + * @noreference This method is not intended to be referenced by clients. + */ + public void setPragmaOnceSemantics(boolean value); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFileNomination.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFileNomination.java new file mode 100644 index 00000000000..28a91aa36d4 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFileNomination.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Markus Schorn - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.core.dom.ast; + +import org.eclipse.cdt.core.index.IIndexFile; +import org.eclipse.cdt.core.parser.ISignificantMacros; +import org.eclipse.core.runtime.CoreException; + +/** + * Interface for constructs that nominate a file for an AST: + * {@link IASTTranslationUnit}, {@link IASTPreprocessorIncludeStatement}, {@link IIndexFile}. + * @since 5.4 + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. + */ +public interface IFileNomination { + /** + * Returns macros relevant to parsing of the file included by this include statement and their + * definitions at the point of the include. + *

+ * This method should only be called after the included file has been parsed. The method will + * return {@link ISignificantMacros#NONE} if it is called prematurely. + * @throws CoreException + */ + public ISignificantMacros getSignificantMacros() throws CoreException; + + /** + * Returns whether pragma once semantics has been detected when parsing the translation unit. + */ + public boolean hasPragmaOnceSemantics() throws CoreException; +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndex.java index ab4050b27fd..2f868eb12e3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndex.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndex.java @@ -19,6 +19,7 @@ import java.util.regex.Pattern; import org.eclipse.cdt.core.dom.IName; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IScope; +import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -133,16 +134,53 @@ public interface IIndex { public long getLastWriteAccess(); /** - * Returns the file-object for the given location and linkage or returns - * null if the file was not indexed in this linkage. + * Returns the file object for the given location and linkage or null if the file + * was not indexed in this linkage. + *

+ * When a header file is stored in the index in multiple variants for different sets of macro + * definitions, this method will return an arbitrary one of these variants. * @param location an IIndexFileLocation representing the location of the file * @return the file in the index or null * @throws CoreException + * @deprecated Use {@link #getFile(int, IIndexFileLocation, ISignificantMacros)} or + * {@link #getFiles(int, IIndexFileLocation)}. */ + @Deprecated public IIndexFile getFile(int linkageID, IIndexFileLocation location) throws CoreException; /** - * Returns the file-objects for the given location in any linkage. + * Returns the file for the given location, linkage, and significant macros + * May return null, if no such file exists. + * + * @param linkageID the id of the linkage in which the file has been parsed. + * @param location the IIndexFileLocation representing the location of the file + * @param macroDictionary The names and definitions of the macros used to disambiguate between + * variants of the file contents corresponding to different inclusion points. + * @return the file for the location, or null if the file is not present in + * the index + * @throws CoreException + * @since 5.4 + */ + IIndexFile getFile(int linkageID, IIndexFileLocation location, ISignificantMacros significantMacros) + throws CoreException; + + /** + * Returns the file objects for the given location and linkage. + * Multiple files are returned when a header file is stored in the index in multiple variants + * for different sets of macro definitions. + * This method may only return files that are actually managed by this fragment. + * This method returns files without content, also. + * + * @param linkageID the id of the linkage in which the file has been parsed. + * @param location the IIndexFileLocation representing the location of the file + * @return the files for the location and the linkage. + * @throws CoreException + * @since 5.4 + */ + IIndexFile[] getFiles(int linkageID, IIndexFileLocation location) throws CoreException; + + /** + * Returns the file objects for the given location in any linkage. * @param location an IIndexFileLocation representing the location of the file * @return an array of file-objects. * @throws CoreException diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexBinding.java index 257b143e064..100a3e11576 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexBinding.java @@ -44,8 +44,8 @@ public interface IIndexBinding extends IBinding { IIndexFile getLocalToFile() throws CoreException; /** - * {@inheritDoc} * @since 5.1 */ + @Override IIndexBinding getOwner(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFile.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFile.java index a1cf9c71ee4..a8010956196 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFile.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFile.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,9 +8,11 @@ * Contributors: * Markus Schorn - initial API and implementation * Andrew Ferguson (Symbian) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.core.index; +import org.eclipse.cdt.core.dom.ast.IFileNomination; import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective; import org.eclipse.core.runtime.CoreException; @@ -22,7 +24,7 @@ import org.eclipse.core.runtime.CoreException; * * @since 4.0 */ -public interface IIndexFile { +public interface IIndexFile extends IFileNomination { IIndexFile[] EMPTY_FILE_ARRAY = {}; /** @@ -69,11 +71,9 @@ public interface IIndexFile { long getContentsHash() throws CoreException; /** - * Returns the hash-code of the scanner configuration that was used to parse the file. - * 0 will be returned in case the hash-code is unknown. - * @return the hash-code of the scanner configuration or 0. - * @throws CoreException + * @deprecated Returns 0. */ + @Deprecated int getScannerConfigurationHashcode() throws CoreException; /** @@ -93,7 +93,7 @@ public interface IIndexFile { * Returns the include that was used to parse this file, may be null. */ IIndexInclude getParsedInContext() throws CoreException; - + /** * Returns the id of the linkage this file was parsed in. * @since 5.0 diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFileSet.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFileSet.java index 1fff5b334fa..a30d8b1f34f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFileSet.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFileSet.java @@ -54,4 +54,10 @@ public interface IIndexFileSet { * @noreference This method is not intended to be referenced by clients. */ void add(IIndexFile indexFile); + + /** + * Removes a file from this set. + * @noreference This method is not intended to be referenced by clients. + */ + void remove(IIndexFile indexFile); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexManager.java index e1f77cc0472..338b6b09f0b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexManager.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexManager.java @@ -43,12 +43,22 @@ public interface IIndexManager extends IPDOMManager { public final static int ADD_DEPENDENT = 0x2; /** - * Constant for passing to getIndex methods. This constant, when set, indicates - * that index content provided via the CIndex extension point should not be included - * in the resulting index, as it would have done otherwise. + * Constant for passing to getIndex methods. This constant, when set, indicates that the index + * content provided via the CIndex extension point should not be included in the resulting + * index, as it would have done otherwise. */ public final static int SKIP_PROVIDED = 0x4; + /** + * Constant for passing to getIndex methods. This constant, when set, indicates that the index + * content provided via the ReadOnlyIndexFragmentProvider element of the CIndex extension point + * should be included in the resulting index. By default such index content is not included. + * This flag is ignored if SKIP_PROVIDED flag is set. + * + * @since 5.4 + */ + public final static int ADD_EXTENSION_FRAGMENTS = 0x8; + /** * Constant for indicating there is no time out period for joining the indexer job. * @see IIndexManager#joinIndexer(int, IProgressMonitor) @@ -197,12 +207,14 @@ public interface IIndexManager extends IPDOMManager { * Returns the id of the indexer working on the project. * @since 4.0 */ + @Override public String getIndexerId(ICProject project); /** * Changes the indexer working on the project. * @since 4.0 */ + @Override public void setIndexerId(ICProject project, String indexerId); /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/ResourceContainerRelativeLocationConverter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/ResourceContainerRelativeLocationConverter.java index 3b01556ebce..7c97454a8c3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/ResourceContainerRelativeLocationConverter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/ResourceContainerRelativeLocationConverter.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial implementation + * Andrew Ferguson (Symbian) - Initial implementation *******************************************************************************/ package org.eclipse.cdt.core.index; import org.eclipse.cdt.internal.core.index.IndexFileLocation; @@ -16,15 +16,13 @@ import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; + /** - * A location converter for converting project resource locations to be relative to a specified container. - * Resources outside of the associated project will not be converted (ignored). + * A location converter for converting project resource locations to be relative to a specified + * container. Resources outside of the associated project will not be converted (ignored). *
* This location converter is internal-representation-compatible with URIRelativeLocationConverter */ - /* - * Internal representation is a relative path - */ public class ResourceContainerRelativeLocationConverter implements IIndexLocationConverter { protected IWorkspaceRoot root; protected IPath fullPath; @@ -36,18 +34,13 @@ public class ResourceContainerRelativeLocationConverter implements IIndexLocatio this.fullPath = container.getFullPath(); this.root = ResourcesPlugin.getWorkspace().getRoot(); } - /* - * (non-Javadoc) - * @see org.eclipse.cdt.core.index.IIndexLocationConverter#fromInternalFormat(java.lang.String) - */ + + @Override public IIndexFileLocation fromInternalFormat(String raw) { IResource member= root.getFile(fullPath.append(raw)); return new IndexFileLocation(member.getLocationURI(), member.getFullPath().toString()); } - /* - * (non-Javadoc) - * @see org.eclipse.cdt.core.index.IIndexLocationConverter#toInternalFormat(org.eclipse.cdt.core.index.IIndexFileLocation) - */ + @Override public String toInternalFormat(IIndexFileLocation location) { String sFullPath= location.getFullPath(); if(sFullPath!=null) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/URIRelativeLocationConverter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/URIRelativeLocationConverter.java index 0e015d69b12..83ec734085a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/URIRelativeLocationConverter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/URIRelativeLocationConverter.java @@ -39,6 +39,7 @@ public class URIRelativeLocationConverter implements IIndexLocationConverter { this.baseURI = baseURI; } + @Override public IIndexFileLocation fromInternalFormat(String raw) { String rawPath = URIUtil.toURI(raw).getRawPath(); if (rawPath.length() > 0 && rawPath.charAt(0) == '/') @@ -47,6 +48,7 @@ public class URIRelativeLocationConverter implements IIndexLocationConverter { return new IndexFileLocation(uri, null); } + @Override public String toInternalFormat(IIndexFileLocation location) { URI relative = baseURI.relativize(location.getURI()); return relative.isAbsolute() ? null : relative.getPath(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/AbstractParserLogService.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/AbstractParserLogService.java index f45f33486ed..64650e13a17 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/AbstractParserLogService.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/AbstractParserLogService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,12 +10,39 @@ *******************************************************************************/ package org.eclipse.cdt.core.parser; + +import org.eclipse.cdt.internal.core.dom.parser.ParserLogServiceWrapper; public abstract class AbstractParserLogService implements IParserLogService { + /** + * @since 5.4 + */ + public static AbstractParserLogService convert(IParserLogService log) { + if (log instanceof AbstractParserLogService) + return (AbstractParserLogService) log; + return new ParserLogServiceWrapper(log); + } + public void traceLog(String message) { } + /** + * @param traceOption an option as defined in the .options file. + * @since 5.4 + */ + public boolean isTracing(String traceOption) { + return isTracing(); + } + + /** + * @param traceOption an option as defined in the .options file. + * @since 5.4 + */ + public void traceLog(String traceOption, String message) { + traceLog(message); + } + public void errorLog(String message) { } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IProblem.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IProblem.java index e521287347a..bd1ffc48c7c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IProblem.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IProblem.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -323,6 +323,12 @@ public interface IProblem */ public final static int PREPROCESSOR_POUND_WARNING = PREPROCESSOR_RELATED | 0x00E; + /** + * Maximum inclusion depth is exceeded + * @since 5.4 + */ + public final static int PREPROCESSOR_EXCEEDS_MAXIMUM_INCLUSION_DEPTH= PREPROCESSOR_RELATED | 0x00F; + /** * Syntax error, detected by the parser. */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISignificantMacros.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISignificantMacros.java new file mode 100644 index 00000000000..e4182f46133 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISignificantMacros.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Markus Schorn - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.core.parser; + +import org.eclipse.cdt.core.parser.util.CharArrayUtils; +import org.eclipse.cdt.internal.core.parser.scanner.SignificantMacros; + +/** + * Significant macros describe the conditions under which the preprocessor selects + * the same active code branches in a file. + * @since 5.4 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ISignificantMacros { + interface IVisitor { + /** + * Returns whether to continue the visit. + */ + boolean visitDefined(char[] macro); + + /** + * Returns whether to continue the visit. + */ + boolean visitUndefined(char[] macro); + + /** + * Returns whether to continue the visit. + */ + boolean visitValue(char[] macro, char[] value); + } + + ISignificantMacros NONE = new SignificantMacros(CharArrayUtils.EMPTY); + + /** + * Returns whether visitor continued its visit till the end. + */ + boolean accept(IVisitor visitor); + + /** + * Returns the significant macros encoded as an array of characters. + */ + char[] encode(); +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArrayObjectMap.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArrayObjectMap.java index 35fba211343..3f120cd7fed 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArrayObjectMap.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArrayObjectMap.java @@ -19,8 +19,8 @@ import java.util.List; /** * @author Doug Schaefer */ -public class CharArrayObjectMap extends CharTable { - public static final CharArrayObjectMap EMPTY_MAP = new CharArrayObjectMap(0) { +public class CharArrayObjectMap extends CharTable { + public static final CharArrayObjectMap EMPTY_MAP = new CharArrayObjectMap(0) { @Override public Object clone() { return this; } @Override @@ -30,6 +30,14 @@ public class CharArrayObjectMap extends CharTable { throw new UnsupportedOperationException(); } }; + /** + * @since 5.4 + */ + @SuppressWarnings("unchecked") + public static CharArrayObjectMap emptyMap() { + return (CharArrayObjectMap) EMPTY_MAP; + } + private Object[] valueTable; @@ -38,40 +46,44 @@ public class CharArrayObjectMap extends CharTable { valueTable = new Object[capacity()]; } - public Object put(char[] key, int start, int length, Object value) { + public T put(char[] key, int start, int length, T value) { int i = addIndex(key, start, length); - Object oldvalue = valueTable[i]; + @SuppressWarnings("unchecked") + T oldvalue = (T) valueTable[i]; valueTable[i] = value; return oldvalue; } - final public Object put(char[] key, Object value) { + final public T put(char[] key, T value) { return put(key, 0, key.length, value); } - final public Object get(char[] key, int start, int length) { + @SuppressWarnings("unchecked") + final public T get(char[] key, int start, int length) { int i = lookup(key, start, length); if (i >= 0) - return valueTable[i]; + return (T) valueTable[i]; return null; } - final public Object get(char[] key) { + final public T get(char[] key) { return get(key, 0, key.length); } - final public Object getAt(int i) { + @SuppressWarnings("unchecked") + final public T getAt(int i) { if (i < 0 || i > currEntry) return null; - return valueTable[i]; + return (T) valueTable[i]; } - final public Object remove(char[] key, int start, int length) { + final public T remove(char[] key, int start, int length) { int i = lookup(key, start, length); if (i < 0) return null; - Object value = valueTable[i]; + @SuppressWarnings("unchecked") + T value = (T) valueTable[i]; if (i < currEntry) System.arraycopy(valueTable, i + 1, valueTable, i, currEntry - i); @@ -85,7 +97,8 @@ public class CharArrayObjectMap extends CharTable { @Override public Object clone() { - CharArrayObjectMap newTable = (CharArrayObjectMap) super.clone(); + @SuppressWarnings("unchecked") + CharArrayObjectMap newTable = (CharArrayObjectMap) super.clone(); newTable.valueTable = new Object[capacity()]; System.arraycopy(valueTable, 0, newTable.valueTable, 0, valueTable.length); @@ -149,4 +162,5 @@ public class CharArrayObjectMap extends CharTable { System.arraycopy(valueTable, 0, values, 0, values.length); return values; } + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousNode.java index 9ab1ba8dc78..772fd3e70c8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousNode.java @@ -83,12 +83,12 @@ public abstract class ASTAmbiguousNode extends ASTNode { int minIssues = Integer.MAX_VALUE; for (IASTNode alternative : alternatives) { - beforeAlternative(alternative); - - // setup the ast to use the alternative + // Setup the ast to use the alternative owner.replace(nodeToReplace, alternative); nodeToReplace= alternative; + beforeAlternative(alternative); + // handle nested ambiguities first, otherwise we cannot visit the alternative alternative.accept(resolver); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java index a1b601b2878..7e1e9020386 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -19,10 +19,9 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IValue; /** - * Base class for c- and c++ enumerators. + * Base class for C and C++ enumerators. */ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, IASTAmbiguityParent { - private IASTName name; private IASTExpression value; private IValue integralValue; @@ -68,27 +67,26 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitEnumerators ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitEnumerators) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - if( name != null ) if( !name.accept( action ) ) return false; - if( value != null ) if( !value.accept( action ) ) return false; - if( action.shouldVisitEnumerators ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + if (name != null && !name.accept(action)) return false; + if (value != null && !value.accept(action)) return false; + if (action.shouldVisitEnumerators) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; } - public int getRoleForName(IASTName n) { if (n == name) return r_definition; @@ -97,11 +95,10 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I } public void replace(IASTNode child, IASTNode other) { - if( child == value) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); - value = (IASTExpression) other; + if (child == value) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); + value = (IASTExpression) other; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java index e4cfb2ef56d..866a55bf964 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; +import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IBinding; @@ -71,7 +72,7 @@ public class ASTInternal { } } - public static String getDeclaredInSourceFileOnly(IBinding binding, boolean requireDefinition, PDOMBinding nonLocal) { + public static IASTNode getDeclaredInSourceFileOnly(IBinding binding, boolean requireDefinition, PDOMBinding nonLocal) { IASTNode[] decls; IASTNode def; if (binding instanceof ICPPInternalBinding) { @@ -88,18 +89,19 @@ public class ASTInternal { if (requireDefinition && def == null) { return null; } - String filePath= null; + IASTNode result= null; if (def != null) { - if ((filePath= isPartOfSource(filePath, def)) == null) { + if (!isPartOfSource(def)) return null; - } + result= def; } if (decls != null) { for (final IASTNode node : decls) { if (node != null) { - if ((filePath= isPartOfSource(filePath, node)) == null) { + if (!isPartOfSource(node)) + return null; + if ((result= resolveConflict(result, node)) == null) return null; - } } } } @@ -110,23 +112,29 @@ public class ASTInternal { } catch (CoreException e) { } } - return filePath; + return result; } - private static String isPartOfSource(String filePath, IASTNode decl) { - if (decl instanceof ASTNode) { - if (((ASTNode) decl).isPartOfSourceFile()) { - if (filePath == null) - return decl.getContainingFilename(); - - if (filePath.equals(decl.getContainingFilename())) - return filePath; - } - } - return null; + private static boolean isPartOfSource(IASTNode decl) { + return decl instanceof ASTNode && ((ASTNode) decl).isPartOfSourceFile(); } - public static String getDeclaredInOneFileOnly(IBinding binding) { + private static IASTNode resolveConflict(IASTNode n1, IASTNode n2) { + if (n1 == null) + return n2; + + IASTFileLocation loc1= n1.getFileLocation(); + if (loc1 == null) + return n2; + + IASTFileLocation loc2= n2.getFileLocation(); + if (loc2 != null && loc1.getContextInclusionStatement() != loc2.getContextInclusionStatement()) + return null; + + return n1; + } + + public static IASTNode getDeclaredInOneFileOnly(IBinding binding) { IASTNode[] decls; IASTNode def; if (binding instanceof ICPPInternalBinding) { @@ -140,23 +148,19 @@ public class ASTInternal { } else { return null; } - String filePath= null; + IASTNode result= null; if (def != null) { - filePath= def.getContainingFilename(); + result= def; } if (decls != null) { for (final IASTNode node : decls) { if (node != null) { - final String fn = node.getContainingFilename(); - if (filePath == null) { - filePath= fn; - } else if (!filePath.equals(fn)) { + if ((result= resolveConflict(result, node)) == null) return null; - } } } } - return filePath; + return result; } public static void addDeclaration(IBinding b, IASTNode declaration) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java index c0fecc0a4fb..25de5bcb568 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java @@ -35,7 +35,7 @@ import org.eclipse.cdt.internal.core.parser.scanner.Token; */ public abstract class ASTNode implements IASTNode { protected static final ICPPFunction UNINITIALIZED_FUNCTION = new CPPFunction(null); - private static final IASTNodeLocation[] EMPTY_LOCATION_ARRAY = new IASTNodeLocation[0]; + private static final IASTNodeLocation[] EMPTY_LOCATION_ARRAY = {}; private IASTNode parent; private ASTNodeProperty property; @@ -184,7 +184,8 @@ public abstract class ASTNode implements IASTNode { public IASTFileLocation getFileLocation() { if (fileLocation != null) return fileLocation; - if (offset <= 0 && (length == 0 || offset < 0)) { + // TODO(sprigogin): The purpose of offset == 0 && length == 0 condition is not clear to me. + if (offset < 0 || (offset == 0 && length == 0 && !(this instanceof IASTTranslationUnit))) { return null; } IASTTranslationUnit ast = getTranslationUnit(); @@ -193,7 +194,7 @@ public abstract class ASTNode implements IASTNode { if (lr != null) { fileLocation= lr.getMappedFileLocation(offset, length); } else { - // support for old location map + // Support for old location map fileLocation= ast.flattenLocationsToFile(getNodeLocations()); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java index 63d2265bc31..75e6fc21f43 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java @@ -6,7 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -37,6 +38,7 @@ import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexFile; import org.eclipse.cdt.core.index.IIndexFileSet; import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.index.IndexBasedFileContentProvider; import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver; @@ -71,6 +73,9 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat private INodeFactory fNodeFactory; private boolean fForContentAssist; private ITranslationUnit fOriginatingTranslationUnit; + private ISignificantMacros fSignificantMacros= ISignificantMacros.NONE; + private boolean fPragmaOnceSemantics; + private SizeofCalculator fSizeofCalculator; /** The semaphore controlling exclusive access to the AST. */ private final Semaphore fSemaphore= new Semaphore(1); @@ -367,6 +372,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat if (fIndexFileSet != null) { List files= fileContent.getFilesIncluded(); for (IIndexFile indexFile : files) { + fASTFileSet.remove(indexFile); fIndexFileSet.add(indexFile); } } @@ -376,13 +382,14 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat return fIndexFileSet; } - public void replacingFile(InternalFileContentProvider provider, InternalFileContent fc) { + public void parsingFile(InternalFileContentProvider provider, InternalFileContent fc) { if (fASTFileSet != null) { if (provider instanceof IndexBasedFileContentProvider) { try { - IIndexFile file= ((IndexBasedFileContentProvider) provider).findIndexFile(fc); - if (file != null) { - fASTFileSet.add(file); + for (IIndexFile file : ((IndexBasedFileContentProvider) provider).findIndexFiles(fc)) { + if (!fIndexFileSet.contains(file)) { + fASTFileSet.add(file); + } } } catch (CoreException e) { // Ignore, tracking of replaced files fails. @@ -450,6 +457,25 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat this.fOriginatingTranslationUnit = tu; } + public ISignificantMacros getSignificantMacros() { + return fSignificantMacros; + } + + public void setSignificantMacros(ISignificantMacros sigMacros) { + assertNotFrozen(); + if (sigMacros != null) + fSignificantMacros= sigMacros; + } + + public boolean hasPragmaOnceSemantics() { + return fPragmaOnceSemantics; + } + + public void setPragmaOnceSemantics(boolean value) { + assertNotFrozen(); + fPragmaOnceSemantics= value; + } + /** * Starts exclusive access * @throws InterruptedException @@ -461,4 +487,11 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat public void endExclusiveAccess() { fSemaphore.release(); } + + public SizeofCalculator getSizeofCalculator() { + if (fSizeofCalculator == null) { + fSizeofCalculator = new SizeofCalculator(this); + } + return fSizeofCalculator; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java index 8baba365940..54e46eacea2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java @@ -200,7 +200,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { private final INodeFactory nodeFactory; private boolean fActiveCode= true; - private int fEndOffset= -1; protected AbstractGNUSourceCodeParser(IScanner scanner, IParserLogService logService, ParserMode parserMode, @@ -435,7 +434,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { try { return LA(i); } catch (EndOfFileException e) { - fEndOffset= e.getEndOffset(); return null; } } @@ -456,7 +454,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { try { return LT(i); } catch (EndOfFileException e) { - fEndOffset= e.getEndOffset(); return 0; } } @@ -1281,9 +1278,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { protected void parseTranslationUnit() { final IASTTranslationUnit tu= getTranslationUnit(); declarationList(tu, DeclarationOptions.GLOBAL, false, 0); - // Bug 3033152: getEndOffset() is computed off the last node and ignores trailing macros. - final int length= Math.max(getEndOffset(), fEndOffset); - ((ASTNode) tu).setLength(length); } protected final void declarationListInBraces(final IASTDeclarationListOwner tu, int offset, DeclarationOptions options) throws EndOfFileException, BacktrackException { @@ -1356,7 +1350,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { IASTDeclaration declaration= skipProblemDeclaration(offset); addDeclaration(tu, declaration, active); if (!e.endsInactiveCode()) { - fEndOffset= e.getEndOffset(); break; } } finally { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalScope.java index 1cb20611cc2..e347d0c22bc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalScope.java @@ -41,4 +41,11 @@ public interface IASTInternalScope extends IScope { * the ambiguities have been resolved. */ public void populateCache(); + + /** + * Can be called during ambiguity resolution to remove the names within the given + * node from the cache. + */ + public void removeNestedFromCache(IASTNode container); + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java index 00750fe2a31..b63128ee0a4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java @@ -68,14 +68,17 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I this.candidateBindings = candidateBindings; } + @Override public EScopeKind getKind() { return EScopeKind.eLocal; } - public IASTNode getASTNode() { + @Override + public IASTNode getASTNode() { return node; } + @Override public IBinding[] getCandidateBindings() { return candidateBindings != null ? candidateBindings : IBinding.EMPTY_BINDING_ARRAY; } @@ -87,14 +90,16 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IProblemBinding#getID() */ - public int getID() { + @Override + public int getID() { return id; } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IProblemBinding#getMessage() */ - public String getMessage() { + @Override + public String getMessage() { if (message != null) return message; @@ -115,28 +120,32 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IBinding#getName() */ - public String getName() { + @Override + public String getName() { return node instanceof IASTName ? new String(((IASTName) node).getSimpleID()) : CPPSemantics.EMPTY_NAME; } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray() */ - public char[] getNameCharArray() { + @Override + public char[] getNameCharArray() { return node instanceof IASTName ? ((IASTName) node).getSimpleID() : CharArrayUtils.EMPTY; } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IBinding#getScope() */ - public IScope getScope() throws DOMException { + @Override + public IScope getScope() throws DOMException { throw new DOMException(this); } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IBinding#getPhysicalNode() */ - public IASTNode getPhysicalNode() { + @Override + public IASTNode getPhysicalNode() { return getASTNode(); } @@ -150,20 +159,23 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#getParent() */ - public IScope getParent() throws DOMException { + @Override + public IScope getParent() throws DOMException { throw new DOMException(this); } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String) */ - public IBinding[] find(String name) { + @Override + public IBinding[] find(String name) { return IBinding.EMPTY_BINDING_ARRAY; } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#getScopeName() */ + @Override public IName getScopeName() { return null; } @@ -171,16 +183,19 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#addName(org.eclipse.cdt.core.dom.ast.IASTName) */ - public void addName(IASTName name) { + @Override + public void addName(IASTName name) { } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean) */ - public IBinding getBinding(IASTName name, boolean resolve) { + @Override + public IBinding getBinding(IASTName name, boolean resolve) { return null; } + @Override public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) { return IBinding.EMPTY_BINDING_ARRAY; } @@ -188,24 +203,28 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean) */ - public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) { + @Override + public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) { return null; } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean) */ - public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) { + @Override + public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) { return IBinding.EMPTY_BINDING_ARRAY; } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType) */ - public boolean isSameType(IType type) { + @Override + public boolean isSameType(IType type) { return type == this; } + @Override public String getFileName() { if (node != null) return node.getContainingFilename(); @@ -213,6 +232,7 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I return ""; //$NON-NLS-1$ } + @Override public int getLineNumber() { if (node != null) { IASTFileLocation fileLoc = node.getFileLocation(); @@ -222,9 +242,11 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I return -1; } + @Override public void addBinding(IBinding binding) { } + @Override public ILinkage getLinkage() { return Linkage.NO_LINKAGE; } @@ -234,6 +256,7 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I return getMessage(); } + @Override public IBinding getOwner() { if (node instanceof IASTName) { IASTTranslationUnit tu= node.getTranslationUnit(); @@ -251,10 +274,13 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I } } + @Override public void populateCache() { } - - + + @Override + public void removeNestedFromCache(IASTNode container) {} + // Dummy methods for derived classes public IType getType() { return new ProblemType(getID()); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java new file mode 100644 index 00000000000..2f56fb701de --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java @@ -0,0 +1,270 @@ +/******************************************************************************* + * Copyright (c) 2011 Google, Inc and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Sergey Prigogin (Google) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.dom.parser; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition; +import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; +import org.eclipse.cdt.core.dom.ast.IArrayType; +import org.eclipse.cdt.core.dom.ast.IBasicType; +import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.ICompositeType; +import org.eclipse.cdt.core.dom.ast.IEnumeration; +import org.eclipse.cdt.core.dom.ast.IField; +import org.eclipse.cdt.core.dom.ast.IPointerType; +import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.IValue; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; + +/** + * Calculator of in-memory size and of types. + */ +public class SizeofCalculator { + /** Size and alignment pair */ + public static class SizeAndAlignment { + public final long size; + public final int alignment; + + public SizeAndAlignment(long size, int alignment) { + this.size = size; + this.alignment = alignment; + } + } + + private static final SizeAndAlignment SIZE_1 = new SizeAndAlignment(1, 1); + + private final SizeAndAlignment size_2; + private final SizeAndAlignment size_4; + private final SizeAndAlignment size_8; + private final SizeAndAlignment sizeof_pointer; + private final SizeAndAlignment sizeof_int; + private final SizeAndAlignment sizeof_long; + private final SizeAndAlignment sizeof_long_long; + private final SizeAndAlignment sizeof_short; + private final SizeAndAlignment sizeof_bool; + private final SizeAndAlignment sizeof_wchar_t; + private final SizeAndAlignment sizeof_float; + private final SizeAndAlignment sizeof_complex_float; + private final SizeAndAlignment sizeof_double; + private final SizeAndAlignment sizeof_complex_double; + private final SizeAndAlignment sizeof_long_double; + private final SizeAndAlignment sizeof_complex_long_double; + + public SizeofCalculator(IASTTranslationUnit ast) { + int maxAlignment = 32; + Map sizeofMacros = new HashMap(); + for (IASTPreprocessorMacroDefinition macro : ast.getBuiltinMacroDefinitions()) { + String name = macro.getName().toString(); + if ("__BIGGEST_ALIGNMENT__".equals(name)) { //$NON-NLS-1$ + try { + maxAlignment = Integer.parseInt(macro.getExpansion()); + } catch (NumberFormatException e) { + // Ignore. + } + } else { + if (name.startsWith("__SIZEOF_")) { //$NON-NLS-1$ + sizeofMacros.put(name, macro.getExpansion()); + } + } + } + size_2 = new SizeAndAlignment(2, Math.min(2, maxAlignment)); + size_4 = new SizeAndAlignment(4, Math.min(4, maxAlignment)); + size_8 = new SizeAndAlignment(8, Math.min(8, maxAlignment)); + sizeof_pointer = getSize(sizeofMacros, "__SIZEOF_POINTER__", maxAlignment); //$NON-NLS-1$ + sizeof_int = getSize(sizeofMacros, "__SIZEOF_INT__", maxAlignment); //$NON-NLS-1$ + sizeof_long = getSize(sizeofMacros, "__SIZEOF_LONG__", maxAlignment); //$NON-NLS-1$ + sizeof_long_long = getSize(sizeofMacros, "__SIZEOF_LONG_LONG__", maxAlignment); //$NON-NLS-1$ + sizeof_short = getSize(sizeofMacros, "__SIZEOF_SHORT__", maxAlignment); //$NON-NLS-1$ + sizeof_bool = getSize(sizeofMacros, "__SIZEOF_BOOL__", maxAlignment); //$NON-NLS-1$ + sizeof_wchar_t = getSize(sizeofMacros, "__SIZEOF_WCHAR_T__", maxAlignment); //$NON-NLS-1$ + sizeof_float = getSize(sizeofMacros, "__SIZEOF_FLOAT__", maxAlignment); //$NON-NLS-1$ + sizeof_complex_float = getDoubleSize(sizeof_float); + sizeof_double = getSize(sizeofMacros, "__SIZEOF_DOUBLE__", maxAlignment); //$NON-NLS-1$ + sizeof_complex_double = getDoubleSize(sizeof_double); + sizeof_long_double = getSize(sizeofMacros, "__SIZEOF_LONG_DOUBLE__", maxAlignment); //$NON-NLS-1$ + sizeof_complex_long_double = getDoubleSize(sizeof_long_double); + } + + /** + * Calculates size and alignment for the given type. + * @param type + * @return size and alignment, or null if could not be calculated. + */ + public SizeAndAlignment sizeAndAlignment(IType type) { + type = SemanticUtil.getNestedType(type, SemanticUtil.CVTYPE | SemanticUtil.TDEF); + + if (type instanceof ICPPBasicType) { + return sizeAndAlignment((IBasicType) type); + } + if (type instanceof IPointerType || type instanceof ICPPReferenceType) { + if (type instanceof ICPPPointerToMemberType) + return null; + return sizeof_pointer; + } + if (type instanceof IEnumeration) { + return sizeAndAlignment((IEnumeration) type); + } + if (type instanceof IArrayType) { + return sizeAndAlignment((IArrayType) type); + } + if (type instanceof ICompositeType) { + return sizeAndAlignment((ICompositeType) type); + } + return null; + } + + private SizeAndAlignment sizeAndAlignment(IBasicType type) { + Kind kind = type.getKind(); + switch (kind) { + case eBoolean: + return sizeof_bool; + case eChar: + return SIZE_1; + case eInt: + return type.isShort() ? sizeof_short : type.isLong() ? sizeof_long : + type.isLongLong() ? sizeof_long_long : sizeof_int; + case eFloat: { + return type.isComplex() ? sizeof_complex_float : sizeof_float; + } + case eDouble: + return type.isComplex() ? + (type.isLong() ? sizeof_long_double : sizeof_double) : + (type.isLong() ? sizeof_complex_long_double : sizeof_complex_double); + case eWChar: + return sizeof_wchar_t; + case eChar16: + return size_2; + case eChar32: + return size_4; + default: + return null; + } + } + + private SizeAndAlignment sizeAndAlignment(IEnumeration type) { + if (type instanceof ICPPEnumeration) { + IType fixedType = ((ICPPEnumeration) type).getFixedType(); + if (fixedType != null) { + return sizeAndAlignment(fixedType); + } + } + long range = Math.max(Math.abs(type.getMinValue()) - 1, Math.abs(type.getMaxValue())); + if (range >= (2 << 32)) + return size_8; + if (type.getMinValue() < 0) + range *= 2; + if (range >= (2 << 32)) + return size_8; + if (range >= (2 << 16)) + return size_4; + if (range >= (2 << 8)) + return size_2; + return SIZE_1; + } + + private SizeAndAlignment sizeAndAlignment(IArrayType type) { + IValue value = type.getSize(); + if (value == null) + return null; + Long numElements = value.numericalValue(); + if (numElements == null) + return null; + IType elementType = type.getType(); + SizeAndAlignment info = sizeAndAlignment(elementType); + if (numElements.longValue() == 1) + return info; + if (info == null) + return null; + return new SizeAndAlignment(info.size * numElements.longValue(), info.alignment); + } + + private SizeAndAlignment sizeAndAlignment(ICompositeType type) { + /* TODO(sprigogin): May produce incorrect result for structures containing bit fields. + * Unfortunately widths of bit fields are not preserved in the AST. */ + long size = 0; + int maxAlignment = 1; + IField[] fields; + if (type instanceof ICPPClassType) { + ICPPClassType classType = (ICPPClassType) type; + for (ICPPBase base : classType.getBases()) { + if (base.isVirtual()) + return null; // Don't know how to calculate size when there are virtual bases. + IBinding baseClass = base.getBaseClass(); + if (!(baseClass instanceof IType)) + return null; + SizeAndAlignment info = sizeAndAlignment((IType) baseClass); + if (info == null) + return null; + size += info.alignment - (size - 1) % info.alignment - 1 + info.size; + if (maxAlignment < info.alignment) + maxAlignment = info.alignment; + for (ICPPMethod method : classType.getDeclaredMethods()) { + if (method.isVirtual()) { + // Don't know how to calculate size when there are virtual functions. + return null; + } + } + } + fields = classType.getDeclaredFields(); + } else { + fields = type.getFields(); + } + + boolean union = type.getKey() == ICompositeType.k_union; + for (IField field : fields) { + if (field.isStatic()) + continue; + IType fieldType = field.getType(); + SizeAndAlignment info = sizeAndAlignment(fieldType); + if (info == null) + return null; + if (union) { + if (size < info.size) + size = info.size; + } else { + size += info.alignment - (size - 1) % info.alignment - 1 + info.size; + } + if (maxAlignment < info.alignment) + maxAlignment = info.alignment; + } + if (size > 0) + size += maxAlignment - (size - 1) % maxAlignment - 1; + return new SizeAndAlignment(size, maxAlignment); + } + + private static SizeAndAlignment getSize(Map macros, String name, + int maxAlignment) { + String value = macros.get(name); + if (value == null) + return null; + try { + int size = Integer.parseInt(value); + return new SizeAndAlignment(size, Math.min(size, maxAlignment)); + } catch (NumberFormatException e) { + return null; + } + } + + private SizeAndAlignment getDoubleSize(SizeAndAlignment sizeAndAlignment) { + return sizeAndAlignment == null ? + null : new SizeAndAlignment(sizeAndAlignment.size * 2, sizeAndAlignment.alignment); + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java index 86bb3379557..ebfb4d1c194 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java @@ -1,12 +1,13 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -23,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTIdExpression; import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression; +import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression; import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IEnumerator; @@ -33,7 +35,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; import org.eclipse.cdt.core.parser.util.CharArrayUtils; +import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator; import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator.EvalException; import org.eclipse.cdt.internal.core.pdom.db.TypeMarshalBuffer; @@ -69,7 +73,7 @@ public class Value implements IValue { new Value(new char[] {'5'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY), new Value(new char[] {'6'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY)}; - + private static class Reevaluation { public final char[] fExpression; private int fPackOffset; @@ -99,6 +103,7 @@ public class Value implements IValue { pos= idx; } } + private static class UnknownValueException extends Exception {} private static UnknownValueException UNKNOWN_EX= new UnknownValueException(); private static int sUnique=0; @@ -130,7 +135,7 @@ public class Value implements IValue { buf.append(fExpression); buf.append('['); for (int i = 0; i < fUnknownBindings.length; i++) { - if (i>0) + if (i > 0) buf.append(','); buf.append(getSignatureForUnknown(fUnknownBindings[i])); } @@ -451,15 +456,27 @@ public class Value implements IValue { case IASTLiteralExpression.lk_char_constant: try { final char[] image= litEx.getValue(); - if (image.length > 1) - if (image[0] == 'L') - return ExpressionEvaluator.getChar(image, 2); - return ExpressionEvaluator.getChar(image, 1); + if (image.length > 1 && image[0] == 'L') + return ExpressionEvaluator.getChar(image, 2); + return ExpressionEvaluator.getChar(image, 1); } catch (EvalException e1) { throw UNKNOWN_EX; } } } + if (e instanceof IASTTypeIdExpression) { + IASTTypeIdExpression typeIdEx = (IASTTypeIdExpression) e; + switch (typeIdEx.getOperator()) { + case IASTTypeIdExpression.op_sizeof: + IType type = CPPVisitor.createType(typeIdEx.getTypeId()); + ASTTranslationUnit ast = (ASTTranslationUnit) typeIdEx.getTranslationUnit(); + SizeofCalculator calculator = ast.getSizeofCalculator(); + SizeAndAlignment info = calculator.sizeAndAlignment(type); + if (info == null) + throw UNKNOWN_EX; + return info.size; + } + } throw UNKNOWN_EX; } @@ -481,7 +498,7 @@ public class Value implements IValue { IValue value= null; if (b instanceof IInternalVariable) { - value= ((IInternalVariable) b).getInitialValue(maxdepth-1); + value= ((IInternalVariable) b).getInitialValue(maxdepth - 1); } else if (b instanceof IVariable) { value= ((IVariable) b).getInitialValue(); } else if (b instanceof IEnumerator) { @@ -521,9 +538,9 @@ public class Value implements IValue { boolean skipToSeparator= false; for (int i = 0; i < expr.length; i++) { final char c= expr[i]; - switch(c) { + switch (c) { case REFERENCE_CHAR: { - int idx= parseNonNegative(expr, i+1); + int idx= parseNonNegative(expr, i + 1); if (idx >= oldUnknowns.length) throw UNKNOWN_EX; final IBinding old = oldUnknowns[idx]; @@ -549,9 +566,21 @@ public class Value implements IValue { private static Object evaluateUnaryExpression(IASTUnaryExpression ue, Map unknownSigs, List unknowns, int maxdepth) throws UnknownValueException { final int unaryOp= ue.getOperator(); + + if (unaryOp == IASTUnaryExpression.op_sizeof) { + IType type = ue.getExpressionType(); + ASTTranslationUnit ast = (ASTTranslationUnit) ue.getTranslationUnit(); + SizeofCalculator calculator = ast.getSizeofCalculator(); + SizeAndAlignment info = calculator.sizeAndAlignment(type); + if (info == null) + throw UNKNOWN_EX; + return info.size; + } + if (unaryOp == IASTUnaryExpression.op_amper || unaryOp == IASTUnaryExpression.op_star || - unaryOp == IASTUnaryExpression.op_sizeof || unaryOp == IASTUnaryExpression.op_sizeofParameterPack) + unaryOp == IASTUnaryExpression.op_sizeofParameterPack) { throw UNKNOWN_EX; + } final Object value= evaluate(ue.getOperand(), unknownSigs, unknowns, maxdepth); return combineUnary(unaryOp, value); @@ -563,14 +592,14 @@ public class Value implements IValue { case IASTUnaryExpression.op_plus: return value; } - + if (value instanceof Number) { long v= ((Number) value).longValue(); - switch(unaryOp) { + switch (unaryOp) { case IASTUnaryExpression.op_prefixIncr: case IASTUnaryExpression.op_postFixIncr: return ++v; - case IASTUnaryExpression.op_prefixDecr : + case IASTUnaryExpression.op_prefixDecr: case IASTUnaryExpression.op_postFixDecr: return --v; case IASTUnaryExpression.op_minus: @@ -586,7 +615,7 @@ public class Value implements IValue { switch (unaryOp) { case IASTUnaryExpression.op_prefixIncr: case IASTUnaryExpression.op_postFixIncr: - case IASTUnaryExpression.op_prefixDecr : + case IASTUnaryExpression.op_prefixDecr: case IASTUnaryExpression.op_postFixDecr: case IASTUnaryExpression.op_minus: case IASTUnaryExpression.op_tilde: @@ -609,21 +638,21 @@ public class Value implements IValue { if (o1 instanceof Number && o2 instanceof Number) { long v1= ((Number) o1).longValue(); long v2= ((Number) o2).longValue(); - switch(op) { + switch (op) { case IASTBinaryExpression.op_multiply: - return v1*v2; + return v1 * v2; case IASTBinaryExpression.op_divide: if (v2 == 0) throw UNKNOWN_EX; - return v1/v2; + return v1 / v2; case IASTBinaryExpression.op_modulo: if (v2 == 0) throw UNKNOWN_EX; return v1 % v2; case IASTBinaryExpression.op_plus: - return v1+v2; + return v1 + v2; case IASTBinaryExpression.op_minus: - return v1-v2; + return v1 - v2; case IASTBinaryExpression.op_shiftLeft: return v1 << v2; case IASTBinaryExpression.op_shiftRight: @@ -637,11 +666,11 @@ public class Value implements IValue { case IASTBinaryExpression.op_greaterEqual: return v1 >= v2 ? 1 : 0; case IASTBinaryExpression.op_binaryAnd: - return v1&v2; + return v1 & v2; case IASTBinaryExpression.op_binaryXor: - return v1^v2; + return v1 ^ v2; case IASTBinaryExpression.op_binaryOr: - return v1|v2; + return v1 | v2; case IASTBinaryExpression.op_logicalAnd: return v1 != 0 && v2 != 0 ? 1 : 0; case IASTBinaryExpression.op_logicalOr: @@ -730,15 +759,15 @@ public class Value implements IValue { throw UNKNOWN_EX; final char c= buf[idx]; - switch(c) { + switch (c) { case BINARY_OP_CHAR: - int op= parseNonNegative(buf, idx+1); + int op= parseNonNegative(buf, idx + 1); reeval.nextSeperator(); Object o1= reevaluate(reeval, maxdepth); Object o2= reevaluate(reeval, maxdepth); return combineBinary(op, o1, o2); case UNARY_OP_CHAR: - op= parseNonNegative(buf, idx+1); + op= parseNonNegative(buf, idx + 1); reeval.nextSeperator(); o1= reevaluate(reeval, maxdepth); return combineUnary(op, o1); @@ -756,7 +785,7 @@ public class Value implements IValue { } return "" + CONDITIONAL_CHAR + SEPARATOR + cond.toString() + SEPARATOR + po.toString() + SEPARATOR + neg.toString(); //$NON-NLS-1$ case REFERENCE_CHAR: - int num= parseNonNegative(buf, idx+1); + int num= parseNonNegative(buf, idx + 1); final IBinding[] resolvedUnknowns= reeval.fResolvedUnknown; if (num >= resolvedUnknowns.length) throw UNKNOWN_EX; @@ -764,7 +793,7 @@ public class Value implements IValue { return evaluateBinding(resolvedUnknowns[num], reeval.fUnknownSigs, reeval.fUnknowns, maxdepth); case TEMPLATE_PARAM_CHAR: - num= parseHex(buf, idx+1); + num= parseHex(buf, idx + 1); reeval.nextSeperator(); ICPPTemplateArgument arg = reeval.fMap.getArgument(num); if (arg != null) { @@ -776,7 +805,7 @@ public class Value implements IValue { return createTemplateParamExpression(num, false); case TEMPLATE_PARAM_PACK_CHAR: - num= parseHex(buf, idx+1); + num= parseHex(buf, idx + 1); reeval.nextSeperator(); arg= null; if (reeval.fPackOffset >= 0) { @@ -807,14 +836,14 @@ public class Value implements IValue { final int len= value.length; int result = 0; boolean ok= false; - for(; offset< len; offset++) { - final int digit= (value[offset]- '0'); + for(; offset < len; offset++) { + final int digit= (value[offset] - '0'); if (digit < 0 || digit > 9) break; if (result > maxvalue) return -1; - result= result*10 + digit; + result= result * 10 + digit; ok= true; } if (!ok) @@ -829,12 +858,12 @@ public class Value implements IValue { int result = 0; boolean ok= false; final int len= value.length; - for(; offset< len; offset++) { - int digit= (value[offset]- '0'); + for(; offset < len; offset++) { + int digit= (value[offset] - '0'); if (digit < 0 || digit > 9) { - digit += '0'-'a'+10; + digit += '0' - 'a' + 10; if (digit < 10 || digit > 15) { - digit += 'a'-'A'; + digit += 'a' - 'A'; if (digit < 10 || digit > 15) { break; } @@ -867,14 +896,14 @@ public class Value implements IValue { offset++; } for(; offset < len; offset++) { - final int digit= (value[offset]- '0'); + final int digit= (value[offset] - '0'); if (digit < 0 || digit > 9) break; if (result > maxvalue) throw UNKNOWN_EX; - result= result*10 + digit; + result= result * 10 + digit; ok= true; } if (!ok) @@ -897,17 +926,17 @@ public class Value implements IValue { negative = true; i++; } - if (i==len) + if (i == len) return null; - for(; i< len; i++) { + for(; i < len; i++) { if (result > maxvalue) return null; - final int digit= (value[i]- '0'); + final int digit= (value[i] - '0'); if (digit < 0 || digit > 9) return null; - result= result*10 + digit; + result= result * 10 + digit; } return negative ? -result : result; } @@ -924,7 +953,6 @@ public class Value implements IValue { } return binding.getName(); } - /** * Converts long to a char array diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguityResolver.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguityResolver.java index eddda75e797..41de90e46a5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguityResolver.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguityResolver.java @@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; -import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTNode; @@ -47,8 +46,6 @@ public final class CASTAmbiguityResolver extends ASTVisitor { } node= node.getParent(); } - } else if (node instanceof IASTDeclarationStatement) { - repopulateScope(((IASTDeclarationStatement) node).getDeclaration()); } return PROCESS_SKIP; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousStatement.java index 0a62bc6d06b..6bc13e2de8f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousStatement.java @@ -11,6 +11,9 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; +import org.eclipse.cdt.core.dom.ast.ASTVisitor; +import org.eclipse.cdt.core.dom.ast.IASTDeclaration; +import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.dom.ast.IScope; @@ -18,11 +21,14 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousStatement; import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPASTInternalScope; public class CASTAmbiguousStatement extends ASTAmbiguousNode implements IASTAmbiguousStatement { private IASTStatement [] stmts = new IASTStatement[2]; private int stmtsPos=-1; + private IScope fScope; + private IASTDeclaration fDeclaration; public CASTAmbiguousStatement(IASTStatement... statements) { for(IASTStatement s : statements) @@ -31,13 +37,39 @@ public class CASTAmbiguousStatement extends ASTAmbiguousNode implements IASTAmbi @Override protected void beforeResolution() { - // populate containing scope, so that it will not be affected by the alternative branches. - IScope scope= CVisitor.getContainingScope(this); - if (scope instanceof IASTInternalScope) { - ((IASTInternalScope) scope).populateCache(); + // Populate containing scope, so that it will not be affected by the alternative + // branches. + fScope= CVisitor.getContainingScope(this); + if (fScope instanceof ICPPASTInternalScope) { + ((ICPPASTInternalScope) fScope).populateCache(); + } + } + + @Override + protected void beforeAlternative(IASTNode alternative) { + cleanupScope(); + if (alternative instanceof IASTDeclarationStatement) { + if (fScope instanceof CScope) { + fDeclaration = ((IASTDeclarationStatement) alternative).getDeclaration(); + ((CScope) fScope).collectNames(fDeclaration); + } + } + } + + private void cleanupScope() { + if (fScope instanceof IASTInternalScope && fDeclaration != null) { + ((IASTInternalScope) fScope).removeNestedFromCache(fDeclaration); } } + @Override + protected void afterResolution(ASTVisitor resolver, IASTNode best) { + beforeAlternative(best); + fDeclaration= null; + fScope= null; + } + + @Override public void addStatement(IASTStatement s) { assertNotFrozen(); if (s != null) { @@ -47,7 +79,8 @@ public class CASTAmbiguousStatement extends ASTAmbiguousNode implements IASTAmbi } } - public IASTStatement[] getStatements() { + @Override + public IASTStatement[] getStatements() { stmts = (IASTStatement[]) ArrayUtil.removeNullsAfter( IASTStatement.class, stmts, stmtsPos ); return stmts; } @@ -58,10 +91,12 @@ public class CASTAmbiguousStatement extends ASTAmbiguousNode implements IASTAmbi } + @Override public IASTStatement copy() { throw new UnsupportedOperationException(); } + @Override public IASTStatement copy(CopyStyle style) { throw new UnsupportedOperationException(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTypeId.java index 0bf0ded885d..b25f08429d1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTypeId.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTypeId.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Rational Software - Initial API and implementation - * Yuan Zhang / Beth Tibbitts (IBM Research) + * IBM Rational Software - Initial API and implementation + * Yuan Zhang / Beth Tibbitts (IBM Research) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -21,7 +21,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; * @author jcamelon */ public class CASTTypeId extends ASTNode implements IASTTypeId { - private IASTDeclSpecifier declSpecifier; private IASTDeclarator declarator; @@ -72,27 +71,26 @@ public class CASTTypeId extends ASTNode implements IASTTypeId { abstractDeclarator.setParent(this); abstractDeclarator.setPropertyInParent(ABSTRACT_DECLARATOR); } - } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitTypeIds ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitTypeIds) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - if( declSpecifier != null ) if( !declSpecifier.accept( action ) ) return false; - if( declarator != null ) if( !declarator.accept( action ) ) return false; + if (declSpecifier != null && !declSpecifier.accept(action)) return false; + if (declarator != null && !declarator.accept(action)) return false; - if( action.shouldVisitTypeIds ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + if (action.shouldVisitTypeIds) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java index fa1fcfd8516..4e9b526a4b6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java @@ -112,7 +112,7 @@ public class CScope implements ICScope, IASTInternalScope { private IASTNode physicalNode = null; private boolean isCached = false; - private CharArrayObjectMap[] mapsToNameOrBinding = { CharArrayObjectMap.EMPTY_MAP, CharArrayObjectMap.EMPTY_MAP }; + private CharArrayObjectMap mapsToNameOrBinding[] = { CharArrayObjectMap.EMPTY_MAP, CharArrayObjectMap.EMPTY_MAP }; private final EScopeKind kind; public CScope(IASTNode physical, EScopeKind eKind) { @@ -120,6 +120,7 @@ public class CScope implements ICScope, IASTInternalScope { kind= eKind; } + @Override public EScopeKind getKind() { return kind; } @@ -127,7 +128,8 @@ public class CScope implements ICScope, IASTInternalScope { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#getParent() */ - public IScope getParent() { + @Override + public IScope getParent() { return CVisitor.getContainingScope(physicalNode); } @@ -167,6 +169,7 @@ public class CScope implements ICScope, IASTInternalScope { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String) */ + @Override public IBinding[] find(String name) { return CVisitor.findBindings(this, name); } @@ -188,19 +191,22 @@ public class CScope implements ICScope, IASTInternalScope { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#getPhysicalNode() */ - public IASTNode getPhysicalNode() { + @Override + public IASTNode getPhysicalNode() { return physicalNode; } + @Override public void addName(IASTName name) { final char[] nchars = name.toCharArray(); if (nchars.length == 0) return; int type = getNamespaceType(name); - CharArrayObjectMap map = mapsToNameOrBinding[type]; + @SuppressWarnings("unchecked") + CharArrayObjectMap map = (CharArrayObjectMap) mapsToNameOrBinding[type]; if (map == CharArrayObjectMap.EMPTY_MAP) - map = mapsToNameOrBinding[type] = new CharArrayObjectMap(1); + mapsToNameOrBinding[type] = map = new CharArrayObjectMap(1); Object o= map.get(nchars); if (o instanceof IASTName) { @@ -234,14 +240,17 @@ public class CScope implements ICScope, IASTInternalScope { return NAMESPACE_TYPE_OTHER; } - public final IBinding getBinding(IASTName name, boolean resolve) { + @Override + public final IBinding getBinding(IASTName name, boolean resolve) { return getBinding(name, resolve, IIndexFileSet.EMPTY); } + @Override public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) { return getBindings(name, resolve, prefix, IIndexFileSet.EMPTY); } + @Override public final IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) { char[] c = name.toCharArray(); if (c.length == 0) { @@ -323,12 +332,13 @@ public class CScope implements ICScope, IASTInternalScope { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.c.ICScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean) */ + @Override public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) { char[] c = name.toCharArray(); Object[] obj = null; populateCache(); - for (CharArrayObjectMap map : mapsToNameOrBinding) { + for (CharArrayObjectMap map : mapsToNameOrBinding) { if (prefixLookup) { IContentAssistMatcher matcher = ContentAssistMatcherFactory.getInstance().createMatcher(c); Object[] keys = map.keyArray(); @@ -405,7 +415,8 @@ public class CScope implements ICScope, IASTInternalScope { return bindings[0]; } - public void populateCache() { + @Override + public void populateCache() { if (isCached) return; @@ -413,6 +424,45 @@ public class CScope implements ICScope, IASTInternalScope { isCached= true; } + @Override + public void removeNestedFromCache(IASTNode container) { + if (mapsToNameOrBinding != null) { + removeFromMap(mapsToNameOrBinding[0], container); + removeFromMap(mapsToNameOrBinding[1], container); + } + } + + private void removeFromMap(CharArrayObjectMap map, IASTNode container) { + for (int i = 0; i < map.size(); i++) { + Object o= map.getAt(i); + if (o instanceof IASTName) { + if (container.contains((IASTNode) o)) { + final char[] key = map.keyAt(i); + map.remove(key, 0, key.length); + i--; + } + } else if (o instanceof IASTName[]) { + final IASTName[] set = (IASTName[]) o; + removeFromSet(set, container); + } + } + } + + private void removeFromSet(IASTName[] set, IASTNode container) { + int j= 0; + for (int i = 0; i < set.length; i++) { + IASTName n= set[i]; + if (n == null) + break; + if (container.contains(n)) { + set[i]= null; + } else if (i != j) { + set[j++]= n; + set[i]= null; + } + } + } + protected void doPopulateCache() { final IASTNode scopeNode = physicalNode; IASTNode[] nodes = null; @@ -569,6 +619,7 @@ public class CScope implements ICScope, IASTInternalScope { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#getScopeName() */ + @Override public IName getScopeName() { if (physicalNode instanceof IASTCompositeTypeSpecifier) { return ((IASTCompositeTypeSpecifier) physicalNode).getName(); @@ -576,15 +627,17 @@ public class CScope implements ICScope, IASTInternalScope { return null; } + @Override public void addBinding(IBinding binding) { int type = NAMESPACE_TYPE_OTHER; if (binding instanceof ICompositeType || binding instanceof IEnumeration) { type = NAMESPACE_TYPE_TAG; } - CharArrayObjectMap map = mapsToNameOrBinding[type]; + @SuppressWarnings("unchecked") + CharArrayObjectMap map = (CharArrayObjectMap) mapsToNameOrBinding[type]; if (map == CharArrayObjectMap.EMPTY_MAP) - map = mapsToNameOrBinding[type] = new CharArrayObjectMap(2); + mapsToNameOrBinding[type] = map= new CharArrayObjectMap(2); map.put(binding.getNameCharArray(), binding); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguityResolver.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguityResolver.java index d31041261e3..3a7043e32cd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguityResolver.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguityResolver.java @@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; -import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; @@ -85,8 +84,6 @@ final class CPPASTAmbiguityResolver extends ASTVisitor { } node= node.getParent(); } - } else if (node instanceof IASTDeclarationStatement) { - repopulateScope(((IASTDeclarationStatement) node).getDeclaration()); } else if (node instanceof IASTDeclaration) { repopulateScope((IASTDeclaration) node); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousStatement.java index 3e42da6fbdd..c168e86be94 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousStatement.java @@ -11,12 +11,16 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; +import org.eclipse.cdt.core.dom.ast.ASTVisitor; +import org.eclipse.cdt.core.dom.ast.IASTDeclaration; +import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousStatement; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; public class CPPASTAmbiguousStatement extends ASTAmbiguousNode implements @@ -24,6 +28,8 @@ public class CPPASTAmbiguousStatement extends ASTAmbiguousNode implements private IASTStatement [] stmts = new IASTStatement[2]; private int stmtsPos=-1; + private IScope fScope; + private IASTDeclaration fDeclaration; public CPPASTAmbiguousStatement(IASTStatement... statements) { for(IASTStatement s : statements) @@ -32,21 +38,49 @@ public class CPPASTAmbiguousStatement extends ASTAmbiguousNode implements @Override protected void beforeResolution() { - // populate containing scope, so that it will not be affected by the alternative branches. - IScope scope= CPPVisitor.getContainingScope(this); - if (scope instanceof ICPPASTInternalScope) { - ((ICPPASTInternalScope) scope).populateCache(); + // Populate containing scope, so that it will not be affected by the alternative + // branches. + fScope= CPPVisitor.getContainingScope(this); + if (fScope instanceof ICPPASTInternalScope) { + ((ICPPASTInternalScope) fScope).populateCache(); + } + } + + @Override + protected void beforeAlternative(IASTNode alternative) { + cleanupScope(); + if (alternative instanceof IASTDeclarationStatement) { + if (fScope instanceof ICPPASTInternalScope) { + fDeclaration = ((IASTDeclarationStatement) alternative).getDeclaration(); + CPPSemantics.populateCache((ICPPASTInternalScope) fScope, fDeclaration); + } + } + } + + private void cleanupScope() { + if (fScope instanceof ICPPASTInternalScope && fDeclaration != null) { + ((ICPPASTInternalScope) fScope).removeNestedFromCache(fDeclaration); } } - public IASTStatement copy() { + @Override + protected void afterResolution(ASTVisitor resolver, IASTNode best) { + beforeAlternative(best); + fDeclaration= null; + fScope= null; + } + + @Override + public IASTStatement copy() { throw new UnsupportedOperationException(); } + @Override public IASTStatement copy(CopyStyle style) { throw new UnsupportedOperationException(); } + @Override public void addStatement(IASTStatement s) { assertNotFrozen(); if (s != null) { @@ -56,7 +90,8 @@ public class CPPASTAmbiguousStatement extends ASTAmbiguousNode implements } } - public IASTStatement[] getStatements() { + @Override + public IASTStatement[] getStatements() { stmts = (IASTStatement[]) ArrayUtil.removeNullsAfter( IASTStatement.class, stmts, stmtsPos ); return stmts; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarationStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarationStatement.java index 29941d0599a..b8c631fec0e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarationStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarationStatement.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation + * IBM - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -20,11 +20,9 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; /** * @author jcamelon */ -public class CPPASTDeclarationStatement extends ASTNode implements - IASTDeclarationStatement, IASTAmbiguityParent { - +public class CPPASTDeclarationStatement extends ASTNode + implements IASTDeclarationStatement, IASTAmbiguityParent { private IASTDeclaration declaration; - public CPPASTDeclarationStatement() { } @@ -61,30 +59,29 @@ public class CPPASTDeclarationStatement extends ASTNode implements } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitStatements ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitStatements) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - if( declaration != null ) if( !declaration.accept( action ) ) return false; - if( action.shouldVisitStatements ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + if (declaration != null && !declaration.accept(action)) return false; + if (action.shouldVisitStatements) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; } public void replace(IASTNode child, IASTNode other) { - if( declaration == child ) - { - other.setParent( child.getParent() ); - other.setPropertyInParent( child.getPropertyInParent() ); + if (declaration == child) { + other.setParent(child.getParent()); + other.setPropertyInParent(child.getPropertyInParent()); declaration = (IASTDeclaration) other; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDefaultStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDefaultStatement.java index 70246ad58b7..a66f576b058 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDefaultStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDefaultStatement.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation + * IBM - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -20,19 +20,19 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; public class CPPASTDefaultStatement extends ASTNode implements IASTDefaultStatement { @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitStatements ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitStatements) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - if( action.shouldVisitStatements ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + if (action.shouldVisitStatements) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java index 382288893f0..4a6d8243e02 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java @@ -15,6 +15,10 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF; + import java.util.ArrayList; import java.util.List; @@ -39,10 +43,9 @@ import org.eclipse.cdt.core.dom.ast.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate; @@ -51,6 +54,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; import org.eclipse.cdt.core.index.IIndexFileSet; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.CharArrayObjectMap; @@ -106,7 +110,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope { ICPPParameter[] ps = new ICPPParameter[] { new CPPParameter(pType, 0) }; int i= 0; - ImplicitsAnalysis ia= new ImplicitsAnalysis(compTypeSpec); + ImplicitsAnalysis ia= new ImplicitsAnalysis(compTypeSpec, clsType); implicits= new ICPPMethod[ia.getImplicitsToDeclareCount()]; if (!ia.hasUserDeclaredConstructor()) { @@ -405,10 +409,12 @@ class ImplicitsAnalysis { private boolean hasUserDeclaredCopyConstructor; private boolean hasUserDeclaredCopyAssignmentOperator; private boolean hasUserDeclaredDestructor; + private ICPPClassType classType; - ImplicitsAnalysis(ICPPASTCompositeTypeSpecifier compSpec) { + ImplicitsAnalysis(ICPPASTCompositeTypeSpecifier compSpec, ICPPClassType clsType) { + classType= clsType; + ICPPASTFunctionDeclarator[] ctors= getUserDeclaredCtorOrDtor(compSpec, true); - hasUserDeclaredConstructor= ctors.length> 0; hasUserDeclaredCopyConstructor= false; hasUserDeclaredCopyAssignmentOperator= false; @@ -418,7 +424,7 @@ class ImplicitsAnalysis { ICPPASTFunctionDeclarator dcltor= ctors[i]; IASTParameterDeclaration[] ps = dcltor.getParameters(); if (ps.length >= 1) { - if (paramHasTypeReferenceToTheAssociatedClassType(ps[0], compSpec.getName().getRawSignature())) { + if (hasTypeReferenceToClassType(ps[0])) { // and all remaining arguments have initializers for (int j = 1; j < ps.length; j++) { if (ps[j].getDeclarator().getInitializer() == null) { @@ -441,7 +447,7 @@ class ImplicitsAnalysis { + (!hasUserDeclaredCopyAssignmentOperator ? 1 : 0); } - private static ICPPASTFunctionDeclarator[] getUserDeclaredCtorOrDtor(ICPPASTCompositeTypeSpecifier compSpec, boolean constructor) { + private ICPPASTFunctionDeclarator[] getUserDeclaredCtorOrDtor(ICPPASTCompositeTypeSpecifier compSpec, boolean constructor) { List result= new ArrayList(); IASTDeclaration[] members = compSpec.getMembers(); char[] name = compSpec.getName().getLookupKey(); @@ -483,7 +489,7 @@ class ImplicitsAnalysis { return result.toArray(new ICPPASTFunctionDeclarator[result.size()]); } - private static ICPPASTFunctionDeclarator[] getUserDeclaredCopyAssignmentOperators(ICPPASTCompositeTypeSpecifier compSpec) { + private ICPPASTFunctionDeclarator[] getUserDeclaredCopyAssignmentOperators(ICPPASTCompositeTypeSpecifier compSpec) { List result= new ArrayList(); IASTDeclaration[] members = compSpec.getMembers(); IASTDeclarator dcltor = null; @@ -504,7 +510,7 @@ class ImplicitsAnalysis { continue; IASTParameterDeclaration[] ps = ((ICPPASTFunctionDeclarator)dcltor).getParameters(); - if (ps.length != 1 || !paramHasTypeReferenceToTheAssociatedClassType(ps[0], null)) + if (ps.length != 1 || !hasTypeReferenceToClassType(ps[0])) continue; result.add((ICPPASTFunctionDeclarator)dcltor); @@ -512,25 +518,20 @@ class ImplicitsAnalysis { return result.toArray(new ICPPASTFunctionDeclarator[result.size()]); } - /** - * @param compSpec the name the parameter must have in order to match, or null for any name - * @param dec - * @return whether the specified parameter is a reference to the associated class type, and - * (optionally) if it has the specified name - */ - private static boolean paramHasTypeReferenceToTheAssociatedClassType(IASTParameterDeclaration dec, String name) { - boolean result= false; - IASTDeclarator pdtor= ASTQueries.findTypeRelevantDeclarator(dec.getDeclarator()); - if (pdtor != null && pdtor.getPointerOperators().length == 1 && - pdtor.getPointerOperators()[0] instanceof ICPPASTReferenceOperator && - pdtor.getParent() == dec && - dec.getDeclSpecifier() instanceof ICPPASTNamedTypeSpecifier) { - ICPPASTNamedTypeSpecifier nts= (ICPPASTNamedTypeSpecifier) dec.getDeclSpecifier(); - if (name == null || name.equals(nts.getName().getRawSignature())) { - result= true; + private boolean hasTypeReferenceToClassType(IASTParameterDeclaration dec) { + if (dec instanceof ICPPASTParameterDeclaration) { + IType t= CPPVisitor.createType((ICPPASTParameterDeclaration) dec, false); + if (t != null) { + t= SemanticUtil.getNestedType(t, TDEF); + if (t instanceof ICPPReferenceType) { + if (!((ICPPReferenceType) t).isRValueReference()) { + t= SemanticUtil.getNestedType(t, TDEF|REF|CVTYPE); + return classType.isSameType(t); + } + } } } - return result; + return false; } public boolean hasUserDeclaredConstructor() { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecializationScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecializationScope.java index bdb119baa53..b03b19a2dd8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecializationScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecializationScope.java @@ -28,8 +28,14 @@ public class CPPClassSpecializationScope extends AbstractCPPClassSpecializationS } // This scope does not cache its own names + @Override public void addName(IASTName name) {} + @Override public IASTNode getPhysicalNode() { return null; } + @Override public void addBinding(IBinding binding) {} + @Override public void populateCache() {} + @Override + public void removeNestedFromCache(IASTNode container) {} } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java index 4b9064f2ef8..3cdf86e5091 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java @@ -143,7 +143,7 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp public ICPPASTCompositeTypeSpecifier getCompositeTypeSpecifier() { if (definition != null) { IASTNode node = definition; - while(node instanceof IASTName) + while (node instanceof IASTName) node = node.getParent(); if (node instanceof ICPPASTCompositeTypeSpecifier) return (ICPPASTCompositeTypeSpecifier)node; @@ -154,7 +154,7 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp private ICPPASTElaboratedTypeSpecifier getElaboratedTypeSpecifier() { if (declarations != null) { IASTNode node = declarations[0]; - while(node instanceof IASTName) + while (node instanceof IASTName) node = node.getParent(); if (node instanceof ICPPASTElaboratedTypeSpecifier) return (ICPPASTElaboratedTypeSpecifier)node; @@ -180,7 +180,7 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp && !getElaboratedTypeSpecifier().isFriend()) { // 3.3.1.5 class-key identifier ; } else { - while(scope instanceof ICPPClassScope || scope instanceof ICPPFunctionScope) { + while (scope instanceof ICPPClassScope || scope instanceof ICPPFunctionScope) { try { scope = scope.getParent(); } catch (DOMException e1) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java index e928a663cfb..15707e5fcdb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java @@ -60,7 +60,7 @@ abstract public class CPPScope implements ICPPASTInternalScope { private IASTNode physicalNode; private boolean isCached = false; - protected CharArrayObjectMap bindings = null; + protected CharArrayObjectMap bindings = null; private ICPPNamespace fIndexNamespace= UNINITIALIZED; public static class CPPScopeProblem extends ProblemBinding implements ICPPScope { @@ -76,14 +76,17 @@ abstract public class CPPScope implements ICPPASTInternalScope { this.physicalNode = physicalNode; } + @Override public IScope getParent() throws DOMException { return CPPVisitor.getContainingNonTemplateScope(physicalNode); } + @Override public IASTNode getPhysicalNode() { return physicalNode; } + @Override @SuppressWarnings({ "unchecked" }) public void addName(IASTName name) { // don't add inactive names to the scope @@ -91,7 +94,7 @@ abstract public class CPPScope implements ICPPASTInternalScope { return; if (bindings == null) - bindings = new CharArrayObjectMap(1); + bindings = new CharArrayObjectMap(1); if (name instanceof ICPPASTQualifiedName) { if (!(physicalNode instanceof ICPPASTCompositeTypeSpecifier) && !(physicalNode instanceof ICPPASTNamespaceDefinition)) { @@ -144,6 +147,7 @@ abstract public class CPPScope implements ICPPASTInternalScope { } } + @Override public IBinding getBinding(IASTName name, boolean forceResolve, IIndexFileSet fileSet) { IBinding binding= getBindingInAST(name, forceResolve); if (binding == null && forceResolve) { @@ -198,10 +202,12 @@ abstract public class CPPScope implements ICPPASTInternalScope { return CPPSemantics.resolveAmbiguities(name, bs); } + @Override public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) { return getBindings(name, resolve, prefixLookup, fileSet, true); } + @Override public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet, boolean checkPointOfDecl) { IBinding[] result = getBindingsInAST(name, resolve, prefixLookup, checkPointOfDecl); @@ -316,24 +322,63 @@ abstract public class CPPScope implements ICPPASTInternalScope { return (IBinding[]) ArrayUtil.append(IBinding.class, result, binding); } + @Override public final void populateCache() { if (!isCached) { CPPSemantics.populateCache(this); isCached= true; } } + + @Override + public void removeNestedFromCache(IASTNode container) { + if (bindings != null) { + removeFromMap(bindings, container); + } + } + + private void removeFromMap(CharArrayObjectMap map, IASTNode container) { + for (int i = 0; i < map.size(); i++) { + Object o= map.getAt(i); + if (o instanceof IASTName) { + if (container.contains((IASTNode) o)) { + final char[] key = map.keyAt(i); + map.remove(key, 0, key.length); + i--; + } + } else if (o instanceof ObjectSet) { + @SuppressWarnings("unchecked") + final ObjectSet set = (ObjectSet) o; + removeFromSet(set, container); + } + } + } + + private void removeFromSet(ObjectSet set, IASTNode container) { + for (int i = 0; i < set.size(); i++) { + Object o= set.keyAt(i); + if (o instanceof IASTName) { + if (container.contains((IASTNode) o)) { + set.remove(o); + i--; + } + } + } + } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String) */ + @Override public IBinding[] find(String name) { return CPPSemantics.findBindings(this, name, false); } + @Override @SuppressWarnings({ "unchecked" }) public void addBinding(IBinding binding) { if (bindings == null) - bindings = new CharArrayObjectMap(1); + bindings = new CharArrayObjectMap(1); char[] c = binding.getNameCharArray(); if (c.length == 0) { return; @@ -353,14 +398,17 @@ abstract public class CPPScope implements ICPPASTInternalScope { } } + @Override public final IBinding getBinding(IASTName name, boolean resolve) { return getBinding(name, resolve, IIndexFileSet.EMPTY); } + @Override public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) { return getBindings(name, resolve, prefix, IIndexFileSet.EMPTY, true); } + @Override public IName getScopeName() { return null; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java index 20ca20dedd2..b1377c38173 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java @@ -52,6 +52,7 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope { this.binding = binding; } + @Override public EScopeKind getKind() { return EScopeKind.eClassType; } @@ -59,37 +60,43 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#getScopeName() */ - public IName getScopeName() { + @Override + public IName getScopeName() { return scopeName; } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#getParent() */ - public IScope getParent() throws DOMException { + @Override + public IScope getParent() throws DOMException { return binding.getScope(); } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String) */ - public IBinding[] find(String name) { + @Override + public IBinding[] find(String name) { return null; } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#getPhysicalNode() */ - public IASTNode getPhysicalNode() { + @Override + public IASTNode getPhysicalNode() { return scopeName; } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#addName(org.eclipse.cdt.core.dom.ast.IASTName) */ - public void addName(IASTName name) { + @Override + public void addName(IASTName name) { } + @Override public final IBinding getBinding(IASTName name, boolean resolve) { return getBinding(name, resolve, IIndexFileSet.EMPTY); } @@ -97,7 +104,8 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean) */ - public IBinding getBinding(final IASTName name, boolean resolve, IIndexFileSet fileSet) { + @Override + public IBinding getBinding(final IASTName name, boolean resolve, IIndexFileSet fileSet) { boolean type= false; boolean function= false; @@ -171,15 +179,18 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope { return result; } + @Override public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) { return getBindings(name, resolve, prefix, IIndexFileSet.EMPTY); } - public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) { + @Override + public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) { return getBindings(name, resolve, prefixLookup, fileSet, true); } - public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet acceptLocalBindings, boolean checkPointOfDecl) { + @Override + public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet acceptLocalBindings, boolean checkPointOfDecl) { if (prefixLookup) { if (binding instanceof ICPPDeferredClassInstance) { ICPPDeferredClassInstance instance = (ICPPDeferredClassInstance) binding; @@ -194,6 +205,7 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope { return new IBinding[] {getBinding(name, resolve, acceptLocalBindings)}; } + @Override public void addBinding(IBinding binding) { // do nothing, this is part of template magic and not a normal scope } @@ -201,6 +213,7 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope { /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope#getUnknownBinding() */ + @Override public ICPPBinding getScopeBinding() { return binding; } @@ -213,5 +226,9 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope { return scopeName.toString(); } + @Override public void populateCache() {} + + @Override + public void removeNestedFromCache(IASTNode container) {} } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index 03a655b8892..b52271bd506 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -6,12 +6,12 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Niefer (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) - * Bryan Wilkinson (QNX) - * Andrew Ferguson (Symbian) - * Sergey Prigogin (Google) - * Mike Kucera (IBM) + * Andrew Niefer (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Bryan Wilkinson (QNX) + * Andrew Ferguson (Symbian) + * Sergey Prigogin (Google) + * Mike Kucera (IBM) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; @@ -220,11 +220,11 @@ public class CPPSemantics { * The maximum depth to search ancestors before assuming infinite looping. */ public static final int MAX_INHERITANCE_DEPTH= 16; - + public static final ASTNodeProperty STRING_LOOKUP_PROPERTY = new ASTNodeProperty("CPPSemantics.STRING_LOOKUP_PROPERTY - STRING_LOOKUP"); //$NON-NLS-1$ public static final String EMPTY_NAME = ""; //$NON-NLS-1$ - public static final char[] OPERATOR_ = new char[] {'o','p','e','r','a','t','o','r',' '}; + public static final char[] OPERATOR_ = new char[] {'o','p','e','r','a','t','o','r',' '}; private static final char[] CALL_FUNCTION = "call-function".toCharArray(); //$NON-NLS-1$ public static final IType VOID_TYPE = new CPPBasicType(Kind.eVoid, 0); public static final IType INT_TYPE = new CPPBasicType(Kind.eInt, 0); @@ -232,12 +232,12 @@ public class CPPSemantics { // Set to true for debugging. public static boolean traceBindingResolution = false; public static int traceIndent= 0; - + // special return value for costForFunctionCall private static final FunctionCost CONTAINS_DEPENDENT_TYPES = new FunctionCost(null, 0); static protected IBinding resolveBinding(IASTName name) { if (traceBindingResolution) { - for (int i = 0; i < traceIndent; i++) + for (int i = 0; i < traceIndent; i++) System.out.print(" "); //$NON-NLS-1$ System.out.println("Resolving " + name + ':' + ((ASTNode) name).getOffset()); //$NON-NLS-1$ traceIndent++; @@ -245,10 +245,10 @@ public class CPPSemantics { if (name instanceof CPPASTNameBase) { ((CPPASTNameBase) name).incResolutionDepth(); } - + // 1: get some context info off of the name to figure out what kind of lookup we want LookupData data = createLookupData(name); - + try { // 2: lookup lookup(data, null); @@ -274,7 +274,7 @@ public class CPPSemantics { binding = postResolution(binding, data); if (traceBindingResolution) { traceIndent--; - for (int i = 0; i < traceIndent; i++) + for (int i = 0; i < traceIndent; i++) System.out.print(" "); //$NON-NLS-1$ System.out.println("Resolved " + name + ':' + ((ASTNode) name).getOffset() + //$NON-NLS-1$ " to " + DebugUtil.toStringWithClass(binding) + ':' + System.identityHashCode(binding)); //$NON-NLS-1$ @@ -290,7 +290,7 @@ public class CPPSemantics { private static IBinding postResolution(IBinding binding, LookupData data) { if (binding instanceof IProblemBinding) return binding; - + if (binding == null && data.checkClassContainingFriend()) { // 3.4.1-10 if we don't find a name used in a friend declaration in the member declaration's class // we should look in the class granting friendship @@ -311,21 +311,21 @@ public class CPPSemantics { // Explicit type conversion in functional notation if (binding instanceof ICPPClassTemplate && data.astName instanceof ICPPASTTemplateId) { final IASTNode parent = data.astName.getParent(); - if (parent instanceof IASTIdExpression && + if (parent instanceof IASTIdExpression && parent.getPropertyInParent() == IASTFunctionCallExpression.FUNCTION_NAME) { return binding; } } - /* 14.6.1-1: - * Within the scope of a class template, when the name of the template is neither qualified nor + /* 14.6.1-1: + * Within the scope of a class template, when the name of the template is neither qualified nor * followed by <, it is equivalent to the name followed by the template parameters enclosed in <>. */ if (binding instanceof ICPPClassTemplate && !(binding instanceof ICPPClassSpecialization) && !(binding instanceof ICPPTemplateParameter) && !(data.astName instanceof ICPPASTTemplateId)) { ASTNodeProperty prop = data.astName.getPropertyInParent(); if (prop != ICPPASTTemplateId.TEMPLATE_NAME && prop != ICPPASTQualifiedName.SEGMENT_NAME) { - // You cannot use a class template name outside of the class template scope, + // You cannot use a class template name outside of the class template scope, // mark it as a problem. IBinding replacement= CPPTemplates.isUsedInClassTemplateScope((ICPPClassTemplate) binding, data.astName); if (replacement != null) { @@ -369,7 +369,7 @@ public class CPPSemantics { } } } - + if (binding instanceof IType) { IType t = getNestedType((IType) binding, TDEF); if (t instanceof ICPPClassType && convertClassToConstructor(data.astName)) { @@ -1222,10 +1222,10 @@ public class CPPSemantics { // For index scopes the point of declaration is ignored. bindings= scope.getBindings(data.astName, true, data.prefixLookup, fileSet); } - return expandUsingDeclarationsAndRemoveObjects(bindings, data.typesOnly); + return expandUsingDeclarationsAndRemoveObjects(bindings, data); } - private static IBinding[] expandUsingDeclarationsAndRemoveObjects(final IBinding[] bindings, boolean removeObjects) { + private static IBinding[] expandUsingDeclarationsAndRemoveObjects(final IBinding[] bindings, LookupData data) { if (bindings == null || bindings.length == 0) return IBinding.EMPTY_BINDING_ARRAY; @@ -1233,9 +1233,9 @@ public class CPPSemantics { if (b == null) break; - if (b instanceof ICPPUsingDeclaration || (removeObjects && isObject(b))) { + if (b instanceof ICPPUsingDeclaration || (data.typesOnly && isObject(b))) { List result= new ArrayList(bindings.length); - expandUsingDeclarations(bindings, removeObjects, result); + expandUsingDeclarations(bindings, data, result); return result.toArray(new IBinding[result.size()]); } } @@ -1246,18 +1246,21 @@ public class CPPSemantics { return !(b instanceof IType || b instanceof ICPPNamespace); } - private static void expandUsingDeclarations(IBinding[] bindings, boolean removeObjects, List result) { + private static void expandUsingDeclarations(IBinding[] bindings, LookupData data, List result) { if (bindings != null) { for (IBinding b : bindings) { if (b == null) return; + // Lookup for a declaration shall ignore the using declarations. if (b instanceof ICPPUsingDeclaration) { - for (IBinding d : ((ICPPUsingDeclaration) b).getDelegates()) { - if (d != null && !(removeObjects && isObject(d))) { - result.add(d); + if (data.forDeclaration() == null) { + for (IBinding d : ((ICPPUsingDeclaration) b).getDelegates()) { + if (d != null && !(data.typesOnly && isObject(d))) { + result.add(d); + } } } - } else if (!(removeObjects && isObject(b))) { + } else if (!(data.typesOnly && isObject(b))) { result.add(b); } } @@ -2041,8 +2044,7 @@ public class CPPSemantics { return type; } - - + if (fns.size() > 0) { final ICPPFunction[] fnArray = fns.keyArray(ICPPFunction.class); if (type != null && overrulesByRelevance(data, type, fnArray)) { @@ -2351,8 +2353,7 @@ public class CPPSemantics { Arrays.asList(data.getFunctionArgumentValueCategories()), data.argsContainImpliedObject); if (tmp.length == 0 || tmp[0] == null) return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_NAME_NOT_FOUND, fns); - - + int viableCount= 0; for (IFunction f : tmp) { if (f instanceof ICPPUnknownBinding) { @@ -2681,7 +2682,7 @@ public class CPPSemantics { return CONTAINS_DEPENDENT_TYPES; Context ctx= Context.ORDINARY; - if (j==0 && sourceLen == 1 && fn instanceof ICPPConstructor) { + if (j == 0 && sourceLen == 1 && fn instanceof ICPPConstructor) { if (paramType instanceof ICPPReferenceType) { if (((ICPPConstructor) fn).getClassOwner().isSameType(getNestedType(paramType, TDEF|REF|CVTYPE))) { ctx= Context.FIRST_PARAM_OF_DIRECT_COPY_CTOR; @@ -3586,7 +3587,7 @@ public class CPPSemantics { } return result; } - + if (obj instanceof IASTName) { return addContentAssistBinding(result, ((IASTName) obj).resolveBinding()); } @@ -3615,7 +3616,7 @@ public class CPPSemantics { Object[] items = (Object[]) data.foundItems; if (items == null) return new IBinding[0]; - + ObjectSet set = new ObjectSet(items.length); IBinding binding = null; for (Object item : items) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index 4d4935bc154..bdc7c70adcf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -6,14 +6,15 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Bryan Wilkinson (QNX) - * Markus Schorn (Wind River Systems) - * Sergey Prigogin (Google) + * IBM - Initial API and implementation + * Bryan Wilkinson (QNX) + * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF; import java.util.ArrayList; import java.util.Collections; @@ -54,7 +55,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBas import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration; @@ -91,7 +91,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration; import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.CharArraySet; -import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode; import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; @@ -155,7 +154,7 @@ public class CPPTemplates { private static final int PACK_SIZE_FAIL = -2; private static final int PACK_SIZE_NOT_FOUND = Integer.MAX_VALUE; private static final ICPPFunction[] NO_FUNCTIONS = {}; - static enum TypeSelection {PARAMETERS, RETURN_TYPE, PARAMETERS_AND_RETURN_TYPE} + static enum TypeSelection { PARAMETERS, RETURN_TYPE, PARAMETERS_AND_RETURN_TYPE } /** * Instantiates a class template with the given arguments. May return null. @@ -183,8 +182,7 @@ public class CPPTemplates { if (template instanceof ICPPClassTemplatePartialSpecialization) { return instantiatePartialSpecialization((ICPPClassTemplatePartialSpecialization) template, arguments, isDefinition, null); } - - + final ICPPTemplateParameter[] parameters= template.getTemplateParameters(); final int numArgs = arguments.length; final int numParams= parameters.length; @@ -255,16 +253,18 @@ public class CPPTemplates { static IBinding isUsedInClassTemplateScope(ICPPClassTemplate ct, IASTName name) { try { IScope scope; - ICPPASTFunctionDefinition func= CPPVisitor.findEnclosingFunctionDefinition(name); - if (func != null) { - name= ASTQueries.findInnermostDeclarator(func.getDeclarator()).getName().getLastName(); - scope= CPPVisitor.getContainingScope(name); - } else { - scope= CPPVisitor.getContainingScope(name); - if (!(scope instanceof IASTInternalScope)) - return null; + IASTNode node= name; + while (node != null) { + if (node.getPropertyInParent() == IASTFunctionDefinition.DECLARATOR) + break; + if (node instanceof IASTFunctionDefinition) { + name= ASTQueries.findInnermostDeclarator(((IASTFunctionDefinition) node).getDeclarator()).getName().getLastName(); + break; + } + node= node.getParent(); } - + + scope= CPPVisitor.getContainingScope(name); while (scope != null) { if (scope instanceof ISemanticProblem) return null; @@ -1232,12 +1232,12 @@ public class CPPTemplates { tdecl= getDirectlyEnclosingTemplateDeclaration(tdecl); } } - // not enough template declartaions + // not enough template declarations return null; } public static void associateTemplateDeclarations(ICPPASTInternalTemplateDeclaration tdecl) { - // find innermost template declaration + // Find innermost template declaration IASTDeclaration decl= tdecl.getDeclaration(); while (decl instanceof ICPPASTInternalTemplateDeclaration) { tdecl= (ICPPASTInternalTemplateDeclaration) decl; @@ -1245,111 +1245,119 @@ public class CPPTemplates { } final ICPPASTInternalTemplateDeclaration innerMostTDecl= tdecl; - // find name declared within the template declaration - IASTName name= getNameForDeclarationInTemplateDeclaration(decl); + // Find name declared within the template declaration + final IASTName declName= getNameForDeclarationInTemplateDeclaration(decl); - // count template declarations - int tdeclcount= 1; - IASTNode node= tdecl.getParent(); + // Count non-empty template declarations + int instDeclCount= 0; + int tdeclCount= 0; + IASTNode node= tdecl; while (node instanceof ICPPASTInternalTemplateDeclaration) { - tdeclcount++; tdecl = (ICPPASTInternalTemplateDeclaration) node; node= node.getParent(); + if (tdecl.getTemplateParameters().length == 0) { + instDeclCount++; + } else { + instDeclCount= 0; + } + tdeclCount++; } final ICPPASTInternalTemplateDeclaration outerMostTDecl= tdecl; + final int paramTDeclCount = tdeclCount-instDeclCount; - // determine association of names with template declarations + // Determine association of names with template declarations boolean lastIsTemplate= true; - int missingTemplateDecls= 0; - if (name instanceof ICPPASTQualifiedName) { - ICPPASTQualifiedName qname= (ICPPASTQualifiedName) name; - final IASTName lastName = qname.getLastName(); - final boolean lastIsID = lastName instanceof ICPPASTTemplateId; + int nestingLevel; + if (declName instanceof ICPPASTQualifiedName) { + ICPPASTQualifiedName qname= (ICPPASTQualifiedName) declName; - // count template-ids - int idcount= 0; + // Count dependent-ids + CharArraySet tparnames= collectTemplateParameterNames(outerMostTDecl); + int depIDCount= 0; + IASTName owner= null; final IASTName[] ns= qname.getNames(); - for (final IASTName n : ns) { + for (int i = 0; i < ns.length-1; i++) { + IASTName n= ns[i]; if (n instanceof ICPPASTTemplateId) { - idcount++; - } - } - - boolean isCtorWithTemplateID= false; - if (lastIsID && ns.length > 1) { - IASTName secondLastName= ns[ns.length-2]; - if (secondLastName instanceof ICPPASTTemplateId) { - final char[] lastNamesLookupKey = lastName.getLookupKey(); - if (CharArrayUtils.equals(lastNamesLookupKey, ((ICPPASTTemplateId) secondLastName).getLookupKey()) || - (lastNamesLookupKey.length > 0 && lastNamesLookupKey[0] == '~')) { - isCtorWithTemplateID= true; - idcount--; + if (depIDCount > 0 || usesTemplateParameter((ICPPASTTemplateId) n, tparnames)) { + depIDCount++; } + } + if (depIDCount == 0) { + owner= n; } } - if (lastIsID && !isCtorWithTemplateID) { - missingTemplateDecls= idcount-tdeclcount; + if (qname.getLastName() instanceof ICPPASTTemplateId + || paramTDeclCount > depIDCount // not enough template ids + || ns.length < 2 // ::name + ) { + lastIsTemplate= true; + depIDCount++; } else { - missingTemplateDecls= idcount+1-tdeclcount; - if (missingTemplateDecls > 0) { - // last name is probably not a template - missingTemplateDecls--; - lastIsTemplate= false; - CharArraySet tparnames= collectTemplateParameterNames(outerMostTDecl); - int j= 0; - for (IASTName n : ns) { - if (n instanceof ICPPASTTemplateId) { - // if we find a dependent id, there can be no explicit specialization. - ICPPASTTemplateId id= (ICPPASTTemplateId) n; - if (usesTemplateParameter(id, tparnames)) - break; - - if (j++ == missingTemplateDecls) { - IBinding b= n.resolveBinding(); - if (b instanceof ICPPTemplateInstance && b instanceof ICPPClassType) { - if (((ICPPTemplateInstance) b).isExplicitSpecialization()) { - // For a template-id of an explicit specialization. - // we don't have a template declaration. (see 14.7.3.5) - missingTemplateDecls++; - lastIsTemplate= true; - } - } - break; - } - } + lastIsTemplate= false; + } + + nestingLevel= 0; + if (owner != null) { + int consumesTDecl= 0; + IBinding b= owner.resolveBinding(); + if (b instanceof IType) { + IType t= SemanticUtil.getNestedType((IType) b, TDEF); + if (t instanceof IBinding) + b= (IBinding) t; + } + while (b != null) { + if (b instanceof ICPPTemplateInstance) { + nestingLevel++; + if (!((ICPPTemplateInstance) b).isExplicitSpecialization()) + consumesTDecl++; + } else if (b instanceof ICPPClassTemplate || b instanceof ICPPClassTemplatePartialSpecialization) { + nestingLevel++; + consumesTDecl++; } + b= b.getOwner(); } - } - } - - if (missingTemplateDecls < 0) { - missingTemplateDecls= 0; // too many template declarations - } - - // determine nesting level of parent - int level= missingTemplateDecls; - if (!isFriendFunctionDeclaration(innerMostTDecl.getDeclaration())) { - node= outerMostTDecl.getParent(); - while (node != null) { - if (node instanceof ICPPASTInternalTemplateDeclaration) { - level+= ((ICPPASTInternalTemplateDeclaration) node).getNestingLevel() + 1; - break; + if (depIDCount > 0) { + nestingLevel+= depIDCount; + } else if (consumesTDecl < tdeclCount && !lastIsTemplate) { + nestingLevel++; + lastIsTemplate= true; } - node= node.getParent(); - } - } - - tdecl= outerMostTDecl; - while(true) { - tdecl.setNestingLevel((short) level++); - tdecl.setAssociatedWithLastName(false); - node= tdecl.getDeclaration(); - if (node instanceof ICPPASTInternalTemplateDeclaration) { - tdecl= (ICPPASTInternalTemplateDeclaration) node; } else { - break; + nestingLevel+= depIDCount; + node= outerMostTDecl.getParent(); + while (node != null) { + if (node instanceof ICPPASTInternalTemplateDeclaration) { + nestingLevel+= ((ICPPASTInternalTemplateDeclaration) node).getNestingLevel() + 1; + break; + } + node= node.getParent(); + } } + } else { + nestingLevel= 1; + lastIsTemplate= true; + if (!isFriendFunctionDeclaration(innerMostTDecl.getDeclaration())) { + node= outerMostTDecl.getParent(); + while (node != null) { + if (node instanceof ICPPASTInternalTemplateDeclaration) { + nestingLevel+= ((ICPPASTInternalTemplateDeclaration) node).getNestingLevel() + 1; + break; + } + node= node.getParent(); + } + } + } + + node= innerMostTDecl; + while(node instanceof ICPPASTInternalTemplateDeclaration) { + if (--nestingLevel < 0) + nestingLevel= 0; + tdecl= (ICPPASTInternalTemplateDeclaration) node; + tdecl.setNestingLevel((short) nestingLevel); + tdecl.setAssociatedWithLastName(false); + node= tdecl.getParent(); } innerMostTDecl.setAssociatedWithLastName(lastIsTemplate); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java index 5799476eeb0..571b28ac652 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java @@ -156,6 +156,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.ProblemType; import org.eclipse.cdt.internal.core.dom.parser.Value; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFieldReference; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionCallExpression; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName; @@ -200,12 +201,14 @@ public class CPPVisitor extends ASTQueries { private static final CPPBasicType UNSIGNED_LONG = new CPPBasicType(Kind.eInt, IBasicType.IS_LONG | IBasicType.IS_UNSIGNED); private static final CPPBasicType INT_TYPE = new CPPBasicType(Kind.eInt, 0); - static final char[] BEGIN = "begin".toCharArray(); //$NON-NLS-1$ + private static final String BEGIN_STR = "begin"; //$NON-NLS-1$ + static final char[] BEGIN = BEGIN_STR.toCharArray(); static final String STD = "std"; //$NON-NLS-1$ private static final char[] SIZE_T = "size_t".toCharArray(); //$NON-NLS-1$ private static final char[] PTRDIFF_T = "ptrdiff_t".toCharArray(); //$NON-NLS-1$ private static final char[] TYPE_INFO= "type_info".toCharArray(); //$NON-NLS-1$ private static final char[] INITIALIZER_LIST = "initializer_list".toCharArray(); //$NON-NLS-1$ + private static final IASTInitializerClause[] NO_ARGS = {}; // Thread-local set of DeclSpecifiers for which auto types are being created. // Used to prevent infinite recursion while processing invalid self-referencing @@ -238,35 +241,8 @@ public class CPPVisitor extends ASTQueries { return CPPSemantics.resolveBinding(name); parent = parent.getParent(); - binding = CPPSemantics.resolveBinding(name); - if (binding instanceof IProblemBinding && !(parent instanceof ICPPASTNamespaceAlias)) { - final IASTName[] ns = qname.getNames(); - if (ns.length > 1 && ns[ns.length - 2].getBinding() instanceof IProblemBinding) - return binding; - - if (((IProblemBinding) binding).getID() == IProblemBinding.SEMANTIC_MEMBER_DECLARATION_NOT_FOUND) { - IASTNode node = getContainingBlockItem(name.getParent()); - ASTNodeProperty prop= node.getPropertyInParent(); - while (prop == ICPPASTTemplateDeclaration.OWNED_DECLARATION) { - node= node.getParent(); - prop= node.getPropertyInParent(); - } - if (prop != IASTCompositeTypeSpecifier.MEMBER_DECLARATION && - prop != ICPPASTNamespaceDefinition.OWNED_DECLARATION) { - return binding; - } - IScope scope= getContainingScope(qname); - while (scope instanceof ICPPTemplateScope) { - try { - scope= scope.getParent(); - } catch (DOMException e) { - return binding; - } - } - if (scope != getContainingScope(name)) - return binding; - } - } else { + if (!declaresMemberInClassOrNamespace(qname)) { + binding = CPPSemantics.resolveBinding(name); if (parent instanceof IASTCompositeTypeSpecifier) { if (binding instanceof IIndexBinding) { // Need to create an AST binding @@ -316,6 +292,52 @@ public class CPPVisitor extends ASTQueries { return null; } + private static boolean declaresMemberInClassOrNamespace(ICPPASTQualifiedName qname) { + IASTName[] names= qname.getNames(); + if (names.length < 2) + return false; + + IBinding pb= names[names.length-2].resolvePreBinding(); + if (pb instanceof IProblemBinding) + return false; + + IScope scope= null; + if (pb instanceof IType) { + IType t= SemanticUtil.getNestedType((IType) pb, TDEF); + if (t instanceof ICPPClassType) { + scope= ((ICPPClassType) t).getCompositeScope(); + } + } else if (pb instanceof ICPPNamespace) { + scope= ((ICPPNamespace)pb).getNamespaceScope(); + } + if (scope == null) + return false; + + IASTNode parent= qname.getParent(); + IASTNode decl= null; + if (parent instanceof IASTCompositeTypeSpecifier) { + decl= parent.getParent(); + } else if (parent instanceof IASTDeclarator) { + decl= ASTQueries.findOutermostDeclarator((IASTDeclarator) parent).getParent(); + } + while (decl != null) { + ASTNodeProperty prop = decl.getPropertyInParent(); + if (prop == IASTCompositeTypeSpecifier.MEMBER_DECLARATION) { + return scope == ((ICPPASTCompositeTypeSpecifier) decl.getParent()).getScope(); + } + if (prop == ICPPASTNamespaceDefinition.OWNED_DECLARATION) { + return scope == ((ICPPASTNamespaceDefinition) decl.getParent()).getScope(); + } + + if (prop == ICPPASTTemplateDeclaration.OWNED_DECLARATION) { + decl= decl.getParent(); + } else { + return false; + } + } + return false; + } + private static IBinding createBinding(IASTGotoStatement gotoStatement) { ICPPFunctionScope functionScope = (ICPPFunctionScope) getContainingScope(gotoStatement.getName()); IASTName name = gotoStatement.getName(); @@ -798,21 +820,12 @@ public class CPPVisitor extends ASTQueries { } public static boolean isConstructor(IScope containingScope, IASTDeclarator declarator) { - if (containingScope == null || !(containingScope instanceof ICPPClassScope)) - return false; - - IASTNode node = ASTInternal.getPhysicalNodeOfScope(containingScope); - if (!(node instanceof ICPPASTCompositeTypeSpecifier)) { - return false; + if (containingScope instanceof ICPPClassScope && isConstructorDtor(declarator)) { + ICPPClassType classType= ((ICPPClassScope) containingScope).getClassType(); + final char[] dtorName = findInnermostDeclarator(declarator).getName().getLookupKey(); + return CharArrayUtils.equals(dtorName, classType.getNameCharArray()); } - - ICPPASTCompositeTypeSpecifier clsTypeSpec = (ICPPASTCompositeTypeSpecifier) node; - IASTName clsName = clsTypeSpec.getName(); - if (clsName instanceof ICPPASTQualifiedName) { - IASTName[] names = ((ICPPASTQualifiedName) clsName).getNames(); - clsName = names[names.length - 1]; - } - return isConstructor(clsName, declarator); + return false; } public static boolean isConstructorDeclaration(IASTName name) { @@ -833,35 +846,39 @@ public class CPPVisitor extends ASTQueries { parent= name.getParent(); } if (parent instanceof IASTDeclarator) { - IASTDeclarator dtor= findTypeRelevantDeclarator((IASTDeclarator) parent); - if (dtor instanceof ICPPASTFunctionDeclarator) { + if (isConstructorDtor((IASTDeclarator) parent)) { if (name instanceof ICPPASTQualifiedName) { IASTName[] names = ((ICPPASTQualifiedName) name).getNames(); if (names.length >= 2) { - return CPPVisitor.isConstructor(names[names.length - 2], dtor); - } - } else { - while (parent != null && !(parent instanceof ICPPASTCompositeTypeSpecifier)) { - parent= parent.getParent(); + IBinding b= names[names.length-2].resolvePreBinding(); + if (b instanceof IType) { + IType classType= getNestedType((IType) b, TDEF); + if (classType instanceof ICPPClassType) { + final char[] dtorName = names[names.length-1].getLookupKey(); + final char[] className = ((ICPPClassType) classType).getNameCharArray(); + return CharArrayUtils.equals(dtorName, className); + } + } } + return false; + } + while (parent != null) { if (parent instanceof ICPPASTCompositeTypeSpecifier) { - IASTName compName= ((ICPPASTCompositeTypeSpecifier) parent).getName().getLastName(); - return CPPVisitor.isConstructor(compName, dtor); + final char[] className= ((ICPPASTCompositeTypeSpecifier) parent).getName().getLastName().getLookupKey(); + final char[] dtorName = name.getLookupKey(); + return CharArrayUtils.equals(dtorName, className); } + parent= parent.getParent(); } } } return false; } - public static boolean isConstructor(IASTName parentName, IASTDeclarator declarator) { + private static boolean isConstructorDtor(IASTDeclarator declarator) { if (declarator == null || !(declarator instanceof IASTFunctionDeclarator)) return false; - IASTName name = findInnermostDeclarator(declarator).getName(); - if (!CharArrayUtils.equals(name.getLookupKey(), parentName.getLookupKey())) - return false; - IASTDeclSpecifier declSpec = null; IASTNode parent = findOutermostDeclarator(declarator).getParent(); if (parent instanceof IASTSimpleDeclaration) { @@ -874,7 +891,6 @@ public class CPPVisitor extends ASTQueries { } return false; - } public static IScope getContainingNonTemplateScope(final IASTNode inputNode) { @@ -1069,21 +1085,7 @@ public class CPPVisitor extends ASTQueries { } return null; } - - /** - * Returns enclosing function definition, or null if the given node - * is not part of a function definition. - */ - public static ICPPASTFunctionDefinition findEnclosingFunctionDefinition(IASTNode node) { - while (node != null) { - if (node instanceof ICPPASTFunctionDefinition) { - return (ICPPASTFunctionDefinition) node; - } - node= node.getParent(); - } - return null; - } - + public static IScope getContainingScope(IASTName name) { return getContainingScope(name, null); } @@ -1840,56 +1842,9 @@ public class CPPVisitor extends ASTQueries { if (declSpec instanceof ICPPASTSimpleDeclSpecifier && ((ICPPASTSimpleDeclSpecifier) declSpec).getType() == IASTSimpleDeclSpecifier.t_auto) { - if (declarator instanceof ICPPASTFunctionDeclarator) { - return createAutoFunctionType(declSpec, (ICPPASTFunctionDeclarator) declarator); - } - IASTInitializerClause autoInitClause= null; - parent = parent.getParent(); - if (parent instanceof ICPPASTNewExpression) { - IASTInitializer initializer = ((ICPPASTNewExpression) parent).getInitializer(); - if (initializer != null) { - IASTInitializerClause[] arguments = ((ICPPASTConstructorInitializer) initializer).getArguments(); - if (arguments.length == 1) { - autoInitClause = arguments[0]; - } - } - } else if (parent instanceof ICPPASTRangeBasedForStatement) { - ICPPASTRangeBasedForStatement forStmt= (ICPPASTRangeBasedForStatement) parent; - IASTInitializerClause forInit = forStmt.getInitializerClause(); - IASTExpression beginExpr= null; - if (forInit instanceof IASTExpression) { - final IASTExpression expr = (IASTExpression) forInit; - IType type= expr.getExpressionType(); - if (type instanceof IArrayType) { - beginExpr= expr.copy(); - } - } - if (beginExpr == null) { - final CPPASTName name = new CPPASTName(BEGIN); - name.setOffset(((ASTNode) forInit).getOffset()); - beginExpr= new CPPASTFunctionCallExpression( - new CPPASTIdExpression(name), - new IASTInitializerClause[] {forInit.copy()}); - } - autoInitClause= new CPPASTUnaryExpression(IASTUnaryExpression.op_star, beginExpr); - autoInitClause.setParent(forStmt); - autoInitClause.setPropertyInParent(ICPPASTRangeBasedForStatement.INITIALIZER); - } else if (parent instanceof IASTCompositeTypeSpecifier && - declSpec.getStorageClass() != IASTDeclSpecifier.sc_static) { - // Non-static auto-typed class members are not allowed. - return new ProblemType(ISemanticProblem.TYPE_AUTO_FOR_NON_STATIC_FIELD); - } else { - IASTInitializer initClause= declarator.getInitializer(); - if (initClause instanceof IASTEqualsInitializer) { - autoInitClause= ((IASTEqualsInitializer) initClause).getInitializerClause(); - } else if (initClause instanceof IASTInitializerClause) { - autoInitClause= (IASTInitializerClause) initClause; - } - } - return createAutoType(autoInitClause, declSpec, declarator); + return createAutoType(declSpec, declarator); } - IType type = createType(declSpec); type = createType(type, declarator); @@ -1914,6 +1869,65 @@ public class CPPVisitor extends ASTQueries { return type; } + private static IType createAutoType(IASTDeclSpecifier declSpec, IASTDeclarator declarator) { + if (declarator instanceof ICPPASTFunctionDeclarator) { + return createAutoFunctionType(declSpec, (ICPPASTFunctionDeclarator) declarator); + } + IASTInitializerClause autoInitClause= null; + IASTNode parent = declarator.getParent().getParent(); + if (parent instanceof ICPPASTNewExpression) { + IASTInitializer initializer = ((ICPPASTNewExpression) parent).getInitializer(); + if (initializer != null) { + IASTInitializerClause[] arguments = ((ICPPASTConstructorInitializer) initializer).getArguments(); + if (arguments.length == 1) { + autoInitClause = arguments[0]; + } + } + } else if (parent instanceof ICPPASTRangeBasedForStatement) { + // See 6.5.4 The range-based for statement [stmt.ranged] + ICPPASTRangeBasedForStatement forStmt= (ICPPASTRangeBasedForStatement) parent; + IASTInitializerClause forInit = forStmt.getInitializerClause(); + IASTExpression beginExpr= null; + if (forInit instanceof IASTExpression) { + final IASTExpression expr = (IASTExpression) forInit; + IType type= SemanticUtil.getNestedType(expr.getExpressionType(), TDEF|CVTYPE); + if (type instanceof IArrayType) { + beginExpr= expr.copy(); + } else if (type instanceof ICPPClassType) { + ICPPClassType ct= (ICPPClassType) type; + if (ct.getCompositeScope().find(BEGIN_STR).length > 0) { + final CPPASTName name = new CPPASTName(BEGIN); + name.setOffset(((ASTNode) forInit).getOffset()); + beginExpr= new CPPASTFunctionCallExpression( + new CPPASTFieldReference(name, expr.copy()), NO_ARGS); + } + } + } + if (beginExpr == null) { + final CPPASTName name = new CPPASTName(BEGIN); + name.setOffset(((ASTNode) forInit).getOffset()); + beginExpr= new CPPASTFunctionCallExpression( + new CPPASTIdExpression(name), + new IASTInitializerClause[] { forInit.copy() }); + } + autoInitClause= new CPPASTUnaryExpression(IASTUnaryExpression.op_star, beginExpr); + autoInitClause.setParent(forStmt); + autoInitClause.setPropertyInParent(ICPPASTRangeBasedForStatement.INITIALIZER); + } else if (parent instanceof IASTCompositeTypeSpecifier && + declSpec.getStorageClass() != IASTDeclSpecifier.sc_static) { + // Non-static auto-typed class members are not allowed. + return new ProblemType(ISemanticProblem.TYPE_AUTO_FOR_NON_STATIC_FIELD); + } else { + IASTInitializer initClause= declarator.getInitializer(); + if (initClause instanceof IASTEqualsInitializer) { + autoInitClause= ((IASTEqualsInitializer) initClause).getInitializerClause(); + } else if (initClause instanceof IASTInitializerClause) { + autoInitClause= (IASTInitializerClause) initClause; + } + } + return createAutoType(autoInitClause, declSpec, declarator); + } + private static IType createAutoType(IASTInitializerClause initClause, IASTDeclSpecifier declSpec, IASTDeclarator declarator) { // C++0x: 7.1.6.4 if (initClause == null || !autoTypeDeclSpecs.get().add(declSpec)) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java index 03346097b98..d80a85d3c36 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java @@ -227,7 +227,7 @@ public class TemplateArgumentDeduction { ICPPTemplateInstance pInst = (ICPPTemplateInstance) pcheck; ICPPClassTemplate pTemplate= getPrimaryTemplate(pInst); if (pTemplate != null) { - ICPPClassType aInst= findBaseInstance((ICPPClassType) argcheck, pTemplate, CPPSemantics.MAX_INHERITANCE_DEPTH); + ICPPClassType aInst= findBaseInstance((ICPPClassType) argcheck, pTemplate); if (aInst != null && aInst != argcheck) { par= pcheck; arg= aInst; @@ -467,10 +467,15 @@ public class TemplateArgumentDeduction { return result.toArray(new ICPPTemplateArgument[result.size()]); } + /** * 14.8.2.1.3 If P is a class and has the form template-id, then A can be a derived class of the deduced A. */ - private static ICPPClassType findBaseInstance(ICPPClassType a, ICPPClassTemplate pTemplate, int maxdepth) throws DOMException { + private static ICPPClassType findBaseInstance(ICPPClassType a, ICPPClassTemplate pTemplate) throws DOMException { + return findBaseInstance(a, pTemplate, CPPSemantics.MAX_INHERITANCE_DEPTH, new HashSet()); + } + + private static ICPPClassType findBaseInstance(ICPPClassType a, ICPPClassTemplate pTemplate, int maxdepth, HashSet handled) throws DOMException { if (a instanceof ICPPTemplateInstance) { final ICPPTemplateInstance inst = (ICPPTemplateInstance) a; ICPPClassTemplate tmpl= getPrimaryTemplate(inst); @@ -480,8 +485,8 @@ public class TemplateArgumentDeduction { if (maxdepth-- > 0) { for (ICPPBase cppBase : a.getBases()) { IBinding base= cppBase.getBaseClass(); - if (base instanceof ICPPClassType) { - final ICPPClassType inst= findBaseInstance((ICPPClassType) base, pTemplate, maxdepth); + if (base instanceof ICPPClassType && handled.add(base)) { + final ICPPClassType inst= findBaseInstance((ICPPClassType) base, pTemplate, maxdepth, handled); if (inst != null) return inst; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java index 05ac5681685..2c0b275e8df 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java @@ -40,7 +40,6 @@ import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ProblemRuntimeExcepti import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; import org.eclipse.cdt.internal.core.dom.rewrite.util.FileContentHelper; import org.eclipse.cdt.internal.core.dom.rewrite.util.FileHelper; -import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver; import org.eclipse.cdt.internal.core.resources.ResourceLookup; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IPath; @@ -136,33 +135,11 @@ public class ChangeGenerator extends ASTVisitor { if (hasChangedChild(translationUnit)) { synthTreatment(translationUnit); } - IASTFileLocation location = getFileLocationOfEmptyTranslationUnit(translationUnit); + IASTFileLocation location = translationUnit.getFileLocation(); sourceOffsets.put(location.getFileName(), Integer.valueOf(location.getNodeOffset())); return super.visit(translationUnit); } - /** - * This is a workaround for a known but not jet solved problem in IASTNode. If you get - * the FileFocation of a translation unit that was built on an empty file you will get null - * because there it explicitly returns null if the index and length is 0. - * To get to the filename and other information, the location is never the less needed. - * @param node - * @return a hopefully non-{@code null} FileLocation - */ - public IASTFileLocation getFileLocationOfEmptyTranslationUnit(IASTNode node) { - IASTFileLocation fileLocation = node.getFileLocation(); - if (fileLocation == null) { - ILocationResolver lr = (ILocationResolver) node.getTranslationUnit().getAdapter(ILocationResolver.class); - if (lr != null) { - fileLocation = lr.getMappedFileLocation(0, 0); - } else { - // Support for old location map - fileLocation = node.getTranslationUnit().flattenLocationsToFile(node.getNodeLocations()); - } - } - return fileLocation; - } - @Override public int leave(IASTTranslationUnit tu) { return super.leave(tu); @@ -205,8 +182,7 @@ public class ChangeGenerator extends ASTVisitor { synthWriter.setModificationStore(modificationStore); for (ASTModification modification : modificationParent.get(synthTU)) { - IASTFileLocation targetLocation = - getFileLocationOfEmptyTranslationUnit(modification.getTargetNode()); + IASTFileLocation targetLocation = modification.getTargetNode().getFileLocation(); String currentFile = targetLocation.getFileName(); IPath implPath = new Path(currentFile); IFile relevantFile= ResourceLookup.selectFileForLocation(implPath, null); @@ -604,8 +580,8 @@ public class ChangeGenerator extends ASTVisitor { private String getReplacementCode(int lastCommonPositionInSynth, int firstOfCommonEndInSynth) { int replacementStart = Math.max(lastCommonPositionInSynth, 0); - int replacementEnd = (firstOfCommonEndInSynth >= 0 ? - firstOfCommonEndInSynth : synthCode.length()); + int replacementEnd = firstOfCommonEndInSynth >= 0 ? + firstOfCommonEndInSynth : synthCode.length(); if (replacementStart < replacementEnd) { return synthCode.substring(replacementStart, replacementEnd); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java index c5907a0da4e..74e05607504 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java @@ -17,13 +17,12 @@ package org.eclipse.cdt.internal.core.index; import java.util.ArrayList; import java.util.Arrays; -import java.util.BitSet; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.Set; import java.util.regex.Pattern; import org.eclipse.cdt.core.CCorePlugin; @@ -42,6 +41,7 @@ import org.eclipse.cdt.core.index.IIndexInclude; import org.eclipse.cdt.core.index.IIndexMacro; import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.index.IndexFilter; +import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.cdt.internal.core.dom.Linkage; import org.eclipse.cdt.internal.core.index.composite.CompositingNotImplementedError; import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; @@ -64,6 +64,14 @@ public class CIndex implements IIndex { private int fReadLock; private ICompositesFactory cppCF, cCF, fCF; + /** + * Creates an index consisting of one or more fragments. + * + * @param fragments Fragments constituting the index. If there are extended fragments, + * they are located in the array after the PDOM fragments for the same project. + * @param primaryFragmentCount The number of primary index fragments. This number may include + * extended fragments. + */ public CIndex(IIndexFragment[] fragments, int primaryFragmentCount) { fFragments= fragments; fPrimaryFragmentCount= primaryFragmentCount; @@ -108,7 +116,8 @@ public class CIndex implements IIndex { IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][]; for (int i = 0; i < fPrimaryFragmentCount; i++) { try { - IBinding[] part = fFragments[i].findBindings(patterns, isFullyQualified, retargetFilter(linkage, filter), monitor); + IBinding[] part = fFragments[i].findBindings(patterns, isFullyQualified, + retargetFilter(linkage, filter), monitor); fragmentBindings[i] = new IIndexFragmentBinding[part.length]; System.arraycopy(part, 0, fragmentBindings[i], 0, part.length); } catch (CoreException e) { @@ -170,29 +179,47 @@ public class CIndex implements IIndex { binding= bindings[0]; } - int fragCount= 0; + // Maps a file location to -1 if the file belongs to an earlier index fragment, + // or to the index of the last checked index fragment plus one, if the file doesn't belong + // to any of the index fragments up to the last checked one. + HashMap fileCheckCache = new HashMap(); for (int i = 0; i < fPrimaryFragmentCount; i++) { - final IIndexFragmentName[] names = fFragments[i].findNames(binding, flags); - if (names.length > 0) { - result.addAll(Arrays.asList(names)); - fragCount++; - } - } - // bug 192352, files can reside in multiple fragments, remove duplicates - if (fragCount > 1 || (flags & IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES) != 0) { - HashMap fileMap= new HashMap(); - for (Iterator iterator = result.iterator(); iterator.hasNext();) { - final IIndexFragmentName name = iterator.next(); - final IIndexFile file= name.getFile(); - final String fileKey= name.getFile().getLocation().getURI().toString(); - final IIndexFile otherFile= fileMap.get(fileKey); - if (otherFile == null) { - fileMap.put(fileKey, file); - } else if (!otherFile.equals(file)) { // same file in another fragment - iterator.remove(); + IIndexFragment fragment = fFragments[i]; + final IIndexFragmentName[] names = fragment.findNames(binding, flags); + for (IIndexFragmentName name : names) { + IIndexFileLocation location = name.getFile().getLocation(); + Integer checkState = fileCheckCache.get(location); + int checkOffset = checkState == null ? 0 : checkState.intValue(); + if (checkOffset >= 0) { + for (; checkOffset < i; checkOffset++) { + IIndexFragment fragment2 = fFragments[checkOffset]; + if (fragment2.getFiles(location).length != 0) { + checkOffset = -1; + break; + } + } + fileCheckCache.put(location, Integer.valueOf(checkOffset)); + } + if (checkOffset == i) { + result.add(name); } } } +// // bug 192352, files can reside in multiple fragments, remove duplicates +// if (fragCount > 1 || (flags & IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES) != 0) { +// HashMap fileMap= new HashMap(); +// for (Iterator iterator = result.iterator(); iterator.hasNext();) { +// final IIndexFragmentName name = iterator.next(); +// final IIndexFile file= name.getFile(); +// final String fileKey= name.getFile().getLocation().getURI().toString(); +// final IIndexFile otherFile= fileMap.get(fileKey); +// if (otherFile == null) { +// fileMap.put(fileKey, file); +// } else if (!otherFile.equals(file)) { // same file in another fragment +// iterator.remove(); +// } +// } +// } return result.toArray(new IIndexName[result.size()]); } @@ -208,6 +235,7 @@ public class CIndex implements IIndex { return findNames(binding, FIND_REFERENCES); } + @Deprecated public IIndexFile getFile(int linkageID, IIndexFileLocation location) throws CoreException { for (int i = 0; i < fPrimaryFragmentCount; i++) { IIndexFragmentFile candidate= fFragments[i].getFile(linkageID, location); @@ -218,19 +246,53 @@ public class CIndex implements IIndex { return null; } + public IIndexFile getFile(int linkageID, IIndexFileLocation location, + ISignificantMacros significantMacros) throws CoreException { + for (int i = 0; i < fPrimaryFragmentCount; i++) { + IIndexFragmentFile candidate= fFragments[i].getFile(linkageID, location, significantMacros); + if (candidate != null && candidate.hasContent()) { + return candidate; + } + } + return null; + } + + public IIndexFile[] getFiles(int linkageID, IIndexFileLocation location) throws CoreException { + if (location == null) { + return IIndexFile.EMPTY_FILE_ARRAY; + } + Set handled = new HashSet(); + ArrayList result= new ArrayList(); + for (int i = 0; i < fPrimaryFragmentCount; i++) { + IIndexFragmentFile[] candidates= fFragments[i].getFiles(linkageID, location); + for (IIndexFragmentFile candidate : candidates) { + if (candidate.hasContent()) { + ISignificantMacros macroKey = candidate.getSignificantMacros(); + if (handled.add(macroKey)) { + result.add(candidate); + } + } + } + } + if (result.isEmpty()) { + return IIndexFile.EMPTY_FILE_ARRAY; + } + return result.toArray(new IIndexFile[result.size()]); + } + public IIndexFile[] getFiles(IIndexFileLocation location) throws CoreException { if (location == null) { return IIndexFile.EMPTY_FILE_ARRAY; } + Set keys = new HashSet(); ArrayList result= new ArrayList(); - BitSet linkages= new BitSet(); for (int i = 0; i < fPrimaryFragmentCount; i++) { IIndexFragmentFile[] candidates= fFragments[i].getFiles(location); for (IIndexFragmentFile candidate : candidates) { - int linkage= candidate.getLinkageID(); - if (!linkages.get(linkage) && candidate.hasContent()) { - result.add(candidate); - linkages.set(linkage); + if (candidate.hasContent()) { + if (keys.add(new FileContentKey(candidate.getLinkageID(), candidate.getLocation(), candidate.getSignificantMacros()))) { + result.add(candidate); + } } } } @@ -241,16 +303,16 @@ public class CIndex implements IIndex { } public IIndexFile resolveInclude(IIndexInclude include) throws CoreException { - if (!include.isResolved()) { - return null; - } IIndexFragmentInclude fragmentInclude = (IIndexFragmentInclude) include; IIndexFragmentFile result= fragmentInclude.getIncludes(); - if (result != null && result.hasContent()) { + if (result == null) + return null; + + if (result.hasContent()) { return result; } - return getFile(include.getIncludedBy().getLinkageID(), include.getIncludesLocation()); + return getFile(result.getLinkageID(), result.getLocation(), result.getSignificantMacros()); } public IIndexInclude[] findIncludedBy(IIndexFile file) throws CoreException { @@ -259,22 +321,25 @@ public class CIndex implements IIndex { public IIndexInclude[] findIncludedBy(IIndexFile file, int depth) throws CoreException { List result= new ArrayList(); - findIncludedBy(Collections.singletonList(file), result, depth, new HashSet()); + findIncludedBy(file.getLinkageID(), Collections.singletonList(file), result, depth, + new HashSet()); return result.toArray(new IIndexInclude[result.size()]); } - public void findIncludedBy(List in, List out, int depth, - HashSet handled) throws CoreException { + public void findIncludedBy(int linkageID, List in, List out, int depth, + HashSet handled) throws CoreException { List nextLevel= depth != 0 ? new LinkedList() : null; for (IIndexFile iIndexFile : in) { IIndexFragmentFile file = (IIndexFragmentFile) iIndexFile; for (int j = 0; j < fPrimaryFragmentCount; j++) { IIndexInclude[] includedBy= fFragments[j].findIncludedBy(file); for (IIndexInclude include : includedBy) { - if (handled.add(include.getIncludedByLocation())) { + final IIndexFile includer = include.getIncludedBy(); + FileContentKey key= new FileContentKey(linkageID, includer.getLocation(), includer.getSignificantMacros()); + if (handled.add(key)) { out.add(include); if (nextLevel != null) { - nextLevel.add(include.getIncludedBy()); + nextLevel.add(includer); } } } @@ -286,10 +351,9 @@ public class CIndex implements IIndex { if (depth > 0) { depth--; } - findIncludedBy(nextLevel, out, depth, handled); + findIncludedBy(linkageID, nextLevel, out, depth, handled); } - public IIndexInclude[] findIncludes(IIndexFile file) throws CoreException { return findIncludes(file, 0); } @@ -398,8 +462,8 @@ public class CIndex implements IIndex { IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][]; for (int i = 0; i < fPrimaryFragmentCount; i++) { try { - IBinding[] part = fFragments[i].findBindings(names, retargetFilter(linkage, filter), - new SubProgressMonitor(monitor, 1)); + IBinding[] part = fFragments[i].findBindings(names, + retargetFilter(linkage, filter), new SubProgressMonitor(monitor, 1)); fragmentBindings[i] = new IIndexFragmentBinding[part.length]; System.arraycopy(part, 0, fragmentBindings[i], 0, part.length); } catch (CoreException e) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/EmptyCIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/EmptyCIndex.java index eb522b54d30..acc91a98edc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/EmptyCIndex.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/EmptyCIndex.java @@ -29,6 +29,7 @@ import org.eclipse.cdt.core.index.IIndexInclude; import org.eclipse.cdt.core.index.IIndexMacro; import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.index.IndexFilter; +import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -54,10 +55,20 @@ final public class EmptyCIndex implements IIndex { return IIndexFragmentName.EMPTY_NAME_ARRAY; } + @Deprecated public IIndexFile getFile(int linkageID, IIndexFileLocation location) { return null; } + public IIndexFile getFile(int linkageID, IIndexFileLocation location, + ISignificantMacros significantFiles) throws CoreException { + return null; + } + + public IIndexFile[] getFiles(int linkageID, IIndexFileLocation location) throws CoreException { + return IIndexFile.EMPTY_FILE_ARRAY; + } + public IIndexFile[] getFiles(IIndexFileLocation location) { return IIndexFile.EMPTY_FILE_ARRAY; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/FileContentKey.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/FileContentKey.java new file mode 100644 index 00000000000..2c6b9d327e9 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/FileContentKey.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2011 Google, Inc and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Sergey Prigogin (Google) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.index; + +import org.eclipse.cdt.core.index.IIndexFileLocation; +import org.eclipse.cdt.core.parser.ISignificantMacros; + +/** + * A key that uniquely determines the preprocessed contents of a file. + */ +public class FileContentKey { + private final int linkageID; + private final IIndexFileLocation location; + private final ISignificantMacros significantMacros; + + /** + * Creates a file content key. + * @param location the file location. + */ + public FileContentKey(int linkageID, IIndexFileLocation location, ISignificantMacros sigMacros) { + this.linkageID= linkageID; + this.location = location; + this.significantMacros = sigMacros; + } + + public int getLinkageID() { + return linkageID; + } + + public IIndexFileLocation getLocation() { + return location; + } + + public ISignificantMacros getSignificantMacros() { + return significantMacros; + } + + @Override + public int hashCode() { + return (linkageID + location.hashCode() * 31) * 31 + significantMacros.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + FileContentKey other = (FileContentKey) obj; + if (linkageID != other.linkageID) + return false; + + if (!location.equals(other.location)) + return false; + + if (!significantMacros.equals(other.significantMacros)) + return false; + + return true; + } + + @SuppressWarnings("nls") + @Override + public String toString() { + return linkageID + ": " + location.getURI().toString() + "[" + significantMacros.hashCode() + "]"; + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java index 42895d8d79b..3675ce5ed57 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java @@ -23,6 +23,7 @@ import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.index.IIndexLinkage; import org.eclipse.cdt.core.index.IIndexMacro; import org.eclipse.cdt.core.index.IndexFilter; +import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -92,14 +93,55 @@ public interface IIndexFragment { * May return null, if no such file exists. * This method may only return files that are actually managed by this fragment. * This method returns files without content, also. + *

+ * When a header file is stored in the index in multiple variants for different sets of macro + * definitions, this method will return an arbitrary one of these variants. + * * @param linkageID the id of the linkage in which the file has been parsed. * @param location the IIndexFileLocation representing the location of the file * @return the file for the location, or null if the file is not present in * the index * @throws CoreException + * @deprecated Use {@link #getFile(int, IIndexFileLocation, ISignificantMacros)} or + * {@link #getFiles(int, IIndexFileLocation)}. */ + @Deprecated IIndexFragmentFile getFile(int linkageID, IIndexFileLocation location) throws CoreException; + /** + * Returns the file for the given location, linkage, and a set of macro definitions. + * May return null, if no such file exists. + * This method may only return files that are actually managed by this fragment. + * This method returns files without content, also. + * + * @param linkageID the id of the linkage in which the file has been parsed. + * @param location the IIndexFileLocation representing the location of the file + * @param macroDictionary The names and definitions of the macros used to disambiguate between + * variants of the file contents corresponding to different inclusion points. + * @return the file for the location, or null if the file is not present in + * the index + * @throws CoreException + */ + IIndexFragmentFile getFile(int linkageID, IIndexFileLocation location, + ISignificantMacros significantMacros) throws CoreException; + + /** + * Returns the files for the given location and linkage. + * Multiple files are returned when a header file is stored in the index in multiple variants + * for different sets of macro definitions. + * This method may only return files that are actually managed by this fragment. + * This method returns files without content, also. + *

+ * When a header file is stored in the index in multiple variants for different sets of macro + * definitions, this method will return an arbitrary one of these variants. + * + * @param linkageID the id of the linkage in which the file has been parsed. + * @param location the IIndexFileLocation representing the location of the file + * @return the files for the location and the linkage. + * @throws CoreException + */ + IIndexFragmentFile[] getFiles(int linkageID, IIndexFileLocation location) throws CoreException; + /** * Returns the files in all linkages for the given location. * This method may only return files that are actually managed by this fragment. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentFile.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentFile.java index 887133feb52..210261583b7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentFile.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentFile.java @@ -1,15 +1,15 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - * Andrew Ferguson (Symbian) + * Markus Schorn - initial API and implementation + * Andrew Ferguson (Symbian) + * Sergey Prigogin (Google) *******************************************************************************/ - package org.eclipse.cdt.internal.core.index; import org.eclipse.cdt.core.index.IIndexFile; @@ -33,19 +33,18 @@ public interface IIndexFragmentFile extends IIndexFile { */ void setContentsHash(long hash) throws CoreException; - /** - * Sets the hash-code of the scanner configuration. - * @param hashcode a hash-code or 0 if it is unknown. - * @throws CoreException - */ - void setScannerConfigurationHashcode(int hashcode) throws CoreException; - /** * Sets the hash-code of the file encoding. * @param hashcode a hash-code or 0 if it is unknown. */ void setEncodingHashcode(int hashcode) throws CoreException; + /** + * Sets the flag that determines whether the file is a header with #pragma once statement + * or an include guard, or it is a source file and parsed only once because of that. + */ + void setPragmaOnceSemantics(boolean value) throws CoreException; + /** * Returns whether this file contains content in its * associated fragment. Files without content are inserted to track includes. @@ -56,4 +55,16 @@ public interface IIndexFragmentFile extends IIndexFile { * Returns the id of the linkage this file belongs to. */ int getLinkageID() throws CoreException; + + /** + * Changes the inclusions pointing to 'source' to point to this file, instead. + * The file 'source' must belong to the same fragment as this file. + */ + void transferIncluders(IIndexFragmentFile source) throws CoreException; + + /** + * Changes the inclusion from the context of 'source' to point to this file, instead. + * The file 'source' must belong to the same fragment as this file. + */ + void transferContext(IIndexFragmentFile source) throws CoreException; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentFileSet.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentFileSet.java index 39eeb9d38bf..bfe5d1ed5cb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentFileSet.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentFileSet.java @@ -25,6 +25,11 @@ public interface IIndexFragmentFileSet { */ void add(IIndexFragmentFile fragFile); + /** + * Removes the fragment file from the file-set. + */ + void remove(IIndexFragmentFile fragFile); + /** * Returns whether the file set contains the given file. */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IWritableIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IWritableIndex.java index b2fd477791d..b0833880aae 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IWritableIndex.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IWritableIndex.java @@ -6,20 +6,19 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - * Andrew Ferguson (Symbian) - * Sergey Prigogin (Google) + * Markus Schorn - initial API and implementation + * Andrew Ferguson (Symbian) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.index; -import java.util.Collection; - import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexFile; import org.eclipse.cdt.core.index.IIndexFileLocation; +import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.cdt.internal.core.pdom.ASTFilePathResolver; import org.eclipse.cdt.internal.core.pdom.YieldableIndexLock; import org.eclipse.core.runtime.CoreException; @@ -33,10 +32,19 @@ import org.eclipse.core.runtime.CoreException; public interface IWritableIndex extends IIndex { static class IncludeInformation { - public IASTPreprocessorIncludeStatement fStatement; - public IIndexFileLocation fLocation; + public final IASTPreprocessorIncludeStatement fStatement; + public final IIndexFileLocation fLocation; + public final ISignificantMacros fSignificantMacros; + public final boolean fIsContext; public IIndexFragmentFile fTargetFile; - public boolean fIsContext= false; + + public IncludeInformation(IASTPreprocessorIncludeStatement stmt, + IIndexFileLocation location, ISignificantMacros sig, boolean isContext) { + fStatement= stmt; + fSignificantMacros= sig; + fLocation= location; + fIsContext= isContext; + } } /** @@ -45,14 +53,21 @@ public interface IWritableIndex extends IIndex { boolean isWritableFile(IIndexFile file); /** - * Returns a writable file for the given location and linkage, or null. This method - * returns file-objects without content, also. + * Returns a writable file for the given location, linkage, and the set of macro definitions, + * or null. This method returns file objects without content, also. */ - IIndexFragmentFile getWritableFile(int linkageID, IIndexFileLocation location) throws CoreException; + IIndexFragmentFile getWritableFile(int linkageID, IIndexFileLocation location, + ISignificantMacros macroDictionary) throws CoreException; + + /** + * Returns the writable files for the given location and linkage. This method + * returns file objects without content, also. + */ + IIndexFragmentFile[] getWritableFiles(int linkageID, IIndexFileLocation location) throws CoreException; /** * Returns the writable files for the given location in any linkage. This method - * returns file-objects without content, also. + * returns file objects without content, also. */ IIndexFragmentFile[] getWritableFiles(IIndexFileLocation location) throws CoreException; @@ -62,21 +77,28 @@ public interface IWritableIndex extends IIndex { * @param a collection that receives IndexFileLocation objects for files that * had the cleared file as a context. May be null. */ - void clearFile(IIndexFragmentFile file, Collection clearedContexts) throws CoreException; + void clearFile(IIndexFragmentFile file) throws CoreException; /** * Creates a file object for the given location or returns an existing one. + * @param linkageID the id of the linkage in which the file has been parsed. + * @param location the IIndexFileLocation representing the location of the file + * @param macroDictionary The names and definitions of the macros used to disambiguate between + * variants of the file contents corresponding to different inclusion points. + * @return A created or an existing file. */ - IIndexFragmentFile addFile(int linkageID, IIndexFileLocation location) throws CoreException; + IIndexFragmentFile addFile(int linkageID, IIndexFileLocation location, + ISignificantMacros macroDictionary) throws CoreException; /** * Creates a uncommitted file object for the given location. */ - IIndexFragmentFile addUncommittedFile(int linkageID, IIndexFileLocation location) throws CoreException; + IIndexFragmentFile addUncommittedFile(int linkageID, IIndexFileLocation location, + ISignificantMacros macroDictionary) throws CoreException; /** * Makes an uncommitted file that was created earlier by calling - * {@link #addUncommittedFile(int, IIndexFileLocation)} method visible in the index. + * {@link #addUncommittedFile(int, IIndexFileLocation, ISignificantMacros)} method visible in the index. * * @return The file that was updated. * @throws CoreException @@ -106,20 +128,20 @@ public interface IWritableIndex extends IIndex { /** * Acquires a write lock, while giving up a certain amount of read locks. */ - void acquireWriteLock(int giveupReadLockCount) throws InterruptedException; + void acquireWriteLock() throws InterruptedException; /** * Releases a write lock, reestablishing a certain amount of read locks. * Fully equivalent to releaseWriteLock(int, true). */ - void releaseWriteLock(int establishReadLockCount); + void releaseWriteLock(); /** * Releases a write lock, reestablishing a certain amount of read locks. * @param establishReadLockCount amount of read-locks to establish. * @param flushDatabase when true the changes are flushed to disk. */ - void releaseWriteLock(int establishReadLockCount, boolean flushDatabase); + void releaseWriteLock(boolean flushDatabase); /** * Resets the counters for cache-hits @@ -156,4 +178,16 @@ public interface IWritableIndex extends IIndex { * Clears the result cache, caller needs to hold a write-lock. */ void clearResultCache(); + + /** + * Changes the inclusions pointing to 'source' to point to 'target', instead. + * Both files must belong to the writable fragment. + */ + void transferIncluders(IIndexFragmentFile source, IIndexFragmentFile target) throws CoreException; + + /** + * Changes the inclusion from the context of 'source' to point to 'target', instead. + * Both files must belong to the writable fragment. + */ + void transferContext(IIndexFragmentFile source, IIndexFragmentFile target) throws CoreException; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IWritableIndexFragment.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IWritableIndexFragment.java index 5aeea79d6d9..0996a4ea8c9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IWritableIndexFragment.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IWritableIndexFragment.java @@ -6,18 +6,17 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - * Andrew Ferguson (Symbian) - * Sergey Prigogin (Google) + * Markus Schorn - initial API and implementation + * Andrew Ferguson (Symbian) + * Sergey Prigogin (Google) ******************************************************************************/ package org.eclipse.cdt.internal.core.index; -import java.util.Collection; - import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement; import org.eclipse.cdt.core.index.IIndexFileLocation; +import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.cdt.internal.core.index.IWritableIndex.IncludeInformation; import org.eclipse.cdt.internal.core.pdom.ASTFilePathResolver; import org.eclipse.cdt.internal.core.pdom.YieldableIndexLock; @@ -39,28 +38,32 @@ public interface IWritableIndexFragment extends IIndexFragment { * @param a collection that receives IndexFileLocation objects for files that * had the cleared file as a context. */ - void clearFile(IIndexFragmentFile file, Collection contextsRemoved) throws CoreException; + void clearFile(IIndexFragmentFile file) throws CoreException; /** * Creates a file object for the given location and linkage or returns an existing one. * @param fileLocation an IIndexFileLocation representing the location of the file. + * @param sigMacros the macro definitions at the inclusion point. * @return the existing IIndexFragmentFile for this location, or a newly created one. * @throws CoreException */ - IIndexFragmentFile addFile(int linkageID, IIndexFileLocation fileLocation) throws CoreException; + IIndexFragmentFile addFile(int linkageID, IIndexFileLocation fileLocation, + ISignificantMacros sigMacros) throws CoreException; /** * Creates a file object for the given location and linkage. The created file object is not added to * the file index. * @param fileLocation an IIndexFileLocation representing the location of the file. + * @param sigMacros the macro definitions at the inclusion point. * @return a newly created IIndexFragmentFile. * @throws CoreException */ - IIndexFragmentFile addUncommittedFile(int linkageID, IIndexFileLocation fileLocation) throws CoreException; + IIndexFragmentFile addUncommittedFile(int linkageID, IIndexFileLocation fileLocation, + ISignificantMacros sigMacros) throws CoreException; /** * Makes an uncommitted file that was created earlier by calling - * {@link #addUncommittedFile(int, IIndexFileLocation)} method visible in the index. + * {@link #addUncommittedFile(int, IIndexFileLocation, ISignificantMacros)} method visible in the index. * * @return The file that was updated. * @throws CoreException diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedFileContentProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedFileContentProvider.java index b08259e370c..ccfc664eed6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedFileContentProvider.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedFileContentProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 QNX Software Systems and others. + * Copyright (c) 2005, 2011 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,16 +11,21 @@ * Andrew Ferguson (Symbian) * Anton Leherbauer (Wind River Systems) * IBM Corporation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.index; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; +import java.util.Map; import java.util.Set; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.ast.IFileNomination; import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexFile; @@ -28,7 +33,9 @@ import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.index.IIndexInclude; import org.eclipse.cdt.core.index.IIndexMacro; import org.eclipse.cdt.core.parser.IncludeFileContentProvider; +import org.eclipse.cdt.internal.core.parser.IMacroDictionary; import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent; +import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.FileVersion; import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.InclusionKind; import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContentProvider; import org.eclipse.cdt.internal.core.pdom.ASTFilePathResolver; @@ -37,8 +44,7 @@ import org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask.IndexFileContent; import org.eclipse.core.runtime.CoreException; /** - * Code reader factory, that fakes code readers for header files already stored in the - * index. + * Code reader factory, that fakes code readers for header files already stored in the index. */ public final class IndexBasedFileContentProvider extends InternalFileContentProvider { private static final class NeedToParseException extends Exception {} @@ -46,14 +52,14 @@ public final class IndexBasedFileContentProvider extends InternalFileContentProv private final IIndex fIndex; private int fLinkage; - private Set fIncludedFiles= new HashSet(); /** The fall-back code reader factory used in case a header file is not indexed */ private final InternalFileContentProvider fFallBackFactory; private final ASTFilePathResolver fPathResolver; private final AbstractIndexerTask fRelatedIndexerTask; - private boolean fSupportFillGapFromContextToHeader= false; private long fFileSizeLimit= 0; - + private IIndexFile[] fContextToHeaderGap; + private final Map fPragmaOnce= new HashMap(); + public IndexBasedFileContentProvider(IIndex index, ASTFilePathResolver pathResolver, int linkage, IncludeFileContentProvider fallbackFactory) { this(index, pathResolver, linkage, fallbackFactory, null); @@ -68,8 +74,8 @@ public final class IndexBasedFileContentProvider extends InternalFileContentProv fLinkage= linkage; } - public void setSupportFillGapFromContextToHeader(boolean val) { - fSupportFillGapFromContextToHeader= val; + public void setContextToHeaderGap(IIndexFile[] ctxToHeader) { + fContextToHeaderGap= ctxToHeader; } public void setFileSizeLimit(long limit) { @@ -79,60 +85,63 @@ public final class IndexBasedFileContentProvider extends InternalFileContentProv public void setLinkage(int linkageID) { fLinkage= linkageID; } - - public void cleanupAfterTranslationUnit() { - fIncludedFiles.clear(); - } + @Override + public void resetForTranslationUnit() { + super.resetForTranslationUnit(); + fPragmaOnce.clear(); + } + + /** + * Reports detection of pragma once semantics. + */ + @Override + public void reportPragmaOnceSemantics(String filePath, IFileNomination nom) { + fPragmaOnce.put(fPathResolver.resolveIncludeFile(filePath), nom); + } + + /** + * Returns whether the given file has been included with pragma once semantics. + */ + @Override + public IFileNomination isIncludedWithPragmaOnceSemantics(String filePath) { + return fPragmaOnce.get(fPathResolver.resolveIncludeFile(filePath)); + } + @Override public boolean getInclusionExists(String path) { return fPathResolver.doesIncludeFileExist(path); } - @Override - public void reportTranslationUnitFile(String path) { - IIndexFileLocation ifl= fPathResolver.resolveASTPath(path); - fIncludedFiles.add(ifl); - } - - @Override - public Boolean hasFileBeenIncludedInCurrentTranslationUnit(String path) { - IIndexFileLocation ifl= fPathResolver.resolveASTPath(path); - return fIncludedFiles.contains(ifl); - } @Override - public InternalFileContent getContentForInclusion(String path) { + public InternalFileContent getContentForInclusion(String path, IMacroDictionary macroDictionary) { IIndexFileLocation ifl= fPathResolver.resolveIncludeFile(path); if (ifl == null) { return null; } + path= fPathResolver.getASTPath(ifl); - - // Include files once, only. - if (!fIncludedFiles.add(ifl)) { - return new InternalFileContent(path, InclusionKind.SKIP_FILE); - } - try { - IIndexFile file= fIndex.getFile(fLinkage, ifl); + IIndexFile file = selectIndexFile(macroDictionary, ifl); if (file != null) { try { List files= new ArrayList(); List macros= new ArrayList(); List directives= new ArrayList(); - Set ifls= new HashSet(); - collectFileContent(file, ifls, files, macros, directives, false); - // add included files only, if no exception was thrown - fIncludedFiles.addAll(ifls); - return new InternalFileContent(path, macros, directives, files); + Map newPragmaOnce= new HashMap(); + LinkedHashSet preLoaded= new LinkedHashSet(); + collectFileContent(file, null, newPragmaOnce, preLoaded, files, macros, directives, null); + // Report pragma once inclusions, only if no exception was thrown. + fPragmaOnce.putAll(newPragmaOnce); + return new InternalFileContent(path, macros, directives, files, toList(preLoaded)); } catch (NeedToParseException e) { } - } + } } catch (CoreException e) { CCorePlugin.log(e); } - + // Skip large files if (fFileSizeLimit > 0 && fPathResolver.getFileSize(path) > fFileSizeLimit) { return new InternalFileContent(path, InclusionKind.SKIP_FILE); @@ -147,6 +156,26 @@ public final class IndexBasedFileContentProvider extends InternalFileContentProv return null; } + public List toPathList(Collection newPragmaOnce) { + List newPragmaOncePaths= new ArrayList(newPragmaOnce.size()); + for (IIndexFileLocation l : newPragmaOnce) { + newPragmaOncePaths.add(fPathResolver.getASTPath(l)); + } + return newPragmaOncePaths; + } + + public IIndexFile selectIndexFile(IMacroDictionary macroDictionary, IIndexFileLocation ifl) + throws CoreException { + if (fRelatedIndexerTask != null) + return fRelatedIndexerTask.selectIndexFile(fLinkage, ifl, macroDictionary); + + for (IIndexFile file : fIndex.getFiles(fLinkage, ifl)) { + if (macroDictionary.satisfies(file.getSignificantMacros())) + return file; + } + return null; + } + @Override public InternalFileContent getContentForInclusion(IIndexFileLocation ifl, String astPath) { if (fFallBackFactory != null) { @@ -155,145 +184,122 @@ public final class IndexBasedFileContentProvider extends InternalFileContentProv return null; } - private void collectFileContent(IIndexFile file, Set ifls, List files, - List macros, List usingDirectives, boolean checkIncluded) - throws CoreException, NeedToParseException { + private boolean collectFileContent(IIndexFile file, IIndexFile stopAt, + Map newPragmaOnce, + LinkedHashSet preLoaded, List files, + List macros, List usingDirectives, + Set preventRecursion) throws CoreException, NeedToParseException { + if (file.equals(stopAt)) + return true; + IIndexFileLocation ifl= file.getLocation(); - if (!ifls.add(ifl) || (checkIncluded && fIncludedFiles.contains(ifl))) { - return; - } - IndexFileContent content; - if (fRelatedIndexerTask != null) { - content= fRelatedIndexerTask.getFileContent(fLinkage, ifl); - if (content == null) { - throw new NeedToParseException(); - } + if (newPragmaOnce.containsKey(ifl)) + return false; + if (file.hasPragmaOnceSemantics()) + newPragmaOnce.put(ifl, file); + + if (preventRecursion != null) { + if (fPragmaOnce.containsKey(ifl)) + return false; } else { - content= new IndexFileContent(); - content.setPreprocessorDirectives(file.getIncludes(), file.getMacros()); - content.setUsingDirectives(file.getUsingDirectives()); + preventRecursion= new HashSet(); + } + if (!preventRecursion.add(file)) + return false; + + final ICPPUsingDirective[] uds; + final Object[] pds; + if (fRelatedIndexerTask != null) { + IndexFileContent content= fRelatedIndexerTask.getFileContent(fLinkage, ifl, file); + if (content == null) + throw new NeedToParseException(); + uds= content.getUsingDirectives(); + pds= content.getPreprocessingDirectives(); + } else { + uds= file.getUsingDirectives(); + pds= IndexFileContent.merge(file.getIncludes(), file.getMacros()); } files.add(file); - usingDirectives.addAll(Arrays.asList(content.getUsingDirectives())); - Object[] dirs= content.getPreprocessingDirectives(); - for (Object d : dirs) { + if (!file.hasPragmaOnceSemantics()) { + preLoaded.add(file); + } + int udx= 0; + for (Object d : pds) { if (d instanceof IIndexMacro) { macros.add((IIndexMacro) d); } else if (d instanceof IIndexInclude) { + IIndexInclude inc= (IIndexInclude) d; IIndexFile includedFile= fIndex.resolveInclude((IIndexInclude) d); if (includedFile != null) { - collectFileContent(includedFile, ifls, files, macros, usingDirectives, true); + // Add in using directives that appear before the inclusion + final int offset= inc.getNameOffset(); + for (; udx < uds.length && uds[udx].getPointOfDeclaration() <= offset; udx++) { + usingDirectives.add(uds[udx]); + } + if (collectFileContent(includedFile, stopAt, newPragmaOnce, preLoaded, files, macros, usingDirectives, preventRecursion)) + return true; } } } + // Add in remaining using directives + for (; udx < uds.length; udx++) { + usingDirectives.add(uds[udx]); + } + preventRecursion.remove(file); + return false; } @Override - public InternalFileContent getContentForContextToHeaderGap(String path) { - if (!fSupportFillGapFromContextToHeader) { - return null; - } - - IIndexFileLocation ifl= fPathResolver.resolveASTPath(path); - if (ifl == null) { + public InternalFileContent getContentForContextToHeaderGap(String path, + IMacroDictionary macroDictionary) { + if (fContextToHeaderGap == null) { return null; } try { - IIndexFile targetFile= fIndex.getFile(fLinkage, ifl); - if (targetFile == null) { + IIndexFile contextFile= fContextToHeaderGap[0]; + IIndexFile targetFile = fContextToHeaderGap[1]; + if (contextFile == null || targetFile == null || contextFile == targetFile) return null; - } - - IIndexFile contextFile= findContext(targetFile); - if (contextFile == targetFile || contextFile == null) { - return null; - } - - HashSet filesIncluded= new HashSet(); + + Map newPragmaOnce= new HashMap(); + List filesIncluded= new ArrayList(); ArrayList macros= new ArrayList(); ArrayList directives= new ArrayList(); - if (!collectFileContentForGap(contextFile, ifl, filesIncluded, macros, directives)) { + LinkedHashSet preLoaded= new LinkedHashSet(); + try { + if (!collectFileContent(contextFile, targetFile, newPragmaOnce, preLoaded, + filesIncluded, macros, directives, new HashSet())) { + return null; + } + } catch (NeedToParseException e) { return null; } - // mark the files in the gap as included - for (IIndexFile file : filesIncluded) { - fIncludedFiles.add(file.getLocation()); - } - return new InternalFileContent(GAP, macros, directives, new ArrayList(filesIncluded)); + // Report pragma once inclusions. + fPragmaOnce.putAll(newPragmaOnce); + return new InternalFileContent(GAP, macros, directives, filesIncluded, toList(preLoaded)); } catch (CoreException e) { CCorePlugin.log(e); } return null; } - private IIndexFile findContext(IIndexFile file) throws CoreException { - final HashSet ifiles= new HashSet(); - ifiles.add(file); - IIndexInclude include= file.getParsedInContext(); - while (include != null) { - final IIndexFile context= include.getIncludedBy(); - if (!ifiles.add(context)) { - return file; - } - file= context; - include= context.getParsedInContext(); + private List toList(LinkedHashSet preLoaded) throws CoreException { + List result= new ArrayList(preLoaded.size()); + for (IIndexFile file : preLoaded) { + String path= fPathResolver.getASTPath(file.getLocation()); + result.add(new FileVersion(path, file.getSignificantMacros())); } - return file; + return result; } - private boolean collectFileContentForGap(IIndexFile from, IIndexFileLocation to, - Set filesIncluded, List macros, - List directives) throws CoreException { - final IIndexFileLocation ifl= from.getLocation(); - if (ifl.equals(to)) { - return true; - } - - if (fIncludedFiles.contains(ifl) || !filesIncluded.add(from)) { - return false; - } - - final IIndexInclude[] ids= from.getIncludes(); - final IIndexMacro[] ms= from.getMacros(); - final Object[] dirs= IndexFileContent.merge(ids, ms); - IIndexInclude success= null; - for (Object d : dirs) { - if (d instanceof IIndexMacro) { - macros.add((IIndexMacro) d); - } else if (d instanceof IIndexInclude) { - IIndexFile includedFile= fIndex.resolveInclude((IIndexInclude) d); - if (includedFile != null) { - if (collectFileContentForGap(includedFile, to, filesIncluded, macros, directives)) { - success= (IIndexInclude) d; - break; - } - } - } - } - - final ICPPUsingDirective[] uds= from.getUsingDirectives(); - if (success == null) { - directives.addAll(Arrays.asList(uds)); - return false; - } - - final int offset= success.getNameOffset(); - for (ICPPUsingDirective ud : uds) { - if (ud.getPointOfDeclaration() > offset) - break; - directives.add(ud); - } - return true; - } - - public IIndexFile findIndexFile(InternalFileContent fc) throws CoreException { + public IIndexFile[] findIndexFiles(InternalFileContent fc) throws CoreException { IIndexFileLocation ifl = fPathResolver.resolveASTPath(fc.getFileLocation()); if (ifl != null) { - return fIndex.getFile(fLinkage, ifl); + return fIndex.getFiles(fLinkage, ifl); } - return null; + return IIndexFile.EMPTY_FILE_ARRAY; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFactory.java index 2ca1f06577b..215ced10904 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFactory.java @@ -8,6 +8,7 @@ * Contributors: * Markus Schorn - initial API and implementation * Andrew Ferguson (Symbian) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.index; @@ -42,6 +43,7 @@ public class IndexFactory { private static final int ADD_DEPENDENCIES = IIndexManager.ADD_DEPENDENCIES; private static final int ADD_DEPENDENT = IIndexManager.ADD_DEPENDENT; private static final int SKIP_PROVIDED = IIndexManager.SKIP_PROVIDED; + private static final int ADD_EXTENSION_FRAGMENTS = IIndexManager.ADD_EXTENSION_FRAGMENTS; private PDOMManager fPDOMManager; @@ -55,6 +57,7 @@ public class IndexFactory { boolean addDependencies= (options & ADD_DEPENDENCIES) != 0; boolean addDependent= (options & ADD_DEPENDENT) != 0; boolean skipProvided= (options & SKIP_PROVIDED) != 0; + boolean addExtensionFragments= (options & ADD_EXTENSION_FRAGMENTS) != 0; HashMap map= new HashMap(); Collection selectedProjects= getProjects(projects, addDependencies, addDependent, @@ -67,7 +70,7 @@ public class IndexFactory { safeAddFragment(fragments, pdom); if (!skipProvided) { - safeAddProvidedFragments(cproject, fragments); + safeAddProvidedFragments(cproject, fragments, addExtensionFragments); } } } @@ -87,7 +90,7 @@ public class IndexFactory { safeAddFragment(fragments, pdom); if (!skipProvided) { - safeAddProvidedFragments(cproject, fragments); + safeAddProvidedFragments(cproject, fragments, addExtensionFragments); } } } @@ -103,7 +106,7 @@ public class IndexFactory { throw new CoreException(CCorePlugin.createStatus( NLS.bind(Messages.IndexFactory_errorNoSuchPDOM0, project.getElementName()))); } - safeAddProvidedFragments(project, readOnlyFrag); + safeAddProvidedFragments(project, readOnlyFrag, false); Collection selectedProjects= getProjects(new ICProject[] {project}, true, false, new HashMap(), new Integer(1)); @@ -201,19 +204,21 @@ public class IndexFactory { } /** - * Adds ID -> IIndexFragment entries to the specified Map, for fragments provided under the - * CIndex extension point for the specified ICProject - * @param cproject + * Adds ID -> IIndexFragment entries to the specified Map, for fragments provided under + * the CIndex extension point for the specified ICProject. + * @param cproject The project to get the provided index fragments for. * @param fragments + * @param includeNonPDOMFragments */ - private void safeAddProvidedFragments(ICProject cproject, Map fragments) { + private void safeAddProvidedFragments(ICProject cproject, Map fragments, + boolean includeNonPDOMFragments) { ICProjectDescription pd= CoreModel.getDefault().getProjectDescription(cproject.getProject(), false); if (pd != null) { IndexProviderManager ipm = CCoreInternals.getPDOMManager().getIndexProviderManager(); ICConfigurationDescription cfg= pd.getDefaultSettingConfiguration(); if (cfg != null) { try { - IIndexFragment[] pFragments= ipm.getProvidedIndexFragments(cfg); + IIndexFragment[] pFragments= ipm.getProvidedIndexFragments(cfg, includeNonPDOMFragments); for (IIndexFragment fragment : pFragments) { safeAddFragment(fragments, fragment); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFileSet.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFileSet.java index d244250377d..395eefc0664 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFileSet.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFileSet.java @@ -40,6 +40,15 @@ public class IndexFileSet implements IIndexFileSet { subSet.add(fragFile); } + public void remove(IIndexFile indexFile) { + final IIndexFragmentFile fragFile = (IIndexFragmentFile) indexFile; + final IIndexFragment frag= fragFile.getIndexFragment(); + IIndexFragmentFileSet subSet= fSubSets.get(frag); + if (subSet != null) { + subSet.remove(fragFile); + } + } + public boolean containsDeclaration(IIndexBinding binding) { return containsDeclaration(binding, false); } @@ -163,6 +172,10 @@ public class IndexFileSet implements IIndexFileSet { public void add(IIndexFile indexFile) { Assert.isLegal(false); } + + public void remove(IIndexFile indexFile) { + Assert.isLegal(false); + } }; } return fInverse; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/WritableCIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/WritableCIndex.java index 8bd8489a716..0a0526da2c5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/WritableCIndex.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/WritableCIndex.java @@ -12,12 +12,11 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.index; -import java.util.Collection; - import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement; import org.eclipse.cdt.core.index.IIndexFile; import org.eclipse.cdt.core.index.IIndexFileLocation; +import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.cdt.internal.core.pdom.ASTFilePathResolver; import org.eclipse.cdt.internal.core.pdom.YieldableIndexLock; import org.eclipse.core.runtime.CoreException; @@ -43,20 +42,27 @@ public class WritableCIndex extends CIndex implements IWritableIndex { return fWritableFragment; } - public IIndexFragmentFile getWritableFile(int linkageID, IIndexFileLocation location) throws CoreException { - return fWritableFragment.getFile(linkageID, location); + public IIndexFragmentFile getWritableFile(int linkageID, IIndexFileLocation location, + ISignificantMacros macroDictionary) throws CoreException { + return fWritableFragment.getFile(linkageID, location, macroDictionary); } - + + public IIndexFragmentFile[] getWritableFiles(int linkageID, IIndexFileLocation location) throws CoreException { + return fWritableFragment.getFiles(linkageID, location); + } + public IIndexFragmentFile[] getWritableFiles(IIndexFileLocation location) throws CoreException { return fWritableFragment.getFiles(location); } - public IIndexFragmentFile addFile(int linkageID, IIndexFileLocation location) throws CoreException { - return fWritableFragment.addFile(linkageID, location); + public IIndexFragmentFile addFile(int linkageID, IIndexFileLocation location, + ISignificantMacros macroDictionary) throws CoreException { + return fWritableFragment.addFile(linkageID, location, macroDictionary); } - public IIndexFragmentFile addUncommittedFile(int linkageID, IIndexFileLocation location) throws CoreException { - return fWritableFragment.addUncommittedFile(linkageID, location); + public IIndexFragmentFile addUncommittedFile(int linkageID, IIndexFileLocation location, + ISignificantMacros macroDictionary) throws CoreException { + return fWritableFragment.addUncommittedFile(linkageID, location, macroDictionary); } public IIndexFragmentFile commitUncommittedFile() throws CoreException { @@ -78,9 +84,10 @@ public class WritableCIndex extends CIndex implements IWritableIndex { if (!isWritableFragment(indexFragment)) { assert false : "Attempt to update file of read-only fragment"; //$NON-NLS-1$ } else { - for (IncludeInformation ii : includes) { - if (ii.fLocation != null) { - ii.fTargetFile= addFile(linkageID, ii.fLocation); + for (IncludeInformation include : includes) { + if (include.fLocation != null) { + include.fTargetFile= addFile(linkageID, include.fLocation, + include.fSignificantMacros); } } ((IWritableIndexFragment) indexFragment).addFileContent(file, includes, macros, names, resolver, lock); @@ -96,12 +103,12 @@ public class WritableCIndex extends CIndex implements IWritableIndex { isWritableFragment(((IIndexFragmentFile)file).getIndexFragment()); } - public void clearFile(IIndexFragmentFile file, Collection clearedContexts) throws CoreException { + public void clearFile(IIndexFragmentFile file) throws CoreException { IIndexFragment indexFragment = file.getIndexFragment(); if (!isWritableFragment(indexFragment)) { assert false : "Attempt to clear file of read-only fragment"; //$NON-NLS-1$ } else { - ((IWritableIndexFragment) indexFragment).clearFile(file, clearedContexts); + ((IWritableIndexFragment) indexFragment).clearFile(file); } } @@ -121,25 +128,25 @@ public class WritableCIndex extends CIndex implements IWritableIndex { fThread= null; } - public void acquireWriteLock(int giveupReadlockCount) throws InterruptedException { + public void acquireWriteLock() throws InterruptedException { checkThread(); assert !fIsWriteLocked: "Multiple write locks is not allowed"; //$NON-NLS-1$ - assert giveupReadlockCount == getReadLockCount(): "Unexpected read lock is not allowed"; //$NON-NLS-1$ - fWritableFragment.acquireWriteLock(giveupReadlockCount); + fWritableFragment.acquireWriteLock(getReadLockCount()); fIsWriteLocked= true; } - public void releaseWriteLock(int establishReadlockCount) { - releaseWriteLock(establishReadlockCount, true); + public void releaseWriteLock() { + releaseWriteLock(true); } - public void releaseWriteLock(int establishReadlockCount, boolean flush) { + public void releaseWriteLock(boolean flush) { checkThread(); assert fIsWriteLocked: "No write lock to be released"; //$NON-NLS-1$ - assert establishReadlockCount == getReadLockCount(): "Unexpected read lock is not allowed"; //$NON-NLS-1$ + // Bug 297641: Result cache of read only providers needs to be cleared. + int establishReadlockCount = getReadLockCount(); if (establishReadlockCount == 0) { clearResultCache(); } @@ -171,10 +178,23 @@ public class WritableCIndex extends CIndex implements IWritableIndex { fWritableFragment.flush(); } - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.index.IWritableIndex#getDatabaseSizeBytes() - */ public long getDatabaseSizeBytes() { return fWritableFragment.getDatabaseSizeBytes(); } + + public void transferIncluders(IIndexFragmentFile source, IIndexFragmentFile target) throws CoreException { + if (source == null || target == null || !isWritableFile(source) || !isWritableFile(target)) + throw new IllegalArgumentException(); + if (source.equals(target)) + return; + target.transferIncluders(source); + } + + public void transferContext(IIndexFragmentFile source, IIndexFragmentFile target) throws CoreException { + if (source == null || target == null || !isWritableFile(source) || !isWritableFile(target)) + throw new IllegalArgumentException(); + if (source.equals(target)) + return; + target.transferContext(source); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java index 092cc94df79..b9946676fb8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java @@ -8,6 +8,7 @@ * Contributors: * Andrew Ferguson (Symbian) - Initial implementation * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.index.provider; @@ -64,9 +65,11 @@ import java.util.Set; */ public final class IndexProviderManager implements IElementChangedListener { private static final String ELEMENT_RO_PDOM_PROVIDER= "ReadOnlyPDOMProvider"; //$NON-NLS-1$ + private static final String ELEMENT_RO_INDEX_FRAGMENT_PROVIDER= "ReadOnlyIndexFragmentProvider"; //$NON-NLS-1$ private static final String ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$ - private IIndexFragmentProvider[] allProviders; + private IIndexFragmentProvider[] pdomFragmentProviders; + private IIndexFragmentProvider[] nonPDOMFragmentProviders; private Map provisionMap; private Set compatibleFragmentUnavailable; private VersionRange pdomVersionRange; @@ -89,14 +92,15 @@ public final class IndexProviderManager implements IElementChangedListener { * @param pdomVersionRange */ public void reset(VersionRange pdomVersionRange) { - this.allProviders= new IIndexFragmentProvider[0]; - this.provisionMap= new HashMap(); + this.pdomFragmentProviders= new IIndexFragmentProvider[0]; + this.provisionMap= new HashMap(); this.pdomVersionRange= pdomVersionRange; this.compatibleFragmentUnavailable= new HashSet(); } public void startup() { - List providers = new ArrayList(); + List pdomProviders = new ArrayList(); + List nonPDOMProviders = new ArrayList(); IExtensionRegistry registry = Platform.getExtensionRegistry(); IExtensionPoint indexProviders = registry.getExtensionPoint(CCorePlugin.INDEX_UNIQ_ID); for (IExtension extension : indexProviders.getExtensions()) { @@ -106,11 +110,20 @@ public final class IndexProviderManager implements IElementChangedListener { Object provider = element.createExecutableExtension(ATTRIBUTE_CLASS); if (provider instanceof IReadOnlyPDOMProvider) { - providers.add(new ReadOnlyPDOMProviderBridge((IReadOnlyPDOMProvider) provider)); + pdomProviders.add(new ReadOnlyPDOMProviderBridge((IReadOnlyPDOMProvider) provider)); } else { CCorePlugin.log(NLS.bind(Messages.IndexProviderManager_0, extension.getContributor().getName())); } + } else if (ELEMENT_RO_INDEX_FRAGMENT_PROVIDER.equals(element.getName())) { + Object provider = element.createExecutableExtension(ATTRIBUTE_CLASS); + + if (provider instanceof IIndexFragmentProvider) { + nonPDOMProviders.add((IIndexFragmentProvider) provider); + } else { + CCorePlugin.log(NLS.bind(Messages.IndexProviderManager_0, + extension.getContributor().getName())); + } } } } catch (CoreException e) { @@ -119,7 +132,8 @@ public final class IndexProviderManager implements IElementChangedListener { } CoreModel.getDefault().addElementChangedListener(this); - this.allProviders = providers.toArray(new IIndexFragmentProvider[providers.size()]); + this.pdomFragmentProviders = pdomProviders.toArray(new IIndexFragmentProvider[pdomProviders.size()]); + this.nonPDOMFragmentProviders = nonPDOMProviders.toArray(new IIndexFragmentProvider[nonPDOMProviders.size()]); } /** @@ -130,26 +144,32 @@ public final class IndexProviderManager implements IElementChangedListener { * @param config * @return the array of IIndexFragment objects for the current state */ - public IIndexFragment[] getProvidedIndexFragments(ICConfigurationDescription config) throws CoreException { + public IIndexFragment[] getProvidedIndexFragments(ICConfigurationDescription config, + boolean includeNonPDOMFragments) throws CoreException { Map id2fragment = new HashMap(); IProject project= config.getProjectDescription().getProject(); - for (IIndexFragmentProvider provider : allProviders) { - try { - if (providesForProject(provider, project)) { - IIndexFragment[] fragments= provider.getIndexFragments(config); - for (IIndexFragment fragment : fragments) { - try { - processCandidate(id2fragment, fragment); - } catch (InterruptedException e) { - CCorePlugin.log(e); // continue with next candidate - } catch (CoreException e) { - CCorePlugin.log(e); // continue with next candidate + IIndexFragmentProvider[][] groups = includeNonPDOMFragments ? + new IIndexFragmentProvider[][] { pdomFragmentProviders, nonPDOMFragmentProviders } : + new IIndexFragmentProvider[][] { pdomFragmentProviders }; + for (IIndexFragmentProvider[] group : groups) { + for (IIndexFragmentProvider provider : group) { + try { + if (providesForProject(provider, project)) { + IIndexFragment[] fragments= provider.getIndexFragments(config); + for (IIndexFragment fragment : fragments) { + try { + processCandidate(id2fragment, fragment); + } catch (InterruptedException e) { + CCorePlugin.log(e); // continue with next candidate + } catch (CoreException e) { + CCorePlugin.log(e); // continue with next candidate + } } } + } catch (CoreException e) { + CCorePlugin.log(e); // move to next provider } - } catch (CoreException e) { - CCorePlugin.log(e); // move to next provider } } @@ -176,14 +196,11 @@ public final class IndexProviderManager implements IElementChangedListener { * @param formatID */ private VersionRange getCurrentlySupportedVersionRangeForFormat(String formatID) { - /* - * TODO - at the point we support alternate IIndexFragment implementations, this method will need - * to be altered to lookup version ranges for the contributed format via an extension point. - */ - if (!PDOM.FRAGMENT_PROPERTY_VALUE_FORMAT_ID.equals(formatID)) { - throw new IllegalArgumentException("Non-PDOM formats are currently unsupported"); //$NON-NLS-1$ + if (PDOM.FRAGMENT_PROPERTY_VALUE_FORMAT_ID.equals(formatID)) { + return pdomVersionRange; } - return pdomVersionRange; + // Version range checks do not apply to non-PDOM IIndexFragments. + return null; } /** @@ -209,7 +226,8 @@ public final class IndexProviderManager implements IElementChangedListener { Version cver= Version.parseVersion(csver); // illegal argument exception IIndexFragment existing= id2fragment.get(cid); - if (getCurrentlySupportedVersionRangeForFormat(cformatID).isIncluded(cver)) { + VersionRange versionRange = getCurrentlySupportedVersionRangeForFormat(cformatID); + if (versionRange == null || versionRange.isIncluded(cver)) { if (existing != null) { String esver= null, eformatID= null; existing.acquireReadLock(); @@ -243,6 +261,8 @@ public final class IndexProviderManager implements IElementChangedListener { } /** + * Adds a PDOM-based index fragment provider. + * * Note: This method should not be called for purposes other than testing * @param provider */ @@ -256,23 +276,25 @@ public final class IndexProviderManager implements IElementChangedListener { return; } - IIndexFragmentProvider[] newAllProviders = new IIndexFragmentProvider[allProviders.length + 1]; - System.arraycopy(allProviders, 0, newAllProviders, 0, allProviders.length); - newAllProviders[allProviders.length] = (IIndexFragmentProvider) provider; - allProviders = newAllProviders; + IIndexFragmentProvider[] newAllProviders = new IIndexFragmentProvider[pdomFragmentProviders.length + 1]; + System.arraycopy(pdomFragmentProviders, 0, newAllProviders, 0, pdomFragmentProviders.length); + newAllProviders[pdomFragmentProviders.length] = (IIndexFragmentProvider) provider; + pdomFragmentProviders = newAllProviders; } /** - * Removes the specified provider by object identity + * Removes the specified provider by object identity. Only a PDOM-based provider can be removed + * using this method. + * * Note: This method should not be called for purposes other than testing * @param provider */ public void removeIndexProvider(IIndexProvider provider) { - ArrayUtil.remove(allProviders, provider); - if (allProviders[allProviders.length - 1] == null) { - IIndexFragmentProvider[] newAllProviders = new IIndexFragmentProvider[allProviders.length - 1]; - System.arraycopy(allProviders, 0, newAllProviders, 0, allProviders.length - 1); - allProviders= newAllProviders; + ArrayUtil.remove(pdomFragmentProviders, provider); + if (pdomFragmentProviders[pdomFragmentProviders.length - 1] == null) { + IIndexFragmentProvider[] newAllProviders = new IIndexFragmentProvider[pdomFragmentProviders.length - 1]; + System.arraycopy(pdomFragmentProviders, 0, newAllProviders, 0, pdomFragmentProviders.length - 1); + pdomFragmentProviders= newAllProviders; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexer.java index dc38809eb7d..5203d4d7041 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexer.java @@ -358,12 +358,12 @@ public abstract class StandaloneIndexer { private void clearIndex() throws CoreException, InterruptedException { IWritableIndex index= getIndex(); // First clear the pdom - index.acquireWriteLock(0); + index.acquireWriteLock(); try { index.clear(); } finally { - index.releaseWriteLock(0); + index.releaseWriteLock(); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexerTask.java index 082e4da6785..8cb4e0b6734 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexerTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexerTask.java @@ -15,13 +15,8 @@ import java.text.NumberFormat; import java.util.Collection; import java.util.Iterator; -import com.ibm.icu.text.MessageFormat; - import org.eclipse.cdt.core.dom.ILinkage; -import org.eclipse.cdt.core.model.AbstractLanguage; -import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.parser.IParserLogService; -import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.internal.core.index.IWritableIndex; import org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask; import org.eclipse.cdt.internal.core.pdom.IndexerProgress; @@ -29,6 +24,8 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import com.ibm.icu.text.MessageFormat; + /** * A task for index updates. * @@ -111,15 +108,6 @@ public abstract class StandaloneIndexerTask extends AbstractIndexerTask { return getIndexer().getIndexAllFiles(); } - @Override - final protected AbstractLanguage[] getLanguages(String filename) { - ILanguage l = fIndexer.getLanguageMapper().getLanguage(filename); - if (l instanceof AbstractLanguage) { - return new AbstractLanguage[] {(AbstractLanguage) l}; - } - return new AbstractLanguage[0]; - } - @Override protected final IWritableIndex createIndex() { return fIndexer.getIndex(); @@ -249,20 +237,6 @@ public abstract class StandaloneIndexerTask extends AbstractIndexerTask { protected void logException(Throwable e) { trace(e.getMessage()); } - - @SuppressWarnings("deprecation") - @Override - protected IScannerInfo createDefaultScannerConfig(int linkageID) { - IStandaloneScannerInfoProvider provider = fIndexer.getScannerInfoProvider(); - if(provider != null) - return provider.getDefaultScannerInformation(linkageID); - - IScannerInfo scannerInfo = fIndexer.getScannerInfo(); - if(scannerInfo != null) - return scannerInfo; - - return super.createDefaultScannerConfig(linkageID); - } /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask#getLinkagesToParse() diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/CodeReaderFactoryAdapter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/CodeReaderFactoryAdapter.java index 39571347044..3ac9468aaab 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/CodeReaderFactoryAdapter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/CodeReaderFactoryAdapter.java @@ -45,7 +45,7 @@ public class CodeReaderFactoryAdapter extends AbstractCodeReaderFactory { } public org.eclipse.cdt.core.parser.CodeReader createCodeReaderForInclusion(String path) { - return CodeReaderAdapter.adapt(fDelegate.getContentForInclusion(path)); + return CodeReaderAdapter.adapt(fDelegate.getContentForInclusion(path, null)); } @Override @@ -55,7 +55,7 @@ public class CodeReaderFactoryAdapter extends AbstractCodeReaderFactory { } public org.eclipse.cdt.core.parser.CodeReader createCodeReaderForTranslationUnit(String path) { - return CodeReaderAdapter.adapt(fDelegate.getContentForInclusion(path)); + return CodeReaderAdapter.adapt(fDelegate.getContentForInclusion(path, null)); } @Deprecated diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/EmptyFilesProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/EmptyFilesProvider.java index f016fcb7982..163488ec3e3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/EmptyFilesProvider.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/EmptyFilesProvider.java @@ -27,7 +27,8 @@ public class EmptyFilesProvider extends InternalFileContentProvider { } @Override - public InternalFileContent getContentForInclusion(String path) { + public InternalFileContent getContentForInclusion(String path, + IMacroDictionary macroDictionary) { if (!getInclusionExists(path)) return null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/FileContentProviderAdapter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/FileContentProviderAdapter.java index 33d65e001f9..08406327aab 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/FileContentProviderAdapter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/FileContentProviderAdapter.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.parser; @@ -26,7 +26,7 @@ import org.eclipse.core.runtime.CoreException; public class FileContentProviderAdapter extends InternalFileContentProvider { /** - * @deprecated avoid using the adapter, its for backwards compatibility, only. + * @deprecated avoid using the adapter, it's for backwards compatibility, only. */ @Deprecated public static InternalFileContentProvider adapt(ICodeReaderFactory fileCreator) { @@ -57,7 +57,7 @@ public class FileContentProviderAdapter extends InternalFileContentProvider { } @Override - public InternalFileContent getContentForInclusion(String path) { + public InternalFileContent getContentForInclusion(String path, IMacroDictionary macroDictionary) { return (InternalFileContent) FileContent.adapt(fDelegate.createCodeReaderForInclusion(path)); } @@ -72,5 +72,4 @@ public class FileContentProviderAdapter extends InternalFileContentProvider { } return null; } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IMacroDictionary.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IMacroDictionary.java new file mode 100644 index 00000000000..a6f854960a2 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IMacroDictionary.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Markus Schorn - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.internal.core.parser; + +import org.eclipse.cdt.core.parser.ISignificantMacros; + + +/** + * Interface for accessing the macro dictionary of the preprocessor. + */ +public interface IMacroDictionary { + + boolean satisfies(ISignificantMacros significantMacros); +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/SavedFilesProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/SavedFilesProvider.java index 5dff2328055..0cea421a535 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/SavedFilesProvider.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/SavedFilesProvider.java @@ -30,7 +30,8 @@ public class SavedFilesProvider extends InternalFileContentProvider { } @Override - public InternalFileContent getContentForInclusion(String path) { + public InternalFileContent getContentForInclusion(String path, + IMacroDictionary macroDictionary) { if (!getInclusionExists(path)) return null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ASTPreprocessorNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ASTPreprocessorNode.java index 23ca3939424..314e83a5751 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ASTPreprocessorNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ASTPreprocessorNode.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.parser.scanner; @@ -40,11 +40,15 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit.IDependencyTree; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit.IDependencyTree.IASTInclusionNode; import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.IFileNomination; import org.eclipse.cdt.core.dom.ast.IMacroBinding; +import org.eclipse.cdt.core.index.IIndexFile; +import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNodeSpecification; +import org.eclipse.core.runtime.CoreException; /** * Models various AST-constructs obtained from the preprocessor. @@ -188,7 +192,7 @@ class ASTIfndef extends ASTDirectiveWithCondition implements IASTPreprocessorIfn } class ASTIfdef extends ASTDirectiveWithCondition implements IASTPreprocessorIfdefStatement { - ASTMacroReferenceName fMacroRef; + private ASTMacroReferenceName fMacroRef; public ASTIfdef(IASTTranslationUnit parent, int startNumber, int condNumber, int condEndNumber, boolean taken, IMacroBinding macro) { super(parent, startNumber, condNumber, condEndNumber, taken); if (macro != null) { @@ -253,21 +257,33 @@ class ASTPragmaOperator extends ASTPragma { } class ASTInclusionStatement extends ASTPreprocessorNode implements IASTPreprocessorIncludeStatement { + private static final ISignificantMacros[] NO_VERSIONS = {}; + private final ASTPreprocessorName fName; private final String fPath; private final boolean fIsResolved; private final boolean fIsSystemInclude; private final boolean fFoundByHeuristics; + private final IFileNomination fNominationDelegate; + private boolean fPragmaOnce; + private boolean fCreatesAST; + private ISignificantMacros fSignificantMacros; + private ISignificantMacros[] fLoadedVersions = NO_VERSIONS; + private long fContentsHash; public ASTInclusionStatement(IASTTranslationUnit parent, int startNumber, int nameStartNumber, int nameEndNumber, int endNumber, - char[] headerName, String filePath, boolean userInclude, boolean active, boolean heuristic) { + char[] headerName, String filePath, boolean userInclude, boolean active, boolean heuristic, + IFileNomination nominationDelegate) { super(parent, IASTTranslationUnit.PREPROCESSOR_STATEMENT, startNumber, endNumber); - fName= new ASTPreprocessorName(this, IASTPreprocessorIncludeStatement.INCLUDE_NAME, nameStartNumber, nameEndNumber, headerName, null); + fName= new ASTPreprocessorName(this, IASTPreprocessorIncludeStatement.INCLUDE_NAME, + nameStartNumber, nameEndNumber, headerName, null); fPath= filePath == null ? "" : filePath; //$NON-NLS-1$ fIsResolved= filePath != null; fIsSystemInclude= !userInclude; fFoundByHeuristics= heuristic; + fSignificantMacros= ISignificantMacros.NONE; + fNominationDelegate= nominationDelegate; if (!active) { setInactive(); } @@ -298,6 +314,69 @@ class ASTInclusionStatement extends ASTPreprocessorNode implements IASTPreproces public boolean isResolvedByHeuristics() { return fFoundByHeuristics; } + + public boolean hasPragmaOnceSemantics() { + if (fNominationDelegate != null) { + try { + return fNominationDelegate.hasPragmaOnceSemantics(); + } catch (CoreException e) { + } + } + return fPragmaOnce; + } + + public void setPragamOnceSemantics(boolean value) { + assert fNominationDelegate == null; + fPragmaOnce= value; + } + + public ISignificantMacros getSignificantMacros() { + if (fNominationDelegate != null) { + try { + return fNominationDelegate.getSignificantMacros(); + } catch (CoreException e) { + } + } + return fSignificantMacros; + } + + public void setSignificantMacros(ISignificantMacros sig) { + assert sig != null; + assert fNominationDelegate == null; + fSignificantMacros= sig; + } + + public void setLoadedVersions(ISignificantMacros[] versions) { + fLoadedVersions= versions; + } + + public ISignificantMacros[] getLoadedVersions() { + return fLoadedVersions; + } + + public long getContentsHash() { + if (fNominationDelegate != null) { + return 0; + } + return fContentsHash; + } + + public void setContentsHash(long hash) { + assert fNominationDelegate == null; + fCreatesAST= true; + fContentsHash= hash; + } + + public boolean createsAST() { + return fCreatesAST; + } + + public IIndexFile getImportedIndexFile() { + if (fNominationDelegate instanceof IIndexFile) + return (IIndexFile) fNominationDelegate; + + return null; + } } class ASTMacroDefinition extends ASTPreprocessorNode implements IASTPreprocessorObjectStyleMacroDefinition { @@ -579,6 +658,10 @@ class ASTFileLocation implements IASTFileLocation { public LocationCtxFile getLocationContext() { return fLocationCtx; } + + public IASTPreprocessorIncludeStatement getContextInclusionStatement() { + return fLocationCtx.getInclusionStatement(); + } } class ASTMacroExpansion extends ASTPreprocessorNode implements IASTPreprocessorMacroExpansion { @@ -708,6 +791,10 @@ class ASTFileLocationForBuiltins implements IASTFileLocation { public int getStartingLineNumber() { return 0; } + + public IASTPreprocessorIncludeStatement getContextInclusionStatement() { + return null; + } } @@ -723,4 +810,3 @@ class ASTImageLocation extends ASTFileLocationForBuiltins implements IASTImageLo return fKind; } } - diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java index a832728cba2..3b3eeb9d3c4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -19,12 +19,17 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; +import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.IFileNomination; import org.eclipse.cdt.core.dom.ast.IMacroBinding; import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration; import org.eclipse.cdt.core.index.IIndexMacro; +import org.eclipse.cdt.core.parser.AbstractParserLogService; import org.eclipse.cdt.core.parser.EndOfFileException; import org.eclipse.cdt.core.parser.FileContent; import org.eclipse.cdt.core.parser.IExtendedScannerInfo; @@ -34,6 +39,7 @@ import org.eclipse.cdt.core.parser.IPreprocessorDirective; import org.eclipse.cdt.core.parser.IProblem; import org.eclipse.cdt.core.parser.IScanner; import org.eclipse.cdt.core.parser.IScannerInfo; +import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.IncludeFileContentProvider; import org.eclipse.cdt.core.parser.Keywords; @@ -42,16 +48,21 @@ import org.eclipse.cdt.core.parser.ParseError; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.util.CharArrayIntMap; import org.eclipse.cdt.core.parser.util.CharArrayMap; +import org.eclipse.cdt.core.parser.util.CharArrayObjectMap; +import org.eclipse.cdt.core.parser.util.CharArraySet; import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.internal.core.dom.IIncludeFileResolutionHeuristics; import org.eclipse.cdt.internal.core.parser.EmptyFilesProvider; +import org.eclipse.cdt.internal.core.parser.IMacroDictionary; import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator.EvalException; +import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.FileVersion; import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.InclusionKind; import org.eclipse.cdt.internal.core.parser.scanner.Lexer.LexerOptions; import org.eclipse.cdt.internal.core.parser.scanner.MacroDefinitionParser.InvalidMacroDefinitionException; import org.eclipse.cdt.internal.core.parser.scanner.ScannerContext.BranchKind; import org.eclipse.cdt.internal.core.parser.scanner.ScannerContext.CodeState; import org.eclipse.cdt.internal.core.parser.scanner.ScannerContext.Conditional; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; /** @@ -88,11 +99,42 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { private static final DynamicMacro __DATE__= new DateMacro("__DATE__".toCharArray()); //$NON-NLS-1$ private static final DynamicMacro __TIME__ = new TimeMacro("__TIME__".toCharArray()); //$NON-NLS-1$ private static final DynamicMacro __LINE__ = new LineMacro("__LINE__".toCharArray()); //$NON-NLS-1$ + private static final char[] ONCE = "once".toCharArray(); //$NON-NLS-1$ - private static final int NO_EXPANSION = 0x01; - private static final int PROTECT_DEFINED = 0x02; - private static final int STOP_AT_NL = 0x04; - private static final int CHECK_NUMBERS = 0x08; + static final int NO_EXPANSION = 0x01; + static final int PROTECT_DEFINED = 0x02; + static final int STOP_AT_NL = 0x04; + static final int CHECK_NUMBERS = 0x08; + static final int REPORT_SIGNIFICANT_MACROS = 0x10; + static final int IGNORE_UNDEFINED_SIGNIFICANT_MACROS = 0x20; + + private static final int MAX_INCLUSION_DEPTH = 200; + + private static final String TRACE_NO_GUARD = CCorePlugin.PLUGIN_ID + "/debug/scanner/missingIncludeGuards"; //$NON-NLS-1$ + + + private final class MacroDictionary implements IMacroDictionary, ISignificantMacros.IVisitor { + public boolean satisfies(ISignificantMacros significantMacros) { + return significantMacros.accept(this); + } + + public boolean visitDefined(char[] macro) { + return isDefined(macro); + } + + public boolean visitUndefined(char[] macro) { + return !isDefined(macro); + } + + public boolean visitValue(char[] macro, char[] value) { + PreprocessorMacro m = fMacroDictionary.get(macro); + return m != null && CharArrayUtils.equals(m.getExpansion(), value); + } + + private boolean isDefined(char[] macro) { + return fMacroDictionary.containsKey(macro); + } + } private interface IIncludeFileTester { T checkFile(String path, boolean isHeuristicMatch, IncludeSearchPathElement onPath); @@ -100,7 +142,13 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { final private IIncludeFileTester createCodeReaderTester= new IIncludeFileTester() { public InternalFileContent checkFile(String path, boolean isHeuristicMatch, IncludeSearchPathElement onPath) { - final InternalFileContent fc= fFileContentProvider.getContentForInclusion(path); + final InternalFileContent fc; + IFileNomination once= fFileContentProvider.isIncludedWithPragmaOnceSemantics(path); + if (once != null) { + fc= new InternalFileContent(path, InclusionKind.SKIP_FILE); + } else { + fc= fFileContentProvider.getContentForInclusion(path, fMacroDictionaryFacade); + } if (fc != null) { fc.setFoundByHeuristics(isHeuristicMatch); fc.setFoundOnPath(onPath); @@ -162,7 +210,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { TokenSequence fInputToMacroExpansion= new TokenSequence(false); TokenSequence fLineInputToMacroExpansion= new TokenSequence(true); - final private IParserLogService fLog; + final private AbstractParserLogService fLog; final private InternalFileContentProvider fFileContentProvider; private IIncludeFileResolutionHeuristics fIncludeFileResolutionHeuristics; @@ -184,10 +232,9 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { // state information private final CharArrayMap fMacroDictionary = new CharArrayMap(512); + private final IMacroDictionary fMacroDictionaryFacade = new MacroDictionary(); private final LocationMap fLocationMap; - - /** Set of already included files */ - private final HashSet fAllIncludedFiles= new HashSet(); + private CharArraySet fPreventInclusion= new CharArraySet(0); private final Lexer fRootLexer; private final ScannerContext fRootContext; @@ -200,6 +247,12 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { private Token fLastToken; private InternalFileContent fRootContent; + private boolean fHandledEndOfTranslationUnit; + + // Detection of include guards used around an include directive + private char[] fExternIncludeGuard; + private Set fTracedGuards; + public CPreprocessor(FileContent fileContent, IScannerInfo info, ParserLanguage language, IParserLogService log, IScannerExtensionConfiguration configuration, @@ -217,7 +270,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { throw new IllegalArgumentException("Illegal file content object"); //$NON-NLS-1$ } - fLog = log; + fLog = AbstractParserLogService.convert(log); fAdditionalNumericLiteralSuffixes= nonNull(configuration.supportAdditionalNumericLiteralSuffixes()); fLexOptions.fSupportDollarInIdentifiers= configuration.support$InIdentifiers(); fLexOptions.fSupportAtSignInIdentifiers= configuration.supportAtSignInIdentifiers(); @@ -239,17 +292,38 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { setupMacroDictionary(configuration, info, language); ILocationCtx ctx= fLocationMap.pushTranslationUnit(filePath, fRootContent.getSource()); - fAllIncludedFiles.add(filePath); - fFileContentProvider.reportTranslationUnitFile(filePath); fRootLexer= new Lexer(fRootContent.getSource(), fLexOptions, this, this); fRootContext= fCurrentContext= new ScannerContext(ctx, null, fRootLexer); if (info instanceof IExtendedScannerInfo) { final IExtendedScannerInfo einfo= (IExtendedScannerInfo) info; - fPreIncludedFiles= new String[][] {einfo.getMacroFiles(), einfo.getIncludeFiles()}; + fPreIncludedFiles= new String[][] { einfo.getMacroFiles(), einfo.getIncludeFiles() }; } + fFileContentProvider.resetForTranslationUnit(); } + + private char[] detectIncludeGuard(String filePath, AbstractCharArray source, ScannerContext ctx) { + final char[] guard = IncludeGuardDetection.detectIncludeGuard(source, fLexOptions, fPPKeywords); + if (guard != null) { + IFileNomination nom= fLocationMap.reportPragmaOnceSemantics(ctx.getLocationCtx()); + fFileContentProvider.reportPragmaOnceSemantics(filePath, nom); + ctx.internalModification(guard); + ctx.setPragmaOnce(true); + return guard; + } else { + ctx.trackSignificantMacros(); + } + if (ctx != fRootContext) { + if (fLog.isTracing(TRACE_NO_GUARD)) { + if (fTracedGuards == null) + fTracedGuards= new HashSet(); + if (fTracedGuards.add(filePath)) + fLog.traceLog(TRACE_NO_GUARD, "No include guard in " + filePath); //$NON-NLS-1$ + } + } + return null; + } - public void setSplitShiftROperator(boolean val) { + public void setSplitShiftROperator(boolean val) { fSplitShiftRightOperator= val; } @@ -371,15 +445,19 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { private void beforeFirstFetchToken() { if (fPreIncludedFiles != null) { - handlePreIncludedFiles(); - } - final String location = fLocationMap.getTranslationUnitPath(); - InternalFileContent content= fFileContentProvider.getContentForContextToHeaderGap(location); - if (content != null && content.getKind() == InclusionKind.FOUND_IN_INDEX) { - processInclusionFromIndex(0, location, content); + handlePreIncludedFiles(); + fPreIncludedFiles= null; } - fLocationMap.replacingFile(fFileContentProvider, fRootContent); - fRootContent= null; + final String location = fLocationMap.getTranslationUnitPath(); + InternalFileContent content= fFileContentProvider.getContentForContextToHeaderGap(location, + fMacroDictionaryFacade); + if (content != null && content.getKind() == InclusionKind.FOUND_IN_INDEX) { + processInclusionFromIndex(0, location, content, false); + } + + detectIncludeGuard(location, fRootContent.getSource(), fRootContext); + fLocationMap.parsingFile(fFileContentProvider, fRootContent); + fRootContent= null; } private void handlePreIncludedFiles() { @@ -726,11 +804,23 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { case IToken.tEND_OF_INPUT: if (fCurrentContext == uptoEndOfCtx || uptoEndOfCtx == null) { + if (fCurrentContext == fRootContext && !fHandledEndOfTranslationUnit + && (options & STOP_AT_NL) == 0) { + fHandledEndOfTranslationUnit= true; + fLocationMap.endTranslationUnit(ppToken.getEndOffset(), fCurrentContext.getSignificantMacros()); + } return ppToken; } - final ILocationCtx locationCtx = fCurrentContext.getLocationCtx(); + + final ILocationCtx locationCtx = fCurrentContext.getLocationCtx(); + ASTInclusionStatement inc = locationCtx.getInclusionStatement(); + if (inc != null) { + completeInclusion(inc); + } fLocationMap.popContext(locationCtx); - fCurrentContext= fCurrentContext.getParent(); + + fCurrentContext.propagateSignificantMacros(); + fCurrentContext= fCurrentContext.getParent(); assert fCurrentContext != null; ppToken= fCurrentContext.currentLexerToken(); @@ -781,7 +871,21 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { } } - private void checkNumber(Token number, final boolean isFloat) { + private void completeInclusion(ASTInclusionStatement inc) { + final ISignificantMacros sig; + CharArrayObjectMap sigMacros= fCurrentContext.getSignificantMacros(); + if (sigMacros == null || sigMacros.isEmpty()) { + sig = ISignificantMacros.NONE; + } else { + sig = new SignificantMacros(sigMacros); + } + inc.setSignificantMacros(sig); + if (!inc.hasPragmaOnceSemantics()) { + fFileContentProvider.addLoadedVersions(inc.getPath(), fCurrentContext.getLoadedVersionCount(), sig); + } + } + + private void checkNumber(Token number, final boolean isFloat) { final char[] image= number.getCharImage(); boolean hasExponent = false; @@ -1151,7 +1255,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { } break; case IPreprocessorDirective.ppPragma: - condOffset= lexer.nextToken().getOffset(); + Token pragmaToken= lexer.nextToken(); + condOffset= pragmaToken.getOffset(); condEndOffset= lexer.consumeLine(ORIGIN_PREPROCESSOR_DIRECTIVE); // Missing argument if (condEndOffset < condOffset) { @@ -1160,6 +1265,10 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { if (fCurrentContext.getCodeState() == CodeState.eActive) { int endOffset= lexer.currentToken().getEndOffset(); fLocationMap.encounterPoundPragma(startOffset, condOffset, condEndOffset, endOffset); + if (CharArrayUtils.equals(ONCE, pragmaToken.getCharImage())) { + IFileNomination nom= fLocationMap.reportPragmaOnceSemantics(fCurrentContext.getLocationCtx()); + fFileContentProvider.reportPragmaOnceSemantics(getCurrentFilename(), nom); + } } break; case IPreprocessorDirective.ppIgnore: @@ -1175,16 +1284,12 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { } } - private boolean hasFileBeenIncluded(String location) { - Boolean itHas= fFileContentProvider.hasFileBeenIncludedInCurrentTranslationUnit(location); - if (itHas != null) { - return itHas.booleanValue(); - } - return fAllIncludedFiles.contains(location); - } - private void executeInclude(final Lexer lexer, int poundOffset, boolean include_next, boolean active, boolean withinExpansion) throws OffsetLimitReachedException { + // Make sure to clear the extern include guard. + final char[] externGuard= fExternIncludeGuard; + fExternIncludeGuard= null; + if (withinExpansion) { final char[] name= lexer.currentToken().getCharImage(); final int endOffset = lexer.consumeLine(ORIGIN_PREPROCESSOR_DIRECTIVE); @@ -1258,71 +1363,129 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { } return; } - - String path= null; - boolean reported= false; - boolean isHeuristic= false; + + if (active && fCurrentContext.getDepth() == MAX_INCLUSION_DEPTH || fPreventInclusion.containsKey(headerName)) { + handleProblem(IProblem.PREPROCESSOR_EXCEEDS_MAXIMUM_INCLUSION_DEPTH, + lexer.getInputChars(poundOffset, condEndOffset), poundOffset, condEndOffset); + fPreventInclusion.put(headerName); + return; + } final String includeDirective = new String(headerName); if (!active) { - // test if the include is inactive just because it was included before (bug 167100) - final IncludeResolution resolved= findInclusion(includeDirective, userInclude, include_next, - getCurrentFilename(), createPathTester); - if (resolved != null && hasFileBeenIncluded(resolved.fLocation)) { - path= resolved.fLocation; - isHeuristic= resolved.fHeuristic; - } - } else { - final InternalFileContent fi= findInclusion(includeDirective, userInclude, include_next, - getCurrentFilename(), createCodeReaderTester); - if (fi != null) { - path= fi.getFileLocation(); - isHeuristic= fi.isFoundByHeuristics(); - switch (fi.getKind()) { - case FOUND_IN_INDEX: - processInclusionFromIndex(poundOffset, path, fi); - break; - case USE_SOURCE: - AbstractCharArray source= fi.getSource(); - if (source != null && !isCircularInclusion(path)) { - reported= true; - fAllIncludedFiles.add(path); - ILocationCtx ctx= fLocationMap.pushInclusion(poundOffset, nameOffsets[0], nameOffsets[1], - condEndOffset, source, path, headerName, userInclude, isHeuristic, fi.isSource()); - ScannerContext fctx= new ScannerContext(ctx, fCurrentContext, - new Lexer(source, fLexOptions, this, this)); - fctx.setFoundOnPath(fi.getFoundOnPath(), includeDirective); - fCurrentContext= fctx; + // Inactive include + String path= null; + boolean isHeuristic= false; + IFileNomination nominationDelegate= null; + + if (externGuard != null) { + // #ifndef GUARD + // #include "file.h" + // #endif + // When the extern guard matches we need to resolve the inclusion. We don't actually + // check whether the guard matches. + final IncludeResolution resolved= findInclusion(includeDirective, userInclude, include_next, + getCurrentFilename(), createPathTester); + if (resolved != null) { + nominationDelegate = fFileContentProvider.isIncludedWithPragmaOnceSemantics(resolved.fLocation); + if (nominationDelegate != null) { + path= resolved.fLocation; + isHeuristic= resolved.fHeuristic; } - fLocationMap.replacingFile(fFileContentProvider, fi); - break; - - case SKIP_FILE: - break; } - } else { - final int len = headerName.length + 2; - StringBuilder name= new StringBuilder(len); - name.append(userInclude ? '"' : '<'); - name.append(headerName); - name.append(userInclude ? '"' : '>'); - - final char[] nameChars= new char[len]; - name.getChars(0, len, nameChars, 0); - handleProblem(IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND, nameChars, poundOffset, condEndOffset); } + fLocationMap.encounterPoundInclude(poundOffset, nameOffsets[0], nameOffsets[1], + condEndOffset, headerName, path, userInclude, active, isHeuristic, nominationDelegate); + return; + } + + // Active include + final InternalFileContent fi= findInclusion(includeDirective, userInclude, include_next, + getCurrentFilename(), createCodeReaderTester); + if (fi == null) { + // Unresolved active include + final int len = headerName.length + 2; + StringBuilder name= new StringBuilder(len); + name.append(userInclude ? '"' : '<'); + name.append(headerName); + name.append(userInclude ? '"' : '>'); + + final char[] nameChars= new char[len]; + name.getChars(0, len, nameChars, 0); + handleProblem(IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND, nameChars, poundOffset, condEndOffset); + fLocationMap.encounterPoundInclude(poundOffset, nameOffsets[0], nameOffsets[1], + condEndOffset, headerName, null, userInclude, active, false, null); + return; } - if (!reported) { - fLocationMap.encounterPoundInclude(poundOffset, nameOffsets[0], nameOffsets[1], - condEndOffset, headerName, path, userInclude, active, isHeuristic); + // Resolved active include + final String path= fi.getFileLocation(); + final boolean isHeuristic= fi.isFoundByHeuristics(); + final boolean pragmaOnceContext= fCurrentContext.isPragmaOnce(); + + IFileNomination nominationDelegate= null; + ASTInclusionStatement stmt= null; + List loadedVerisons = null; + switch (fi.getKind()) { + case FOUND_IN_INDEX: + // Pulled in from index + nominationDelegate= fi.getFilesIncluded().get(0); + try { + ISignificantMacros sm = nominationDelegate.getSignificantMacros(); + fCurrentContext.addSignificantMacros(sm); + if (pragmaOnceContext && !nominationDelegate.hasPragmaOnceSemantics()) + loadedVerisons= fFileContentProvider.getLoadedVersions(path); + } catch (CoreException e) { + } + + processInclusionFromIndex(poundOffset, path, fi, true); + break; + case USE_SOURCE: + // Will be parsed + AbstractCharArray source= fi.getSource(); + if (source != null) { + ILocationCtx ctx= fLocationMap.pushInclusion(poundOffset, nameOffsets[0], nameOffsets[1], + condEndOffset, source, path, headerName, userInclude, isHeuristic, fi.isSource()); + ScannerContext fctx= new ScannerContext(ctx, fCurrentContext, + new Lexer(source, fLexOptions, this, this)); + fctx.setFoundOnPath(fi.getFoundOnPath(), includeDirective); + detectIncludeGuard(path, source, fctx); + fCurrentContext= fctx; + stmt= ctx.getInclusionStatement(); + stmt.setContentsHash(source.getContentsHash()); + if (!fCurrentContext.isPragmaOnce()) { + // Track the loaded version count, even in a non-pragma-once context. + loadedVerisons= fFileContentProvider.getLoadedVersions(path); + fctx.setLoadedVersionCount(loadedVerisons.size()); + } + } + fLocationMap.parsingFile(fFileContentProvider, fi); + break; + + case SKIP_FILE: + // Already included or fast parsing mode. + break; + } + if (stmt == null) { + // Found in index or skipped. + stmt= fLocationMap.encounterPoundInclude(poundOffset, nameOffsets[0], nameOffsets[1], + condEndOffset, headerName, path, userInclude, active, isHeuristic, nominationDelegate); + } + // In a pragma once context store loaded versions of this non-pragma-once include + if (pragmaOnceContext && loadedVerisons != null && !loadedVerisons.isEmpty()) { + stmt.setLoadedVersions(loadedVerisons.toArray(new ISignificantMacros[loadedVerisons.size()])); } } - private void processInclusionFromIndex(int offset, String path, InternalFileContent fi) { + private void processInclusionFromIndex(int offset, String path, InternalFileContent fi, boolean updateContext) { List mdefs= fi.getMacroDefinitions(); for (IIndexMacro macro : mdefs) { addMacroDefinition(macro); + if (updateContext) + fCurrentContext.internalModification(macro.getNameCharArray()); + } + for (FileVersion version : fi.getNonPragmaOnceVersions()) { + fFileContentProvider.addLoadedVersions(version.fPath, Integer.MAX_VALUE, version.fSigMacros); } fLocationMap.skippedFile(fLocationMap.getSequenceNumberForOffset(offset), fi); } @@ -1346,24 +1509,15 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { return headerName; } - private boolean isCircularInclusion(String filename) { - ILocationCtx checkContext= fCurrentContext.getLocationCtx(); - while (checkContext != null) { - if (filename.equals(checkContext.getFilePath())) { - return true; - } - checkContext= checkContext.getParent(); - } - return false; - } - - private void executeDefine(final Lexer lexer, int startOffset, boolean isActive) throws OffsetLimitReachedException { try { ObjectStyleMacro macrodef = fMacroDefinitionParser.parseMacroDefinition(lexer, this); - if (isActive) - fMacroDictionary.put(macrodef.getNameCharArray(), macrodef); + if (isActive) { + final char[] macroName = macrodef.getNameCharArray(); + fMacroDictionary.put(macroName, macrodef); + fCurrentContext.internalModification(macroName); + } final Token name= fMacroDefinitionParser.getNameToken(); fLocationMap.encounterPoundDefine(startOffset, name.getOffset(), name.getEndOffset(), @@ -1393,6 +1547,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { PreprocessorMacro definition; if (isActive) { definition= fMacroDictionary.remove(namechars, 0, namechars.length); + fCurrentContext.internalModification(namechars); } else { definition= fMacroDictionary.get(namechars); } @@ -1422,10 +1577,18 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { handleProblem(IProblem.PREPROCESSOR_DEFINITION_NOT_FOUND, name.getCharImage(), offset, nameEndOffset); } else { final char[] namechars= name.getCharImage(); + if (isIfndef) { + if (IncludeGuardDetection.detectIncludeEndif(lexer)) { + fExternIncludeGuard= namechars; + } + } macro= fMacroDictionary.get(namechars); isTaken= (macro == null) == isIfndef; if (macro == null) { macro = new UndefinedMacro(namechars); + fCurrentContext.significantMacroUndefined(namechars); + } else { + fCurrentContext.significantMacroDefined(namechars); } } } @@ -1442,7 +1605,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { return fCurrentContext.setBranchState(conditional, isTaken, withinExpansion, offset); } - private CodeState executeIf(Lexer lexer, int startOffset, boolean isElif, + private CodeState executeIf(Lexer lexer, int startOffset, boolean isElif, boolean withinExpansion) throws OffsetLimitReachedException { Conditional cond= fCurrentContext.newBranch(isElif ? BranchKind.eElif : BranchKind.eIf, withinExpansion); if (cond == null) { @@ -1458,6 +1621,11 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { int condEndOffset, endOffset; if (cond.canHaveActiveBranch(withinExpansion)) { + char[] macro= IncludeGuardDetection.detectIfNotDefinedIncludeEndif(lexer); + if (macro != null) { + fExternIncludeGuard= macro; + } + TokenList condition= new TokenList(); condEndOffset= getTokensWithinPPDirective(true, condition, withinExpansion); endOffset= lexer.currentToken().getEndOffset(); @@ -1469,6 +1637,14 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { fExpressionEvaluator.clearMacrosInDefinedExpression(); isTaken= fExpressionEvaluator.evaluate(condition, fMacroDictionary, fLocationMap); refs = fExpressionEvaluator.clearMacrosInDefinedExpression(); + for (IASTName iastName : refs) { + IBinding mb= iastName.getBinding(); + if (mb instanceof UndefinedMacro) { + fCurrentContext.significantMacroUndefined(iastName.toCharArray()); + } else { + fCurrentContext.significantMacroDefined(iastName.toCharArray()); + } + } } catch (EvalException e) { handleProblem(e.getProblemID(), e.getProblemArg(), condOffset, endOffset); } @@ -1531,7 +1707,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { boolean withinExpansion) throws OffsetLimitReachedException { final ScannerContext scannerCtx= fCurrentContext; scannerCtx.clearInactiveCodeMarkerToken(); - int options= STOP_AT_NL; + int options= STOP_AT_NL | REPORT_SIGNIFICANT_MACROS; if (isCondition) options |= PROTECT_DEFINED; @@ -1545,10 +1721,9 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { case Lexer.tNEWLINE: break loop; case IToken.tIDENTIFIER: - if (isCondition && CharArrayUtils.equals(Keywords.cDEFINED, t.getCharImage())) { - t.setType(CPreprocessor.tDEFINED); - options |= NO_EXPANSION; - } + break; + case tDEFINED: + options |= NO_EXPANSION; break; case IToken.tLPAREN: break; @@ -1639,9 +1814,16 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { */ private boolean expandMacro(final Token identifier, Lexer lexer, int options, boolean withinExpansion) throws OffsetLimitReachedException { + final boolean reportSignificant = (options & REPORT_SIGNIFICANT_MACROS) != 0; final char[] name= identifier.getCharImage(); + if ((options & PROTECT_DEFINED) != 0 && CharArrayUtils.equals(name, Keywords.cDEFINED)) { + identifier.setType(tDEFINED); + return false; + } PreprocessorMacro macro= fMacroDictionary.get(name); if (macro == null) { + if (reportSignificant && (options & IGNORE_UNDEFINED_SIGNIFICANT_MACROS) == 0) + fCurrentContext.significantMacroUndefined(name); return false; } boolean stopAtNewline= (options & STOP_AT_NL) != 0; @@ -1653,6 +1835,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { } } if (t.getType() != IToken.tLPAREN) { + if (reportSignificant) + fCurrentContext.significantMacro(macro); return false; } } @@ -1660,8 +1844,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { final ITokenSequence input= stopAtNewline ? fLineInputToMacroExpansion : fInputToMacroExpansion; final MacroExpander expander = withinExpansion ? new MacroExpander(this, fMacroDictionary, fLocationMap, fLexOptions) : fMacroExpander; - TokenList replacement= expander.expand(input, (options & PROTECT_DEFINED) != 0, macro, - identifier, contentAssist); + TokenList replacement= expander.expand(input, options, macro, identifier, contentAssist, fCurrentContext); final IASTName[] expansions= expander.clearImplicitExpansions(); final ImageLocationInfo[] ili= expander.clearImageLocationInfos(); final Token last= replacement.last(); @@ -1679,5 +1862,5 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { return fMacroExpander; } return null; - } + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ExpressionEvaluator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ExpressionEvaluator.java index fba757060a2..09ccfce9787 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ExpressionEvaluator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ExpressionEvaluator.java @@ -299,11 +299,13 @@ public class ExpressionEvaluator { if (LA() != IToken.tIDENTIFIER) { throw new EvalException(IProblem.SCANNER_ILLEGAL_IDENTIFIER, null); } - PreprocessorMacro macro= fDictionary.get(fTokens.getCharImage()); - if (macro != null) { - fMacrosInDefinedExpressions.add(fLocationMap.encounterDefinedExpression(macro, fTokens.getOffset(), fTokens.getEndOffset())); - } + final char[] macroName = fTokens.getCharImage(); + PreprocessorMacro macro= fDictionary.get(macroName); int result= macro != null ? 1 : 0; + if (macro == null) + macro= new UndefinedMacro(macroName); + + fMacrosInDefinedExpressions.add(fLocationMap.encounterDefinedExpression(macro, fTokens.getOffset(), fTokens.getEndOffset())); consume(); if (parenthesis) { if (LA() != IToken.tRPAREN) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ILocationCtx.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ILocationCtx.java index ac52538bea4..2d9ac67ff07 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ILocationCtx.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ILocationCtx.java @@ -30,4 +30,8 @@ public interface ILocationCtx { */ ILocationCtx getParent(); + /** + * Returns inclusion statement that created this context, or null. + */ + ASTInclusionStatement getInclusionStatement(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ISkippedIndexedFilesListener.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ISkippedIndexedFilesListener.java index 607e1fd784d..6e913d46d4d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ISkippedIndexedFilesListener.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ISkippedIndexedFilesListener.java @@ -28,5 +28,5 @@ public interface ISkippedIndexedFilesListener { /** * Notifies the listeners that a file is being parsed. */ - void replacingFile(InternalFileContentProvider fileContentProvider, InternalFileContent fileContent); + void parsingFile(InternalFileContentProvider fileContentProvider, InternalFileContent fileContent); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeGuardDetection.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeGuardDetection.java new file mode 100644 index 00000000000..2674e80e36a --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeGuardDetection.java @@ -0,0 +1,165 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Markus Schorn - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.internal.core.parser.scanner; + +import static org.eclipse.cdt.core.parser.OffsetLimitReachedException.ORIGIN_PREPROCESSOR_DIRECTIVE; + +import org.eclipse.cdt.core.parser.IPreprocessorDirective; +import org.eclipse.cdt.core.parser.IToken; +import org.eclipse.cdt.core.parser.Keywords; +import org.eclipse.cdt.core.parser.OffsetLimitReachedException; +import org.eclipse.cdt.core.parser.util.CharArrayIntMap; +import org.eclipse.cdt.core.parser.util.CharArrayUtils; + +/** + * Helper class for detecting include guards + */ +public class IncludeGuardDetection { + public static char[] detectIncludeGuard(AbstractCharArray content, Lexer.LexerOptions lexOptions, CharArrayIntMap ppKeywords) { + Lexer l= new Lexer(content, lexOptions, ILexerLog.NULL, null); + char[] guard= findIncludeGuard(l, ppKeywords); + if (guard != null && currentIfSpansFile(l, ppKeywords)) { + return guard; + } + return null; + } + + private static char[] findIncludeGuard(Lexer l, CharArrayIntMap ppKeywords) { + try { + if (skipAll(l, Lexer.tNEWLINE).getType() == IToken.tPOUND) { + Token t = l.nextToken(); + if (t.getType() == IToken.tIDENTIFIER) { + char[] guard= null; + switch(ppKeywords.get(t.getCharImage())) { + case IPreprocessorDirective.ppIfndef: + // #ifndef GUARD + t= l.nextToken(); + if (t.getType() == IToken.tIDENTIFIER) { + guard= t.getCharImage(); + } + break; + case IPreprocessorDirective.ppIf: + // #if !defined GUARD + // #if ((!((defined (GUARD))))) + guard = findNotDefined(l); + break; + } + if (guard != null) { + // #define GUARD + l.consumeLine(ORIGIN_PREPROCESSOR_DIRECTIVE); + if (skipAll(l, Lexer.tNEWLINE).getType() == IToken.tPOUND + && checkToken(l.nextToken(), Keywords.cDEFINE) + && checkToken(l.nextToken(), guard)) { + l.consumeLine(ORIGIN_PREPROCESSOR_DIRECTIVE); + return guard; + } + } + } + } + } catch (OffsetLimitReachedException e) { + } + return null; + } + + private static char[] findNotDefined(Lexer l) throws OffsetLimitReachedException { + Token t; + if (skipAll(l, IToken.tLPAREN).getType() == IToken.tNOT + && checkToken(skipAll(l, IToken.tLPAREN), Keywords.cDEFINED)) { + t= l.nextToken(); // only a single parenthesis is allowed + if (t.getType() == IToken.tLPAREN) + t= l.nextToken(); + if (t.getType() == IToken.tIDENTIFIER) { + char[] guard= t.getCharImage(); + if (skipAll(l, IToken.tRPAREN).getType() == Lexer.tNEWLINE) + return guard; + } + } + return null; + } + + private static boolean checkToken(Token t, char[] image) throws OffsetLimitReachedException { + return CharArrayUtils.equals(t.getCharImage(), image); + } + + private static boolean currentIfSpansFile(Lexer l, CharArrayIntMap ppKeywords) { + // Check if the #ifndef spans the entire file + try { + int nesting= 1; + while (nesting > 0) { + Token t= l.nextDirective(); + if (t.getType() == IToken.tEND_OF_INPUT) + return true; + switch(ppKeywords.get(l.nextToken().getCharImage())) { + case IPreprocessorDirective.ppIf: + case IPreprocessorDirective.ppIfdef: + case IPreprocessorDirective.ppIfndef: + nesting++; + break; + case IPreprocessorDirective.ppEndif: + nesting--; + break; + } + } + l.consumeLine(ORIGIN_PREPROCESSOR_DIRECTIVE); + return skipAll(l, Lexer.tNEWLINE).getType() == IToken.tEND_OF_INPUT; + } catch (OffsetLimitReachedException e) { + } + return true; + } + + private static Token skipAll(Lexer l, int kind) throws OffsetLimitReachedException { + // Skip empty lines + Token t= l.nextToken(); + while (t.getType() == kind) + t= l.nextToken(); + return t; + } + + + public static boolean detectIncludeEndif(Lexer l) { + l.saveState(); + try { + return findIncludeEndif(l); + } catch (OffsetLimitReachedException e) { + } finally { + l.restoreState(); + } + return false; + } + + private static boolean findIncludeEndif(Lexer l) throws OffsetLimitReachedException { + if (skipAll(l, Lexer.tNEWLINE).getType() != IToken.tPOUND) + return false; + if (!checkToken(l.nextToken(), Keywords.cINCLUDE)) + return false; + l.consumeLine(ORIGIN_PREPROCESSOR_DIRECTIVE); + if (skipAll(l, Lexer.tNEWLINE).getType() != IToken.tPOUND) + return false; + if (!checkToken(l.nextToken(), Keywords.cENDIF)) + return false; + + return true; + } + + public static char[] detectIfNotDefinedIncludeEndif(Lexer l) { + l.saveState(); + try { + char[] guard= findNotDefined(l); + if (guard != null && findIncludeEndif(l)) + return guard; + } catch (OffsetLimitReachedException e) { + } finally { + l.restoreState(); + } + return null; + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContent.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContent.java index ccfacf5ece7..56534886481 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContent.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContent.java @@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective; import org.eclipse.cdt.core.index.IIndexFile; import org.eclipse.cdt.core.index.IIndexMacro; import org.eclipse.cdt.core.parser.FileContent; +import org.eclipse.cdt.core.parser.ISignificantMacros; /** * Instructs the preprocessor on how to handle a file-inclusion. @@ -38,11 +39,21 @@ public class InternalFileContent extends FileContent { USE_SOURCE } + public static class FileVersion { + public final String fPath; + public final ISignificantMacros fSigMacros; + public FileVersion(String path, ISignificantMacros sig) { + fPath= path; + fSigMacros= sig; + } + } + private final InclusionKind fKind; private final AbstractCharArray fSource; private final List fMacroDefinitions; private final List fUsingDirectives; private final String fFileLocation; + private final List fNonPragmaOnceFiles; private boolean fHeuristic; private boolean fIsSource= false; private List fFiles; @@ -64,6 +75,7 @@ public class InternalFileContent extends FileContent { fMacroDefinitions= null; fUsingDirectives= null; fSource= null; + fNonPragmaOnceFiles= null; } /** @@ -79,6 +91,7 @@ public class InternalFileContent extends FileContent { fSource= content; fMacroDefinitions= null; fUsingDirectives= null; + fNonPragmaOnceFiles= null; if (fFileLocation == null) { throw new IllegalArgumentException(); } @@ -92,13 +105,14 @@ public class InternalFileContent extends FileContent { * @throws IllegalArgumentException in case the fileLocation or the macroDefinitions are null. */ public InternalFileContent(String fileLocation, List macroDefinitions, List usingDirectives, - List files) { + List files, List nonPragmaOnceVersions) { fKind= InclusionKind.FOUND_IN_INDEX; fFileLocation= fileLocation; fSource= null; fUsingDirectives= usingDirectives; fMacroDefinitions= macroDefinitions; fFiles= files; + fNonPragmaOnceFiles= nonPragmaOnceVersions; } /** @@ -155,6 +169,10 @@ public class InternalFileContent extends FileContent { public List getFilesIncluded() { return fFiles; } + + public List getNonPragmaOnceVersions() { + return fNonPragmaOnceFiles; + } /** * Returns whether this inclusion was found by a heuristics. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContentProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContentProvider.java index 17c9e046bd3..82668c6293b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContentProvider.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContentProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2009, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,14 +7,25 @@ * * Contributors: * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.parser.scanner; import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement; +import org.eclipse.cdt.core.dom.ast.IFileNomination; +import org.eclipse.cdt.core.index.IIndexFile; import org.eclipse.cdt.core.index.IIndexFileLocation; +import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.cdt.core.parser.IncludeFileContentProvider; import org.eclipse.cdt.internal.core.dom.IIncludeFileResolutionHeuristics; +import org.eclipse.cdt.internal.core.parser.IMacroDictionary; import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.InclusionKind; /** @@ -22,20 +33,25 @@ import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.Inclusio */ public abstract class InternalFileContentProvider extends IncludeFileContentProvider { private IIncludeFileResolutionHeuristics fIncludeResolutionHeuristics; + private final Map fPragmaOnce= new HashMap(); + private final Map> fLoadedVersions= new HashMap>(); /** - * Check whether the specified inclusion exists. + * Checks whether the specified inclusion exists. */ public boolean getInclusionExists(String path) { return new File(path).exists(); } /** - * Create an InclusionContent object for the given location. - * return an inclusion content or null if the location does not exist. + * Creates an InclusionContent object for the given location. + * @param filePath the absolute location of the file. + * @param macroDictionary macros defined at the inclusion point. + * @return Returns an inclusion content, or null if the location does not exist. * @see InternalFileContent */ - public abstract InternalFileContent getContentForInclusion(String path); + public abstract InternalFileContent getContentForInclusion(String filePath, + IMacroDictionary macroDictionary); /** * Called only when used as a delegate of the index file content provider. @@ -46,28 +62,38 @@ public abstract class InternalFileContentProvider extends IncludeFileContentProv * Returns a file-content object of kind {@link InclusionKind#FOUND_IN_INDEX}, representing * the content from the context of the given file up to where the file actually gets included, * or null if this cannot be done. + * @param filePath the absolute location of the file. + * @param macroDictionary macros defined at the inclusion point. */ - public InternalFileContent getContentForContextToHeaderGap(String location) { + public InternalFileContent getContentForContextToHeaderGap(String filePath, + IMacroDictionary macroDictionary) { return null; } - /** - * Reports the path of the translation unit, such that it is known as included. - */ - public void reportTranslationUnitFile(String filePath) { + public void resetForTranslationUnit() { + fPragmaOnce.clear(); + fLoadedVersions.clear(); } - - /** - * Returns whether or not the file has been included, or null if the content provider - * does not track that. + + /** + * Reports detection of pragma once semantics. */ - public Boolean hasFileBeenIncludedInCurrentTranslationUnit(String location) { - return null; + public void reportPragmaOnceSemantics(String file, IFileNomination nomination) { + fPragmaOnce.put(file, nomination); } /** - * Returns a strategy for heuristically resolving includes, or null if this shall not - * be done. + * Returns {@link IASTPreprocessorIncludeStatement} or {@link IIndexFile}, in + * case the file has been included using pragma once semantics, + * or null otherwise. + */ + public IFileNomination isIncludedWithPragmaOnceSemantics(String filePath) { + return fPragmaOnce.get(filePath); + } + + /** + * Returns a strategy for heuristically resolving includes, or null if this shall + * not be done. */ public final IIncludeFileResolutionHeuristics getIncludeHeuristics() { return fIncludeResolutionHeuristics; @@ -76,4 +102,26 @@ public abstract class InternalFileContentProvider extends IncludeFileContentProv public final void setIncludeResolutionHeuristics(IIncludeFileResolutionHeuristics heuristics) { fIncludeResolutionHeuristics= heuristics; } + + public List getLoadedVersions(String path) { + List result = fLoadedVersions.get(path); + return result == null ? Collections.emptyList() : result; + } + + public void addLoadedVersions(String path, int reduceVersions, ISignificantMacros sig) { + List list= fLoadedVersions.get(path); + if (list == null || reduceVersions == 0) { + fLoadedVersions.put(path, Collections.singletonList(sig)); + } else if (!list.contains(sig)) { + if (list.size() == 1) { + ISignificantMacros first = list.get(0); + list= new ArrayList(2); + list.add(first); + fLoadedVersions.put(path, list); + } else if (reduceVersions > 0 && reduceVersions < list.size()) { + list.subList(reduceVersions, list.size()).clear(); + } + list.add(sig); + } + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java index 2bf70b1e2f8..441c2907d1b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java @@ -85,10 +85,14 @@ final public class Lexer implements ITokenSequence { private Token fToken; private Token fLastToken; - // for the few cases where we have to lookahead more than one character + // For the few cases where we have to lookahead more than one character private int fMarkOffset; private int fMarkEndOffset; private int fMarkPrefetchedChar; + // To store the entire state. + private boolean fMarkInsideIncludeDirective; + private Token fMarkToken; + private Token fMarkLastToken; public Lexer(char[] input, LexerOptions options, ILexerLog log, Object source) { this(new CharArray(input), 0, input.length, options, log, source); @@ -1256,4 +1260,22 @@ final public class Lexer implements ITokenSequence { restorePhase3(); return result; } + + public void saveState() { + fMarkOffset= fOffset; + fMarkEndOffset= fEndOffset; + fMarkPrefetchedChar= fCharPhase3; + fMarkInsideIncludeDirective= fInsideIncludeDirective; + fMarkToken= fToken; + fMarkLastToken= fLastToken; + } + + public void restoreState() { + fOffset= fMarkOffset; + fEndOffset= fMarkEndOffset; + fCharPhase3= fMarkPrefetchedChar; + fInsideIncludeDirective= fMarkInsideIncludeDirective; + fToken= fMarkToken; + fLastToken= fMarkLastToken; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationCtxContainer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationCtxContainer.java index 61e76bf99b5..bd4e98ad844 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationCtxContainer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationCtxContainer.java @@ -259,4 +259,9 @@ class LocationCtxContainer extends LocationCtx { } return result; } + + @Override + public String toString() { + return ""; //$NON-NLS-1$ + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationCtxFile.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationCtxFile.java index 8964b2bf755..a33b6195dbc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationCtxFile.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationCtxFile.java @@ -131,4 +131,9 @@ class LocationCtxFile extends LocationCtxContainer { public boolean isSourceFile() { return fIsSource; } + + @Override + public String toString() { + return fFilename; + } } \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationCtxMacroExpansion.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationCtxMacroExpansion.java index ed92105bffc..9e37e56a97f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationCtxMacroExpansion.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationCtxMacroExpansion.java @@ -105,4 +105,9 @@ class LocationCtxMacroExpansion extends LocationCtx { public ASTPreprocessorName[] getNestedMacroReferences() { return fLocationMap.getNestedMacroReferences((ASTMacroExpansion) fExpansionName.getParent()); } + + @Override + public String toString() { + return "Expansion of " + fExpansionName.toString(); //$NON-NLS-1$ + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationMap.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationMap.java index 23141ad545e..1e849f2b4f5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationMap.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationMap.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,8 +30,12 @@ import org.eclipse.cdt.core.dom.ast.IASTProblem; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit.IDependencyTree; import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.IFileNomination; import org.eclipse.cdt.core.dom.ast.IMacroBinding; +import org.eclipse.cdt.core.parser.ISignificantMacros; +import org.eclipse.cdt.core.parser.util.CharArrayObjectMap; import org.eclipse.cdt.core.parser.util.CharArrayUtils; +import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNodeSpecification; import org.eclipse.cdt.internal.core.dom.parser.ASTProblem; import org.eclipse.cdt.internal.core.parser.scanner.Lexer.LexerOptions; @@ -130,7 +134,7 @@ public class LocationMap implements ILocationResolver { int nameEndNumber= getSequenceNumberForOffset(nameEndOffset); int endNumber= getSequenceNumberForOffset(endOffset); final ASTInclusionStatement inclusionStatement= - new ASTInclusionStatement(fTranslationUnit, startNumber, nameNumber, nameEndNumber, endNumber, name, filename, userInclude, true, heuristic); + new ASTInclusionStatement(fTranslationUnit, startNumber, nameNumber, nameEndNumber, endNumber, name, filename, userInclude, true, heuristic, null); fDirectives.add(inclusionStatement); fCurrentContext= new LocationCtxFile((LocationCtxContainer) fCurrentContext, filename, buffer, startOffset, endOffset, endNumber, inclusionStatement, isSource); fLastChildInsertionOffset= 0; @@ -226,14 +230,17 @@ public class LocationMap implements ILocationResolver { * @param userInclude true when specified with double-quotes. * @param active true when include appears in active code. */ - public void encounterPoundInclude(int startOffset, int nameOffset, int nameEndOffset, int endOffset, - char[] name, String filename, boolean userInclude, boolean active, boolean heuristic) { + public ASTInclusionStatement encounterPoundInclude(int startOffset, int nameOffset, int nameEndOffset, int endOffset, + char[] name, String filename, boolean userInclude, boolean active, boolean heuristic, + IFileNomination nominationDelegate) { startOffset= getSequenceNumberForOffset(startOffset); nameOffset= getSequenceNumberForOffset(nameOffset); nameEndOffset= getSequenceNumberForOffset(nameEndOffset); endOffset= getSequenceNumberForOffset(endOffset); - fDirectives.add(new ASTInclusionStatement(fTranslationUnit, startOffset, nameOffset, - nameEndOffset, endOffset, name, filename, userInclude, active, heuristic)); + final ASTInclusionStatement inc = new ASTInclusionStatement(fTranslationUnit, startOffset, nameOffset, + nameEndOffset, endOffset, name, filename, userInclude, active, heuristic, nominationDelegate); + fDirectives.add(inc); + return inc; } public void encounteredComment(int offset, int endOffset, boolean isBlockComment) { @@ -743,10 +750,39 @@ public class LocationMap implements ILocationResolver { } } - public void replacingFile(InternalFileContentProvider fileContentProvider, + public void parsingFile(InternalFileContentProvider fileContentProvider, InternalFileContent fileContent) { for (ISkippedIndexedFilesListener l : fSkippedFilesListeners) { - l.replacingFile(fileContentProvider, fileContent); + l.parsingFile(fileContentProvider, fileContent); } - } + } + + public IFileNomination reportPragmaOnceSemantics(ILocationCtx locationCtx) { + if (locationCtx == fRootContext) { + if (fTranslationUnit != null) { + fTranslationUnit.setPragmaOnceSemantics(true); + } + return fTranslationUnit; + } else if (locationCtx instanceof LocationCtxFile) { + ASTInclusionStatement stmt = ((LocationCtxFile) locationCtx).getInclusionStatement(); + if (stmt != null) { + stmt.setPragamOnceSemantics(true); + } + return stmt; + } + return null; + } + + public void endTranslationUnit(int endOffset, CharArrayObjectMap sigMacros) { + if (fTranslationUnit != null) { + int offset= getSequenceNumberForOffset(endOffset); + ((ASTNode) fTranslationUnit).setLength(offset); + + if (sigMacros != null) { + ISignificantMacros sig = sigMacros.isEmpty() ? ISignificantMacros.NONE + : new SignificantMacros(sigMacros); + fTranslationUnit.setSignificantMacros(sig); + } + } + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/MacroExpander.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/MacroExpander.java index b3a05055682..9667a1ea3cc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/MacroExpander.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/MacroExpander.java @@ -136,6 +136,8 @@ public class MacroExpander { private String fFixedCurrentFilename; private int fFixedLineNumber; private char[] fFixedInput; + private ScannerContext fReportMacros; + private boolean fReportUndefined; public MacroExpander(ILexerLog log, CharArrayMap macroDictionary, LocationMap locationMap, LexerOptions lexOptions) { fDictionary= macroDictionary; @@ -147,8 +149,19 @@ public class MacroExpander { /** * Expects that the identifier has been consumed, stores the result in the list provided. + * @param scannerContext */ - public TokenList expand(ITokenSequence lexer, final boolean isPPCondition, PreprocessorMacro macro, Token identifier, boolean completionMode) throws OffsetLimitReachedException { + public TokenList expand(ITokenSequence lexer, final int ppOptions, + PreprocessorMacro macro, Token identifier, boolean completionMode, + ScannerContext scannerContext) throws OffsetLimitReachedException { + final boolean protectDefined= (ppOptions & CPreprocessor.PROTECT_DEFINED) != 0; + if ((ppOptions & CPreprocessor.REPORT_SIGNIFICANT_MACROS) != 0) { + fReportMacros= scannerContext; + fReportUndefined= (ppOptions & CPreprocessor.IGNORE_UNDEFINED_SIGNIFICANT_MACROS) == 0; + } else { + fReportMacros= null; + } + fImplicitMacroExpansions.clear(); fImageLocationInfos.clear(); @@ -170,7 +183,7 @@ public class MacroExpander { input.prepend(firstExpansion); - result= expandAll(input, forbidden, isPPCondition, null); + result= expandAll(input, forbidden, protectDefined, null); } catch (CompletionInMacroExpansionException e) { // for content assist in macro expansions, we return the list of tokens of the // parameter at the current cursor position and hope that they make sense if @@ -180,6 +193,7 @@ public class MacroExpander { result= e.getParameterTokens().cloneTokens(); } postProcessTokens(result); + fReportMacros= null; return result; } @@ -193,6 +207,7 @@ public class MacroExpander { fFixedInput= beforeExpansion.toCharArray(); fFixedCurrentFilename= filePath; fFixedLineNumber= lineNumber; + fReportMacros= null; Lexer lexer= new Lexer(fFixedInput, fLexOptions, fLog, this); try { @@ -240,6 +255,9 @@ public class MacroExpander { IdentityHashMap forbidden, TokenSource input, TokenList result, MacroExpansionTracker tracker) throws OffsetLimitReachedException { + if (fReportMacros != null) + fReportMacros.significantMacro(macro); + if (macro.isFunctionStyle()) { final int paramCount = macro.getParameterPlaceholderList().length; final TokenSource[] argInputs= new TokenSource[paramCount]; @@ -351,6 +369,13 @@ public class MacroExpander { protect= true; } else if (macro == null || (macro.isFunctionStyle() && !input.findLParenthesis())) { // Tricky: Don't mark function-style macros if you don't find the left parenthesis + if (fReportMacros != null) { + if (macro != null) { + fReportMacros.significantMacro(macro); + } else if (fReportUndefined){ + fReportMacros.significantMacroUndefined(image); + } + } result.append(t); } else if (forbidden.containsKey(macro)) { t.setType(CPreprocessor.tEXPANDED_IDENTIFIER); // prevent any further expansion diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/MultiMacroExpansionExplorer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/MultiMacroExpansionExplorer.java index a307d673c4b..89deea45e9e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/MultiMacroExpansionExplorer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/MultiMacroExpansionExplorer.java @@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNodeSelector; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorElifStatement; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfStatement; +import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroExpansion; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; @@ -48,13 +49,14 @@ public class MultiMacroExpansionExplorer extends MacroExpansionExplorer { fOffset= offset; fLength= length; } - public int getNodeOffset() {return fOffset;} - public int getNodeLength() {return fLength;} - public String getFileName() {return fFilePath;} + public int getNodeOffset() { return fOffset; } + public int getNodeLength() { return fLength; } + public String getFileName() { return fFilePath; } - public int getStartingLineNumber() {return 0;} - public int getEndingLineNumber() {return 0;} - public IASTFileLocation asFileLocation() {return this;} + public int getStartingLineNumber() { return 0; } + public int getEndingLineNumber() { return 0; } + public IASTFileLocation asFileLocation() { return this; } + public IASTPreprocessorIncludeStatement getContextInclusionStatement() { return null; } } private final char[] fSource; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java index b032956b7d8..256fb07825e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,8 +12,12 @@ package org.eclipse.cdt.internal.core.parser.scanner; import java.util.ArrayList; +import org.eclipse.cdt.core.dom.ast.IMacroBinding; +import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.OffsetLimitReachedException; +import org.eclipse.cdt.core.parser.util.CharArrayObjectMap; +import org.eclipse.cdt.core.parser.util.CharArraySet; /** * Represents part of the input to the preprocessor. This may be a file or the result of a macro expansion. @@ -43,6 +47,7 @@ final class ScannerContext { } private CodeState fInactiveState= CodeState.eSkipInactive; + private final int fDepth; private final ILocationCtx fLocationCtx; private final ScannerContext fParent; private final Lexer fLexer; @@ -51,6 +56,11 @@ final class ScannerContext { private CodeState fCurrentState= CodeState.eActive; private IncludeSearchPathElement fFoundOnPath; private String fFoundViaDirective; + private CharArraySet fInternalModifications; + private CharArrayObjectMap fSignificantMacros; + private boolean fPragmaOnce; + private int fLoadedVersionCount; + /** * @param ctx @@ -60,6 +70,7 @@ final class ScannerContext { fLocationCtx= ctx; fParent= parent; fLexer= lexer; + fDepth = parent == null ? 0 : parent.fDepth+1; } public ScannerContext(ILocationCtx ctx, ScannerContext parent, TokenList tokens) { @@ -87,6 +98,13 @@ final class ScannerContext { return fParent; } + /** + * Returns the depth of this context, equals the number of parents of this context. + */ + public final int getDepth() { + return fDepth; + } + /** * Returns the lexer for this context. */ @@ -297,4 +315,123 @@ final class ScannerContext { fFoundOnPath= foundOnPath; fFoundViaDirective= viaDirective; } + + public void trackSignificantMacros() { + fInternalModifications= new CharArraySet(5); + fSignificantMacros= new CharArrayObjectMap(5); + } + + public void setPragmaOnce(boolean val) { + fPragmaOnce= val; + } + + public boolean isPragmaOnce() { + return fPragmaOnce; + } + + public void internalModification(char[] macroName) { + if (fInternalModifications != null) + fInternalModifications.put(macroName); + } + + public void significantMacro(IMacroBinding macro) { + final char[] macroName= macro.getNameCharArray(); + if (fInternalModifications != null && !fInternalModifications.containsKey(macroName)) { + fSignificantMacros.put(macroName, macro.getExpansion()); + } + } + + public void significantMacroDefined(char[] macroName) { + if (fInternalModifications != null && !fInternalModifications.containsKey(macroName)) { + addSignificantMacroDefined(macroName); + } + } + + private void addSignificantMacroDefined(char[] macroName) { + char[] old= fSignificantMacros.put(macroName, SignificantMacros.DEFINED); + if (old != null && old != SignificantMacros.DEFINED) { + // Put back more detailed condition + fSignificantMacros.put(macroName, old); + } + } + + public void significantMacroUndefined(char[] macroName) { + if (fInternalModifications != null && !fInternalModifications.containsKey(macroName)) { + fSignificantMacros.put(macroName, SignificantMacros.UNDEFINED); + } + } + + public CharArrayObjectMap getSignificantMacros() { + return fSignificantMacros; + } + + public void propagateSignificantMacros() { + if (fInternalModifications == null) + return; + + if (fParent != null) { + final CharArraySet local = fParent.fInternalModifications; + if (local != null) { + final CharArrayObjectMap significant = fParent.fSignificantMacros; + for (int i=0; i as an array of characters and to decode + * it back. + * + * The map is encoded as: + * <number_of_entries>,<key1><value1>...<keyN><valueN>. + *

+ * Each string is encoded as: <number_of_characters>,<characters>. + * A null string is encoded as a single comma. + */ +public class SignificantMacros implements ISignificantMacros { + public static final char[] UNDEFINED = {}; + public static final char[] DEFINED = {}; + private static final int ENCODED_UNDEFINED = Character.MAX_VALUE; + private static final int ENCODED_DEFINED = Character.MAX_VALUE-1; + private static final Comparator SORTER = new Comparator() { + public int compare(Object o1, Object o2) { + return CharArrayUtils.compare((char[])o1, (char[])o2); + } + }; + + private final char[] fEncoded; + private int fHash; + + public SignificantMacros(char[] encoded) { + assert encoded != null; + fEncoded= encoded; + } + + public SignificantMacros(CharArrayObjectMap sigMacros) { + fEncoded= encode(sigMacros); + } + + private char[] encode(CharArrayObjectMap sigMacros) { + StringBuilder buffer= new StringBuilder(); + Object[] keys= sigMacros.keyArray(); + Arrays.sort(keys, SORTER); + for (Object key : keys) { + char[] name= (char[]) key; + char[] value= sigMacros.get(name); + buffer.append((char) name.length).append(name); + if (value == DEFINED) { + buffer.append((char) ENCODED_DEFINED); + } else if (value == UNDEFINED) { + buffer.append((char) ENCODED_UNDEFINED); + } else { + buffer.append((char) value.length).append(value); + } + } + int len= buffer.length(); + char[] result= new char[len]; + buffer.getChars(0, len, result, 0); + return result; + } + + @Override + public int hashCode() { + int h = fHash; + if (h == 0) { + char val[] = fEncoded; + int len = fEncoded.length; + for (int i = 0; i < len; i++) { + h = 31*h + val[i]; + } + fHash = h; + } + return h; + } + + @Override + public boolean equals(Object obj) { + return obj instanceof SignificantMacros + && hashCode() == obj.hashCode() + && CharArrayUtils.equals(fEncoded, ((SignificantMacros) obj).fEncoded); + } + + public boolean accept(IVisitor visitor) { + final char[] encoded = fEncoded; + final int len = encoded.length; + int i= 0; + while (i < len) { + final int len1 = encoded[i++]; + int v= i + len1; + if (v >= len) + break; + + char[] macro= extract(encoded, i, len1); + final int len2 = encoded[v++]; + switch(len2) { + case ENCODED_UNDEFINED: + i= v; + if (!visitor.visitUndefined(macro)) + return false; + break; + case ENCODED_DEFINED: + i= v; + if (!visitor.visitDefined(macro)) + return false; + break; + default: + i= v+len2; + if (i > len) + break; + if (!visitor.visitValue(macro, extract(encoded, v, len2))) + return false; + break; + } + } + return true; + } + + public char[] extract(final char[] source, int from, final int length) { + char[] value= new char[length]; + System.arraycopy(source, from, value, 0, length); + return value; + } + + public char[] encode() { + return fEncoded; + } + + /** + * For debugging purposes. + */ + @SuppressWarnings("nls") + @Override + public String toString() { + final StringBuilder buf= new StringBuilder(); + buf.append('{'); + accept(new IVisitor() { + public boolean visitValue(char[] macro, char[] value) { + buf.append(macro).append('=').append(value).append(','); + return true; + } + public boolean visitUndefined(char[] macro) { + buf.append(macro).append('=').append("null,"); + return true; + } + public boolean visitDefined(char[] macro) { + buf.append(macro).append('=').append("*,"); + return true; + } + }); + int buflen = buf.length(); + if (buflen > 1) + buf.setLength(buflen-1); + buf.append('}'); + return buf.toString(); + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java index 52c0ed51bdc..6f69f48146a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java @@ -15,19 +15,18 @@ package org.eclipse.cdt.internal.core.pdom; import java.lang.reflect.InvocationTargetException; import java.net.URI; import java.util.ArrayList; -import java.util.Arrays; +import java.util.BitSet; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMIndexerTask; -import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit.IDependencyTree; @@ -42,21 +41,20 @@ import org.eclipse.cdt.core.index.IndexLocationFactory; import org.eclipse.cdt.core.model.AbstractLanguage; import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.parser.FileContent; -import org.eclipse.cdt.core.parser.IExtendedScannerInfo; import org.eclipse.cdt.core.parser.IParserLogService; import org.eclipse.cdt.core.parser.IScannerInfo; +import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.cdt.core.parser.IncludeFileContentProvider; import org.eclipse.cdt.core.parser.ParserUtil; -import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.internal.core.dom.IIncludeFileResolutionHeuristics; +import org.eclipse.cdt.internal.core.index.FileContentKey; import org.eclipse.cdt.internal.core.index.IIndexFragment; import org.eclipse.cdt.internal.core.index.IIndexFragmentFile; import org.eclipse.cdt.internal.core.index.IWritableIndex; import org.eclipse.cdt.internal.core.index.IndexBasedFileContentProvider; +import org.eclipse.cdt.internal.core.parser.IMacroDictionary; import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContentProvider; -import org.eclipse.cdt.internal.core.parser.scanner.StreamHasher; import org.eclipse.cdt.utils.EFSExtensionManager; -import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -74,55 +72,161 @@ public abstract class AbstractIndexerTask extends PDOMWriter { skip, useDefaultLanguage, useAlternateLanguage, useBoth } private static final int MAX_ERRORS = 500; - - private static class FileKey { - final URI fUri; + + private static enum UpdateKind {REQUIRED_SOURCE, REQUIRED_HEADER, OTHER_HEADER} + private static class LinkageTask { final int fLinkageID; + private final Map fLocationTasks; - public FileKey(int linkageID, URI uri) { - fUri= uri; + LinkageTask(int linkageID) { fLinkageID= linkageID; + fLocationTasks= new HashMap(); + } + + boolean requestUpdate(IIndexFileLocation ifl, IIndexFragmentFile ifile, Object tu, + UpdateKind kind) { + LocationTask locTask= fLocationTasks.get(ifl); + if (locTask == null) { + locTask= new LocationTask(); + fLocationTasks.put(ifl, locTask); + } + return locTask.requestUpdate(ifile, tu, kind); } - @Override - public int hashCode() { - return fUri.hashCode() * 31 + fLinkageID; - } - - @Override - public boolean equals(Object obj) { - FileKey other = (FileKey) obj; - return fLinkageID == other.fLinkageID && fUri.equals(other.fUri); + LocationTask find(IIndexFileLocation ifl) { + return fLocationTasks.get(ifl); } } + private static class LocationTask { + private boolean fCountedUnknownVersion; + private boolean fStoredAVersion; + Object fTu; + UpdateKind fKind= UpdateKind.OTHER_HEADER; + private List fVersionTasks= Collections.emptyList(); + + /** + * Requests the update of a file, returns whether the total count needs to be updated. + */ + boolean requestUpdate(IIndexFragmentFile ifile, Object tu, UpdateKind kind) { + if (tu != null) + fTu= tu; + if (kind != null) + fKind= kind; + + if (ifile == null) { + assert fVersionTasks.isEmpty(); + final boolean countRequest= !fCountedUnknownVersion; + fCountedUnknownVersion= true; + return countRequest; + } + + return addVersionTask(ifile); + } + + /** + * Return whether the task needs to be counted. + */ + private boolean addVersionTask(IIndexFragmentFile ifile) { + FileVersionTask fc= findVersion(ifile); + if (fc != null) + return false; + + fc= new FileVersionTask(ifile); + boolean countRequest= true; + if (fCountedUnknownVersion) { + fCountedUnknownVersion= false; + countRequest= false; + } + + switch (fVersionTasks.size()) { + case 0: + fVersionTasks= Collections.singletonList(fc); + break; + case 1: + List newList= new ArrayList(2); + newList.add(fVersionTasks.get(0)); + newList.add(fc); + fVersionTasks= newList; + break; + default: + fVersionTasks.add(fc); + break; + } + return countRequest; + } + + void removeVersionTask(Iterator it) { + if (fVersionTasks.size() == 1) { + fVersionTasks= Collections.emptyList(); + } else { + it.remove(); + } + } + + private FileVersionTask findVersion(IIndexFile ifile) { + for (FileVersionTask fc : fVersionTasks) { + if (fc.fIndexFile.equals(ifile)) + return fc; + } + return null; + } + + FileVersionTask findVersion(ISignificantMacros sigMacros) throws CoreException { + for (FileVersionTask fc : fVersionTasks) { + if (sigMacros.equals(fc.fIndexFile.getSignificantMacros())) + return fc; + } + return null; + } + + boolean isCompleted() { + for (FileVersionTask fc : fVersionTasks) { + if (fc.fOutdated) + return false; + } + if (fKind == UpdateKind.OTHER_HEADER) + return true; + + return fStoredAVersion; + } + + public boolean needsVersion() { + if (fKind == UpdateKind.OTHER_HEADER) + return false; + + return !fStoredAVersion; + } + } + + public static class FileVersionTask { + private final IIndexFragmentFile fIndexFile; + private boolean fOutdated; + + FileVersionTask(IIndexFragmentFile file) { + fIndexFile= file; + fOutdated= true; + } + + void setUpdated() { + fOutdated= false; + } + } + public static class IndexFileContent { - private IIndexFile fIndexFile; - private boolean fRequestUpdate; - private boolean fRequestIsCounted= true; - private boolean fIsUpdated; private Object[] fPreprocessingDirectives; private ICPPUsingDirective[] fDirectives; - public IndexFileContent() { - fRequestIsCounted = true; + public IndexFileContent(IIndexFile ifile) throws CoreException { + setPreprocessorDirectives(ifile.getIncludes(), ifile.getMacros()); + setUsingDirectives(ifile.getUsingDirectives()); } public Object[] getPreprocessingDirectives() throws CoreException { - if (fPreprocessingDirectives == null) { - if (fIndexFile == null) - return new Object[0]; - setPreprocessorDirectives(fIndexFile.getIncludes(), fIndexFile.getMacros()); - } return fPreprocessingDirectives; } public ICPPUsingDirective[] getUsingDirectives() throws CoreException { - if (fDirectives == null) { - if (fIndexFile == null) - return ICPPUsingDirective.EMPTY_ARRAY; - setUsingDirectives(fIndexFile.getUsingDirectives()); - } return fDirectives; } @@ -134,11 +238,6 @@ public abstract class AbstractIndexerTask extends PDOMWriter { fDirectives= usingDirectives; } - public void clearCaches() { - fPreprocessingDirectives= null; - fDirectives= null; - } - public static Object[] merge(IIndexInclude[] includes, IIndexMacro[] macros) throws CoreException { Object[] merged= new Object[includes.length + macros.length]; int i= 0; @@ -177,11 +276,12 @@ public abstract class AbstractIndexerTask extends PDOMWriter { private int fUpdateFlags= IIndexManager.UPDATE_ALL; private UnusedHeaderStrategy fIndexHeadersWithoutContext= UnusedHeaderStrategy.useDefaultLanguage; private boolean fIndexFilesWithoutConfiguration= true; - private HashMap fFileInfos= new HashMap(); - + private List fRequestsPerLinkage= new ArrayList(); + private Map fIndexContentCache= new HashMap(); + private Map fIndexFilesCache= new HashMap(); + private Object[] fFilesToUpdate; private List fFilesToRemove = new ArrayList(); - private List fFilesUpFront= new ArrayList(); private int fASTOptions; private int fForceNumberFiles= 0; @@ -197,7 +297,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { */ private final LinkedList fUrgentTasks; boolean fTaskCompleted; - + private IndexerProgress fInfo= new IndexerProgress(); public AbstractIndexerTask(Object[] filesToUpdate, Object[] filesToRemove, IndexerInputAdapter resolver, boolean fastIndexer) { super(resolver); @@ -228,8 +328,8 @@ public abstract class AbstractIndexerTask extends PDOMWriter { fUpdateFlags= flags; } + // TODO(197989) remove public final void setParseUpFront(String[] astFilePaths) { - fFilesUpFront.addAll(Arrays.asList(astFilePaths)); } public final void setForceFirstFiles(int number) { @@ -240,96 +340,122 @@ public abstract class AbstractIndexerTask extends PDOMWriter { fFileSizeLimit= limit; } + /** + * @see IPDOMIndexerTask#acceptUrgentTask(IPDOMIndexerTask) + */ + public synchronized boolean acceptUrgentTask(IPDOMIndexerTask urgentTask) { + if (!(urgentTask instanceof AbstractIndexerTask)) { + return false; + } + AbstractIndexerTask task = (AbstractIndexerTask) urgentTask; + if (task.fIsFastIndexer != fIsFastIndexer || + task.fIndexFilesWithoutConfiguration != fIndexFilesWithoutConfiguration || + (fIndexFilesWithoutConfiguration && task.fIndexHeadersWithoutContext != fIndexHeadersWithoutContext) || + fTaskCompleted) { + // Reject the urgent work since this task is not capable of doing it, or it's too late. + return false; + } + if (task.fFilesToUpdate.length > + (fFilesToUpdate != null ? fFilesToUpdate.length : getProgressInformation().fRequestedFilesCount)) { + // Reject the urgent work since it's too heavy for this task. + return false; + } + fUrgentTasks.add(task); + return true; + } + + private synchronized boolean hasUrgentTasks() { + return !fUrgentTasks.isEmpty(); + } + + /** + * Retrieves the first urgent task from the queue of urgent tasks. + * @return An urgent task, or {@code null} if there are no urgent tasks. + */ + private synchronized AbstractIndexerTask getUrgentTask() { + return fUrgentTasks.poll(); + } + protected abstract IWritableIndex createIndex(); protected abstract IIncludeFileResolutionHeuristics createIncludeHeuristics(); protected abstract IncludeFileContentProvider createReaderFactory(); - protected abstract AbstractLanguage[] getLanguages(String fileName); - protected ITodoTaskUpdater createTodoTaskUpdater() { return null; } - - protected IScannerInfo createDefaultScannerConfig(int linkageID) { - return new ScannerInfo(); - } - - protected String getASTPathForParsingUpFront() { - return "______"; //$NON-NLS-1$ - } - - private final IASTTranslationUnit createAST(String code, AbstractLanguage lang, IScannerInfo scanInfo, - int options, IProgressMonitor monitor) throws CoreException { - String dummyName= getASTPathForParsingUpFront(); - if (dummyName != null) { - IIndexFileLocation dummyLoc= fResolver.resolveASTPath(dummyName); - setIndexed(lang.getLinkageID(), dummyLoc); - FileContent codeReader= FileContent.create(dummyName, code.toCharArray()); - return createAST(lang, codeReader, scanInfo, options, false, monitor); - } - return null; - } - - - private final IASTTranslationUnit createAST(Object tu, AbstractLanguage language, FileContent codeReader, - IScannerInfo scanInfo, int options, boolean inContext, IProgressMonitor pm) throws CoreException { - if (codeReader == null) { - return null; - } - if (fResolver.isSourceUnit(tu)) { - options |= ILanguage.OPTION_IS_SOURCE_UNIT; - } - return createAST(language, codeReader, scanInfo, options, inContext, pm); - } - - private final IASTTranslationUnit createAST(AbstractLanguage language, FileContent codeReader, - IScannerInfo scanInfo, int options, boolean inContext, IProgressMonitor pm) throws CoreException { - if (fFileSizeLimit > 0 && fResolver.getFileSize(codeReader.getFileLocation()) > fFileSizeLimit) { - if (fShowActivity) { - trace("Indexer: Skipping large file " + codeReader.getFileLocation()); //$NON-NLS-1$ - } - return null; - } - if (fCodeReaderFactory == null) { - InternalFileContentProvider fileContentProvider = createInternalFileContentProvider(); - if (fIsFastIndexer) { - IndexBasedFileContentProvider ibfcp = new IndexBasedFileContentProvider(fIndex, fResolver, - language.getLinkageID(), fileContentProvider, this); - ibfcp.setSupportFillGapFromContextToHeader(inContext); - ibfcp.setFileSizeLimit(fFileSizeLimit); - fCodeReaderFactory= ibfcp; - } else { - fCodeReaderFactory= fileContentProvider; - } - } else if (fIsFastIndexer) { - ((IndexBasedFileContentProvider) fCodeReaderFactory).setLinkage(language.getLinkageID()); - } - fCodeReaderFactory.setIncludeResolutionHeuristics(createIncludeHeuristics()); - try { - IASTTranslationUnit ast= language.getASTTranslationUnit(codeReader, scanInfo, fCodeReaderFactory, - fIndex, options, getLogService()); - if (pm.isCanceled()) { - return null; - } - return ast; - } finally { - if (fIsFastIndexer) { - ((IndexBasedFileContentProvider) fCodeReaderFactory).cleanupAfterTranslationUnit(); - } - } - } - - private InternalFileContentProvider createInternalFileContentProvider() { - final IncludeFileContentProvider fileContentProvider = createReaderFactory(); - if (fileContentProvider instanceof InternalFileContentProvider) - return (InternalFileContentProvider) fileContentProvider; - throw new IllegalArgumentException("Invalid file content provider"); //$NON-NLS-1$ + /** + * @return array of linkage IDs that shall be parsed + */ + protected int[] getLinkagesToParse() { + return PDOMManager.IDS_FOR_LINKAGES_TO_INDEX; } protected IParserLogService getLogService() { return ParserUtil.getParserLogService(); } + protected void logError(IStatus s) { + CCorePlugin.log(s); + } + + protected void logException(Throwable e) { + CCorePlugin.log(e); + } + + protected String getMessage(MessageKind kind, Object... arguments) { + switch (kind) { + case parsingFileTask: + return NLS.bind(Messages.AbstractIndexerTask_parsingFileTask, arguments); + case errorWhileParsing: + return NLS.bind(Messages.AbstractIndexerTask_errorWhileParsing, arguments); + case tooManyIndexProblems: + return Messages.AbstractIndexerTask_tooManyIndexProblems; + } + return null; + } + + /** + * Makes a copy of the current progress information and returns it. + * @since 4.0 + */ + public IndexerProgress getProgressInformation() { + synchronized (fInfo) { + return new IndexerProgress(fInfo); + } + } + + /** + * Updates current progress information with the provided delta. + */ + private final void updateFileCount(int sources, int primaryHeader, int header) { + synchronized (fInfo) { + fInfo.fCompletedSources += sources; + fInfo.fPrimaryHeaderCount += primaryHeader; + fInfo.fCompletedHeaders += header; + } + } + + private final void reportFile(boolean wasCounted, UpdateKind kind) { + if (wasCounted) { + if (kind == UpdateKind.REQUIRED_SOURCE) { + updateFileCount(1, 0, 0); + } else { + updateFileCount(0, 1, 1); + } + } else { + updateFileCount(0, 0, 1); + } + } + + /** + * Updates current progress information with the provided delta. + */ + private final void incrementRequestedFilesCount(int delta) { + synchronized (fInfo) { + fInfo.fRequestedFilesCount += delta; + } + } + public final void runTask(IProgressMonitor monitor) throws InterruptedException { try { if (!fIndexFilesWithoutConfiguration) { @@ -354,7 +480,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { try { try { // Split into sources and headers, remove excluded sources. - HashMap> files= new HashMap>(); + HashMap> files= new HashMap>(); final ArrayList indexFilesToRemove= new ArrayList(); extractFiles(files, indexFilesToRemove, monitor); @@ -362,13 +488,16 @@ public abstract class AbstractIndexerTask extends PDOMWriter { // Remove files from index removeFilesInIndex(fFilesToRemove, indexFilesToRemove, monitor); - - parseFilesUpFront(monitor); - HashMap> moreFiles= null; + HashMap> moreFiles= null; while (true) { for (int linkageID : getLinkagesToParse()) { - parseLinkage(linkageID, files, monitor); + final List filesForLinkage = files.get(linkageID); + if (filesForLinkage != null) { + parseLinkage(linkageID, filesForLinkage, monitor); + fIndexContentCache.clear(); + fIndexFilesCache.clear(); + } if (hasUrgentTasks()) break; } @@ -390,8 +519,8 @@ public abstract class AbstractIndexerTask extends PDOMWriter { if (moreFiles == null) { moreFiles = files; } else { - for (Map.Entry> entry : files.entrySet()) { - List list= moreFiles.get(entry.getKey()); + for (Map.Entry> entry : files.entrySet()) { + List list= moreFiles.get(entry.getKey()); if (list == null) { moreFiles.put(entry.getKey(), entry.getValue()); } else { @@ -400,7 +529,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } } // Extract files from the urgent task. - files = new HashMap>(); + files = new HashMap>(); fFilesToUpdate = urgentTask.fFilesToUpdate; fForceNumberFiles = urgentTask.fForceNumberFiles; fFilesToRemove = urgentTask.fFilesToRemove; @@ -427,49 +556,24 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } } - /** - * @see IPDOMIndexerTask#acceptUrgentTask(IPDOMIndexerTask) - */ - public synchronized boolean acceptUrgentTask(IPDOMIndexerTask urgentTask) { - if (!(urgentTask instanceof AbstractIndexerTask)) { - return false; - } - AbstractIndexerTask task = (AbstractIndexerTask) urgentTask; - if (!task.fFilesUpFront.isEmpty() || - task.fIsFastIndexer != fIsFastIndexer || - task.fIndexFilesWithoutConfiguration != fIndexFilesWithoutConfiguration || - (fIndexFilesWithoutConfiguration && task.fIndexHeadersWithoutContext != fIndexHeadersWithoutContext) || - fTaskCompleted) { - // Reject the urgent work since this task is not capable of doing it, or it's too late. - return false; - } - if (task.fFilesToUpdate.length > - (fFilesToUpdate != null ? fFilesToUpdate.length : getProgressInformation().fRequestedFilesCount)) { - // Reject the urgent work since it's too heavy for this task. - return false; - } - fUrgentTasks.add(task); - return true; - } - private void setResume(boolean value) throws InterruptedException, CoreException { - fIndex.acquireWriteLock(1); + fIndex.acquireWriteLock(); try { fIndex.getWritableFragment().setProperty(IIndexFragment.PROPERTY_RESUME_INDEXER, String.valueOf(value)); } finally { - fIndex.releaseWriteLock(1); + fIndex.releaseWriteLock(); } } - private void extractFiles(HashMap> files, List iFilesToRemove, + private void extractFiles(HashMap> files, List iFilesToRemove, IProgressMonitor monitor) throws CoreException { final boolean forceAll= (fUpdateFlags & IIndexManager.UPDATE_ALL) != 0; final boolean checkTimestamps= (fUpdateFlags & IIndexManager.UPDATE_CHECK_TIMESTAMPS) != 0; final boolean checkFileContentsHash = (fUpdateFlags & IIndexManager.UPDATE_CHECK_CONTENTS_HASH) != 0; - final boolean checkConfig= (fUpdateFlags & IIndexManager.UPDATE_CHECK_CONFIGURATION) != 0; int count= 0; int forceFirst= fForceNumberFiles; + BitSet linkages= new BitSet(); for (final Object tu : fFilesToUpdate) { if (monitor.isCanceled()) return; @@ -480,39 +584,35 @@ public abstract class AbstractIndexerTask extends PDOMWriter { continue; final IIndexFragmentFile[] indexFiles= fIndex.getWritableFiles(ifl); - if (!fResolver.isIndexedOnlyIfIncluded(tu)) { - final boolean isSourceUnit= fResolver.isSourceUnit(tu); - final boolean isExcludedSource= isSourceUnit && !fIndexFilesWithoutConfiguration && !fResolver.isFileBuildConfigured(tu); - - if ((isSourceUnit && !isExcludedSource) || fIndexHeadersWithoutContext != UnusedHeaderStrategy.skip || - fResolver.isIndexedUnconditionally(ifl)) { - // Headers or sources required with a specific linkage - AbstractLanguage[] langs= fResolver.getLanguages(tu, fIndexHeadersWithoutContext == UnusedHeaderStrategy.useBoth); - for (AbstractLanguage lang : langs) { - int linkageID = lang.getLinkageID(); - IIndexFragmentFile ifile= getFile(linkageID, indexFiles); - if (ifile == null || !ifile.hasContent()) { - store(tu, linkageID, isSourceUnit, files); - requestUpdate(linkageID, ifl, null); - count++; - } else { - takeFile(ifile, indexFiles); - boolean update= false; - if (checkConfig) { - update= isSourceUnit ? isSourceUnitConfigChange(tu, ifile) : isHeaderConfigChange(tu, ifile); - } - update= update || force || isModified(checkTimestamps, checkFileContentsHash, ifl, tu, ifile); - if (update) { - requestUpdate(linkageID, ifl, ifile); - store(tu, linkageID, isSourceUnit, files); + final boolean isSourceUnit= fResolver.isSourceUnit(tu); + linkages.clear(); + if (isRequiredInIndex(tu, ifl, isSourceUnit)) { + // Headers or sources required with a specific linkage + final UpdateKind updateKind = isSourceUnit ? UpdateKind.REQUIRED_SOURCE : UpdateKind.REQUIRED_HEADER; + AbstractLanguage[] langs= fResolver.getLanguages(tu, fIndexHeadersWithoutContext == UnusedHeaderStrategy.useBoth); + for (AbstractLanguage lang : langs) { + int linkageID = lang.getLinkageID(); + boolean foundInLinkage = false; + for (int i = 0; i < indexFiles.length; i++) { + IIndexFragmentFile ifile = indexFiles[i]; + if (ifile != null && ifile.getLinkageID() == linkageID && ifile.hasContent()) { + foundInLinkage = true; + indexFiles[i]= null; // Take the file. + boolean update= force || isModified(checkTimestamps, checkFileContentsHash, ifl, tu, ifile); + if (update && requestUpdate(linkageID, ifl, ifile, tu, updateKind)) { count++; + linkages.set(linkageID); } } } + if (!foundInLinkage && requestUpdate(linkageID, ifl, null, tu, updateKind)) { + linkages.set(linkageID); + count++; + } } } - // handle other files present in index + // Handle other files present in index. for (IIndexFragmentFile ifile : indexFiles) { if (ifile != null) { IIndexInclude ctx= ifile.getParsedInContext(); @@ -520,20 +620,18 @@ public abstract class AbstractIndexerTask extends PDOMWriter { iFilesToRemove.add(ifile); count++; } else { - boolean update= false; - if (checkConfig) { - update= isHeaderConfigChange(tu, ifile); - } - update= update || force || isModified(checkTimestamps, checkFileContentsHash, ifl, tu, ifile); - if (update) { - final int linkageID = ifile.getLinkageID(); - requestUpdate(linkageID, ifl, ifile); - store(tu, linkageID, false, files); + boolean update= force || isModified(checkTimestamps, checkFileContentsHash, ifl, tu, ifile); + final int linkageID = ifile.getLinkageID(); + if (update && requestUpdate(linkageID, ifl, ifile, tu, UpdateKind.OTHER_HEADER)) { count++; + linkages.set(linkageID); } } } } + for (int lid = linkages.nextSetBit(0); lid >= 0; lid= linkages.nextSetBit(lid+1)) { + addPerLinkage(lid, ifl, files); + } } synchronized (this) { incrementRequestedFilesCount(count - fFilesToUpdate.length); @@ -541,6 +639,36 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } } + private void addPerLinkage(int linkageID, IIndexFileLocation ifl, HashMap> files) { + List list= files.get(linkageID); + if (list == null) { + list= new LinkedList(); + files.put(linkageID, list); + } + list.add(ifl); + } + + private boolean isRequiredInIndex(Object tu, IIndexFileLocation ifl, boolean isSourceUnit) { + // External files are never required + if (fResolver.isIndexedOnlyIfIncluded(tu)) + return false; + + // User preference to require all + if (fIndexHeadersWithoutContext != UnusedHeaderStrategy.skip) + return true; + + // File required because it is open in the editor. + if (fResolver.isIndexedUnconditionally(ifl)) + return true; + + // Source file + if (isSourceUnit) { + if (fIndexFilesWithoutConfiguration || fResolver.isFileBuildConfigured(tu)) + return true; + } + return false; + } + private boolean isModified(boolean checkTimestamps, boolean checkFileContentsHash, IIndexFileLocation ifl, Object tu, IIndexFragmentFile file) throws CoreException { if (checkTimestamps) { @@ -555,84 +683,64 @@ public abstract class AbstractIndexerTask extends PDOMWriter { return false; } - private void requestUpdate(int linkageID, IIndexFileLocation ifl, IIndexFragmentFile ifile) { - FileKey key= new FileKey(linkageID, ifl.getURI()); - IndexFileContent info= fFileInfos.get(key); - if (info == null) { - info= createFileInfo(key, null); - } - info.fIndexFile= ifile; - info.fRequestUpdate= true; - info.fIsUpdated= false; + private long computeFileContentsHash(Object tu) { + FileContent codeReader= fResolver.getCodeReader(tu); + return codeReader != null ? codeReader.getContentsHash() : 0; + } + + private boolean requestUpdate(int linkageID, IIndexFileLocation ifl, IIndexFragmentFile ifile, Object tu, UpdateKind kind) { + LinkageTask fileMap= createRequestMap(linkageID); + return fileMap.requestUpdate(ifl, ifile, tu, kind); } - private void setIndexed(int linkageID, IIndexFileLocation ifl) { - FileKey key= new FileKey(linkageID, ifl.getURI()); - IndexFileContent info= fFileInfos.get(key); - if (info == null) { - info= createFileInfo(key, null); + private LinkageTask createRequestMap(int linkageID) { + LinkageTask map= findRequestMap(linkageID); + if (map == null) { + map= new LinkageTask(linkageID); + fRequestsPerLinkage.add(map); } - info.fIsUpdated= true; - info.clearCaches(); + return map; } - private IndexFileContent createFileInfo(FileKey key, IIndexFile ifile) { - IndexFileContent info = new IndexFileContent(); - fFileInfos.put(key, info); - info.fIndexFile= ifile; - return info; - } - - private IndexFileContent getFileInfo(int linkageID, IIndexFileLocation ifl) { - FileKey key= new FileKey(linkageID, ifl.getURI()); - return fFileInfos.get(key); - } - - private boolean isSourceUnitConfigChange(Object tu, IIndexFragmentFile ifile) { - return false; - } - - private boolean isHeaderConfigChange(Object tu, IIndexFragmentFile ifile) { - return false; - } - - private IIndexFragmentFile getFile(int linkageID, IIndexFragmentFile[] indexFiles) throws CoreException { - for (IIndexFragmentFile ifile : indexFiles) { - if (ifile != null && ifile.getLinkageID() == linkageID) { - return ifile; - } + private LinkageTask findRequestMap(int linkageID) { + for (LinkageTask map : fRequestsPerLinkage) { + if (map.fLinkageID == linkageID) + return map; } return null; } - - private void takeFile(IIndexFragmentFile ifile, IIndexFragmentFile[] indexFiles) { - for (int i = 0; i < indexFiles.length; i++) { - if (indexFiles[i] == ifile) { - indexFiles[i]= null; - return; + + @Override + protected void reportFileWrittenToIndex(FileInAST file, IIndexFragmentFile ifile) throws CoreException { + final FileContentKey fck = file.fFileContentKey; + boolean wasCounted= false; + UpdateKind kind= UpdateKind.OTHER_HEADER; + LinkageTask map = findRequestMap(fck.getLinkageID()); + if (map != null) { + LocationTask locTask = map.find(fck.getLocation()); + if (locTask != null) { + kind= locTask.fKind; + FileVersionTask v = locTask.findVersion(ifile); + if (v != null) { + wasCounted= v.fOutdated; + v.setUpdated(); + } else { + // We have added a version, the request is fulfilled. + wasCounted= locTask.fCountedUnknownVersion; + locTask.fCountedUnknownVersion= false; + } + locTask.fStoredAVersion= true; } } - } - - private void store(Object tu, int linkageID, boolean isSourceUnit, HashMap> files) { - Integer key = getFileListKey(linkageID, isSourceUnit); - List list= files.get(key); - if (list == null) { - list= new LinkedList(); - files.put(key, list); - } - list.add(tu); - } - - private Integer getFileListKey(int linkageID, boolean isSourceUnit) { - Integer key= new Integer(linkageID * 2 + (isSourceUnit ? 0 : 1)); - return key; + fIndexContentCache.remove(ifile); + fIndexFilesCache.remove(file.fFileContentKey.getLocation()); + reportFile(wasCounted, kind); } private void removeFilesInIndex(List filesToRemove, List indexFilesToRemove, IProgressMonitor monitor) throws InterruptedException, CoreException { if (!filesToRemove.isEmpty() || !indexFilesToRemove.isEmpty()) { - fIndex.acquireWriteLock(1); + fIndex.acquireWriteLock(); try { for (Object tu : filesToRemove) { if (monitor.isCanceled()) { @@ -643,7 +751,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { continue; IIndexFragmentFile[] ifiles= fIndex.getWritableFiles(ifl); for (IIndexFragmentFile ifile : ifiles) { - fIndex.clearFile(ifile, null); + fIndex.clearFile(ifile); } incrementRequestedFilesCount(-1); } @@ -651,205 +759,182 @@ public abstract class AbstractIndexerTask extends PDOMWriter { if (monitor.isCanceled()) { return; } - fIndex.clearFile(ifile, null); + fIndex.clearFile(ifile); incrementRequestedFilesCount(-1); } } finally { - fIndex.releaseWriteLock(1); + fIndex.releaseWriteLock(); } } filesToRemove.clear(); } - private void parseFilesUpFront(IProgressMonitor monitor) throws CoreException { - for (String upfront : fFilesUpFront) { - if (monitor.isCanceled()) { - return; - } - String filePath = upfront; - filePath= filePath.trim(); - if (filePath.length() == 0) { - continue; - } - final IPath path= new Path(filePath); - final String fileName = path.lastSegment(); - try { - monitor.subTask(getMessage(MessageKind.parsingFileTask, - fileName, path.removeLastSegments(1).toString())); - - AbstractLanguage[] langs= getLanguages(fileName); - for (AbstractLanguage lang : langs) { - if (fShowActivity) { - trace("Indexer: " + lang.getName() + ": Parsing " + filePath + " up front"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - int linkageID= lang.getLinkageID(); - String code= "#include \"" + filePath + "\"\n"; //$NON-NLS-1$ //$NON-NLS-2$ - - IScannerInfo scanInfo= createDefaultScannerConfig(linkageID); - if (scanInfo != null) { - long start= System.currentTimeMillis(); - IASTTranslationUnit ast= createAST(code, lang, scanInfo, fASTOptions, monitor); - fStatistics.fParsingTime += System.currentTimeMillis() - start; - if (ast != null) { - if (fShowActivity || fShowInclusionProblems) { - IASTNode node= ast.getNodeSelector(null).findEnclosingNode(0,6); - if (node instanceof IASTPreprocessorIncludeStatement) { - IASTPreprocessorIncludeStatement p= (IASTPreprocessorIncludeStatement) node; - String found= p.getPath(); - if (found != null) { - IIndexFileLocation ifl= fResolver.resolveASTPath(found); - IndexFileContent fileinfo = getFileInfo(linkageID, ifl); - if (fileinfo != null) { - if (fileinfo.fIndexFile != null) { - trace(filePath + " was not properly parsed up front for " + lang.getName()); //$NON-NLS-1$ - } - } - } - } - } - writeToIndex(linkageID, ast, StreamHasher.hash(code), computeHashCode(scanInfo), - monitor); - updateFileCount(0, 0, 1); - } - } - } - } catch (Exception e) { - swallowError(path, e); - } catch (Error e) { - swallowError(path, e); - } - } - fFilesUpFront.clear(); - } - - private void parseLinkage(int linkageID, Map> fileListMap, IProgressMonitor monitor) + private void parseLinkage(int linkageID, List files, IProgressMonitor monitor) throws CoreException, InterruptedException { - // Sources - List files= fileListMap.get(getFileListKey(linkageID, true)); - if (files != null) { - for (Iterator iter = files.iterator(); iter.hasNext();) { - Object tu = iter.next(); + LinkageTask map = findRequestMap(linkageID); + if (map == null || files == null || files.isEmpty()) + return; + + // First parse the required sources + for (Iterator it= files.iterator(); it.hasNext();) { + IIndexFileLocation ifl= it.next(); + LocationTask locTask = map.find(ifl); + if (locTask == null || locTask.isCompleted()) { + it.remove(); + } else if (locTask.fKind == UpdateKind.REQUIRED_SOURCE) { if (monitor.isCanceled() || hasUrgentTasks()) return; - - final IIndexFileLocation ifl = fResolver.resolveFile(tu); - if (ifl != null) { - final IndexFileContent info= getFileInfo(linkageID, ifl); - if (info != null && info.fRequestUpdate && !info.fIsUpdated) { - info.fRequestIsCounted= false; - final IScannerInfo scannerInfo= fResolver.getBuildConfiguration(linkageID, tu); - parseFile(tu, linkageID, ifl, scannerInfo, false, monitor); - if (info.fIsUpdated) { - updateFileCount(1, 0, 0); // a source file was parsed - } - } - } - iter.remove(); + final Object tu = locTask.fTu; + final IScannerInfo scannerInfo= fResolver.getBuildConfiguration(linkageID, tu); + parseFile(tu, linkageID, ifl, scannerInfo, null, monitor); } } - // Headers with context - HashMap contextMap= new HashMap(); - files= fileListMap.get(getFileListKey(linkageID, false)); - if (files != null) { - for (Iterator iter = files.iterator(); iter.hasNext();) { - if (monitor.isCanceled() || hasUrgentTasks()) - return; + // Files with context + for (Iterator it= files.iterator(); it.hasNext();) { + IIndexFileLocation ifl= it.next(); + LocationTask locTask = map.find(ifl); + if (locTask == null || locTask.isCompleted()) { + it.remove(); + } else { + for (FileVersionTask versionTask : locTask.fVersionTasks) { + if (versionTask.fOutdated) { + if (monitor.isCanceled() || hasUrgentTasks()) + return; + parseVersionInContext(linkageID, map, ifl, versionTask, locTask.fTu, + new LinkedHashSet(), monitor); + } + } + } + } + + // Files without context + for (Iterator it= files.iterator(); it.hasNext();) { + IIndexFileLocation ifl= it.next(); + LocationTask locTask = map.find(ifl); + if (locTask == null || locTask.isCompleted()) { + it.remove(); + } else { + if (locTask.needsVersion()) { + if (monitor.isCanceled() || hasUrgentTasks()) + return; + final Object tu = locTask.fTu; + final IScannerInfo scannerInfo= fResolver.getBuildConfiguration(linkageID, tu); + parseFile(tu, linkageID, ifl, scannerInfo, null, monitor); + if (locTask.isCompleted()) + it.remove(); + + } + } + } - final Object header= iter.next(); - final IIndexFileLocation ifl = fResolver.resolveFile(header); - final IndexFileContent info= getFileInfo(linkageID, ifl); - if (info != null && info.fRequestUpdate && !info.fIsUpdated) { - if (info.fIndexFile != null && fIndex.isWritableFile(info.fIndexFile)) { - Object tu= findContext(linkageID, (IIndexFragmentFile) info.fIndexFile, contextMap); - if (tu != null) { - final IScannerInfo scannerInfo= fResolver.getBuildConfiguration(linkageID, tu); - info.fRequestIsCounted= false; - parseFile(header, linkageID, ifl, scannerInfo, true, monitor); - if (info.fIsUpdated) { - updateFileCount(0, 1, 1); // a header was parsed in context - iter.remove(); + // Delete remaining files. + fIndex.acquireWriteLock(); + try { + for (IIndexFileLocation ifl : files) { + LocationTask locTask = map.find(ifl); + if (locTask != null && !locTask.isCompleted()) { + if (!locTask.needsVersion()) { + if (monitor.isCanceled() || hasUrgentTasks()) + return; + Iterator it= locTask.fVersionTasks.iterator(); + while (it.hasNext()) { + FileVersionTask v = it.next(); + if (v.fOutdated) { + fIndex.clearFile(v.fIndexFile); + reportFile(true, locTask.fKind); + locTask.removeVersionTask(it); + fIndexContentCache.remove(v.fIndexFile); + fIndexFilesCache.remove(ifl); } } } - } else { - // The file has been parsed already. - iter.remove(); } } - - // Headers without context - contextMap= null; - for (Iterator iter = files.iterator(); iter.hasNext();) { - if (monitor.isCanceled() || hasUrgentTasks()) - return; - - final Object header= iter.next(); - final IIndexFileLocation ifl = fResolver.resolveFile(header); - final IndexFileContent info= getFileInfo(linkageID, ifl); - if (info != null && info.fRequestUpdate && !info.fIsUpdated) { - info.fRequestIsCounted= false; - final IScannerInfo scannerInfo= fResolver.getBuildConfiguration(linkageID, header); - parseFile(header, linkageID, ifl, scannerInfo, false, monitor); - if (info.fIsUpdated) { - updateFileCount(0, 1, 1); // a header was parsed without context - } - } - iter.remove(); - } + } finally { + fIndex.releaseWriteLock(); } } - private synchronized boolean hasUrgentTasks() { - return !fUrgentTasks.isEmpty(); + private void parseVersionInContext(int linkageID, LinkageTask map, IIndexFileLocation ifl, + final FileVersionTask versionTask, Object tu, LinkedHashSet safeGuard, + IProgressMonitor monitor) throws CoreException, InterruptedException { + final IIndexFragmentFile headerFile = versionTask.fIndexFile; + + final int safeguardSize= safeGuard.size(); + for(;;) { + // Look for a context and parse the file + IIndexFragmentFile ctxFile = findContextFile(linkageID, map, versionTask, safeGuard, monitor); + if (ctxFile == null || ctxFile == headerFile) + return; + + Object contextTu= fResolver.getInputFile(ctxFile.getLocation()); + if (contextTu == null) + return; + + final IScannerInfo scannerInfo= fResolver.getBuildConfiguration(linkageID, contextTu); + FileContext ctx= new FileContext(ctxFile, headerFile); + parseFile(tu, linkageID, ifl, scannerInfo, ctx, monitor); + if (!ctx.fLostPragmaOnceSemantics) + return; + + // Try the next context + restoreSet(safeGuard, safeguardSize); + } } - /** - * Retrieves the first urgent task from the queue of urgent tasks. - * @return An urgent task, or {@code null} if there are no urgent tasks. - */ - private synchronized AbstractIndexerTask getUrgentTask() { - return fUrgentTasks.poll(); - } - - private static final Object NO_CONTEXT= new Object(); - - private Object findContext(int linkageID, IIndexFragmentFile ifile, HashMap contextMap) { - Object cachedContext= contextMap.get(ifile); - if (cachedContext != null) { - return cachedContext == NO_CONTEXT ? null : cachedContext; + private void restoreSet(LinkedHashSet set, int restoreSize) { + for (Iterator it = set.iterator(); it.hasNext();) { + it.next(); + if (restoreSize == 0) { + it.remove(); + } else { + restoreSize--; + } } - try { - Object context= fResolver.getInputFile(ifile.getLocation()); - if (context != null && fResolver.isSourceUnit(context)) { - contextMap.put(ifile, context); - return context; - } + } - contextMap.put(ifile, NO_CONTEXT); // prevent recursion - final IIndexInclude contextInclude= ifile.getParsedInContext(); - if (contextInclude != null) { - // in case we are in context of another file that will be indexed, just wait. - final IndexFileContent info= getFileInfo(linkageID, contextInclude.getIncludedByLocation()); - if (info != null && info.fRequestUpdate) { - return null; - } - final IIndexFragmentFile contextIFile= (IIndexFragmentFile) contextInclude.getIncludedBy(); - context= findContext(linkageID, contextIFile, contextMap); - if (context != null) { - contextMap.put(ifile, context); - return context; + private IIndexFragmentFile findContextFile(int linkageID, LinkageTask map, + final FileVersionTask versionTask, LinkedHashSet safeGuard, IProgressMonitor monitor) + throws CoreException, InterruptedException { + IIndexFragmentFile ctxFile= versionTask.fIndexFile; + for(;;) { + IIndexInclude ctxInclude= ctxFile.getParsedInContext(); + if (ctxInclude == null) + return ctxFile; + + IIndexFragmentFile nextCtx= (IIndexFragmentFile) ctxInclude.getIncludedBy(); + if (!fIndex.isWritableFile(nextCtx)) + return ctxFile; + + // Found a recursion + if (!safeGuard.add(nextCtx)) + return null; + + final IIndexFileLocation ctxIfl = nextCtx.getLocation(); + LocationTask ctxTask= map.find(ctxIfl); + if (ctxTask != null) { + FileVersionTask ctxVersionTask = ctxTask.findVersion(nextCtx); + if (ctxVersionTask != null && ctxVersionTask.fOutdated) { + // Handle the context first. + parseVersionInContext(linkageID, map, ctxIfl, ctxVersionTask, ctxTask.fTu, + safeGuard, monitor); + if (ctxVersionTask.fOutdated // This is unexpected. + || !versionTask.fOutdated) // Our file was parsed. + return null; + + // The file is no longer a context, look for a different one. + nextCtx= ctxFile; } } - } catch (CoreException e) { - CCorePlugin.log(e); + ctxFile= nextCtx; } - return null; } + private void parseFile(Object tu, int linkageID, IIndexFileLocation ifl, IScannerInfo scanInfo, - boolean inContext, IProgressMonitor pm) throws CoreException, InterruptedException { - IPath path= getPathForLabel(ifl); + FileContext ctx, IProgressMonitor pm) throws CoreException, InterruptedException { + IPath path= getLabel(ifl); AbstractLanguage[] langs= fResolver.getLanguages(tu, true); AbstractLanguage lang= null; for (AbstractLanguage lang2 : langs) { @@ -871,10 +956,12 @@ public abstract class AbstractIndexerTask extends PDOMWriter { path.lastSegment(), path.removeLastSegments(1).toString())); long start= System.currentTimeMillis(); FileContent codeReader= fResolver.getCodeReader(tu); - IASTTranslationUnit ast= createAST(tu, lang, codeReader, scanInfo, fASTOptions, inContext, pm); + IIndexFile[] ctxFiles = ctx == null ? null : new IIndexFile[] {ctx.fContext, ctx.fOldFile}; + + IASTTranslationUnit ast= createAST(tu, lang, codeReader, scanInfo, fASTOptions, ctxFiles, pm); fStatistics.fParsingTime += System.currentTimeMillis() - start; if (ast != null) { - writeToIndex(linkageID, ast, codeReader.getContentsHash(), computeHashCode(scanInfo), pm); + writeToIndex(linkageID, ast, codeReader.getContentsHash(), ctx, pm); } } catch (CoreException e) { th= e; @@ -894,80 +981,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } } - private void writeToIndex(final int linkageID, IASTTranslationUnit ast, long fileContentsHash, - int configHash, IProgressMonitor pm) throws CoreException, InterruptedException { - HashSet enteredFiles= new HashSet(); - ArrayList orderedIFLs= new ArrayList(); - - final IIndexFileLocation topIfl = fResolver.resolveASTPath(ast.getFilePath()); - enteredFiles.add(topIfl); - IDependencyTree tree= ast.getDependencyTree(); - IASTInclusionNode[] inclusions= tree.getInclusions(); - for (IASTInclusionNode inclusion : inclusions) { - collectOrderedIFLs(linkageID, inclusion, enteredFiles, orderedIFLs); - } - - IndexFileContent info= getFileInfo(linkageID, topIfl); - if (info != null && info.fRequestUpdate && !info.fIsUpdated) { - orderedIFLs.add(topIfl); - } - - IIndexFileLocation[] ifls= orderedIFLs.toArray(new IIndexFileLocation[orderedIFLs.size()]); - try { - addSymbols(ast, ifls, fIndex, 1, false, fileContentsHash, configHash, fTodoTaskUpdater, pm); - } finally { - // mark as updated in any case, to avoid parsing files that caused an exception to be thrown. - for (IIndexFileLocation ifl : ifls) { - info= getFileInfo(linkageID, ifl); - Assert.isNotNull(info); - info.fIsUpdated= true; - } - } - } - - private void collectOrderedIFLs(final int linkageID, IASTInclusionNode inclusion, - HashSet enteredFiles, ArrayList orderedIFLs) throws CoreException { - final IASTPreprocessorIncludeStatement id= inclusion.getIncludeDirective(); - if (id.isActive() && id.isResolved()) { - final IIndexFileLocation ifl= fResolver.resolveASTPath(id.getPath()); - final boolean isFirstEntry= enteredFiles.add(ifl); - IASTInclusionNode[] nested= inclusion.getNestedInclusions(); - for (IASTInclusionNode element : nested) { - collectOrderedIFLs(linkageID, element, enteredFiles, orderedIFLs); - } - if (isFirstEntry && needToUpdateHeader(linkageID, ifl)) { - orderedIFLs.add(ifl); - } - } - } - - public final boolean needToUpdateHeader(int linkageID, IIndexFileLocation ifl) throws CoreException { - IndexFileContent info= getFileInfo(linkageID, ifl); - if (info == null) { - IIndexFile ifile= null; - if (fResolver.canBePartOfSDK(ifl)) { - ifile= fIndex.getFile(linkageID, ifl); - } else { - IIndexFragmentFile fragFile= fIndex.getWritableFile(linkageID, ifl); - if (fragFile != null && fragFile.hasContent()) { - ifile= fragFile; - } - } - info= createFileInfo(new FileKey(linkageID, ifl.getURI()), ifile); - if (ifile == null) { - info.fRequestIsCounted= false; - info.fRequestUpdate= true; - } - } - final boolean needUpdate= !info.fIsUpdated && info.fRequestUpdate; - if (needUpdate && info.fRequestIsCounted) { - updateFileCount(0, 1, 0); // total headers will be counted when written to db - info.fRequestIsCounted= false; - } - return needUpdate; - } - - private IPath getPathForLabel(IIndexFileLocation ifl) { + private IPath getLabel(IIndexFileLocation ifl) { String fullPath= ifl.getFullPath(); if (fullPath != null) { return new Path(fullPath); @@ -992,7 +1006,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { if (CCorePlugin.PLUGIN_ID.equals(s.getPlugin())) throw (CoreException) e; } - + // mask errors in order to avoid dialog from platform Throwable exception = s.getException(); if (exception != null) { @@ -1021,100 +1035,226 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } return e; } - - protected void logError(IStatus s) { - CCorePlugin.log(s); - } - - protected void logException(Throwable e) { - CCorePlugin.log(e); + + private final IASTTranslationUnit createAST(Object tu, AbstractLanguage language, + FileContent codeReader, IScannerInfo scanInfo, int options, + IIndexFile[] ctx2header, IProgressMonitor pm) throws CoreException { + if (codeReader == null) { + return null; + } + if (fResolver.isSourceUnit(tu)) { + options |= ILanguage.OPTION_IS_SOURCE_UNIT; + } + if (fFileSizeLimit > 0 && fResolver.getFileSize(codeReader.getFileLocation()) > fFileSizeLimit) { + if (fShowActivity) { + trace("Indexer: Skipping large file " + codeReader.getFileLocation()); //$NON-NLS-1$ + } + return null; + } + if (fCodeReaderFactory == null) { + InternalFileContentProvider fileContentProvider = createInternalFileContentProvider(); + if (fIsFastIndexer) { + IndexBasedFileContentProvider ibfcp = new IndexBasedFileContentProvider(fIndex, fResolver, + language.getLinkageID(), fileContentProvider, this); + ibfcp.setContextToHeaderGap(ctx2header); + ibfcp.setFileSizeLimit(fFileSizeLimit); + fCodeReaderFactory= ibfcp; + } else { + fCodeReaderFactory= fileContentProvider; + } + fCodeReaderFactory.setIncludeResolutionHeuristics(createIncludeHeuristics()); + } else if (fIsFastIndexer) { + final IndexBasedFileContentProvider ibfcp = (IndexBasedFileContentProvider) fCodeReaderFactory; + ibfcp.setContextToHeaderGap(ctx2header); + ibfcp.setLinkage(language.getLinkageID()); + } + + IASTTranslationUnit ast= language.getASTTranslationUnit(codeReader, scanInfo, fCodeReaderFactory, + fIndex, options, getLogService()); + if (pm.isCanceled()) { + return null; + } + return ast; } - private static int computeHashCode(IScannerInfo scannerInfo) { - int result= 0; - Map macros= scannerInfo.getDefinedSymbols(); - if (macros != null) { - for (Entry entry : macros.entrySet()) { - String key = entry.getKey(); - String value = entry.getValue(); - result= addToHashcode(result, key); - if (value != null && value.length() > 0) { - result= addToHashcode(result, value); + private InternalFileContentProvider createInternalFileContentProvider() { + final IncludeFileContentProvider fileContentProvider = createReaderFactory(); + if (fileContentProvider instanceof InternalFileContentProvider) + return (InternalFileContentProvider) fileContentProvider; + + throw new IllegalArgumentException("Invalid file content provider"); //$NON-NLS-1$ + } + + private void writeToIndex(final int linkageID, IASTTranslationUnit ast, long fileContentsHash, + FileContext ctx, IProgressMonitor pm) throws CoreException, InterruptedException { + HashSet enteredFiles= new HashSet(); + ArrayList orderedFileKeys= new ArrayList(); + + final IIndexFileLocation topIfl = fResolver.resolveASTPath(ast.getFilePath()); + FileContentKey topKey = new FileContentKey(linkageID, topIfl, ast.getSignificantMacros()); + enteredFiles.add(topKey); + IDependencyTree tree= ast.getDependencyTree(); + IASTInclusionNode[] inclusions= tree.getInclusions(); + for (IASTInclusionNode inclusion : inclusions) { + collectOrderedFileKeys(linkageID, inclusion, enteredFiles, orderedFileKeys); + } + + IIndexFile newFile= selectIndexFile(linkageID, topIfl, ast.getSignificantMacros()); + if (ctx != null) { + orderedFileKeys.add(new FileInAST(null, topKey, fileContentsHash)); + if (newFile != null && fIndex.isWritableFile(newFile)) { + // File can be reused + ctx.fNewFile= (IIndexFragmentFile) newFile; + } + } else if (newFile == null) { + orderedFileKeys.add(new FileInAST(null, topKey, fileContentsHash)); + } + + FileInAST[] fileKeys= orderedFileKeys.toArray(new FileInAST[orderedFileKeys.size()]); + try { + addSymbols(ast, fileKeys, fIndex, false, ctx, fTodoTaskUpdater, pm); + } catch (CoreException e) { + // Avoid parsing files again, that caused an exception to be thrown. + withdrawRequests(linkageID, fileKeys); + throw e; + } catch (RuntimeException e) { + withdrawRequests(linkageID, fileKeys); + throw e; + } catch (Error e) { + withdrawRequests(linkageID, fileKeys); + throw e; + } + } + + private void collectOrderedFileKeys(final int linkageID, IASTInclusionNode inclusion, + HashSet enteredFiles, ArrayList orderedFileKeys) throws CoreException { + final IASTPreprocessorIncludeStatement include= inclusion.getIncludeDirective(); + if (include.createsAST()) { + final IIndexFileLocation ifl= fResolver.resolveASTPath(include.getPath()); + FileContentKey fileKey = new FileContentKey(linkageID, ifl, include.getSignificantMacros()); + final boolean isFirstEntry= enteredFiles.add(fileKey); + IASTInclusionNode[] nested= inclusion.getNestedInclusions(); + for (IASTInclusionNode element : nested) { + collectOrderedFileKeys(linkageID, element, enteredFiles, orderedFileKeys); + } + if (isFirstEntry && selectIndexFile(linkageID, ifl, include.getSignificantMacros()) == null) { + orderedFileKeys.add(new FileInAST(include, fileKey, include.getContentsHash())); + } + } + } + + private void withdrawRequests(int linkageID, FileInAST[] fileKeys) { + LinkageTask map = findRequestMap(linkageID); + if (map != null) { + for (FileInAST fileKey : fileKeys) { + LocationTask locTask = map.find(fileKey.fFileContentKey.getLocation()); + if (locTask != null) { + if (locTask.fCountedUnknownVersion) { + locTask.fCountedUnknownVersion= false; + reportFile(true, locTask.fKind); + } else { + for (FileVersionTask fc : locTask.fVersionTasks) { + if (fc.fOutdated) { + reportFile(true, locTask.fKind); + fc.setUpdated(); + } + } + } } } } - String[] a= scannerInfo.getIncludePaths(); - if (a != null) { - for (String element : a) { - result= addToHashcode(result, element); - - } - } - if (scannerInfo instanceof IExtendedScannerInfo) { - IExtendedScannerInfo esi= (IExtendedScannerInfo) scannerInfo; - a= esi.getIncludeFiles(); - if (a != null) { - for (String element : a) { - result= addToHashcode(result, element); - - } - } - a= esi.getLocalIncludePath(); - if (a != null) { - for (String element : a) { - result= addToHashcode(result, element); - } - } - a= esi.getMacroFiles(); - if (a != null) { - for (String element : a) { - result= addToHashcode(result, element); - } - } - } - return result; } - private static int addToHashcode(int result, String key) { - return result * 31 + key.hashCode(); - } - - private long computeFileContentsHash(Object tu) { - FileContent codeReader= fResolver.getCodeReader(tu); - return codeReader != null ? codeReader.getContentsHash() : 0; - } - - public final IndexFileContent getFileContent(int linkageID, IIndexFileLocation ifl) throws CoreException { - if (!needToUpdateHeader(linkageID, ifl)) { - IndexFileContent info= getFileInfo(linkageID, ifl); - Assert.isNotNull(info); - if (info.fIndexFile == null) { - info.fIndexFile= fIndex.getFile(linkageID, ifl); - if (info.fIndexFile == null) { + public final IndexFileContent getFileContent(int linkageID, IIndexFileLocation ifl, + IIndexFile file) throws CoreException { + LinkageTask map = findRequestMap(linkageID); + if (map != null) { + LocationTask request= map.find(ifl); + if (request != null) { + FileVersionTask task= request.findVersion(file); + if (task != null && task.fOutdated) return null; - } } - return info; } - return null; + IndexFileContent fc= fIndexContentCache.get(file); + if (fc == null) { + fc= new IndexFileContent(file); + fIndexContentCache.put(file, fc); + } + return fc; } - protected String getMessage(MessageKind kind, Object... arguments) { - switch (kind) { - case parsingFileTask: - return NLS.bind(Messages.AbstractIndexerTask_parsingFileTask, arguments); - case errorWhileParsing: - return NLS.bind(Messages.AbstractIndexerTask_errorWhileParsing, arguments); - case tooManyIndexProblems: - return Messages.AbstractIndexerTask_tooManyIndexProblems; + IIndexFile selectIndexFile(int linkageID, IIndexFileLocation ifl, ISignificantMacros sigMacros) throws CoreException { + LinkageTask map = findRequestMap(linkageID); + if (map != null) { + LocationTask locTask= map.find(ifl); + if (locTask != null) { + FileVersionTask task = locTask.findVersion(sigMacros); + if (task != null) { + return task.fOutdated ? null : task.fIndexFile; + } + } + } + + IIndexFile[] files = getAvailableIndexFiles(linkageID, ifl); + for (IIndexFile file : files) { + if (sigMacros.equals(file.getSignificantMacros())) + return file; } return null; } - /** - * @return array of linkage IDs that should be parsed - */ - protected int[] getLinkagesToParse() { - return PDOMManager.IDS_FOR_LINKAGES_TO_INDEX; + public IIndexFile selectIndexFile(int linkageID, IIndexFileLocation ifl, IMacroDictionary md) throws CoreException { + LinkageTask map = findRequestMap(linkageID); + if (map != null) { + LocationTask request= map.find(ifl); + if (request != null) { + for (FileVersionTask fileVersion : request.fVersionTasks) { + final IIndexFile indexFile = fileVersion.fIndexFile; + if (md.satisfies(indexFile.getSignificantMacros())) { + if (fileVersion.fOutdated) + return null; + return indexFile; + } + } + } + } + + IIndexFile[] files = getAvailableIndexFiles(linkageID, ifl); + for (IIndexFile indexFile : files) { + if (md.satisfies(indexFile.getSignificantMacros())) { + return indexFile; + } + } + return null; } -} \ No newline at end of file + + public IIndexFile[] getAvailableIndexFiles(int linkageID, IIndexFileLocation ifl) + throws CoreException { + IIndexFile[] files= fIndexFilesCache.get(ifl); + if (files == null) { + if (fResolver.canBePartOfSDK(ifl)) { + // Check for a version in potentially another pdom. + files= fIndex.getFiles(linkageID, ifl); + } else { + IIndexFragmentFile[] fragFiles = fIndex.getWritableFiles(linkageID, ifl); + int j= 0; + for (int i = 0; i < fragFiles.length; i++) { + if (fragFiles[i].hasContent()) { + if (j != i) + fragFiles[j]= fragFiles[i]; + j++; + } + } + if (j == fragFiles.length) { + files= fragFiles; + } else { + files= new IIndexFile[j]; + System.arraycopy(fragFiles, 0, files, 0, j); + } + } + fIndexFilesCache.put(ifl, files); + } + return files; + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/CModelListener.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/CModelListener.java index 39ccacca4c6..f8fe49eec04 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/CModelListener.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/CModelListener.java @@ -50,6 +50,7 @@ public class CModelListener implements IElementChangedListener, IResourceChangeL fManager= manager; } + @Override public void elementChanged(ElementChangedEvent event) { // Only respond to post change events if (event.getType() != ElementChangedEvent.POST_CHANGE) @@ -151,6 +152,7 @@ public class CModelListener implements IElementChangedListener, IResourceChangeL } } + @Override public void resourceChanged(IResourceChangeEvent event) { if (event.getType() == IResourceChangeEvent.POST_BUILD) { fManager.handlePostBuildEvent(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/CProjectDescriptionListener.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/CProjectDescriptionListener.java index 6f094b46dd5..59d20dca1d9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/CProjectDescriptionListener.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/CProjectDescriptionListener.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ - + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom; import org.eclipse.cdt.core.index.IndexerSetupParticipant; @@ -22,7 +21,6 @@ import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; import org.eclipse.core.resources.IProject; public class CProjectDescriptionListener implements ICProjectDescriptionListener { - private PDOMManager fIndexManager; private IndexerSetupParticipant fIndexerSetupParticipant; @@ -41,6 +39,7 @@ public class CProjectDescriptionListener implements ICProjectDescriptionListener }; } + @Override public void handleEvent(CProjectDescriptionEvent event) { ICProjectDescription old= event.getOldCProjectDescription(); ICProjectDescription act= event.getNewCProjectDescription(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/JobChangeListener.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/JobChangeListener.java index 73718480512..af8b6bf0467 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/JobChangeListener.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/JobChangeListener.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom; @@ -25,12 +25,15 @@ class JobChangeListener implements IJobChangeListener { fPDomManager= pdomManager; } + @Override public void aboutToRun(IJobChangeEvent event) { } + @Override public void awake(IJobChangeEvent event) { } + @Override public void done(IJobChangeEvent event) { if (event.getJob().belongsTo(fPDomManager)) { if (Job.getJobManager().find(fPDomManager).length == 0) { @@ -39,15 +42,18 @@ class JobChangeListener implements IJobChangeListener { } } + @Override public void running(IJobChangeEvent event) { } + @Override public void scheduled(IJobChangeEvent event) { if (event.getJob().belongsTo(fPDomManager)) { fPDomManager.fireStateChange(IndexerStateEvent.STATE_BUSY); } } + + @Override public void sleeping(IJobChangeEvent event) { } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/LanguageMappingChangeListener.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/LanguageMappingChangeListener.java index bb58ad0cb4f..dab7303107b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/LanguageMappingChangeListener.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/LanguageMappingChangeListener.java @@ -28,19 +28,14 @@ import org.eclipse.core.runtime.CoreException; * This class handles changes in language mappings for the PDOM by reindexing the appropriate projects. * This class is a a work in progress and will be changed soon to be smarter about the resources it reindexes. */ -public class LanguageMappingChangeListener implements - ILanguageMappingChangeListener { - +public class LanguageMappingChangeListener implements ILanguageMappingChangeListener { private IIndexManager fManager; public LanguageMappingChangeListener(IIndexManager manager) { fManager = manager; } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.model.ILanguageMappingChangeListener#handleLanguageMappingChangeEvent(org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent) - */ + @Override public void handleLanguageMappingChangeEvent(ILanguageMappingChangeEvent event) { CModelManager manager = CModelManager.getDefault(); if (event.getType() == ILanguageMappingChangeEvent.TYPE_WORKSPACE) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/NotifyCModelManagerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/NotifyCModelManagerTask.java index ef74efe03e4..5be547c62d5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/NotifyCModelManagerTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/NotifyCModelManagerTask.java @@ -31,14 +31,17 @@ public class NotifyCModelManagerTask implements IPDOMIndexerTask { fProject= project; } + @Override public IPDOMIndexer getIndexer() { return null; } + @Override public IndexerProgress getProgressInformation() { return new IndexerProgress(); } + @Override public void run(IProgressMonitor monitor) throws InterruptedException { IContentType ct1= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_CXXHEADER); IContentType ct2= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE); @@ -51,6 +54,7 @@ public class NotifyCModelManagerTask implements IPDOMIndexerTask { } } + @Override public boolean acceptUrgentTask(IPDOMIndexerTask task) { return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java index 0c1d82decf1..3b588970ca5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java @@ -56,6 +56,7 @@ import org.eclipse.cdt.core.index.IIndexLocationConverter; import org.eclipse.cdt.core.index.IIndexMacro; import org.eclipse.cdt.core.index.IIndexMacroContainer; import org.eclipse.cdt.core.index.IndexFilter; +import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.internal.core.dom.Linkage; @@ -210,10 +211,11 @@ public class PDOM extends PlatformObject implements IPDOM { * CDT 8.1 development (versions not supported on teh 8.0.x branch) * 120.0 - Enumerators in global index, bug 356235 * 120.1 - Specializations of using declarations, bug 357293. + * 121.0 - Multiple variants of included header file, bug 197989. */ - private static final int MIN_SUPPORTED_VERSION= version(120, 0); - private static final int MAX_SUPPORTED_VERSION= version(120, Short.MAX_VALUE); - private static final int DEFAULT_VERSION = version(120, 1); + private static final int MIN_SUPPORTED_VERSION= version(121, 0); + private static final int MAX_SUPPORTED_VERSION= version(121, Short.MAX_VALUE); + private static final int DEFAULT_VERSION = version(121, 0); private static int version(int major, int minor) { return (major << 16) + minor; @@ -388,12 +390,14 @@ public class PDOM extends PlatformObject implements IPDOM { } } + @Override public void addListener(IListener listener) { if (listeners == null) listeners = new LinkedList(); listeners.add(listener); } + @Override public void removeListener(IListener listener) { if (listeners == null) return; @@ -419,6 +423,8 @@ public class PDOM extends PlatformObject implements IPDOM { return fileIndex; } + @Deprecated + @Override public PDOMFile getFile(int linkageID, IIndexFileLocation location) throws CoreException { PDOMLinkage linkage= getLinkage(linkageID); if (linkage == null) @@ -426,20 +432,43 @@ public class PDOM extends PlatformObject implements IPDOM { return PDOMFile.findFile(linkage, getFileIndex(), location, locationConverter); } - public PDOMFile getFile(PDOMLinkage linkage, IIndexFileLocation location) throws CoreException { - return PDOMFile.findFile(linkage, getFileIndex(), location, locationConverter); + @Override + public PDOMFile getFile(int linkageID, IIndexFileLocation location, + ISignificantMacros macroDictionary) throws CoreException { + PDOMLinkage linkage= getLinkage(linkageID); + if (linkage == null) + return null; + return PDOMFile.findFile(linkage, getFileIndex(), location, locationConverter, + macroDictionary); } + public PDOMFile getFile(PDOMLinkage linkage, IIndexFileLocation location, + ISignificantMacros macroDictionary) throws CoreException { + return PDOMFile.findFile(linkage, getFileIndex(), location, locationConverter, macroDictionary); + } + + @Override + public IIndexFragmentFile[] getFiles(int linkageID, IIndexFileLocation location) throws CoreException { + PDOMLinkage linkage= getLinkage(linkageID); + if (linkage == null) + return IIndexFragmentFile.EMPTY_ARRAY; + return PDOMFile.findFiles(linkage, getFileIndex(), location, locationConverter); + } + + @Override public IIndexFragmentFile[] getFiles(IIndexFileLocation location) throws CoreException { return PDOMFile.findFiles(this, getFileIndex(), location, locationConverter); } + @Override public IIndexFragmentFile[] getAllFiles() throws CoreException { final List locations = new ArrayList(); - getFileIndex().accept(new IBTreeVisitor(){ + getFileIndex().accept(new IBTreeVisitor() { + @Override public int compare(long record) throws CoreException { return 0; } + @Override public boolean visit(long record) throws CoreException { PDOMFile file = PDOMFile.recreateFile(PDOM.this, record); locations.add(file); @@ -449,11 +478,12 @@ public class PDOM extends PlatformObject implements IPDOM { return locations.toArray(new IIndexFragmentFile[locations.size()]); } - protected IIndexFragmentFile addFile(int linkageID, IIndexFileLocation location) throws CoreException { + protected IIndexFragmentFile addFile(int linkageID, IIndexFileLocation location, + ISignificantMacros sigMacros) throws CoreException { PDOMLinkage linkage= createLinkage(linkageID); - IIndexFragmentFile file = getFile(linkage, location); + IIndexFragmentFile file = getFile(linkage, location, sigMacros); if (file == null) { - PDOMFile pdomFile = new PDOMFile(linkage, location, linkageID); + PDOMFile pdomFile = new PDOMFile(linkage, location, linkageID, sigMacros); getFileIndex().insert(pdomFile.getRecord()); file= pdomFile; fEvent.setHasNewFiles(); @@ -495,6 +525,7 @@ public class PDOM extends PlatformObject implements IPDOM { return getFirstLinkageRecord() == 0; } + @Override public IIndexFragmentBinding findBinding(IASTName name) throws CoreException { IBinding binding= name.resolveBinding(); if (binding != null) { @@ -532,6 +563,7 @@ public class PDOM extends PlatformObject implements IPDOM { matchStack.add(matchesUpToLevel); } + @Override public boolean visit(IPDOMNode node) throws CoreException { if (monitor.isCanceled()) throw new CoreException(Status.OK_STATUS); @@ -579,6 +611,7 @@ public class PDOM extends PlatformObject implements IPDOM { return false; } + @Override public void leave(IPDOMNode node) throws CoreException { final int idx= currentPath.size()-1; if (idx >= 0 && currentPath.get(idx) == node) { @@ -596,7 +629,9 @@ public class PDOM extends PlatformObject implements IPDOM { return findBindings(new Pattern[] { pattern }, isFullyQualified, filter, monitor); } - public IIndexFragmentBinding[] findBindings(Pattern[] patterns, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException { + @Override + public IIndexFragmentBinding[] findBindings(Pattern[] patterns, boolean isFullyQualified, + IndexFilter filter, IProgressMonitor monitor) throws CoreException { if (monitor == null) { monitor= new NullProgressMonitor(); } @@ -689,7 +724,9 @@ public class PDOM extends PlatformObject implements IPDOM { return null; } - public IIndexFragmentBinding[] findMacroContainers(Pattern pattern, IndexFilter filter, IProgressMonitor monitor) throws CoreException { + @Override + public IIndexFragmentBinding[] findMacroContainers(Pattern pattern, IndexFilter filter, + IProgressMonitor monitor) throws CoreException { if (monitor == null) { monitor= new NullProgressMonitor(); } @@ -726,7 +763,9 @@ public class PDOM extends PlatformObject implements IPDOM { return result.toArray(new IIndexFragmentBinding[result.size()]); } - public IIndexFragmentBinding[] findBindings(char[][] names, IndexFilter filter, IProgressMonitor monitor) throws CoreException { + @Override + public IIndexFragmentBinding[] findBindings(char[][] names, IndexFilter filter, + IProgressMonitor monitor) throws CoreException { return findBindings(names, true, filter, monitor); } @@ -776,11 +815,13 @@ public class PDOM extends PlatformObject implements IPDOM { return db.getRecPtr(LINKAGES); } + @Override public IIndexLinkage[] getLinkages() { Collection values = getLinkageList(); return values.toArray(new IIndexLinkage[values.size()]); } + @Override public PDOMLinkage[] getLinkageImpls() { Collection values = getLinkageList(); return values.toArray(new PDOMLinkage[values.size()]); @@ -801,6 +842,7 @@ public class PDOM extends PlatformObject implements IPDOM { private long lastReadAccess= 0; private long timeWriteLockAcquired; + @Override public void acquireReadLock() throws InterruptedException { long t = sDEBUG_LOCKS ? System.nanoTime() : 0; synchronized (mutex) { @@ -824,6 +866,7 @@ public class PDOM extends PlatformObject implements IPDOM { } } + @Override public void releaseReadLock() { boolean clearCache= false; synchronized (mutex) { @@ -927,12 +970,14 @@ public class PDOM extends PlatformObject implements IPDOM { fireChange(event); } + @Override public boolean hasWaitingReaders() { synchronized (mutex) { return waitingReaders > 0; } } + @Override public long getLastWriteAccess() { return lastWriteAccess; } @@ -945,6 +990,7 @@ public class PDOM extends PlatformObject implements IPDOM { return fLinkageIDCache.get(linkage.getLinkageID()); } + @Override public IIndexFragmentBinding adaptBinding(IBinding binding) throws CoreException { if (binding == null) { return null; @@ -976,6 +1022,7 @@ public class PDOM extends PlatformObject implements IPDOM { return null; } + @Override public IIndexFragmentName[] findNames(IBinding binding, int options) throws CoreException { ArrayList names= new ArrayList(); IIndexFragmentBinding myBinding= adaptBinding(binding); @@ -1058,6 +1105,7 @@ public class PDOM extends PlatformObject implements IPDOM { return true; } + @Override public IIndexFragmentInclude[] findIncludedBy(IIndexFragmentFile file) throws CoreException { PDOMFile pdomFile= adaptFile(file); if (pdomFile != null) { @@ -1077,13 +1125,14 @@ public class PDOM extends PlatformObject implements IPDOM { return (PDOMFile) file; } - return getFile(file.getLinkageID(), file.getLocation()); + return getFile(file.getLinkageID(), file.getLocation(), file.getSignificantMacros()); } public File getPath() { return fPath; } + @Override public IIndexFragmentBinding[] findBindingsForPrefix(char[] prefix, boolean filescope, IndexFilter filter, IProgressMonitor monitor) throws CoreException { return findBindingsForPrefix(prefix, filescope, false, filter, monitor); } @@ -1092,6 +1141,7 @@ public class PDOM extends PlatformObject implements IPDOM { return findBindingsForPrefixOrContentAssist(prefix, filescope, false, caseSensitive, filter, monitor); } + @Override public IIndexFragmentBinding[] findBindingsForContentAssist(char[] prefix, boolean filescope, IndexFilter filter, IProgressMonitor monitor) throws CoreException { return findBindingsForPrefixOrContentAssist(prefix, filescope, true, false, filter, monitor); } @@ -1122,11 +1172,14 @@ public class PDOM extends PlatformObject implements IPDOM { return result.toArray(new IIndexFragmentBinding[result.size()]); } - public IIndexFragmentBinding[] findBindings(char[] name, boolean filescope, IndexFilter filter, IProgressMonitor monitor) throws CoreException { + @Override + public IIndexFragmentBinding[] findBindings(char[] name, boolean filescope, IndexFilter filter, + IProgressMonitor monitor) throws CoreException { return findBindings(name, filescope, true, filter, monitor); } - public IIndexFragmentBinding[] findBindings(char[] name, boolean filescope, boolean isCaseSensitive, IndexFilter filter, IProgressMonitor monitor) throws CoreException { + public IIndexFragmentBinding[] findBindings(char[] name, boolean filescope, + boolean isCaseSensitive, IndexFilter filter, IProgressMonitor monitor) throws CoreException { ArrayList result= new ArrayList(); try { for (PDOMLinkage linkage : getLinkageList()) { @@ -1182,7 +1235,9 @@ public class PDOM extends PlatformObject implements IPDOM { return result.toArray(new IIndexFragmentBinding[result.size()]); } - public IIndexMacro[] findMacros(char[] prefix, boolean isPrefix, boolean isCaseSensitive, IndexFilter filter, IProgressMonitor monitor) throws CoreException { + @Override + public IIndexMacro[] findMacros(char[] prefix, boolean isPrefix, boolean isCaseSensitive, + IndexFilter filter, IProgressMonitor monitor) throws CoreException { ArrayList result= new ArrayList(); try { for (PDOMLinkage linkage : getLinkageList()) { @@ -1200,6 +1255,7 @@ public class PDOM extends PlatformObject implements IPDOM { return result.toArray(new IIndexMacro[result.size()]); } + @Override public String getProperty(String propertyName) throws CoreException { if (IIndexFragment.PROPERTY_FRAGMENT_FORMAT_ID.equals(propertyName)) { return FRAGMENT_PROPERTY_VALUE_FORMAT_ID; @@ -1229,20 +1285,24 @@ public class PDOM extends PlatformObject implements IPDOM { clearResultCache(); } + @Override public void clearResultCache() { synchronized (fResultCache) { fResultCache.clear(); } } + @Override public long getCacheHits() { return db.getCacheHits(); } + @Override public long getCacheMisses() { return db.getCacheMisses(); } + @Override public void resetCacheCounters() { db.resetCacheCounters(); } @@ -1251,6 +1311,7 @@ public class PDOM extends PlatformObject implements IPDOM { db.flush(); } + @Override public Object getCachedResult(Object key) { synchronized (fResultCache) { return fResultCache.get(key); @@ -1261,6 +1322,7 @@ public class PDOM extends PlatformObject implements IPDOM { putCachedResult(key, result, true); } + @Override public Object putCachedResult(Object key, Object result, boolean replace) { synchronized (fResultCache) { Object old= fResultCache.put(key, result); @@ -1424,6 +1486,7 @@ public class PDOM extends PlatformObject implements IPDOM { return PDOMBinding.EMPTY_PDOMBINDING_ARRAY; } + @Override public IIndexFragmentFileSet createFileSet() { return new PDOMFileSet(); } @@ -1568,9 +1631,7 @@ public class PDOM extends PlatformObject implements IPDOM { } } - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.index.IIndexFragment#getInlineNamespaces() - */ + @Override public IIndexScope[] getInlineNamespaces() throws CoreException { PDOMLinkage linkage = getLinkage(ILinkage.CPP_LINKAGE_ID); if (linkage == null) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMFileSet.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMFileSet.java index bf00566c876..fa9c9d3068a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMFileSet.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMFileSet.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom; @@ -20,19 +20,27 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile; import org.eclipse.core.runtime.CoreException; public class PDOMFileSet implements IIndexFragmentFileSet { - private HashSet fFileIDs= new HashSet(); + @Override public void add(IIndexFragmentFile fragFile) { PDOMFile pdomFile= (PDOMFile) fragFile; fFileIDs.add(pdomFile.getRecord()); } + @Override + public void remove(IIndexFragmentFile fragFile) { + PDOMFile pdomFile= (PDOMFile) fragFile; + fFileIDs.remove(pdomFile.getRecord()); + } + + @Override public boolean containsFileOfLocalBinding(IIndexFragmentBinding fb) throws CoreException { PDOMBinding pdomBinding= (PDOMBinding) fb; return fFileIDs.contains(pdomBinding.getLocalToFileRec()); } + @Override public boolean contains(IIndexFragmentFile file) throws CoreException { if (file instanceof PDOMFile) { return fFileIDs.contains(((PDOMFile) file).getRecord()); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java index 12dd4253ad5..425c2b95641 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java @@ -123,6 +123,8 @@ public class PDOMManager implements IWritableIndexManager, IListener { public PCL(ICProject prj) { fProject= prj; } + + @Override public void preferenceChange(PreferenceChangeEvent event) { if (fProject.getProject().isOpen()) { onPreferenceChange(fProject, event); @@ -193,6 +195,7 @@ public class PDOMManager implements IWritableIndexManager, IListener { fProjectDescriptionListener= new CProjectDescriptionListener(this); fJobChangeListener= new JobChangeListener(this); fPreferenceChangeListener= new IPreferenceChangeListener() { + @Override public void preferenceChange(PreferenceChangeEvent event) { onPreferenceChange(event); } @@ -426,20 +429,24 @@ public class PDOMManager implements IWritableIndexManager, IListener { return project.getElementName() + "." + time + ".pdom"; //$NON-NLS-1$//$NON-NLS-2$ } + @Override public String getDefaultIndexerId() { return getIndexerId(null); } + @Override public void setDefaultIndexerId(String indexerId) { IndexerPreferences.setDefaultIndexerId(indexerId); } - public String getIndexerId(ICProject project) { + @Override + public String getIndexerId(ICProject project) { IProject prj= project != null ? project.getProject() : null; return IndexerPreferences.get(prj, IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_NO_INDEXER); } - public void setIndexerId(final ICProject project, String indexerId) { + @Override + public void setIndexerId(final ICProject project, String indexerId) { IProject prj= project.getProject(); IndexerPreferences.set(prj, IndexerPreferences.KEY_INDEXER_ID, indexerId); CCoreInternals.savePreferences(prj, IndexerPreferences.getScope(prj) == IndexerPreferences.SCOPE_PROJECT_SHARED); @@ -737,7 +744,8 @@ public class PDOMManager implements IWritableIndexManager, IListener { } } - public boolean isIndexerIdle() { + @Override + public boolean isIndexerIdle() { return Job.getJobManager().find(this).length == 0; } @@ -948,6 +956,7 @@ public class PDOMManager implements IWritableIndexManager, IListener { } } + @Override public void reindex(final ICProject project) { Job job= new Job(Messages.PDOMManager_notifyJob_label) { @Override @@ -981,18 +990,22 @@ public class PDOMManager implements IWritableIndexManager, IListener { job.schedule(); } + @Override public void addIndexChangeListener(IIndexChangeListener listener) { fChangeListeners.add(listener); } + @Override public void removeIndexChangeListener(IIndexChangeListener listener) { fChangeListeners.remove(listener); } + @Override public void addIndexerStateListener(IIndexerStateListener listener) { fStateListeners.add(listener); } + @Override public void removeIndexerStateListener(IIndexerStateListener listener) { fStateListeners.remove(listener); } @@ -1038,16 +1051,19 @@ public class PDOMManager implements IWritableIndexManager, IListener { return; } Runnable notify= new Runnable() { - public void run() { + @Override + public void run() { fIndexerStateEvent.setState(state); Object[] listeners= fStateListeners.getListeners(); for (Object listener2 : listeners) { final IIndexerStateListener listener = (IIndexerStateListener) listener2; SafeRunner.run(new ISafeRunnable(){ - public void handleException(Throwable exception) { + @Override + public void handleException(Throwable exception) { CCorePlugin.log(exception); } - public void run() throws Exception { + @Override + public void run() throws Exception { listener.indexChanged(fIndexerStateEvent); } }); @@ -1058,6 +1074,7 @@ public class PDOMManager implements IWritableIndexManager, IListener { } } + @Override public void handleChange(PDOM pdom, final PDOM.ChangeEvent e) { if (fChangeListeners.isEmpty()) { return; @@ -1071,15 +1088,18 @@ public class PDOMManager implements IWritableIndexManager, IListener { if (project != null) { final ICProject finalProject= project; Runnable notify= new Runnable() { + @Override public void run() { fIndexChangeEvent.setAffectedProject(finalProject, e); Object[] listeners= fChangeListeners.getListeners(); for (Object listener2 : listeners) { final IIndexChangeListener listener = (IIndexChangeListener) listener2; SafeRunner.run(new ISafeRunnable(){ + @Override public void handleException(Throwable exception) { CCorePlugin.log(exception); } + @Override public void run() throws Exception { listener.indexChanged(fIndexChangeEvent); } @@ -1091,16 +1111,19 @@ public class PDOMManager implements IWritableIndexManager, IListener { } } + @Override public boolean joinIndexer(final int waitMaxMillis, final IProgressMonitor monitor) { assert monitor != null; Thread th= null; if (waitMaxMillis != FOREVER) { + final Thread callingThread= Thread.currentThread(); th= new Thread() { @Override public void run() { try { Thread.sleep(waitMaxMillis); monitor.setCanceled(true); + callingThread.interrupt(); } catch (InterruptedException e) { } } @@ -1171,22 +1194,27 @@ public class PDOMManager implements IWritableIndexManager, IListener { return currentTicks; } + @Override public IWritableIndex getWritableIndex(ICProject project) throws CoreException { return fIndexFactory.getWritableIndex(project); } + @Override public IIndex getIndex(ICProject project) throws CoreException { return fIndexFactory.getIndex(new ICProject[] {project}, 0); } + @Override public IIndex getIndex(ICProject[] projects) throws CoreException { return fIndexFactory.getIndex(projects, 0); } + @Override public IIndex getIndex(ICProject project, int options) throws CoreException { return fIndexFactory.getIndex(new ICProject[] {project}, options); } + @Override public IIndex getIndex(ICProject[] projects, int options) throws CoreException { return fIndexFactory.getIndex(projects, options); } @@ -1296,6 +1324,7 @@ public class PDOMManager implements IWritableIndexManager, IListener { } } + @Override public void export(ICProject project, String location, int options, IProgressMonitor monitor) throws CoreException { TeamPDOMExportOperation operation= new TeamPDOMExportOperation(project); operation.setTargetLocation(location); @@ -1315,16 +1344,19 @@ public class PDOMManager implements IWritableIndexManager, IListener { pdom.setProperty(IIndexFragment.PROPERTY_FRAGMENT_ID, id); } + @Override public boolean isProjectIndexed(ICProject proj) { return !IPDOMManager.ID_NO_INDEXER.equals(getIndexerId(proj)); } + @Override public boolean isIndexerSetupPostponed(ICProject proj) { synchronized (fSetupParticipants) { return fPostponedProjects.contains(proj); } } + @Override public void update(ICElement[] tuSelection, int options) throws CoreException { Map> projectsToElements= splitSelection(tuSelection); for (Map.Entry> entry : projectsToElements.entrySet()) { @@ -1429,12 +1461,15 @@ public class PDOMManager implements IWritableIndexManager, IListener { fPostponedProjects.remove(cproject); final IndexerSetupParticipant[] participants= fSetupParticipants.toArray(new IndexerSetupParticipant[fSetupParticipants.size()]); Runnable notify= new Runnable() { + @Override public void run() { for (final IndexerSetupParticipant p : participants) { SafeRunner.run(new ISafeRunnable(){ + @Override public void handleException(Throwable exception) { CCorePlugin.log(exception); } + @Override public void run() throws Exception { p.onIndexerSetup(cproject); } @@ -1461,12 +1496,14 @@ public class PDOMManager implements IWritableIndexManager, IListener { } } + @Override public void addIndexerSetupParticipant(IndexerSetupParticipant participant) { synchronized (fSetupParticipants) { fSetupParticipants.add(participant); } } + @Override public void removeIndexerSetupParticipant(IndexerSetupParticipant participant) { synchronized (fSetupParticipants) { fSetupParticipants.remove(participant); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMProxy.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMProxy.java index f7684b13de8..1607aae69d8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMProxy.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMProxy.java @@ -24,6 +24,7 @@ import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.index.IIndexLinkage; import org.eclipse.cdt.core.index.IIndexMacro; import org.eclipse.cdt.core.index.IndexFilter; +import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; import org.eclipse.cdt.internal.core.index.IIndexFragmentFile; import org.eclipse.cdt.internal.core.index.IIndexFragmentFileSet; @@ -53,6 +54,8 @@ public class PDOMProxy implements IPDOM { fLockDebugging= new HashMap(); } } + + @Override public synchronized void acquireReadLock() throws InterruptedException { if (fDelegate != null) { fDelegate.acquireReadLock(); @@ -64,6 +67,7 @@ public class PDOMProxy implements IPDOM { } } + @Override public IIndexMacro[] findMacros(char[] name, boolean isPrefix, boolean caseSensitive, IndexFilter filter, IProgressMonitor monitor) throws CoreException { if (fDelegate != null) @@ -71,18 +75,21 @@ public class PDOMProxy implements IPDOM { return IIndexMacro.EMPTY_INDEX_MACRO_ARRAY; } + @Override public synchronized IIndexFragmentBinding adaptBinding(IBinding binding) throws CoreException { if (fDelegate != null) return fDelegate.adaptBinding(binding); return null; } + @Override public synchronized IIndexFragmentBinding findBinding(IASTName astName) throws CoreException { if (fDelegate != null) return fDelegate.findBinding(astName); return null; } + @Override public synchronized IIndexFragmentBinding[] findBindings(char[][] names, IndexFilter filter, IProgressMonitor monitor) throws CoreException { if (fDelegate != null) @@ -91,6 +98,7 @@ public class PDOMProxy implements IPDOM { return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY; } + @Override public synchronized IIndexFragmentBinding[] findBindings(Pattern[] patterns, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException { if (fDelegate != null) @@ -99,6 +107,7 @@ public class PDOMProxy implements IPDOM { return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY; } + @Override public synchronized IIndexFragmentBinding[] findBindings(char[] name, boolean filescope, IndexFilter filter, IProgressMonitor monitor) throws CoreException { if (fDelegate != null) @@ -107,6 +116,7 @@ public class PDOMProxy implements IPDOM { return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY; } + @Override public synchronized IIndexFragmentBinding[] findBindingsForPrefix(char[] prefix, boolean filescope, IndexFilter filter, IProgressMonitor monitor) throws CoreException { if (fDelegate != null) @@ -115,6 +125,7 @@ public class PDOMProxy implements IPDOM { return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY; } + @Override public synchronized IIndexFragmentBinding[] findBindingsForContentAssist(char[] prefix, boolean filescope, IndexFilter filter, IProgressMonitor monitor) throws CoreException { if (fDelegate != null) @@ -123,6 +134,7 @@ public class PDOMProxy implements IPDOM { return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY; } + @Override public synchronized IIndexFragmentInclude[] findIncludedBy(IIndexFragmentFile file) throws CoreException { if (fDelegate != null) return fDelegate.findIncludedBy(file); @@ -130,6 +142,7 @@ public class PDOMProxy implements IPDOM { return new IIndexFragmentInclude[0]; } + @Override public synchronized IIndexFragmentName[] findNames(IBinding binding, int flags) throws CoreException { if (fDelegate != null) @@ -138,6 +151,7 @@ public class PDOMProxy implements IPDOM { return IIndexFragmentName.EMPTY_NAME_ARRAY; } + @Override public synchronized long getCacheHits() { if (fDelegate != null) return fDelegate.getCacheHits(); @@ -145,6 +159,7 @@ public class PDOMProxy implements IPDOM { return 0; } + @Override public synchronized long getCacheMisses() { if (fDelegate != null) return fDelegate.getCacheMisses(); @@ -152,6 +167,8 @@ public class PDOMProxy implements IPDOM { return 0; } + @Deprecated + @Override public synchronized IIndexFragmentFile getFile(int linkageID, IIndexFileLocation location) throws CoreException { if (fDelegate != null) return fDelegate.getFile(linkageID, location); @@ -159,6 +176,25 @@ public class PDOMProxy implements IPDOM { return null; } + @Override + public IIndexFragmentFile getFile(int linkageID, IIndexFileLocation location, + ISignificantMacros sigMacros) throws CoreException { + if (fDelegate != null) + return fDelegate.getFile(linkageID, location, sigMacros); + + return null; + } + + @Override + public IIndexFragmentFile[] getFiles(int linkageID, IIndexFileLocation location) + throws CoreException { + if (fDelegate != null) + return fDelegate.getFiles(linkageID, location); + + return IIndexFragmentFile.EMPTY_ARRAY; + } + + @Override public synchronized IIndexFragmentFile[] getFiles(IIndexFileLocation location) throws CoreException { if (fDelegate != null) return fDelegate.getFiles(location); @@ -166,6 +202,7 @@ public class PDOMProxy implements IPDOM { return IIndexFragmentFile.EMPTY_ARRAY; } + @Override public synchronized long getLastWriteAccess() { if (fDelegate != null) return fDelegate.getLastWriteAccess(); @@ -173,6 +210,7 @@ public class PDOMProxy implements IPDOM { return 0; } + @Override public synchronized IIndexLinkage[] getLinkages() { if (fDelegate != null) return fDelegate.getLinkages(); @@ -180,6 +218,7 @@ public class PDOMProxy implements IPDOM { return new IIndexLinkage[0]; } + @Override public synchronized String getProperty(String propertyName) throws CoreException { if (fDelegate != null) return fDelegate.getProperty(propertyName); @@ -187,6 +226,7 @@ public class PDOMProxy implements IPDOM { return null; } + @Override public synchronized void releaseReadLock() { // read-locks not forwarded to delegate need to be released here if (fReadLockCount > 0) { @@ -198,10 +238,12 @@ public class PDOMProxy implements IPDOM { } } + @Override public boolean hasWaitingReaders() { return fDelegate != null && fDelegate.hasWaitingReaders(); } + @Override public synchronized void resetCacheCounters() { if (fDelegate != null) fDelegate.resetCacheCounters(); @@ -215,6 +257,7 @@ public class PDOMProxy implements IPDOM { return null; } + @Override public synchronized void addListener(IListener listener) { if (fDelegate != null) { fDelegate.addListener(listener); @@ -223,6 +266,7 @@ public class PDOMProxy implements IPDOM { } } + @Override public synchronized PDOMLinkage[] getLinkageImpls() { if (fDelegate != null) return fDelegate.getLinkageImpls(); @@ -230,6 +274,7 @@ public class PDOMProxy implements IPDOM { return new PDOMLinkage[0]; } + @Override public synchronized void removeListener(IListener listener) { if (fDelegate != null) { fDelegate.removeListener(listener); @@ -261,19 +306,19 @@ public class PDOMProxy implements IPDOM { } } + @Override public IIndexFragmentFileSet createFileSet() { return new PDOMFileSet(); } + @Override public synchronized IIndexFragmentFile[] getAllFiles() throws CoreException { if (fDelegate != null) return fDelegate.getAllFiles(); return IIndexFragmentFile.EMPTY_ARRAY; } - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.index.IIndexFragment#findMacroContainers(java.util.regex.Pattern, org.eclipse.cdt.core.index.IndexFilter, org.eclipse.core.runtime.IProgressMonitor) - */ + @Override public synchronized IIndexFragmentBinding[] findMacroContainers(Pattern pattern, IndexFilter filter, IProgressMonitor monitor) throws CoreException { if (fDelegate != null) { @@ -282,20 +327,23 @@ public class PDOMProxy implements IPDOM { return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY; } + @Override public Object getCachedResult(Object key) { return null; } + @Override public Object putCachedResult(Object key, Object value, boolean replace) { return value; } + + @Override public void clearResultCache() { if (fDelegate != null) fDelegate.clearResultCache(); } - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.index.IIndexFragment#getInlineNamespaces() - */ + + @Override public IIndexScope[] getInlineNamespaces() throws CoreException { if (fDelegate != null) return fDelegate.getInlineNamespaces(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java index b435461ca37..7bf753147d3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,8 +13,6 @@ package org.eclipse.cdt.internal.core.pdom; import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -47,11 +45,14 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; +import org.eclipse.cdt.core.index.IIndexFile; import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.index.IIndexInclude; import org.eclipse.cdt.core.parser.IProblem; +import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; +import org.eclipse.cdt.internal.core.index.FileContentKey; import org.eclipse.cdt.internal.core.index.IIndexFragmentFile; import org.eclipse.cdt.internal.core.index.IWritableIndex; import org.eclipse.cdt.internal.core.index.IWritableIndex.IncludeInformation; @@ -70,6 +71,36 @@ import org.eclipse.osgi.util.NLS; * @since 4.0 */ abstract public class PDOMWriter { + public static class FileInAST { + final IASTPreprocessorIncludeStatement fIncludeStatement; + final FileContentKey fFileContentKey; + final long fContentsHash; + + public FileInAST(IASTPreprocessorIncludeStatement includeStmt, FileContentKey key, long contentsHash) { + fIncludeStatement= includeStmt; + fFileContentKey= key; + fContentsHash= contentsHash; + } + + @Override + public String toString() { + return fFileContentKey.toString(); + } + } + + public static class FileContext { + final IIndexFragmentFile fContext; + final IIndexFragmentFile fOldFile; + IIndexFragmentFile fNewFile; + public boolean fLostPragmaOnceSemantics; + + public FileContext(IIndexFragmentFile context, IIndexFragmentFile oldFile) { + fContext= context; + fOldFile= oldFile; + fNewFile= null; + } + } + public static int SKIP_ALL_REFERENCES= -1; public static int SKIP_TYPE_REFERENCES= 1; public static int SKIP_MACRO_REFERENCES= 2; @@ -77,9 +108,24 @@ abstract public class PDOMWriter { public static int SKIP_NO_REFERENCES= 0; private static class Symbols { - ArrayList fNames= new ArrayList(); - ArrayList fMacros= new ArrayList(); - ArrayList fIncludes= new ArrayList(); + final ArrayList fNames= new ArrayList(); + final ArrayList fMacros= new ArrayList(); + final ArrayList fIncludes= new ArrayList(); + } + + private static class Data { + final IASTTranslationUnit fAST; + final FileInAST[] fSelectedFiles; + final IWritableIndex fIndex; + final Map fSymbolMap = new HashMap(); + final Set fContextIncludes = new HashSet(); + final List fStati= new ArrayList(); + + public Data(IASTTranslationUnit ast, FileInAST[] selectedFiles, IWritableIndex index) { + fAST= ast; + fSelectedFiles= selectedFiles; + fIndex= index; + } } private boolean fShowProblems; @@ -90,7 +136,6 @@ abstract public class PDOMWriter { protected final IndexerStatistics fStatistics; protected final IndexerInputAdapter fResolver; - private IndexerProgress fInfo= new IndexerProgress(); private int fSkipReferences= SKIP_NO_REFERENCES; public PDOMWriter(IndexerInputAdapter resolver) { @@ -140,39 +185,45 @@ abstract public class PDOMWriter { * * When flushIndex is set to false, you must make sure to flush * the index after your last write operation. - * @since 4.0 */ - public void addSymbols(IASTTranslationUnit ast, IIndexFileLocation[] ifls, IWritableIndex index, - int readlockCount, boolean flushIndex, long fileContentsHash, int configHash, - ITodoTaskUpdater taskUpdater, IProgressMonitor pm) throws InterruptedException, CoreException { + final protected void addSymbols(IASTTranslationUnit ast, FileInAST[] selectedFiles, + IWritableIndex index, boolean flushIndex, FileContext ctx, + ITodoTaskUpdater taskUpdater, IProgressMonitor pm) throws InterruptedException, + CoreException { if (fShowProblems) { fShowInclusionProblems= true; fShowScannerProblems= true; fShowSyntaxProblems= true; } - final Map symbolMap= new HashMap(); - for (IIndexFileLocation ifl : ifls) { - prepareInMap(symbolMap, ifl); + + Data data= new Data(ast, selectedFiles, index); + for (FileInAST file : selectedFiles) { + data.fSymbolMap.put(file.fIncludeStatement, new Symbols()); } - ArrayList stati= new ArrayList(); + - HashSet contextIncludes= new HashSet(); - extractSymbols(ast, symbolMap, contextIncludes); + // Extract symbols from AST + extractSymbols(data); - // name resolution - resolveNames(symbolMap, ifls, stati, pm); + // Name resolution + resolveNames(data, pm); - // index update - storeSymbolsInIndex(symbolMap, ifls, ast.getLinkage().getLinkageID(), fileContentsHash, - configHash, contextIncludes, index, readlockCount, flushIndex, stati, pm); + // Index update + storeSymbolsInIndex(data, ctx, flushIndex, pm); + // Tasks update if (taskUpdater != null) { - taskUpdater.updateTasks(ast.getComments(), ifls); + Set locations= new HashSet(); + for (FileInAST file : selectedFiles) { + locations.add(file.fFileContentKey.getLocation()); + } + taskUpdater.updateTasks(ast.getComments(), locations.toArray(new IIndexFileLocation[locations.size()])); } - if (!stati.isEmpty()) { + if (!data.fStati.isEmpty()) { + List stati = data.fStati; String path= null; - if (ifls.length > 0) { - path= ifls[ifls.length - 1].getURI().getPath(); + if (selectedFiles.length > 0) { + path= selectedFiles[selectedFiles.length - 1].fFileContentKey.getLocation().getURI().getPath(); } else { path= ast.getFilePath().toString(); } @@ -190,60 +241,73 @@ abstract public class PDOMWriter { } } - private void storeSymbolsInIndex(final Map symbolMap, IIndexFileLocation[] ifls, - int linkageID, long fileContentsHash, int configHash, - HashSet contextIncludes, IWritableIndex index, int readlockCount, - boolean flushIndex, ArrayList stati, IProgressMonitor pm) + private void storeSymbolsInIndex(final Data data, FileContext ctx, boolean flushIndex, IProgressMonitor pm) throws InterruptedException, CoreException { - for (int i= 0; i < ifls.length; i++) { + final IIndexFragmentFile newFile= ctx == null ? null : ctx.fNewFile; + final int linkageID= data.fAST.getLinkage().getLinkageID(); + for (int i= 0; i < data.fSelectedFiles.length; i++) { if (pm.isCanceled()) return; - final IIndexFileLocation ifl= ifls[i]; - if (ifl != null) { + final FileInAST fileInAST= data.fSelectedFiles[i]; + if (fileInAST != null) { if (fShowActivity) { - trace("Indexer: adding " + ifl.getURI()); //$NON-NLS-1$ + trace("Indexer: adding " + fileInAST.fFileContentKey.getLocation().getURI()); //$NON-NLS-1$ } Throwable th= null; - YieldableIndexLock lock = new YieldableIndexLock(index, readlockCount, flushIndex); + YieldableIndexLock lock = new YieldableIndexLock(data.fIndex, flushIndex); lock.acquire(); try { - storeFileInIndex(index, ifl, symbolMap, linkageID, fileContentsHash, configHash, - contextIncludes, lock); - } catch (RuntimeException e) { + final boolean isReplacement= ctx != null && fileInAST.fIncludeStatement == null; + IIndexFragmentFile ifile= null; + if (!isReplacement || newFile == null) { + ifile= storeFileInIndex(data, fileInAST, linkageID, lock); + reportFileWrittenToIndex(fileInAST, ifile); + } + + if (isReplacement) { + if (ifile == null) + ifile= newFile; + if (ctx != null && !ctx.fOldFile.equals(ifile) && ifile != null) { + if (ctx.fOldFile.hasPragmaOnceSemantics() && + !ifile.hasPragmaOnceSemantics()) { + data.fIndex.transferContext(ctx.fOldFile, ifile); + ctx.fLostPragmaOnceSemantics= true; + } else { + data.fIndex.transferIncluders(ctx.fOldFile, ifile); + } + } + } + } catch (RuntimeException e) { th= e; } catch (StackOverflowError e) { th= e; } catch (AssertionError e) { th= e; } finally { - // When the caller holds a read-lock, the result cache of the index is never cleared. + // Because the caller holds a read-lock, the result cache of the index is never cleared. // ==> Before releasing the lock for the last time in this ast, we clear the result cache. - if (readlockCount > 0 && i == ifls.length-1) { - index.clearResultCache(); + if (i == data.fSelectedFiles.length-1) { + data.fIndex.clearResultCache(); } lock.release(); } if (th != null) { - stati.add(createStatus(NLS.bind(Messages.PDOMWriter_errorWhileParsing, - ifl.getURI().getPath()), th)); - } - if (i < ifls.length - 1) { - updateFileCount(0, 0, 1); // update header count + data.fStati.add(createStatus(NLS.bind(Messages.PDOMWriter_errorWhileParsing, + fileInAST.fFileContentKey.getLocation().getURI().getPath()), th)); } fStatistics.fAddToIndexTime += lock.getCumulativeLockTime(); } } } - private void resolveNames(final Map symbolMap, IIndexFileLocation[] ifls, - ArrayList stati, IProgressMonitor pm) { + private void resolveNames(Data data, IProgressMonitor pm) { long start= System.currentTimeMillis(); - for (IIndexFileLocation path : ifls) { + for (FileInAST file : data.fSelectedFiles) { if (pm.isCanceled()) { return; } - Symbols symbols= symbolMap.get(path); + Symbols symbols= data.fSymbolMap.get(file.fIncludeStatement); final ArrayList names= symbols.fNames; boolean reported= false; @@ -286,8 +350,8 @@ abstract public class PDOMWriter { } if (th != null) { if (!reported) { - stati.add(CCorePlugin.createStatus(NLS.bind(Messages.PDOMWriter_errorResolvingName, - name.toString(), path.getURI().getPath()), th)); + data.fStati.add(CCorePlugin.createStatus(NLS.bind(Messages.PDOMWriter_errorResolvingName, + name.toString(), file.fFileContentKey.getLocation().getURI().getPath()), th)); } reported= true; j.remove(); @@ -298,45 +362,44 @@ abstract public class PDOMWriter { fStatistics.fResolutionTime += System.currentTimeMillis()-start; } - private void extractSymbols(IASTTranslationUnit ast, final Map symbolMap, - Collection contextIncludes) throws CoreException { - final HashSet contextIFLs= new HashSet(); - final IIndexFileLocation astIFL = fResolver.resolveASTPath(ast.getFilePath()); - + private void extractSymbols(Data data) throws CoreException { int unresolvedIncludes= 0; + final IASTTranslationUnit ast = data.fAST; + final Map symbolMap = data.fSymbolMap; + IASTPreprocessorStatement[] stmts = ast.getAllPreprocessorStatements(); for (final IASTPreprocessorStatement stmt : stmts) { - // includes + // Includes. if (stmt instanceof IASTPreprocessorIncludeStatement) { IASTPreprocessorIncludeStatement include= (IASTPreprocessorIncludeStatement) stmt; final IASTFileLocation astLoc= include.getFileLocation(); - final IIndexFileLocation sourceIFL= astLoc != null ? fResolver.resolveASTPath(astLoc.getFileName()) : astIFL; // command-line includes - final boolean updateSource= symbolMap.containsKey(sourceIFL); + IASTPreprocessorIncludeStatement owner = astLoc.getContextInclusionStatement(); + final boolean updateSource= symbolMap.containsKey(owner); if (updateSource) { - addToMap(symbolMap, sourceIFL, include); + addToMap(symbolMap, owner, include); } if (include.isActive()) { if (!include.isResolved()) { unresolvedIncludes++; } else if (updateSource) { - // the include was parsed, check if we want to update the included file in the index - final IIndexFileLocation targetIFL= fResolver.resolveASTPath(include.getPath()); - if (symbolMap.containsKey(targetIFL) && contextIFLs.add(targetIFL)) { - contextIncludes.add(include); + // The include was parsed, check if we want to update the included file in the index. + if (symbolMap.containsKey(include)) { + data.fContextIncludes.add(include); } } } - } else if (stmt.isActive() && (stmt instanceof IASTPreprocessorUndefStatement || stmt instanceof IASTPreprocessorMacroDefinition)) { + } else if (stmt.isActive() && + (stmt instanceof IASTPreprocessorUndefStatement || stmt instanceof IASTPreprocessorMacroDefinition)) { IASTFileLocation sourceLoc = stmt.getFileLocation(); if (sourceLoc != null) { // skip built-ins and command line macros - IIndexFileLocation path2 = fResolver.resolveASTPath(sourceLoc.getFileName()); - addToMap(symbolMap, path2, stmt); + IASTPreprocessorIncludeStatement owner = sourceLoc.getContextInclusionStatement(); + addToMap(symbolMap, owner, stmt); } } } - // names + // Names. final IndexerASTVisitor visitor = new IndexerASTVisitor((fSkipReferences & SKIP_IMPLICIT_REFERENCES) == 0) { @Override public void visit(IASTName name, IASTName caller) { @@ -348,13 +411,13 @@ abstract public class PDOMWriter { } } - // assign a location to anonymous types. + // Assign a location to anonymous types. name= PDOMASTAdapter.getAdapterIfAnonymous(name); if (name != null) { IASTFileLocation nameLoc = name.getFileLocation(); if (nameLoc != null) { - IIndexFileLocation location = fResolver.resolveASTPath(nameLoc.getFileName()); - addToMap(symbolMap, location, new IASTName[]{name, caller}); + IASTPreprocessorIncludeStatement owner= nameLoc.getContextInclusionStatement(); + addToMap(symbolMap, owner, new IASTName[] { name, caller }); } } } @@ -368,8 +431,8 @@ abstract public class PDOMWriter { for (IASTName name : refs) { IASTFileLocation nameLoc = name.getFileLocation(); if (nameLoc != null) { - IIndexFileLocation location = fResolver.resolveASTPath(nameLoc.getFileName()); - addToMap(symbolMap, location, new IASTName[]{name, null}); + IASTPreprocessorIncludeStatement owner= nameLoc.getContextInclusionStatement(); + addToMap(symbolMap, owner, new IASTName[] { name, null }); } } } @@ -426,57 +489,45 @@ abstract public class PDOMWriter { return false; } - private void addToMap(Map map, IIndexFileLocation location, IASTName[] thing) { - Symbols lists= map.get(location); + private void addToMap(Map symbolMap, IASTPreprocessorIncludeStatement owner, IASTName[] thing) { + Symbols lists= symbolMap.get(owner); if (lists != null) lists.fNames.add(thing); } - private void addToMap(Map map, IIndexFileLocation location, - IASTPreprocessorIncludeStatement thing) { - Symbols lists= map.get(location); + private void addToMap(Map symbolMap, IASTPreprocessorIncludeStatement owner, IASTPreprocessorIncludeStatement thing) { + Symbols lists= symbolMap.get(owner); if (lists != null) lists.fIncludes.add(thing); } - private void addToMap(Map map, IIndexFileLocation location, - IASTPreprocessorStatement thing) { - Symbols lists= map.get(location); + private void addToMap(Map symbolMap, + IASTPreprocessorIncludeStatement owner, IASTPreprocessorStatement thing) { + Symbols lists= symbolMap.get(owner); if (lists != null) lists.fMacros.add(thing); } - private boolean prepareInMap(Map map, IIndexFileLocation location) { - if (map.get(location) == null) { - map.put(location, new Symbols()); - } - return false; - } - - private IIndexFragmentFile storeFileInIndex(IWritableIndex index, IIndexFileLocation location, - Map symbolMap, int linkageID, long fileContentsHash, - int configHash, Set contextIncludes, + private IIndexFragmentFile storeFileInIndex(Data data, FileInAST astFile, int linkageID, YieldableIndexLock lock) throws CoreException, InterruptedException { - Set clearedContexts= Collections.emptySet(); + final IWritableIndex index = data.fIndex; IIndexFragmentFile file; - // We create a temporary PDOMFile with zero timestamp, add names to it, then replace contents - // of the old file from the temporary one, then delete the temporary file. The write lock on - // the index can be yielded between adding names to the temporary file, if another thread - // is waiting for a read lock. - IIndexFragmentFile oldFile = index.getWritableFile(linkageID, location); - if (oldFile != null) { - IIndexInclude[] includedBy = index.findIncludedBy(oldFile); - if (includedBy.length > 0) { - clearedContexts= new HashSet(); - for (IIndexInclude include : includedBy) { - clearedContexts.add(include.getIncludedByLocation()); - } - } - } - file= index.addUncommittedFile(linkageID, location); + // We create a temporary PDOMFile with zero timestamp, add names to it, then replace + // contents of the old file from the temporary one, then delete the temporary file. + // The write lock on the index can be yielded between adding names to the temporary file, + // if another thread is waiting for a read lock. + final FileContentKey fileKey = astFile.fFileContentKey; + final IASTPreprocessorIncludeStatement owner= astFile.fIncludeStatement; + + IIndexFileLocation location = fileKey.getLocation(); + ISignificantMacros significantMacros = fileKey.getSignificantMacros(); + IIndexFragmentFile oldFile = index.getWritableFile(linkageID, location, significantMacros); + file= index.addUncommittedFile(linkageID, location, significantMacros); try { - file.setScannerConfigurationHashcode(configHash); - Symbols lists= symbolMap.get(location); + boolean pragmaOnce= owner != null ? owner.hasPragmaOnceSemantics() : data.fAST.hasPragmaOnceSemantics(); + file.setPragmaOnceSemantics(pragmaOnce); + + Symbols lists= data.fSymbolMap.get(owner); if (lists != null) { IASTPreprocessorStatement[] macros= lists.fMacros.toArray(new IASTPreprocessorStatement[lists.fMacros.size()]); IASTName[][] names= lists.fNames.toArray(new IASTName[lists.fNames.size()][]); @@ -487,22 +538,30 @@ abstract public class PDOMWriter { } } - IncludeInformation[] includeInfos= new IncludeInformation[lists.fIncludes.size()]; + List includeInfos= new ArrayList(); for (int i= 0; i < lists.fIncludes.size(); i++) { - final IASTPreprocessorIncludeStatement include = lists.fIncludes.get(i); - final IncludeInformation info= includeInfos[i]= new IncludeInformation(); - info.fStatement= include; - if (include.isResolved()) { - info.fLocation= fResolver.resolveASTPath(include.getPath()); - info.fIsContext= include.isActive() && - (contextIncludes.contains(include) || clearedContexts.contains(info.fLocation)); + final IASTPreprocessorIncludeStatement stmt = lists.fIncludes.get(i); + if (!stmt.isResolved()) { + includeInfos.add(new IncludeInformation(stmt, null, ISignificantMacros.NONE, false)); + } else { + IIndexFileLocation targetLoc = fResolver.resolveASTPath(stmt.getPath()); + ISignificantMacros mainSig= stmt.getSignificantMacros(); + for (ISignificantMacros sig : stmt.getLoadedVersions()) { + if (!sig.equals(mainSig)) { + includeInfos.add(new IncludeInformation(stmt, targetLoc, sig, false)); + } + } + final boolean isContext = stmt.isActive() && stmt.isResolved() && + (data.fContextIncludes.contains(stmt) || isContextFor(oldFile, stmt)); + includeInfos.add(new IncludeInformation(stmt, targetLoc, mainSig, isContext)); } } - index.setFileContent(file, linkageID, includeInfos, macros, names, fResolver, lock); + IncludeInformation[] includeInfoArray= includeInfos.toArray(new IncludeInformation[includeInfos.size()]); + index.setFileContent(file, linkageID, includeInfoArray, macros, names, fResolver, lock); } file.setTimestamp(fResolver.getLastModified(location)); file.setEncodingHashcode(fResolver.getEncoding(location).hashCode()); - file.setContentsHash(fileContentsHash); + file.setContentsHash(astFile.fContentsHash); file = index.commitUncommittedFile(); } finally { index.clearUncommittedFile(); @@ -510,35 +569,21 @@ abstract public class PDOMWriter { return file; } - /** - * Makes a copy of the current progress information and returns it. - * @since 4.0 - */ - public IndexerProgress getProgressInformation() { - synchronized (fInfo) { - return new IndexerProgress(fInfo); + private boolean isContextFor(IIndexFragmentFile oldFile, IASTPreprocessorIncludeStatement stmt) + throws CoreException { + IIndexFile target= stmt.getImportedIndexFile(); + if (oldFile != null && target != null) { + IIndexInclude ctxInclude = target.getParsedInContext(); + if (ctxInclude != null && oldFile.equals(ctxInclude.getIncludedBy())) + return true; } + return false; } /** - * Updates current progress information with the provided delta. + * Informs the subclass that a file has been stored in the index. */ - protected final void updateFileCount(int sources, int primaryHeader, int header) { - synchronized (fInfo) { - fInfo.fCompletedSources += sources; - fInfo.fPrimaryHeaderCount += primaryHeader; - fInfo.fCompletedHeaders += header; - } - } - - /** - * Updates current progress information with the provided delta. - */ - protected final void incrementRequestedFilesCount(int delta) { - synchronized (fInfo) { - fInfo.fRequestedFilesCount += delta; - } - } + protected abstract void reportFileWrittenToIndex(FileInAST file, IIndexFragmentFile iFile) throws CoreException; private String getLocationInfo(String filename, int lineNumber) { return " at " + filename + "(" + lineNumber + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/TeamPDOMExportOperation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/TeamPDOMExportOperation.java index ea81c5e8f0b..90242f833a9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/TeamPDOMExportOperation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/TeamPDOMExportOperation.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom; @@ -50,7 +50,6 @@ import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.SubProgressMonitor; public class TeamPDOMExportOperation implements IWorkspaceRunnable { - /** * Option constant (value:1) to indicate that a resource snapshot * should be saved along with the exported PDOM. @@ -84,6 +83,7 @@ public class TeamPDOMExportOperation implements IWorkspaceRunnable { fMessageDigest= md; } + @Override public void run(IProgressMonitor monitor) throws CoreException { getMessageDigest(); getTargetLocation(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/TeamPDOMImportOperation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/TeamPDOMImportOperation.java index 65c286d4943..3fbeaa380a7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/TeamPDOMImportOperation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/TeamPDOMImportOperation.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom; @@ -82,6 +82,7 @@ public class TeamPDOMImportOperation implements IWorkspaceRunnable { fShowActivity= PDOMIndexerTask.checkDebugOption(IPDOMIndexerTask.TRACE_ACTIVITY, "true"); //$NON-NLS-1$ } + @Override public void run(IProgressMonitor pm) { if (fShowActivity) { System.out.println("Indexer: PDOMImporter start"); //$NON-NLS-1$ @@ -264,7 +265,7 @@ public class TeamPDOMImportOperation implements IWorkspaceRunnable { for (IIndexFragmentFile ifile : filesToDelete) { if (ifile != null) { checkMonitor(monitor); - pdom.clearFile(ifile, null); + pdom.clearFile(ifile); } } for (FileAndChecksum fc : updateTimestamps) { @@ -275,7 +276,6 @@ public class TeamPDOMImportOperation implements IWorkspaceRunnable { IResource r= fc.fFile.getResource(); if (r != null) { file.setTimestamp(r.getLocalTimeStamp()); - file.setScannerConfigurationHashcode(0); } } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/WaitForRefreshJobs.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/WaitForRefreshJobs.java index 784d8bd5ef9..795cf114a70 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/WaitForRefreshJobs.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/WaitForRefreshJobs.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom; @@ -30,13 +30,19 @@ public class WaitForRefreshJobs extends IndexerSetupParticipant { private Set fRefreshJobs= Collections.synchronizedSet(new HashSet()); private IJobChangeListener fJobListener= new IJobChangeListener() { + @Override public void sleeping(IJobChangeEvent event) {} + @Override public void scheduled(IJobChangeEvent event) {} + @Override public void running(IJobChangeEvent event) {} + @Override public void done(IJobChangeEvent event) { onJobDone(event.getJob()); } + @Override public void awake(IJobChangeEvent event) {} + @Override public void aboutToRun(IJobChangeEvent event) {} }; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/WritablePDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/WritablePDOM.java index 8de0cb7e20d..a0cb1fe0c94 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/WritablePDOM.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/WritablePDOM.java @@ -1,32 +1,36 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - * Andrew Ferguson (Symbian) - * Sergey Prigogin (Google) + * Markus Schorn - initial API and implementation + * Andrew Ferguson (Symbian) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom; import java.io.File; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Map; +import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement; +import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.index.IIndexLocationConverter; +import org.eclipse.cdt.core.parser.ISignificantMacros; +import org.eclipse.cdt.internal.core.index.FileContentKey; import org.eclipse.cdt.internal.core.index.IIndexFragment; import org.eclipse.cdt.internal.core.index.IIndexFragmentFile; -import org.eclipse.cdt.internal.core.index.IWritableIndexFragment; import org.eclipse.cdt.internal.core.index.IWritableIndex.IncludeInformation; -import org.eclipse.cdt.internal.core.pdom.db.BTree; +import org.eclipse.cdt.internal.core.index.IWritableIndexFragment; import org.eclipse.cdt.internal.core.pdom.db.ChunkCache; import org.eclipse.cdt.internal.core.pdom.db.DBProperties; import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor; @@ -45,7 +49,7 @@ public class WritablePDOM extends PDOM implements IWritableIndexFragment { private ASTFilePathResolver fPathResolver; private PDOMFile fileBeingUpdated; private PDOMFile uncommittedFile; - private IIndexFileLocation uncommittedLocation; + private FileContentKey uncommittedKey; public WritablePDOM(File dbPath, IIndexLocationConverter locationConverter, Map linkageFactoryMappings) throws CoreException { @@ -62,62 +66,65 @@ public class WritablePDOM extends PDOM implements IWritableIndexFragment { } @Override - public IIndexFragmentFile addFile(int linkageID, IIndexFileLocation location) throws CoreException { - if (uncommittedLocation != null && uncommittedLocation.equals(location)) { + public IIndexFragmentFile addFile(int linkageID, IIndexFileLocation location, ISignificantMacros sigMacros) throws CoreException { + if (uncommittedKey != null && uncommittedKey.equals(new FileContentKey(linkageID, location, sigMacros))) return uncommittedFile; - } - return super.addFile(linkageID, location); + + return super.addFile(linkageID, location, sigMacros); } - public IIndexFragmentFile addUncommittedFile(int linkageID, IIndexFileLocation location) throws CoreException { - uncommittedLocation = location; - fileBeingUpdated = getFile(linkageID, uncommittedLocation); + @Override + public IIndexFragmentFile addUncommittedFile(int linkageID, IIndexFileLocation location, + ISignificantMacros significantMacros) throws CoreException { + uncommittedKey = new FileContentKey(linkageID, location, significantMacros); + fileBeingUpdated = getFile(linkageID, location, significantMacros); PDOMLinkage linkage= createLinkage(linkageID); - uncommittedFile = new PDOMFile(linkage, location, linkageID); + uncommittedFile = new PDOMFile(linkage, location, linkageID, significantMacros); return uncommittedFile; } + @Override public IIndexFragmentFile commitUncommittedFile() throws CoreException { if (uncommittedFile == null) return null; - IIndexFragmentFile file; + PDOMFile file; if (fileBeingUpdated == null) { - // New file. - BTree fileIndex = getFileIndex(); - fileIndex.insert(uncommittedFile.getRecord()); + // New file, insert it into the index. file = uncommittedFile; + getFileIndex().insert(file.getRecord()); } else { // Existing file. fileBeingUpdated.replaceContentsFrom(uncommittedFile); file = fileBeingUpdated; fileBeingUpdated = null; } - fEvent.fFilesWritten.add(uncommittedLocation); + fEvent.fFilesWritten.add(uncommittedKey.getLocation()); uncommittedFile = null; - uncommittedLocation = null; + uncommittedKey = null; return file; } + @Override public void clearUncommittedFile() throws CoreException { if (uncommittedFile != null) { try { - uncommittedFile.clear(null); + uncommittedFile.clear(); uncommittedFile.delete(); } finally { uncommittedFile = null; - uncommittedLocation = null; + uncommittedKey = null; fileBeingUpdated = null; } } } + @Override public void addFileContent(IIndexFragmentFile sourceFile, IncludeInformation[] includes, IASTPreprocessorStatement[] macros, IASTName[][] names, ASTFilePathResolver pathResolver, YieldableIndexLock lock) throws CoreException, InterruptedException { assert sourceFile.getIndexFragment() == this; PDOMFile pdomFile = (PDOMFile) sourceFile; - pdomFile.addIncludesTo(includes); pdomFile.addMacros(macros); final ASTFilePathResolver origResolver= fPathResolver; fPathResolver= pathResolver; @@ -126,6 +133,8 @@ public class WritablePDOM extends PDOM implements IWritableIndexFragment { } finally { fPathResolver= origResolver; } + // Includes expose the temporary file in the index, we must not yield the lock beyond this point. + pdomFile.addIncludesTo(includes); final IIndexFileLocation location = pdomFile.getLocation(); if (location != null) { @@ -134,12 +143,14 @@ public class WritablePDOM extends PDOM implements IWritableIndexFragment { } } - public void clearFile(IIndexFragmentFile file, Collection contextsRemoved) - throws CoreException { + @Override + public void clearFile(IIndexFragmentFile file) throws CoreException { assert file.getIndexFragment() == this; - ((PDOMFile) file).clear(contextsRemoved); - - fEvent.fClearedFiles.add(file.getLocation()); + IIndexFileLocation location = file.getLocation(); + PDOMFile pdomFile = (PDOMFile) file; + pdomFile.clear(); + + fEvent.fClearedFiles.add(location); } @Override @@ -152,10 +163,7 @@ public class WritablePDOM extends PDOM implements IWritableIndexFragment { super.flush(); } - /* - * (non-Javadoc) - * @see org.eclipse.cdt.internal.core.index.IWritableIndexFragment#setProperty(java.lang.String, java.lang.String) - */ + @Override public void setProperty(String propertyName, String value) throws CoreException { if (IIndexFragment.PROPERTY_FRAGMENT_FORMAT_ID.equals(propertyName) || IIndexFragment.PROPERTY_FRAGMENT_FORMAT_VERSION.equals(propertyName)) { @@ -165,9 +173,9 @@ public class WritablePDOM extends PDOM implements IWritableIndexFragment { } /** - * Use the specified location converter to update each internal representation of a file location. - * The file index is rebuilt with the new representations. Individual PDOMFile records are unmoved so - * as to maintain referential integrity with other PDOM records. + * Uses the specified location converter to update each internal representation of a file + * location. The file index is rebuilt with the new representations. Individual PDOMFile records + * are unmoved so as to maintain referential integrity with other PDOM records. * * A write-lock must be obtained before calling this method * @@ -177,9 +185,11 @@ public class WritablePDOM extends PDOM implements IWritableIndexFragment { public void rewriteLocations(final IIndexLocationConverter newConverter) throws CoreException { final List pdomfiles = new ArrayList(); getFileIndex().accept(new IBTreeVisitor() { + @Override public int compare(long record) throws CoreException { return 0; } + @Override public boolean visit(long record) throws CoreException { PDOMFile file = PDOMFile.recreateFile(WritablePDOM.this, record); pdomfiles.add(file); @@ -202,7 +212,7 @@ public class WritablePDOM extends PDOM implements IWritableIndexFragment { // remove content where converter returns null for (PDOMFile file : notConverted) { file.convertIncludersToUnresolved(); - file.clear(null); + file.clear(); } } @@ -227,16 +237,34 @@ public class WritablePDOM extends PDOM implements IWritableIndexFragment { return false; } - public PDOMFile getFileForASTPath(int linkageID, String astPath) throws CoreException { - if (fPathResolver != null && astPath != null) { - IIndexFileLocation location = fPathResolver.resolveASTPath(astPath); - if (location.equals(uncommittedLocation)) - return fileBeingUpdated != null ? fileBeingUpdated : uncommittedFile; - return getFile(linkageID, location); + public PDOMFile getFileForASTNode(int linkageID, IASTNode node) throws CoreException { + if (fPathResolver != null && node != null) { + IASTFileLocation loc= node.getFileLocation(); + if (loc != null) { + ISignificantMacros sigMacros= getSignificantMacros(node, loc); + if (sigMacros != null) { + IIndexFileLocation location = fPathResolver.resolveASTPath(loc.getFileName()); + if (uncommittedKey != null && uncommittedKey.equals(new FileContentKey(linkageID, location, sigMacros))) + return fileBeingUpdated != null ? fileBeingUpdated : uncommittedFile; + return getFile(linkageID, location, sigMacros); + } + } } return null; } + private ISignificantMacros getSignificantMacros(IASTNode node, IASTFileLocation loc) throws CoreException { + IASTPreprocessorIncludeStatement owner= loc.getContextInclusionStatement(); + if (owner != null) + return owner.getSignificantMacros(); + + IASTTranslationUnit tu = node.getTranslationUnit(); + if (tu != null) + return tu.getSignificantMacros(); + + return null; + } + @Override public boolean hasLastingDefinition(PDOMBinding binding) throws CoreException { if (fileBeingUpdated == null) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/YieldableIndexLock.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/YieldableIndexLock.java index 8e110800675..03015c012c4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/YieldableIndexLock.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/YieldableIndexLock.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Sergey Prigogin (Google) - initial API and implementation + * Sergey Prigogin (Google) - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom; @@ -19,14 +19,12 @@ import org.eclipse.cdt.internal.core.index.IWritableIndex; */ public class YieldableIndexLock { private final IWritableIndex index; - private final int readlockCount; private final boolean flushIndex; private long lastLockTime; private long cumulativeLockTime; - public YieldableIndexLock(IWritableIndex index, int readlockCount, boolean flushIndex) { + public YieldableIndexLock(IWritableIndex index, boolean flushIndex) { this.index = index; - this.readlockCount = readlockCount; this.flushIndex = flushIndex; } @@ -36,7 +34,7 @@ public class YieldableIndexLock { * @throws InterruptedException */ public void acquire() throws InterruptedException { - index.acquireWriteLock(readlockCount); + index.acquireWriteLock(); lastLockTime = System.currentTimeMillis(); } @@ -45,7 +43,7 @@ public class YieldableIndexLock { */ public void release() { if (lastLockTime != 0) { - index.releaseWriteLock(readlockCount, flushIndex); + index.releaseWriteLock(flushIndex); cumulativeLockTime += System.currentTimeMillis() - lastLockTime; lastLockTime = 0; } @@ -58,7 +56,7 @@ public class YieldableIndexLock { */ public void yield() throws InterruptedException { if (index.hasWaitingReaders()) { - index.releaseWriteLock(readlockCount, false); + index.releaseWriteLock(false); cumulativeLockTime += System.currentTimeMillis() - lastLockTime; lastLockTime = 0; acquire(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java index 5e11beb7dc2..8d630540efd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java @@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IASTImageLocation; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNodeLocation; +import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.ICompositeType; @@ -73,6 +74,10 @@ public class PDOMASTAdapter { public int getNodeOffset() { return loc.getNodeOffset(); } + + public IASTPreprocessorIncludeStatement getContextInclusionStatement() { + return loc.getContextInclusionStatement(); + } }; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFile.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFile.java index f8368489476..dac2a04cdc1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFile.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFile.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 QNX Software Systems and others. + * Copyright (c) 2005, 2011 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,7 +16,6 @@ package org.eclipse.cdt.internal.core.pdom.dom; import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -31,18 +30,19 @@ import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IMacroBinding; import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective; -import org.eclipse.cdt.core.index.IIndexFile; import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.index.IIndexInclude; import org.eclipse.cdt.core.index.IIndexLocationConverter; import org.eclipse.cdt.core.index.IIndexMacro; import org.eclipse.cdt.core.index.IIndexName; +import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.cdt.internal.core.index.IIndexFragment; import org.eclipse.cdt.internal.core.index.IIndexFragmentFile; import org.eclipse.cdt.internal.core.index.IIndexFragmentName; import org.eclipse.cdt.internal.core.index.IWritableIndex.IncludeInformation; import org.eclipse.cdt.internal.core.index.IWritableIndexFragment; import org.eclipse.cdt.internal.core.index.IndexFileLocation; +import org.eclipse.cdt.internal.core.parser.scanner.SignificantMacros; import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.YieldableIndexLock; import org.eclipse.cdt.internal.core.pdom.db.BTree; @@ -56,28 +56,31 @@ import org.eclipse.core.runtime.Status; /** * Represents a file containing names. - * + * * @author Doug Schaefer */ public class PDOMFile implements IIndexFragmentFile { private final PDOMLinkage fLinkage; private final long record; - private IIndexFileLocation location; // No need to make volatile, all fields of IIndexFileLocation are final. + private IIndexFileLocation location; // No need to make volatile, all fields of IndexFileLocation are final. + private ISignificantMacros sigMacros; // No need to make volatile, all fields of SignificantMacros are either final or atomically updated. private static final int FIRST_NAME = 0; - private static final int FIRST_INCLUDE = 4; - private static final int FIRST_INCLUDED_BY = 8; - private static final int FIRST_MACRO = 12; - private static final int LOCATION_REPRESENTATION = 16; - private static final int LINKAGE_ID= 20; - private static final int TIME_STAMP = 24; - private static final int CONTENT_HASH= 32; - private static final int SCANNER_CONFIG_HASH= 40; - private static final int ENCODING_HASH= 44; - private static final int LAST_USING_DIRECTIVE= 48; - private static final int FIRST_MACRO_REFERENCE= 52; + private static final int FIRST_INCLUDE = FIRST_NAME + Database.PTR_SIZE; + private static final int FIRST_INCLUDED_BY = FIRST_INCLUDE + Database.PTR_SIZE; + private static final int FIRST_MACRO = FIRST_INCLUDED_BY + Database.PTR_SIZE; + private static final int LOCATION_REPRESENTATION = FIRST_MACRO + Database.PTR_SIZE; + private static final int LINKAGE_ID= LOCATION_REPRESENTATION + Database.PTR_SIZE; // size 3 + private static final int FLAGS= LINKAGE_ID + 3; // size 1 + private static final int TIME_STAMP = FLAGS + 1; // long + private static final int CONTENT_HASH= TIME_STAMP + 8; // long + private static final int ENCODING_HASH= CONTENT_HASH + 8; + private static final int LAST_USING_DIRECTIVE= ENCODING_HASH + 4; + private static final int FIRST_MACRO_REFERENCE= LAST_USING_DIRECTIVE + Database.PTR_SIZE; + private static final int SIGNIFICANT_MACROS= FIRST_MACRO_REFERENCE + Database.PTR_SIZE; + private static final int RECORD_SIZE= SIGNIFICANT_MACROS + Database.PTR_SIZE; // 8*PTR_SIZE + 3+1+8+8+4 = 56 - private static final int RECORD_SIZE= 56; + private static final int FLAG_PRAGMA_ONCE_SEMANTICS = 0x01; public static class Comparator implements IBTreeComparator { private Database db; @@ -91,10 +94,26 @@ public class PDOMFile implements IIndexFragmentFile { IString name2 = db.getString(db.getRecPtr(record2 + LOCATION_REPRESENTATION)); int cmp= name1.compare(name2, true); if (cmp == 0) { - cmp= db.getInt(record1 + LINKAGE_ID) - db.getInt(record2 + LINKAGE_ID); + cmp= db.get3ByteUnsignedInt(record1 + LINKAGE_ID) - db.get3ByteUnsignedInt(record2 + LINKAGE_ID); + if (cmp == 0) { + IString sm1= getString(record1 + SIGNIFICANT_MACROS); + IString sm2= getString(record2 + SIGNIFICANT_MACROS); + if (sm1 == null) { + cmp= sm2 == null ? 0 : -1; + } else if (sm2 == null) { + cmp= 1; + } else { + cmp= sm1.compare(sm2, true); + } + } } return cmp; } + + private IString getString(long offset) throws CoreException { + long rec = db.getRecPtr(offset); + return rec != 0 ? db.getString(rec) : null; + } } public PDOMFile(PDOMLinkage linkage, long record) { @@ -102,7 +121,7 @@ public class PDOMFile implements IIndexFragmentFile { this.record = record; } - public PDOMFile(PDOMLinkage linkage, IIndexFileLocation location, int linkageID) throws CoreException { + public PDOMFile(PDOMLinkage linkage, IIndexFileLocation location, int linkageID, ISignificantMacros macros) throws CoreException { fLinkage = linkage; this.location= location; Database db = fLinkage.getDB(); @@ -112,7 +131,8 @@ public class PDOMFile implements IIndexFragmentFile { throw new CoreException(CCorePlugin.createStatus(Messages.getString("PDOMFile.toInternalProblem") + location.getURI())); //$NON-NLS-1$ IString locationDBString = db.newString(locationString); db.putRecPtr(record + LOCATION_REPRESENTATION, locationDBString.getRecord()); - db.putInt(record + LINKAGE_ID, linkageID); + db.put3ByteUnsignedInt(record + LINKAGE_ID, linkageID); + db.putRecPtr(record + SIGNIFICANT_MACROS, db.newString(macros.encode()).getRecord()); setTimestamp(-1); } @@ -123,7 +143,7 @@ public class PDOMFile implements IIndexFragmentFile { public PDOM getPDOM() { return fLinkage.getPDOM(); } - + @Override public boolean equals(Object obj) { if (obj == this) @@ -139,86 +159,45 @@ public class PDOMFile implements IIndexFragmentFile { public final int hashCode() { return System.identityHashCode(fLinkage.getPDOM()) + (int) (41 * record); } - + /** * Transfers names, macros and includes from another file to this one and deletes the other file. * @param sourceFile the file to transfer the local bindings from. * @throws CoreException */ public void replaceContentsFrom(PDOMFile sourceFile) throws CoreException { - ICPPUsingDirective[] directives= getUsingDirectives(); - for (ICPPUsingDirective ud : directives) { - if (ud instanceof IPDOMNode) { - ((IPDOMNode) ud).delete(null); - } - } - setFirstUsingDirectiveRec(sourceFile.getLastUsingDirectiveRec()); + // Delete current content + clear(); - // Replace the includes - PDOMInclude include = getFirstInclude(); - while (include != null) { - PDOMInclude nextInclude = include.getNextInIncludes(); - IIndexFile includedBy = include.getIncludedBy(); - if (this.equals(includedBy)) { - include.delete(); - } - include = nextInclude; - } - include = sourceFile.getFirstInclude(); + // Link in the using directives + setLastUsingDirective(sourceFile.getLastUsingDirectiveRec()); + + // Link in the includes, replace the owner. + PDOMInclude include = sourceFile.getFirstInclude(); setFirstInclude(include); - while (include != null) { - IIndexFile includedBy = include.getIncludedBy(); - if (sourceFile.equals(includedBy)) { - include.setIncludedBy(this); - if (sourceFile.equals(include.getIncludes())) { - include.setIncludes(this); - } - } - include = include.getNextInIncludes(); + for (; include != null; include= include.getNextInIncludes()) { + include.setIncludedBy(this); } - // Replace all the macros in this file. - PDOMLinkage linkage= getLinkage(); - PDOMMacro macro = getFirstMacro(); - while (macro != null) { - PDOMMacro nextMacro = macro.getNextMacro(); - macro.delete(linkage); - macro = nextMacro; - } - macro = sourceFile.getFirstMacro(); + // In the unexpected case that there is an included by relation, append it. + transferIncluders(sourceFile); + + // Link in the macros. + PDOMMacro macro = sourceFile.getFirstMacro(); setFirstMacro(macro); for (; macro != null; macro = macro.getNextMacro()) { macro.setFile(this); } - // Replace all macro references - ArrayList mrefs= new ArrayList(); - PDOMMacroReferenceName mref = getFirstMacroReference(); - while (mref != null) { - mrefs.add(mref); - mref= mref.getNextInFile(); - } - for (PDOMMacroReferenceName m : mrefs) { - m.delete(); - } - mref = sourceFile.getFirstMacroReference(); + // Link in macro references + PDOMMacroReferenceName mref = sourceFile.getFirstMacroReference(); setFirstMacroReference(mref); for (; mref != null; mref = mref.getNextInFile()) { mref.setFile(this); } // Replace all the names in this file - ArrayList names= new ArrayList(); - PDOMName name = getFirstName(); - for (; name != null; name= name.getNextInFile()) { - names.add(name); - linkage.onDeleteName(name); - } - for (Iterator iterator = names.iterator(); iterator.hasNext();) { - name = iterator.next(); - name.delete(); - } - name = sourceFile.getFirstName(); + PDOMName name = sourceFile.getFirstName(); setFirstName(name); for (; name != null; name= name.getNextInFile()) { name.setFile(this); @@ -227,11 +206,58 @@ public class PDOMFile implements IIndexFragmentFile { setTimestamp(sourceFile.getTimestamp()); setEncodingHashcode(sourceFile.getEncodingHashcode()); setContentsHash(sourceFile.getContentsHash()); - setScannerConfigurationHashcode(sourceFile.getScannerConfigurationHashcode()); + // Transfer the flags. + Database db= fLinkage.getDB(); + db.putByte(record + FLAGS, db.getByte(sourceFile.record + FLAGS)); + + // Delete the source file sourceFile.delete(); } + public void transferIncluders(IIndexFragmentFile sourceFile) throws CoreException { + PDOMFile source= (PDOMFile) sourceFile; + PDOMInclude include = source.getFirstIncludedBy(); + if (include != null) { + // Detach the includes + source.setFirstIncludedBy(null); + // Adjust the includes + for (PDOMInclude i= include; i != null; i= i.getNextInIncludedBy()) { + i.setIncludes(this); + } + // Append the includes + PDOMInclude last= getFirstIncludedBy(); + if (last == null) { + setFirstIncludedBy(include); + } else { + for (PDOMInclude i= last; i != null; i= i.getNextInIncludedBy()) { + last= i; + } + last.setNextInIncludedBy(include); + include.setPrevInIncludedBy(last); + } + } + } + + public void transferContext(IIndexFragmentFile sourceFile) throws CoreException { + PDOMFile source= (PDOMFile) sourceFile; + PDOMInclude include = source.getFirstIncludedBy(); + if (include != null) { + // Detach the include + final PDOMInclude next = include.getNextInIncludedBy(); + include.setNextInIncludedBy(null); + source.setFirstIncludedBy(next); + if (next != null) + next.setPrevInIncludedBy(null); + + // Adjust the include + include.setIncludes(this); + + // Insert the include + addIncludedBy(include, false); + } + } + /** * This method should not be called on PDOMFile objects that are referenced by the file index. * @param location a new location @@ -239,9 +265,10 @@ public class PDOMFile implements IIndexFragmentFile { */ public void setLocation(IIndexFileLocation location) throws CoreException { String locationString = fLinkage.getPDOM().getLocationConverter().toInternalFormat(location); - if (locationString == null) + if (locationString == null) { throw new CoreException(CCorePlugin.createStatus(Messages.getString("PDOMFile.toInternalProblem") + //$NON-NLS-1$ location.getURI())); + } setInternalLocation(locationString); } @@ -260,10 +287,10 @@ public class PDOMFile implements IIndexFragmentFile { db.putRecPtr(record + LOCATION_REPRESENTATION, db.newString(internalLocation).getRecord()); location= null; } - + public int getLinkageID() throws CoreException { Database db = fLinkage.getDB(); - return db.getInt(record + LINKAGE_ID); + return db.get3ByteUnsignedInt(record + LINKAGE_ID); } public long getTimestamp() throws CoreException { @@ -287,13 +314,7 @@ public class PDOMFile implements IIndexFragmentFile { } public int getScannerConfigurationHashcode() throws CoreException { - Database db = fLinkage.getDB(); - return db.getInt(record + SCANNER_CONFIG_HASH); - } - - public void setScannerConfigurationHashcode(int hashcode) throws CoreException { - Database db= fLinkage.getDB(); - db.putInt(record + SCANNER_CONFIG_HASH, hashcode); + return 0; } public int getEncodingHashcode() throws CoreException { @@ -306,6 +327,21 @@ public class PDOMFile implements IIndexFragmentFile { db.putInt(record + ENCODING_HASH, hashcode); } + public boolean hasPragmaOnceSemantics() throws CoreException { + return (fLinkage.getDB().getByte(record + FLAGS) & FLAG_PRAGMA_ONCE_SEMANTICS) != 0; + } + + public void setPragmaOnceSemantics(boolean value) throws CoreException { + Database db = fLinkage.getDB(); + byte flags = db.getByte(record + FLAGS); + if (value) { + flags |= FLAG_PRAGMA_ONCE_SEMANTICS; + } else { + flags &= ~FLAG_PRAGMA_ONCE_SEMANTICS; + } + db.putByte(record + FLAGS, flags); + } + private PDOMName getFirstName() throws CoreException { long namerec = fLinkage.getDB().getRecPtr(record + FIRST_NAME); return namerec != 0 ? new PDOMName(fLinkage, namerec) : null; @@ -340,7 +376,7 @@ public class PDOMFile implements IIndexFragmentFile { long rec = fLinkage.getDB().getRecPtr(record + FIRST_INCLUDED_BY); return rec != 0 ? new PDOMInclude(fLinkage, rec) : null; } - + public IIndexInclude getParsedInContext() throws CoreException { return getFirstIncludedBy(); } @@ -459,22 +495,22 @@ public class PDOMFile implements IIndexFragmentFile { return new PDOMMacroReferenceName(fLinkage, name, this, cont); } - public void clear(Collection contextsRemoved) throws CoreException { + public void clear() throws CoreException { ICPPUsingDirective[] directives= getUsingDirectives(); for (ICPPUsingDirective ud : directives) { if (ud instanceof IPDOMNode) { ((IPDOMNode) ud).delete(null); } } - setFirstUsingDirectiveRec(0); + setLastUsingDirective(0); // Remove the includes PDOMInclude include = getFirstInclude(); while (include != null) { PDOMInclude nextInclude = include.getNextInIncludes(); - if (contextsRemoved != null && include.getPrevInIncludedByRecord() == 0) { - contextsRemoved.add(include.getIncludesLocation()); - } +// if (contextsRemoved != null && include.getPrevInIncludedByRecord() == 0) { +// contextsRemoved.add(include.getIncludesLocation()); +// } include.delete(); include = nextInclude; } @@ -515,7 +551,6 @@ public class PDOMFile implements IIndexFragmentFile { m.delete(); } setFirstMacroReference(null); - setTimestamp(-1); } @@ -527,6 +562,9 @@ public class PDOMFile implements IIndexFragmentFile { public void delete() throws CoreException { Database db = fLinkage.getDB(); long locRecord = db.getRecPtr(record + LOCATION_REPRESENTATION); + if (locRecord != 0) + db.getString(locRecord).delete(); + locRecord = db.getRecPtr(record + SIGNIFICANT_MACROS); if (locRecord != 0) db.getString(locRecord).delete(); @@ -539,7 +577,7 @@ public class PDOMFile implements IIndexFragmentFile { PDOMInclude lastInclude= null; for (final IncludeInformation info : includeInfos) { final PDOMFile targetFile= (PDOMFile) info.fTargetFile; - + PDOMInclude pdomInclude = new PDOMInclude(fLinkage, info.fStatement, this, targetFile); assert targetFile == null || targetFile.getIndexFragment() instanceof IWritableIndexFragment; if (targetFile != null) { @@ -560,7 +598,7 @@ public class PDOMFile implements IIndexFragmentFile { if (isContext) { setFirstIncludedBy(include); include.setNextInIncludedBy(firstIncludedBy); - firstIncludedBy.setPrevInIncludedBy(include); + firstIncludedBy.setPrevInIncludedBy(include); } else { PDOMInclude secondIncludedBy= firstIncludedBy.getNextInIncludedBy(); if (secondIncludedBy != null) { @@ -606,13 +644,12 @@ public class PDOMFile implements IIndexFragmentFile { if (nameOffset >= offset) { if (nameOffset + name.getNodeLength() <= offset + length) { result.add(name); - } else if (name.isReference()) { + } else if (name.isReference()) { // Names are ordered, but callers are inserted before // their references. break; } } - } for (PDOMMacro macro= getFirstMacro(); macro != null; macro= macro.getNextMacro()) { int nameOffset= macro.getNodeOffset(); @@ -622,7 +659,7 @@ public class PDOMFile implements IIndexFragmentFile { if (name != null) { result.add(name); } - } else { + } else { break; } } @@ -632,7 +669,7 @@ public class PDOMFile implements IIndexFragmentFile { if (nameOffset >= offset) { if (nameOffset + name.getNodeLength() <= offset + length) { result.add(name); - } else { + } else { break; } } @@ -640,11 +677,53 @@ public class PDOMFile implements IIndexFragmentFile { return result.toArray(new IIndexName[result.size()]); } - public static PDOMFile findFile(PDOMLinkage linkage, BTree btree, IIndexFileLocation location, + public static IIndexFragmentFile[] findFiles(PDOMLinkage linkage, BTree btree, IIndexFileLocation location, IIndexLocationConverter strategy) throws CoreException { String internalRepresentation= strategy.toInternalFormat(location); if (internalRepresentation != null) { - Finder finder = new Finder(linkage.getDB(), internalRepresentation, linkage.getLinkageID()); + Finder finder = new Finder(linkage.getDB(), internalRepresentation, linkage.getLinkageID(), null); + btree.accept(finder); + long[] records= finder.getRecords(); + IIndexFragmentFile[] result= new IIndexFragmentFile[records.length]; + for (int i = 0; i < result.length; i++) { + result[i]= new PDOMFile(linkage, records[i]); + } + return result; + } + return IIndexFragmentFile.EMPTY_ARRAY; + } + + /** + * When a header file is stored in the index in multiple variants for different sets of macro + * definitions this method will return an arbitrary one of these variants. + * + * @deprecated Use + * {@link #findFile(PDOMLinkage, BTree, IIndexFileLocation, IIndexLocationConverter, ISignificantMacros)} + * or {@link #findFiles(PDOMLinkage, BTree, IIndexFileLocation, IIndexLocationConverter)} + */ + @Deprecated + public static PDOMFile findFile(PDOMLinkage linkage, BTree btree, IIndexFileLocation location, + IIndexLocationConverter strategy) throws CoreException { + return findFile(linkage, btree, location, strategy, null); + } + + /** + * Finds the file in index. + * + * @param linkage The linkage of the file. + * @param btree The file index. + * @param location The location of the file. + * @param strategy The index location converter. + * @param macroDictionary The names and definitions of the macros used to disambiguate between + * variants of the file contents corresponding to different inclusion points. + * @return The found file, or null if the matching file was not found. + */ + public static PDOMFile findFile(PDOMLinkage linkage, BTree btree, IIndexFileLocation location, + IIndexLocationConverter strategy, ISignificantMacros macroDictionary) throws CoreException { + String internalRepresentation= strategy.toInternalFormat(location); + if (internalRepresentation != null) { + Finder finder = new Finder(linkage.getDB(), internalRepresentation, linkage.getLinkageID(), + macroDictionary); btree.accept(finder); long record= finder.getRecord(); if (record != 0) { @@ -658,7 +737,7 @@ public class PDOMFile implements IIndexFragmentFile { IIndexLocationConverter strategy) throws CoreException { String internalRepresentation= strategy.toInternalFormat(location); if (internalRepresentation != null) { - Finder finder = new Finder(pdom.getDB(), internalRepresentation, -1); + Finder finder = new Finder(pdom.getDB(), internalRepresentation, -1, null); btree.accept(finder); long[] records= finder.getRecords(); PDOMFile[] result= new PDOMFile[records.length]; @@ -672,12 +751,11 @@ public class PDOMFile implements IIndexFragmentFile { public static PDOMFile recreateFile(PDOM pdom, final long record) throws CoreException { final Database db= pdom.getDB(); - final int linkageID= db.getInt(record + PDOMFile.LINKAGE_ID); + final int linkageID= db.get3ByteUnsignedInt(record + LINKAGE_ID); PDOMLinkage linkage= pdom.getLinkage(linkageID); if (linkage == null) throw new CoreException(createStatus("Invalid linkage ID in database")); //$NON-NLS-1$ - PDOMFile file= new PDOMFile(linkage, record); - return file; + return new PDOMFile(linkage, record); } private static class Finder implements IBTreeVisitor { @@ -687,14 +765,17 @@ public class PDOMFile implements IIndexFragmentFile { private long record; private long[] records; private final int linkageID; + private char[] rawSignificantMacros; /** * Searches for a file with the given linkage id. */ - public Finder(Database db, String internalRepresentation, int linkageID) { + public Finder(Database db, String internalRepresentation, int linkageID, ISignificantMacros sigMacros) { this.db = db; this.rawKey = internalRepresentation; this.linkageID= linkageID; + this.rawSignificantMacros = sigMacros == null ? null : sigMacros.encode(); + assert linkageID >= 0 || rawSignificantMacros == null; } public long[] getRecords() { @@ -706,32 +787,48 @@ public class PDOMFile implements IIndexFragmentFile { } return records; } - + public int compare(long record) throws CoreException { IString name = db.getString(db.getRecPtr(record + PDOMFile.LOCATION_REPRESENTATION)); int cmp= name.compare(rawKey, true); if (cmp == 0 && linkageID >= 0) { - cmp= db.getInt(record + PDOMFile.LINKAGE_ID) - linkageID; + cmp= db.get3ByteUnsignedInt(record + PDOMFile.LINKAGE_ID) - linkageID; + if (cmp == 0 && rawSignificantMacros != null) { + IString significantMacrosStr = getString(record + SIGNIFICANT_MACROS); + if (significantMacrosStr != null) { + cmp = significantMacrosStr.compare(rawSignificantMacros, true); + } else { + cmp = rawSignificantMacros.length > 0 ? -1 : 0; + } + } } return cmp; } - + + private IString getString(long offset) throws CoreException { + long rec = db.getRecPtr(offset); + return rec != 0 ? db.getString(rec) : null; + } + public boolean visit(long record) throws CoreException { - if (linkageID >= 0) { + if (rawSignificantMacros != null) { this.record = record; - return false; + return false; + // Stop searching. } + if (this.record == 0) { this.record= record; } else if (this.records == null) { - this.records= new long[] {this.record, record}; + this.records= new long[] { this.record, record }; } else { long[] cpy= new long[this.records.length + 1]; System.arraycopy(this.records, 0, cpy, 0, this.records.length); cpy[cpy.length - 1]= record; this.records= cpy; } - return linkageID < 0; + // Continue search. + return true; } public long getRecord() { @@ -757,7 +854,17 @@ public class PDOMFile implements IIndexFragmentFile { } return location; } + + public ISignificantMacros getSignificantMacros() throws CoreException { + if (sigMacros == null) { + Database db= fLinkage.getDB(); + final IString encoded = db.getString(db.getRecPtr(record + SIGNIFICANT_MACROS)); + sigMacros= encoded == null ? ISignificantMacros.NONE : new SignificantMacros(encoded.getChars()); + } + return sigMacros; + } + public boolean hasContent() throws CoreException { return getTimestamp() != -1; } @@ -779,7 +886,7 @@ public class PDOMFile implements IIndexFragmentFile { return fLinkage.getDB().getRecPtr(record + LAST_USING_DIRECTIVE); } - public void setFirstUsingDirectiveRec(long rec) throws CoreException { + public void setLastUsingDirective(long rec) throws CoreException { fLinkage.getDB().putRecPtr(record + LAST_USING_DIRECTIVE, rec); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java index 35cc42ef67b..78d13b8b15b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java @@ -256,9 +256,9 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage } if (checkIfInSourceOnly) { - String path= ASTInternal.getDeclaredInSourceFileOnly(binding, requireDefinition, glob); - if (path != null) { - return wpdom.getFileForASTPath(getLinkageID(), path); + IASTNode node= ASTInternal.getDeclaredInSourceFileOnly(binding, requireDefinition, glob); + if (node != null) { + return wpdom.getFileForASTNode(getLinkageID(), node); } } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacro.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacro.java index 7ea5c88564d..8f8b0a6f10d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacro.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacro.java @@ -20,6 +20,7 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMVisitor; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorUndefStatement; import org.eclipse.cdt.core.dom.ast.IMacroBinding; @@ -278,10 +279,6 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation { fLinkage.getDB().putRecPtr(fRecord + FILE, file != null ? file.getRecord() : 0); } - public int getEndingLineNumber() { - return 0; - } - public String getFileName() { try { IIndexFile file = getFile(); @@ -303,6 +300,14 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation { return 0; } + public int getEndingLineNumber() { + return 0; + } + + public IASTPreprocessorIncludeStatement getContextInclusionStatement() { + return null; + } + public IASTFileLocation asFileLocation() { return this; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacroReferenceName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacroReferenceName.java index dc2807e21d4..ff242e63d2e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacroReferenceName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacroReferenceName.java @@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.pdom.dom; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement; import org.eclipse.cdt.core.index.IIndexFile; import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.index.IndexLocationFactory; @@ -216,6 +217,10 @@ public final class PDOMMacroReferenceName implements IIndexFragmentName, IASTFil return 0; } + public IASTPreprocessorIncludeStatement getContextInclusionStatement() { + return null; + } + public IASTFileLocation asFileLocation() { return this; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java index f8a5bb59273..cad23af7f64 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (QNX) - Initial API and implementation - * Markus Schorn (Wind River Systems) - * Sergey Prigogin (Google) + * Doug Schaefer (QNX) - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom; @@ -17,6 +17,7 @@ import java.util.ArrayList; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement; import org.eclipse.cdt.core.index.IIndexFile; import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.index.IndexLocationFactory; @@ -323,6 +324,10 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation { return 0; } + public IASTPreprocessorIncludeStatement getContextInclusionStatement() { + return null; + } + public IASTFileLocation asFileLocation() { return this; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java index eb3c04ceb0e..fb1c617cbcf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java @@ -6,10 +6,10 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (QNX) - Initial API and implementation - * Markus Schorn (Wind River Systems) - * Andrew Ferguson (Symbian) - * Sergey Prigogin (Google) + * Doug Schaefer (QNX) - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Andrew Ferguson (Symbian) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom.cpp; @@ -127,10 +127,12 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { super(pdom, CPP_LINKAGE_NAME, CPP_LINKAGE_NAME.toCharArray()); } + @Override public String getLinkageName() { return CPP_LINKAGE_NAME; } + @Override public int getLinkageID() { return CPP_LINKAGE_ID; } @@ -156,6 +158,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { postProcesses.add(this); } + @Override public void run() { for (int i = 0; i < fOriginal.length; i++) { final IPDOMCPPTemplateParameter tp = fPersisted[i]; @@ -176,6 +179,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { postProcesses.add(this); } + @Override public void run() { try { ICPPTemplateArgument[] args = binding.getTemplateArguments(); @@ -209,6 +213,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { postProcesses.add(this); } + @Override public void run() { for (int i = 0; i < fOriginalTemplateParameters.length; i++) { final IPDOMCPPTemplateParameter tp = fTemplateParameters[i]; @@ -890,7 +895,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { long rec= file.getLastUsingDirectiveRec(); PDOMCPPUsingDirective ud= new PDOMCPPUsingDirective(this, rec, containerNS, pdomName.getBinding(), pdomName.getFileLocation().getNodeOffset()); - file.setFirstUsingDirectiveRec(ud.getRecord()); + file.setLastUsingDirective(ud.getRecord()); } } else if (parentNode instanceof ICPPASTElaboratedTypeSpecifier) { ICPPASTElaboratedTypeSpecifier elaboratedSpecifier = (ICPPASTElaboratedTypeSpecifier)parentNode; @@ -983,23 +988,23 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { final WritablePDOM wpdom= (WritablePDOM) pdom; PDOMFile file= null; if (binding instanceof ICPPUsingDeclaration) { - String path= ASTInternal.getDeclaredInOneFileOnly(binding); - if (path != null) { - file= wpdom.getFileForASTPath(getLinkageID(), path); + IASTNode node= ASTInternal.getDeclaredInOneFileOnly(binding); + if (node != null) { + file= wpdom.getFileForASTNode(getLinkageID(), node); } } else if (binding instanceof ICPPNamespaceAlias) { - String path= ASTInternal.getDeclaredInSourceFileOnly(binding, false, glob); - if (path != null) { - file= wpdom.getFileForASTPath(getLinkageID(), path); + IASTNode node= ASTInternal.getDeclaredInSourceFileOnly(binding, false, glob); + if (node != null) { + file= wpdom.getFileForASTNode(getLinkageID(), node); } } if (file == null && !(binding instanceof IIndexBinding)) { IBinding owner= binding.getOwner(); if (owner instanceof ICPPNamespace) { if (owner.getNameCharArray().length == 0) { - String path= ASTInternal.getDeclaredInSourceFileOnly(owner, false, glob); - if (path != null) { - file= wpdom.getFileForASTPath(getLinkageID(), path); + IASTNode node= ASTInternal.getDeclaredInSourceFileOnly(owner, false, glob); + if (node != null) { + file= wpdom.getFileForASTNode(getLinkageID(), node); } } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/AbstractPDOMIndexer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/AbstractPDOMIndexer.java index b17b9f9f522..34140806933 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/AbstractPDOMIndexer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/AbstractPDOMIndexer.java @@ -21,6 +21,9 @@ import org.eclipse.cdt.core.model.ICProject; * Abstract base class for all indexers. */ public abstract class AbstractPDOMIndexer implements IPDOMIndexer { + // For testing purposes + public static boolean noFilesUpFront= false; + protected ICProject project; protected Properties fProperties= new Properties(); @@ -82,11 +85,13 @@ public abstract class AbstractPDOMIndexer implements IPDOMIndexer { } public String[] getFilesToParseUpFront() { - String prefSetting= getProperty(IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT); - if (prefSetting != null) { - prefSetting= prefSetting.trim(); - if (prefSetting.length() > 0) { - return prefSetting.split(","); //$NON-NLS-1$ + if (!noFilesUpFront) { + String prefSetting= getProperty(IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT); + if (prefSetting != null) { + prefSetting= prefSetting.trim(); + if (prefSetting.length() > 0) { + return prefSetting.split(","); //$NON-NLS-1$ + } } } return new String[0]; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java index 9fba3a7cd2c..cd99d472626 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMIndexerTask.java @@ -15,37 +15,25 @@ import java.util.Arrays; import java.util.Calendar; import java.util.Comparator; import java.util.HashSet; -import java.util.Map; import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.dom.ILinkage; import org.eclipse.cdt.core.dom.IPDOMIndexer; import org.eclipse.cdt.core.dom.IPDOMIndexerTask; import org.eclipse.cdt.core.index.IIndexManager; -import org.eclipse.cdt.core.model.AbstractLanguage; import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.model.ITranslationUnit; -import org.eclipse.cdt.core.model.LanguageManager; -import org.eclipse.cdt.core.parser.IScannerInfo; -import org.eclipse.cdt.core.parser.IScannerInfoProvider; -import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.internal.core.index.IWritableIndex; import org.eclipse.cdt.internal.core.index.IWritableIndexManager; import org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask; import org.eclipse.cdt.internal.core.pdom.ITodoTaskUpdater; import org.eclipse.cdt.internal.core.pdom.IndexerProgress; import org.eclipse.cdt.internal.core.pdom.db.ChunkCache; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.content.IContentType; import org.eclipse.osgi.util.NLS; import com.ibm.icu.text.NumberFormat; @@ -177,59 +165,6 @@ public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPD return defaultValue; } - @Override - protected String getASTPathForParsingUpFront() { - final IProject project = getProject().getProject(); - final IPath prjLocation= project.getLocation(); - if (prjLocation == null) { - return null; - } - return prjLocation.append(super.getASTPathForParsingUpFront()).toString(); - } - - @Override - protected AbstractLanguage[] getLanguages(String filename) { - IProject project = getProject().getProject(); - IContentType ct= CCorePlugin.getContentType(project, filename); - if (ct != null) { - ILanguage l = LanguageManager.getInstance().getLanguage(ct, project); - if (l instanceof AbstractLanguage) { - if (filename.indexOf('.') >= 0 && ct.getId().equals(CCorePlugin.CONTENT_TYPE_CXXHEADER) && - l.getLinkageID() == ILinkage.CPP_LINKAGE_ID) { - ILanguage l2= LanguageManager.getInstance().getLanguageForContentTypeID(CCorePlugin.CONTENT_TYPE_CHEADER); - if (l2 instanceof AbstractLanguage) { - return new AbstractLanguage[] {(AbstractLanguage) l, (AbstractLanguage) l2}; - } - } - return new AbstractLanguage[] {(AbstractLanguage) l}; - } - } - return new AbstractLanguage[0]; - } - - @Override - protected IScannerInfo createDefaultScannerConfig(int linkageID) { - IProject project= getProject().getProject(); - IScannerInfoProvider provider= CCorePlugin.getDefault().getScannerInfoProvider(project); - IScannerInfo scanInfo; - if (provider != null) { - String filename= linkageID == ILinkage.C_LINKAGE_ID ? "__cdt__.c" : "__cdt__.cpp"; //$NON-NLS-1$//$NON-NLS-2$ - IFile file= project.getFile(filename); - scanInfo= provider.getScannerInformation(file); - if (scanInfo == null || scanInfo.getDefinedSymbols().isEmpty()) { - scanInfo= provider.getScannerInformation(project); - } - if (linkageID == ILinkage.C_LINKAGE_ID) { - final Map definedSymbols = scanInfo.getDefinedSymbols(); - definedSymbols.remove("__cplusplus__"); //$NON-NLS-1$ - definedSymbols.remove("__cplusplus"); //$NON-NLS-1$ - } - } else { - scanInfo= new ScannerInfo(); - } - return scanInfo; - } - private ICProject getProject() { return getIndexer().getProject(); } @@ -406,4 +341,4 @@ public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPD } return super.acceptUrgentTask(urgentTask); } -} \ No newline at end of file +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMRebuildTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMRebuildTask.java index 9c93a98cae3..37f82a39365 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMRebuildTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMRebuildTask.java @@ -88,7 +88,7 @@ public class PDOMRebuildTask implements IPDOMIndexerTask { private void clearIndex(ICProject project, IWritableIndex index) throws CoreException, InterruptedException { // First clear the pdom - index.acquireWriteLock(0); + index.acquireWriteLock(); try { index.clear(); IWritableIndexFragment wf= index.getWritableFragment(); @@ -96,7 +96,7 @@ public class PDOMRebuildTask implements IPDOMIndexerTask { PDOMManager.writeProjectPDOMProperties((WritablePDOM) wf, project.getProject()); } } finally { - index.releaseWriteLock(0); + index.releaseWriteLock(); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/ProjectIndexerInputAdapter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/ProjectIndexerInputAdapter.java index 2c712127471..85a503c9141 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/ProjectIndexerInputAdapter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/ProjectIndexerInputAdapter.java @@ -146,7 +146,7 @@ public class ProjectIndexerInputAdapter extends IndexerInputAdapter { public String getASTPath(IIndexFileLocation ifl) { IPath path= IndexLocationFactory.getAbsolutePath(ifl); if (path != null) { - return path.toString(); + return path.toOSString(); } return ifl.getURI().getPath(); } diff --git a/core/org.eclipse.cdt.core/pom.xml b/core/org.eclipse.cdt.core/pom.xml index d5cad97fae8..cff6e59fbbc 100644 --- a/core/org.eclipse.cdt.core/pom.xml +++ b/core/org.eclipse.cdt.core/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/core/org.eclipse.cdt.core/schema/CIndex.exsd b/core/org.eclipse.cdt.core/schema/CIndex.exsd index 8c02bba8c74..f35783e15cd 100644 --- a/core/org.eclipse.cdt.core/schema/CIndex.exsd +++ b/core/org.eclipse.cdt.core/schema/CIndex.exsd @@ -1,6 +1,6 @@ - + @@ -11,10 +11,16 @@ + + + + + + @@ -156,16 +162,51 @@ public class AcmeSDKProvider implements IReadOnlyPDOMProvider { - the fully qualified name of the IReadOnlyPDOMProvider implementation to register + The fully qualified name of the IReadOnlyPDOMProvider implementation to register - + + + + + <h2>ReadOnlyIndexFragmentProvider</h2> +<p> +This subelement of CIndex allows ISVs to contribute read-only index fragments to the CDT Index. This extension point imposes no limitations on how the index information is collected and stored. The index fragments may, for example, be based on data dynamically fetched from a remote server. +<p> +The only information needed for this extension point is the fully qualified name of a class implementing the org.eclipse.cdt.core.index.IIndexFragmentProvider interface. This class will be consulted during the eclipse session for the appropriate read-only content to add to the logical index. The logical index is accessible via the org.eclipse.core.index.IIndex API. + + + + + + + The fully qualified name of a class implementing IIndexFragmentProvider interface. + + + + + + + + + + + + + + + Index content provided by ISVs under this extension point will be accessible via the logical index org.eclipse.core.index.IIndex API + +For export functionality, see package org.eclipse.cdt.core.index.export + + + @@ -184,23 +225,12 @@ public class AcmeSDKProvider implements IReadOnlyPDOMProvider { - - - - - - Index content provided by ISVs under this extension point will be accessible via the logical index org.eclipse.core.index.IIndex API - -For export functionality, see package org.eclipse.cdt.core.index.export - - - - [Enter information about supplied implementation of this extension point.] + See subelement documentation @@ -209,7 +239,7 @@ For export functionality, see package org.eclipse.cdt.core.index.export - Copyright (c) 2007 Symbian Software Systems and others. + Copyright (c) 2007, 2011 Symbian Software Systems and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CConventions.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CConventions.java index 382ade7670d..330d94e220a 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CConventions.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CConventions.java @@ -371,7 +371,7 @@ public class CConventions { } private static boolean isLegalFilename(String name) { - if (name == null || name.length() == 0) { + if (name == null || name.isEmpty()) { return false; } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java index 08d5bd5b470..b167e9edb8f 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java @@ -680,7 +680,7 @@ public class CCorePlugin extends Plugin { public IBinaryParser getDefaultBinaryParser() throws CoreException { IBinaryParser parser = null; String id = getPluginPreferences().getDefaultString(PREF_BINARY_PARSER); - if (id == null || id.length() == 0) { + if (id == null || id.isEmpty()) { id = DEFAULT_BINARY_PARSER_UNIQ_ID; } IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, BINARY_PARSER_SIMPLE_ID); @@ -1379,4 +1379,4 @@ public class CCorePlugin extends Plugin { return InstanceScope.INSTANCE.getNode(PLUGIN_ID) .getBoolean(CCorePreferenceConstants.SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT, true); } -} \ No newline at end of file +} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/parser/ParserLogService.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/parser/ParserLogService.java index 5f6eb04e6b0..c08ca43d547 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/parser/ParserLogService.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/parser/ParserLogService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2008 IBM Corporation and others. + * Copyright (c) 2002, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -19,6 +19,7 @@ import org.eclipse.cdt.internal.core.model.DebugLogConstants; import org.eclipse.cdt.internal.core.model.Util; import org.eclipse.cdt.internal.core.util.ICancelable; import org.eclipse.cdt.internal.core.util.ICanceler; +import org.eclipse.core.runtime.Platform; /** * @author jcamelon @@ -53,6 +54,16 @@ public class ParserLogService extends AbstractParserLogService implements ICance Util.debugLog( message, topic ); } + @Override + public boolean isTracing(String option) { + return "true".equals(Platform.getDebugOption(option)); //$NON-NLS-1$ + } + + @Override + public void traceLog(String option, String message) { + if (isTracing(option)) + System.out.println(message); + } @Override public void errorLog(String message) { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java index 2368c0aee5c..b6808425482 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java @@ -2032,6 +2032,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, scribe.space(); } } + scribe.printTrailingComment(); if (enumIndent > braceIndent) { scribe.unIndent(); @@ -3032,22 +3033,24 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, final IASTStatement action = node.getBody(); formatAction(line, action, preferences.brace_position_for_block); - if (peekNextToken() == Token.t_while) { - if (preferences.insert_new_line_before_while_in_do_statement) { - scribe.startNewLine(); + if (scribe.scanner.getCurrentPosition() < getNodeEndLocation(node)) { + if (peekNextToken() == Token.t_while) { + if (preferences.insert_new_line_before_while_in_do_statement) { + scribe.startNewLine(); + } + scribe.printNextToken(Token.t_while, preferences.insert_space_after_closing_brace_in_block); + scribe.printNextToken(Token.tLPAREN, preferences.insert_space_before_opening_paren_in_while); + + if (preferences.insert_space_after_opening_paren_in_while) { + scribe.space(); + } + + node.getCondition().accept(this); + + scribe.printNextToken(Token.tRPAREN, preferences.insert_space_before_closing_paren_in_while); } - scribe.printNextToken(Token.t_while, preferences.insert_space_after_closing_brace_in_block); - scribe.printNextToken(Token.tLPAREN, preferences.insert_space_before_opening_paren_in_while); - - if (preferences.insert_space_after_opening_paren_in_while) { - scribe.space(); - } - - node.getCondition().accept(this); - - scribe.printNextToken(Token.tRPAREN, preferences.insert_space_before_closing_paren_in_while); + scribe.printNextToken(Token.tSEMI, preferences.insert_space_before_semicolon); } - scribe.printNextToken(Token.tSEMI, preferences.insert_space_before_semicolon); scribe.printTrailingComment(); return PROCESS_SKIP; } @@ -4020,6 +4023,11 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, return node1.getFileLocation().getNodeOffset() == node2.getFileLocation().getNodeOffset(); } + private static int getNodeEndLocation(IASTNode node) { + IASTFileLocation loc = node.getFileLocation(); + return loc.getNodeOffset() + loc.getNodeLength(); + } + private void formatBlock(IASTCompoundStatement block, String block_brace_position, boolean insertSpaceBeforeOpeningBrace, boolean indentStatements) { formatBlockOpening(block, block_brace_position, insertSpaceBeforeOpeningBrace); diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/Coff.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/Coff.java index 1636f455f70..745fa3d2cf3 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/Coff.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/Coff.java @@ -441,12 +441,35 @@ public class Coff { public int n_type; /* Unsigned short. Symbolic type. */ public byte n_sclass; /* char, Storage class. */ public byte n_numaux; /* char. Number of auxiliary enties. */ + /** @since 5.4 */ + public short n_aux_lnno; /* short, line number in auxiliary entry */ + /** @since 5.4 */ + public short n_aux_size; /* short, size in bytes in auxiliary entry */ + /** @since 5.4 */ + public int n_aux_fcn_size; /* long, size of function in bytes found in auxiliary entry */ + + private boolean is64Bit; public Symbol(RandomAccessFile file) throws IOException { - this(file, file.getFilePointer()); + this(file, file.getFilePointer(), false); } public Symbol(RandomAccessFile file, long offset) throws IOException { + this(file, offset, false); + } + + /** + * @since 5.4 + */ + public Symbol(RandomAccessFile file, boolean is64Bit) throws IOException { + this(file, file.getFilePointer(), is64Bit); + } + + /** + * @since 5.4 + */ + public Symbol(RandomAccessFile file, long offset, boolean is64Bit) throws IOException { + this.is64Bit = is64Bit; file.seek(offset); byte[] bytes = new byte[SYMSZ]; file.readFully(bytes); @@ -457,6 +480,20 @@ public class Coff { n_type = memory.getUnsignedShort(); n_sclass = memory.getByte(); n_numaux = memory.getByte(); + if (n_numaux > 0) { + // read auxiliary section + byte[] bytes2 = new byte[SYMSZ * n_numaux]; + file.readFully(bytes2); + memory = new ReadMemoryAccess(bytes2, true); + memory.getInt(); // ignore first 4 bytes - tag index + n_aux_lnno = memory.getShort(); + n_aux_size = memory.getShort(); + // function size is unioned with lnno and size so we must rewind and + // reread + memory = new ReadMemoryAccess(bytes2, true); + memory.getInt(); // ignore first 4 bytes - tag index + n_aux_fcn_size = memory.getInt(); + } } public boolean isLongName() { @@ -509,6 +546,48 @@ public class Coff { return (n_type & N_TMASK) == (DT_ARY << N_BTSHFT); } + /** + * @since 5.4 + */ + public int getSize() { + if (n_type <= T_LNGDBL) { + switch (n_type) { + case T_CHAR: + case T_UCHAR: + return 1; + case T_SHORT: + case T_USHORT: + return 2; + case T_LONG: + case T_ULONG: + return 4; + case T_INT: + case T_UINT: + return 4; + case T_FLOAT: + return 4; + case T_DOUBLE: + return 8; + case T_MOE: + return 4; + case T_LNGDBL: + return 16; + case T_ENUM: + case T_STRUCT: + case T_UNION: + return n_aux_size; + } + } + else if (isFunction()) { + return n_aux_fcn_size; + } else if (isArray()) { + return n_aux_size; + } else if (isPointer()) { + return is64Bit ? 8 : 4; + } + return 1; + } + @Override public String toString() { return getName(); @@ -541,7 +620,7 @@ public class Coff { rfile.seek(offset); symbols = new Symbol[getFileHeader().f_nsyms]; for (int i = 0; i < symbols.length; i++) { - symbols[i] = new Symbol(rfile); + symbols[i] = new Symbol(rfile, (getFileHeader().f_flags & FileHeader.F_AR32WR) == 0); } } return symbols; diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PE.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PE.java index 36ec80062b8..3f76008b614 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PE.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PE.java @@ -655,7 +655,7 @@ public class PE { long offset = fileHeader.f_symptr; symbolTable = new Symbol[fileHeader.f_nsyms]; for (int i = 0; i < symbolTable.length; i++, offset += Symbol.SYMSZ) { - Symbol newSym = new Symbol(accessFile, offset); + Symbol newSym = new Symbol(accessFile, offset, (fileHeader.f_flags & FileHeader.F_AR32WR) == 0); // Now convert section offset of the symbol to image offset. if (newSym.n_scnum >= 1 && newSym.n_scnum <= secHeaders.length) // valid section # diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryObject.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryObject.java index e29b33e2c31..228598fce21 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryObject.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryObject.java @@ -184,7 +184,7 @@ public class PEBinaryObject extends BinaryObjectAdapter { continue; } int type = peSym.isFunction() ? ISymbol.FUNCTION : ISymbol.VARIABLE; - list.add(new Symbol(this, name, type, new Addr32(peSym.n_value), 1)); + list.add(new Symbol(this, name, type, new Addr32(peSym.n_value), peSym.getSize())); } } } diff --git a/core/org.eclipse.cdt.ui.tests/.classpath b/core/org.eclipse.cdt.ui.tests/.classpath index e2fea57c451..371cb64d12a 100644 --- a/core/org.eclipse.cdt.ui.tests/.classpath +++ b/core/org.eclipse.cdt.ui.tests/.classpath @@ -2,7 +2,7 @@ - + diff --git a/core/org.eclipse.cdt.ui.tests/.settings/org.eclipse.jdt.core.prefs b/core/org.eclipse.cdt.ui.tests/.settings/org.eclipse.jdt.core.prefs index 684bece864b..081369fcd11 100644 --- a/core/org.eclipse.cdt.ui.tests/.settings/org.eclipse.jdt.core.prefs +++ b/core/org.eclipse.cdt.ui.tests/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Wed Feb 27 13:20:15 CET 2008 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -79,7 +79,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 diff --git a/core/org.eclipse.cdt.ui.tests/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui.tests/META-INF/MANIFEST.MF index cfa931fd6b1..915d3ebb7fc 100644 --- a/core/org.eclipse.cdt.ui.tests/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.ui.tests/META-INF/MANIFEST.MF @@ -37,4 +37,4 @@ Require-Bundle: org.eclipse.jface.text, org.eclipse.core.filesystem;bundle-version="1.2.0" Bundle-ActivationPolicy: lazy Bundle-Vendor: Eclipse CDT -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/core/org.eclipse.cdt.ui.tests/pom.xml b/core/org.eclipse.cdt.ui.tests/pom.xml index bd0a7e91f40..d382d72abe2 100644 --- a/core/org.eclipse.cdt.ui.tests/pom.xml +++ b/core/org.eclipse.cdt.ui.tests/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml @@ -44,7 +44,7 @@ org.eclipse.cdt.feature.group - 8.0.0.${buildQualifier} + 8.1.0.${buildQualifier} p2-installable-unit diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/BasicIncludeBrowserTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/BasicIncludeBrowserTest.java index 6c82b07a5bf..f5174157a6a 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/BasicIncludeBrowserTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/BasicIncludeBrowserTest.java @@ -16,6 +16,7 @@ import junit.framework.Test; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.TreeItem; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMManager; @@ -37,6 +38,7 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest { // // source // #include "user.h" // #include + // #include "user.h" public void testSimpleInclusion() throws Exception { TestScannerProvider.sIncludes= new String[] { getProject().getProject().getLocation().toOSString() }; @@ -50,9 +52,10 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest { openIncludeBrowser(source); Tree tree = getIBTree(); - checkTreeNode(tree, 0, "source.cpp"); + TreeItem node = checkTreeNode(tree, 0, "source.cpp"); checkTreeNode(tree, 0, 0, "user.h"); checkTreeNode(tree, 0, 1, "system.h"); + assertEquals(2, node.getItemCount()); // The tree has to be reversed openIncludeBrowser(user, true); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTests.java index 938d873e7c2..978507cb480 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTests.java @@ -74,7 +74,7 @@ public class RenameTests extends RefactoringTests { CRenameProcessor proc= new CRenameProcessor(CRefactory.getInstance(), arg); proc.setReplacementText( newName ); proc.setSelectedOptions(-1); - proc.setScope(TextSearchWrapper.SCOPE_WORKSPACE); + proc.setExhaustiveSearchScope(TextSearchWrapper.SCOPE_WORKSPACE); return new CRenameRefactoring(proc); } @@ -124,8 +124,7 @@ public class RenameTests extends RefactoringTests { ((CRenameProcessor) proc.getProcessor()).lockIndex(); try { RefactoringStatus rs = checkConditions(proc); - - return (rs.getSeverity()); + return rs.getSeverity(); } finally { ((CRenameProcessor) proc.getProcessor()).unlockIndex(); } @@ -134,7 +133,7 @@ public class RenameTests extends RefactoringTests { protected int countOccurrences(String contents, String lookup) { int idx= contents.indexOf(lookup); int count= 0; - while (idx >=0) { + while (idx >= 0) { count++; idx= contents.indexOf(lookup, idx+lookup.length()); } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java index 989fa1fac6c..a38fe09518a 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java @@ -2736,4 +2736,45 @@ public class CodeFormatterTest extends BaseUITestCase { assertFormatterResult(); } + //enum SomeEnum { + //FirstValue,// first value comment + //SecondValue// second value comment + //}; + //enum OtherEnum { + //First,// first value comment + //Second,// second value comment + //}; + + //enum SomeEnum { + // FirstValue, // first value comment + // SecondValue // second value comment + //}; + //enum OtherEnum { + // First, // first value comment + // Second, // second value comment + //}; + public void testEnum() throws Exception { + fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE); + fOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_MIN_DISTANCE_BETWEEN_CODE_AND_LINE_COMMENT, "2"); + assertFormatterResult(); + } + + //#define TESTING(m) ;do{}while(0) + //void f() { + // TESTING(1); + // if(Test(a) != 1) { + // status = ERROR; + // } + //} + + //#define TESTING(m) ;do{}while(0) + //void f() { + // TESTING(1); + // if (Test(a) != 1) { + // status = ERROR; + // } + //} + public void testDoWhileInMacro_Bug359658() throws Exception { + assertFormatterResult(); + } } diff --git a/core/org.eclipse.cdt.ui/.classpath b/core/org.eclipse.cdt.ui/.classpath index 7eaf69875e9..4dc12ec5c0f 100644 --- a/core/org.eclipse.cdt.ui/.classpath +++ b/core/org.eclipse.cdt.ui/.classpath @@ -4,7 +4,7 @@ - + diff --git a/core/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.core.prefs b/core/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.core.prefs index f4f437e8cd3..3cdb4be1c68 100644 --- a/core/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.core.prefs +++ b/core/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ -#Thu Jan 29 16:45:29 CET 2009 +#Mon Oct 17 17:37:10 PDT 2011 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -79,7 +79,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 @@ -151,10 +151,12 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false org.eclipse.jdt.core.formatter.indentation.size=4 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF index efe42aa5749..cd374ed28a2 100644 --- a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF @@ -117,5 +117,5 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.3.0,4.0.0)", org.eclipse.ltk.ui.refactoring;bundle-version="3.4.0", org.eclipse.ui.navigator.resources;bundle-version="3.3.100" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: com.ibm.icu.text diff --git a/core/org.eclipse.cdt.ui/build.properties b/core/org.eclipse.cdt.ui/build.properties index 5ded10c9809..d4e8a17bf13 100644 --- a/core/org.eclipse.cdt.ui/build.properties +++ b/core/org.eclipse.cdt.ui/build.properties @@ -32,6 +32,6 @@ source.. = src/,\ utils.ui/,\ templateengine/ -jre.compilation.profile=J2SE-1.5 -javacSource=1.5 -javacTarget=1.5 +jre.compilation.profile=JavaSE-1.6 +javacSource=1.6 +javacTarget=1.6 diff --git a/core/org.eclipse.cdt.ui/pom.xml b/core/org.eclipse.cdt.ui/pom.xml index fb32604c943..cc5f654078f 100644 --- a/core/org.eclipse.cdt.ui/pom.xml +++ b/core/org.eclipse.cdt.ui/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java index bd047e26758..245816efe30 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java @@ -15,11 +15,13 @@ import java.io.IOException; import java.io.PrintStream; import java.util.ArrayList; import java.util.Comparator; +import java.util.Date; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import java.util.SortedMap; import java.util.SortedSet; import java.util.TreeMap; @@ -42,6 +44,7 @@ import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.ILinkage; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement; @@ -55,12 +58,14 @@ import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexFile; import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.index.IIndexInclude; +import org.eclipse.cdt.core.index.IndexLocationFactory; import org.eclipse.cdt.core.model.CModelException; +import org.eclipse.cdt.core.model.CoreModelUtil; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.parser.ExtendedScannerInfo; -import org.eclipse.cdt.core.parser.IScannerInfoProvider; +import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; @@ -76,6 +81,7 @@ import org.eclipse.cdt.internal.ui.editor.ASTProvider; @SuppressWarnings("nls") public class CreateParserLogAction implements IObjectActionDelegate { + private static final String INDENT = " "; private static final class MyVisitor extends ASTVisitor { List fProblems= new ArrayList(); @@ -118,6 +124,8 @@ public class CreateParserLogAction implements IObjectActionDelegate { private ISelection fSelection; private IWorkbenchPartSite fSite; + + private boolean fWroteUnresolvedTitle; public void setActivePart(IAction action, IWorkbenchPart targetPart) { fSite= targetPart.getSite(); @@ -209,81 +217,90 @@ public class CreateParserLogAction implements IObjectActionDelegate { IStatus status = Status.OK_STATUS; final ICProject cproject = tu.getCProject(); final String projectName= cproject == null ? null : cproject.getElementName(); - String scannerInfoProvider= "null"; - if (cproject != null) { - IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(cproject.getProject()); - if (provider != null) { - scannerInfoProvider= provider.getClass().getName(); - } - } - - ITranslationUnit ctx= tu; + final IIndex index = ast.getIndex(); + + ITranslationUnit configureWith = tu; + int ctxLinkage= 0; + ISignificantMacros ctxSigMacros= null; if (tu instanceof TranslationUnit) { TranslationUnit itu= (TranslationUnit) tu; - ctx= itu.getSourceContextTU(ast.getIndex(), ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT); + IIndexFile[] ctxToHeader = itu.getContextToHeader(index, ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT); + if (ctxToHeader != null) { + try { + final IIndexFile ctxFile = ctxToHeader[0]; + ctxLinkage= ctxToHeader[0].getLinkageID(); + ctxSigMacros= ctxFile.getSignificantMacros(); + configureWith = CoreModelUtil.findTranslationUnitForLocation(ctxFile.getLocation(), cproject); + } catch (CoreException e) { + } + if (configureWith == null) { + configureWith= tu; + ctxToHeader= null; + } + } } - final ExtendedScannerInfo scfg= new ExtendedScannerInfo(ctx.getScannerInfo(true)); - final String indent= " "; + + final ExtendedScannerInfo scfg= new ExtendedScannerInfo(configureWith.getScannerInfo(true)); final MyVisitor visitor= new MyVisitor(); ast.accept(visitor); out.println("Project: " + projectName); + out.println("File: " + tu.getLocationURI()); + out.println("Language: " + lang.getName()); out.println("Index Version: " + PDOM.versionString(PDOM.getDefaultVersion())); - out.println("Scanner Info Provider: " + scannerInfoProvider); out.println("Build Configuration: " + getBuildConfig(cproject)); - out.println("File: " + tu.getLocationURI()); - out.println("Context: " + ctx.getLocationURI()); - out.println("Language: " + lang.getName()); - out.println(); - out.println("Include Search Path (option -I):"); - output(out, indent, scfg.getIncludePaths()); - out.println(); - out.println("Local Include Search Path (option -iquote):"); - output(out, indent, scfg.getLocalIncludePath()); - out.println(); - out.println("Preincluded files (option -include):"); - output(out, indent, scfg.getIncludeFiles()); - out.println(); - out.println("Preincluded macro files (option -imacros):"); - output(out, indent, scfg.getMacroFiles()); - out.println(); - out.println("Macro definitions (option -D):"); - HashSet reported= new HashSet(); - output(out, indent, scfg.getDefinedSymbols(), reported); - out.println(); - out.println("Macro definitions (from configuration + headers in index):"); - output(out, indent, ast.getBuiltinMacroDefinitions(), reported); - out.println(); - out.println("Macro definitions (from files actually parsed):"); - output(out, indent, ast.getMacroDefinitions(), reported); - - out.println(); - out.println("Unresolved includes (from headers in index):"); + if (configureWith == tu) { + out.println("Context: none"); + } else { + out.println("Context: " + configureWith.getLocationURI()); + out.println(INDENT + getLinkageName(ctxLinkage) + ", " + ctxSigMacros); + } + try { - outputUnresolvedIncludes(cproject, ast.getIndex(), out, indent, ast.getIncludeDirectives(), ast.getLinkage().getLinkageID()); + IIndexFile[] versions= index.getFiles(IndexLocationFactory.getIFL(tu)); + out.println("Versions in Index: " + versions.length); + for (IIndexFile f : versions) { + out.println(INDENT + getLinkageName(f.getLinkageID()) + ": " + f.getSignificantMacros()); + } } catch (CoreException e) { status= e.getStatus(); } + out.println(); + + output(out, "Include Search Path (option -I):", scfg.getIncludePaths()); + output(out, "Local Include Search Path (option -iquote):", scfg.getLocalIncludePath()); + output(out, "Preincluded files (option -include):", scfg.getIncludeFiles()); + output(out, "Preincluded macro files (option -imacros):", scfg.getMacroFiles()); - out.println(); - out.println("Scanner problems:"); - output(out, indent, ast.getPreprocessorProblems()); - - out.println(); - out.println("Parser problems:"); - output(out, indent, visitor.fProblems.toArray(new IASTProblem[visitor.fProblems.size()])); - - out.println(); - out.println("Unresolved names:"); - output(out, indent, visitor.fProblemBindings); - - out.println(); - out.println("Exceptions in name resolution:"); - output(out, visitor.fExceptions); + HashSet reported= new HashSet(); + output(out, "Macro definitions (option -D):", scfg.getDefinedSymbols(), reported); + output(out, "Macro definitions (from language + headers in index):", ast.getBuiltinMacroDefinitions(), reported); + output(out, "Macro definitions (from files actually parsed):", ast.getMacroDefinitions(), reported); + try { + outputUnresolvedIncludes(cproject, ast.getIndex(), out, ast.getIncludeDirectives(), ast.getLinkage().getLinkageID()); + } catch (CoreException e) { + status= e.getStatus(); + } + output(out, "Scanner problems:", ast.getPreprocessorProblems()); + output(out, "Parser problems:", visitor.fProblems.toArray(new IASTProblem[0])); + output(out, "Unresolved names:", visitor.fProblemBindings.toArray(new IProblemBinding[0])); + output(out, "Exceptions in name resolution:", visitor.fExceptions); + out.println("Written on " + new Date().toString()); return status; } + private String getLinkageName(int linkageID) { + switch(linkageID) { + case ILinkage.NO_LINKAGE_ID: return ILinkage.NO_LINKAGE_NAME; + case ILinkage.C_LINKAGE_ID: return ILinkage.C_LINKAGE_NAME; + case ILinkage.CPP_LINKAGE_ID: return ILinkage.CPP_LINKAGE_NAME; + case ILinkage.FORTRAN_LINKAGE_ID: return ILinkage.FORTRAN_LINKAGE_NAME; + case ILinkage.OBJC_LINKAGE_ID: return ILinkage.OBJC_LINKAGE_NAME; + } + return String.valueOf(linkageID); + } + private String getBuildConfig(ICProject cproject) { ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager(); ICProjectDescription prefs= prjDescMgr.getProjectDescription(cproject.getProject(), false); @@ -295,35 +312,37 @@ public class CreateParserLogAction implements IObjectActionDelegate { return "unknown"; } - private void outputUnresolvedIncludes(ICProject prj, IIndex index, PrintStream out, String indent, + private void outputUnresolvedIncludes(ICProject prj, IIndex index, PrintStream out, IASTPreprocessorIncludeStatement[] includeDirectives, int linkageID) throws CoreException { + fWroteUnresolvedTitle= false; ASTFilePathResolver resolver= new ProjectIndexerInputAdapter(prj); - HashSet handled= new HashSet(); + HashSet handled= new HashSet(); for (IASTPreprocessorIncludeStatement include : includeDirectives) { - if (include.isActive() && include.isResolved()) { - outputUnresolvedIncludes(index, out, indent, resolver.resolveASTPath(include.getPath()), linkageID, handled); + if (include.isResolved()) { + IIndexFileLocation ifl = resolver.resolveASTPath(include.getPath()); + IIndexFile ifile= index.getFile(linkageID, ifl, include.getSignificantMacros()); + outputUnresolvedIncludes(index, out, ifl, ifile, handled); } } + if (fWroteUnresolvedTitle) + out.println(); } - private void outputUnresolvedIncludes(IIndex index, PrintStream out, String indent, - IIndexFileLocation ifl, int linkageID, HashSet handled) throws CoreException { - if (!handled.add(ifl)) { - return; - } - IIndexFile ifile= index.getFile(linkageID, ifl); + private void outputUnresolvedIncludes(IIndex index, PrintStream out, + IIndexFileLocation ifl, IIndexFile ifile, Set handled) throws CoreException { if (ifile == null) { - out.println(indent + ifl.getURI() + " is not indexed"); - } - else { + writeUnresolvedTitle(out); + out.println(INDENT + ifl.getURI() + " is not indexed"); + } else if (handled.add(ifile)) { IIndexInclude[] includes = ifile.getIncludes(); for (IIndexInclude inc : includes) { if (inc.isActive()) { if (inc.isResolved()) { - outputUnresolvedIncludes(index, out, indent, inc.getIncludesLocation(), linkageID, handled); - } - else { - out.println(indent + "Unresolved inclusion: " + inc.getFullName() + " in file " + + IIndexFile next = index.resolveInclude(inc); + outputUnresolvedIncludes(index, out, inc.getIncludesLocation(), next, handled); + } else { + writeUnresolvedTitle(out); + out.println(INDENT + "Unresolved inclusion: " + inc.getFullName() + " in file " + inc.getIncludedByLocation().getURI()); } } @@ -331,53 +350,85 @@ public class CreateParserLogAction implements IObjectActionDelegate { } } - private void output(PrintStream out, String indent, String[] list) { - for (String line : list) { - out.println(indent + line); + public void writeUnresolvedTitle(PrintStream out) { + if (!fWroteUnresolvedTitle) { + fWroteUnresolvedTitle= true; + out.println("Unresolved includes (from headers in index):"); } } - private void output(PrintStream out, String indent, Map definedSymbols, HashSet reported) { - SortedMap sorted= new TreeMap(COMP_INSENSITIVE); - sorted.putAll(definedSymbols); - for (Entry entry : sorted.entrySet()) { - final String macro = entry.getKey() + '=' + entry.getValue(); - if (reported.add(macro)) { - out.println(indent + macro); + private void output(PrintStream out, String label, String[] list) { + if (list.length > 0) { + out.println(label); + for (String line : list) { + out.println(INDENT + line); } + out.println(); + } + } + + private void output(PrintStream out, String label, Map definedSymbols, HashSet reported) { + if (!definedSymbols.isEmpty()) { + out.println(label); + + SortedMap sorted= new TreeMap(COMP_INSENSITIVE); + sorted.putAll(definedSymbols); + for (Entry entry : sorted.entrySet()) { + final String macro = entry.getKey() + '=' + entry.getValue(); + if (reported.add(macro)) { + out.println(INDENT + macro); + } + } + out.println(); } } - private void output(PrintStream out, String indent, IASTPreprocessorMacroDefinition[] defs, HashSet reported) { - SortedSet macros= new TreeSet(COMP_INSENSITIVE); - for (IASTPreprocessorMacroDefinition def : defs) { - macros.add(def.toString()); + private void output(PrintStream out, String label, IASTPreprocessorMacroDefinition[] defs, HashSet reported) { + if (defs.length > 0) { + out.println(label); + SortedSet macros= new TreeSet(COMP_INSENSITIVE); + for (IASTPreprocessorMacroDefinition def : defs) { + macros.add(def.toString()); + } + + for (String macro : macros) { + if (reported.add(macro)) { + out.println(INDENT + macro); + } + } + out.println(); } + } + + private void output(PrintStream out, String label, IASTProblem[] preprocessorProblems) { + if (preprocessorProblems.length > 0) { + out.println(label); + for (IASTProblem problem : preprocessorProblems) { + out.println(INDENT + problem.getMessageWithLocation()); + } + out.println(); + } + } - for (String macro : macros) { - if (reported.add(macro)) { - out.println(indent + macro); + private void output(PrintStream out, String label, IProblemBinding[] list) { + if (list.length > 0) { + out.println(label); + for (IProblemBinding problem : list) { + String file= problem.getFileName(); + int line = problem.getLineNumber(); + out.println(INDENT + problem.getMessage() + " in file " + file + ':' + line); } - } - } - - private void output(PrintStream out, String indent, IASTProblem[] preprocessorProblems) { - for (IASTProblem problem : preprocessorProblems) { - out.println(indent + problem.getMessageWithLocation()); - } - } - - private void output(PrintStream out, String indent, List list) { - for (IProblemBinding problem : list) { - String file= problem.getFileName(); - int line = problem.getLineNumber(); - out.println(indent + problem.getMessage() + " in file " + file + ':' + line); + out.println(); } } - private void output(PrintStream out, List list) { - for (Exception problem : list) { - problem.printStackTrace(out); + private void output(PrintStream out, String label, List list) { + if (!list.isEmpty()) { + out.println(label); + for (Exception problem : list) { + problem.printStackTrace(out); + } + out.println(); } } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java index ed0d6811f88..c8aef901061 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.ui.callhierarchy; @@ -23,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexFile; +import org.eclipse.cdt.core.index.IIndexManager; import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICElement; @@ -150,7 +152,7 @@ public class CHContentProvider extends AsyncTreeContentProvider { private Object[] asyncronouslyComputeReferencedBy(CHNode parent) throws CoreException, InterruptedException { ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects(); - IIndex index= CCorePlugin.getIndexManager().getIndex(scope); + IIndex index= CCorePlugin.getIndexManager().getIndex(scope, IIndexManager.ADD_EXTENSION_FRAGMENTS); index.acquireReadLock(); try { return CHQueries.findCalledBy(this, parent, index, NPM); @@ -161,7 +163,7 @@ public class CHContentProvider extends AsyncTreeContentProvider { private Object[] asyncronouslyComputeRefersTo(CHNode parent) throws CoreException, InterruptedException { ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects(); - IIndex index= CCorePlugin.getIndexManager().getIndex(scope); + IIndex index= CCorePlugin.getIndexManager().getIndex(scope, IIndexManager.ADD_EXTENSION_FRAGMENTS); index.acquireReadLock(); try { return CHQueries.findCalls(this, parent, index, NPM); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBContentProvider.java index 6c92fbf840e..96a8383a060 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBContentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBContentProvider.java @@ -12,6 +12,8 @@ package org.eclipse.cdt.internal.ui.includebrowser; import java.util.ArrayList; import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.Set; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -102,7 +104,7 @@ public class IBContentProvider extends AsyncTreeContentProvider { directiveFile= node.getRepresentedFile(); } if (includes.length > 0) { - ArrayList result= new ArrayList(includes.length); + Set result= new LinkedHashSet(includes.length); for (int i = 0; i < includes.length; i++) { IIndexInclude include = includes[i]; try { @@ -122,7 +124,8 @@ public class IBContentProvider extends AsyncTreeContentProvider { include.getIncludedBy().getTimestamp()); newnode.setIsActiveCode(include.isActive()); newnode.setIsSystemInclude(include.isSystemInclude()); - result.add(newnode); + if (!result.contains(newnode) || newnode.isActiveCode()) + result.add(newnode); } catch (CoreException e) { CUIPlugin.log(e); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStyleBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStyleBlock.java index f0f168ea7ec..f31d47696dc 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStyleBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStyleBlock.java @@ -405,7 +405,7 @@ public class NameStyleBlock extends OptionsConfigurationBlock { @Override protected void validateSettings(Key changedKey, String oldValue, String newValue) { StatusInfo status = new StatusInfo(); - if (selectedCategory != null) { + if (selectedCategory != null && changedKey != null) { NameValidator validator = selectedCategory.getNameValidator(); if (changedKey.equals(selectedCategory.getPrefixKey()) || changedKey.equals(selectedCategory.getAlternativePrefixKey())) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelper.java index 2e81f379479..545b93a4522 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelper.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelper.java @@ -57,14 +57,16 @@ public class RefactoringExecutionHelper { private final int fSaveMode; private class Operation implements IWorkspaceRunnable { - public Change fChange; - public PerformChangeOperation fPerformChangeOperation; - private final boolean fForked; - private final boolean fForkChangeExecution; + Change fChange; + PerformChangeOperation fPerformChangeOperation; + final boolean fForked; + final boolean fForkChangeExecution; + final boolean fCancelable; - public Operation(boolean forked, boolean forkChangeExecution) { + public Operation(boolean forked, boolean forkChangeExecution, boolean cancelable) { fForked= forked; fForkChangeExecution= forkChangeExecution; + this.fCancelable = cancelable; } public void run(IProgressMonitor pm) throws CoreException { @@ -72,7 +74,8 @@ public class RefactoringExecutionHelper { pm.beginTask("", fForked && !fForkChangeExecution ? 7 : 11); //$NON-NLS-1$ pm.subTask(""); //$NON-NLS-1$ - final RefactoringStatus status= fRefactoring.checkAllConditions(new SubProgressMonitor(pm, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); + final RefactoringStatus status= fRefactoring.checkAllConditions( + new SubProgressMonitor(pm, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); if (status.getSeverity() >= fStopSeverity) { final boolean[] canceled= { false }; if (fForked) { @@ -92,10 +95,7 @@ public class RefactoringExecutionHelper { fChange= fRefactoring.createChange(new SubProgressMonitor(pm, 2, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); fChange.initializeValidationData(new SubProgressMonitor(pm, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); - fPerformChangeOperation= new PerformChangeOperation(fChange);//RefactoringUI.createUIAwareChangeOperation(fChange); - fPerformChangeOperation.setUndoManager(RefactoringCore.getUndoManager(), fRefactoring.getName()); - if (fRefactoring instanceof IScheduledRefactoring) - fPerformChangeOperation.setSchedulingRule(((IScheduledRefactoring) fRefactoring).getSchedulingRule()); + fPerformChangeOperation = createPerformChangeOperation(fChange); if (!fForked || fForkChangeExecution) fPerformChangeOperation.run(new SubProgressMonitor(pm, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); @@ -157,15 +157,31 @@ public class RefactoringExecutionHelper { * @throws InterruptedException thrown when the operation is canceled * @throws InvocationTargetException thrown when the operation failed to execute */ - public void perform(boolean fork, boolean forkChangeExecution, boolean cancelable) throws InterruptedException, InvocationTargetException { + public void perform(boolean fork, boolean forkChangeExecution, boolean cancelable) + throws InterruptedException, InvocationTargetException { + Operation operation = new Operation(fork, forkChangeExecution, cancelable); + performOperation(operation, null, fork); + } + + public void performChange(Change change, boolean fork) + throws InterruptedException, InvocationTargetException { + PerformChangeOperation operation = createPerformChangeOperation(change); + performOperation(null, operation, fork); + } + + /** + * Executes either a complete refactoring operation or a change operation. + * @param operation The refactoring operation. Can be null. + * @param changeOperation The change operation. Has to be null if {@code operation} + * is not null and not null otherwise. + * @param fork If set, the execution will be forked. + */ + private void performOperation(Operation operation, PerformChangeOperation changeOperation, boolean fork) + throws InterruptedException, InvocationTargetException { + Assert.isTrue((operation == null) != (changeOperation == null)); Assert.isTrue(Display.getCurrent() != null); final IJobManager manager= Job.getJobManager(); - final ISchedulingRule rule; - if (fRefactoring instanceof IScheduledRefactoring) { - rule= ((IScheduledRefactoring) fRefactoring).getSchedulingRule(); - } else { - rule= ResourcesPlugin.getWorkspace().getRoot(); - } + final ISchedulingRule rule = getSchedulingRule(); try { try { Runnable r= new Runnable() { @@ -179,17 +195,22 @@ public class RefactoringExecutionHelper { } RefactoringSaveHelper saveHelper= new RefactoringSaveHelper(fSaveMode); - if (!saveHelper.saveEditors(fParent)) - throw new InterruptedException(); - final Operation op= new Operation(fork, forkChangeExecution); + if (operation != null) { + if (!saveHelper.saveEditors(fParent)) + throw new InterruptedException(); + } fRefactoring.setValidationContext(fParent); try { - fExecContext.run(fork, cancelable, new WorkbenchRunnableAdapter(op, rule, true)); - if (fork && !forkChangeExecution && op.fPerformChangeOperation != null) - fExecContext.run(false, false, new WorkbenchRunnableAdapter(op.fPerformChangeOperation, rule, true)); - - if (op.fPerformChangeOperation != null) { - RefactoringStatus validationStatus= op.fPerformChangeOperation.getValidationStatus(); + if (operation != null) { + fExecContext.run(fork, operation.fCancelable, new WorkbenchRunnableAdapter(operation, rule, true)); + changeOperation = operation.fPerformChangeOperation; + fork = fork && !operation.fForkChangeExecution; + } + + if (changeOperation != null) { + if (fork) + fExecContext.run(false, false, new WorkbenchRunnableAdapter(changeOperation, rule, true)); + RefactoringStatus validationStatus= changeOperation.getValidationStatus(); if (validationStatus != null && validationStatus.hasFatalError()) { MessageDialog.openError(fParent, fRefactoring.getName(), NLS.bind(Messages.RefactoringExecutionHelper_cannot_execute, @@ -198,14 +219,13 @@ public class RefactoringExecutionHelper { } } } catch (InvocationTargetException e) { - PerformChangeOperation pco= op.fPerformChangeOperation; - if (pco != null && pco.changeExecutionFailed()) { + if (changeOperation != null && changeOperation.changeExecutionFailed()) { ChangeExceptionHandler handler= new ChangeExceptionHandler(fParent, fRefactoring); Throwable inner= e.getTargetException(); if (inner instanceof RuntimeException) { - handler.handle(pco.getChange(), (RuntimeException)inner); + handler.handle(changeOperation.getChange(), (RuntimeException)inner); } else if (inner instanceof CoreException) { - handler.handle(pco.getChange(), (CoreException)inner); + handler.handle(changeOperation.getChange(), (CoreException)inner); } else { throw e; } @@ -222,4 +242,20 @@ public class RefactoringExecutionHelper { fRefactoring.setValidationContext(null); } } + + private ISchedulingRule getSchedulingRule() { + if (fRefactoring instanceof IScheduledRefactoring) { + return ((IScheduledRefactoring) fRefactoring).getSchedulingRule(); + } else { + return ResourcesPlugin.getWorkspace().getRoot(); + } + } + + private PerformChangeOperation createPerformChangeOperation(Change change) { + PerformChangeOperation operation = new PerformChangeOperation(change); + operation.setUndoManager(RefactoringCore.getUndoManager(), fRefactoring.getName()); + if (fRefactoring instanceof IScheduledRefactoring) + operation.setSchedulingRule(((IScheduledRefactoring) fRefactoring).getSchedulingRule()); + return operation; + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterNamesInputPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterNamesInputPage.java index 8247988ebd6..b5c6c09248e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterNamesInputPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterNamesInputPage.java @@ -218,4 +218,12 @@ public class ParameterNamesInputPage extends UserInputWizardPage { } delayedPreviewUpdater.schedule(PREVIEW_UPDATE_DELAY); } + + @Override + public boolean isPageComplete() { + if (!config.isChecked()) { + return true; + } + return super.isPageComplete(); + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringArgument.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringArgument.java index 96e57d03d0d..ff9eee6f3db 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringArgument.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringArgument.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation ******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.rename; @@ -39,8 +39,8 @@ import org.eclipse.cdt.ui.CUIPlugin; * can be calculated from the AST. */ public class CRefactoringArgument { - private int fOffset= 0; - private int fLength= 0; + private int fOffset; + private int fLength; private String fText= ""; //$NON-NLS-1$ private int fKind= CRefactory.ARGUMENT_UNKNOWN; private IFile fFile; @@ -72,22 +72,18 @@ public class CRefactoringArgument { } } - // overrider public String getName() { return fText; } - // overrider public IFile getSourceFile() { return fFile; } - // overrider public int getArgumentKind() { return fKind; } - // overrider public int getOffset() { return fOffset; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java index e0514e8eefd..3bbcfce2558 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - * Sergey Prigogin (Google) + * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) ******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.rename; @@ -18,8 +18,6 @@ import java.util.Iterator; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.content.IContentType; import org.eclipse.jface.text.ITextSelection; @@ -29,24 +27,20 @@ import org.eclipse.ui.ide.IDE; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.IWorkingCopy; -import org.eclipse.cdt.ui.CUIPlugin; - -import org.eclipse.cdt.internal.ui.refactoring.RefactoringStarter; /** * Serves to launch the various refactorings. */ public class CRefactory { - public static final int OPTION_ASK_SCOPE = 0x01; - public static final int OPTION_IN_COMMENT = 0x02; - public static final int OPTION_IN_STRING_LITERAL = 0x04; - public static final int OPTION_IN_INCLUDE_DIRECTIVE = 0x08; - public static final int OPTION_IN_MACRO_DEFINITION = 0x10; - public static final int OPTION_IN_PREPROCESSOR_DIRECTIVE = 0x20; - public static final int OPTION_IN_INACTIVE_CODE = 0x40; - public static final int OPTION_IN_CODE = 0x80; - public static final int OPTION_DO_VIRTUAL = 0x100; - public static final int OPTION_EXHAUSTIVE_FILE_SEARCH = 0x200; + public static final int OPTION_IN_CODE_REFERENCES = 0x01; + public static final int OPTION_IN_INACTIVE_CODE = 0x02; + public static final int OPTION_IN_COMMENT = 0x04; + public static final int OPTION_IN_STRING_LITERAL = 0x08; + public static final int OPTION_IN_INCLUDE_DIRECTIVE = 0x10; + public static final int OPTION_IN_MACRO_DEFINITION = 0x20; + public static final int OPTION_IN_PREPROCESSOR_DIRECTIVE = 0x40; + public static final int OPTION_DO_VIRTUAL = 0x80; + public static final int OPTION_EXHAUSTIVE_FILE_SEARCH = 0x100; public static final int ARGUMENT_UNKNOWN = 0; public static final int ARGUMENT_LOCAL_VAR = 1; @@ -64,7 +58,7 @@ public class CRefactory { public static final int ARGUMENT_ENUMERATOR = 13; public static final int ARGUMENT_CLASS_TYPE = 14; public static final int ARGUMENT_NAMESPACE = 15; - + private static CRefactory sInstance= new CRefactory(); private TextSearchWrapper fTextSearch; @@ -83,7 +77,7 @@ public class CRefactory { CRefactoringArgument iarg= new CRefactoringArgument(arg); final CRenameProcessor processor = new CRenameProcessor(this, iarg); CRenameRefactoring refactoring= new CRenameRefactoring(processor); - openDialog(shell, refactoring, false); + RenameSupport.openDialog(shell, refactoring); } public void rename(Shell shell, IWorkingCopy workingCopy, ITextSelection selection) { @@ -98,51 +92,7 @@ public class CRefactory { new CRefactoringArgument((IFile) res, selection.getOffset(), selection.getLength()); final CRenameProcessor processor = new CRenameProcessor(this, iarg); CRenameRefactoring refactoring= new CRenameRefactoring(processor); - openDialog(shell, refactoring, false); - } - - /** - * Opens the refactoring dialog. - * - *

- * This method has to be called from within the UI thread. - *

- * - * @param shell a shell used as a parent for the refactoring, preview, or error dialog - * @param showPreviewOnly if true, the dialog skips all user input pages and - * directly shows the preview or error page. Otherwise, shows all pages. - * @return true if the refactoring has been executed successfully, - * or false if it has been canceled. - */ - static boolean openDialog(Shell shell, CRenameRefactoring refactoring, boolean showPreviewOnly) { - try { - CRenameRefactoringWizard wizard; - if (!showPreviewOnly) { - wizard = new CRenameRefactoringWizard(refactoring); - } else { - wizard = new CRenameRefactoringWizard(refactoring) { - @Override - protected void addUserInputPages() { - // nothing to add - } - }; - wizard.setForcePreviewReview(showPreviewOnly); - } - RefactoringStarter starter = new RefactoringStarter(); - CRenameProcessor processor = (CRenameProcessor) refactoring.getProcessor(); - processor.lockIndex(); - try { - processor.checkInitialConditions(new NullProgressMonitor()); - return starter.activate(wizard, shell, RenameMessages.CRefactory_title_rename, processor.getSaveMode()); - } finally { - processor.unlockIndex(); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } catch (CoreException e) { - CUIPlugin.log(e); - } - return false; + RenameSupport.openDialog(shell, refactoring); } public TextSearchWrapper getTextSearch() { @@ -156,19 +106,19 @@ public class CRefactory { IContentType[] cts= Platform.getContentTypeManager().getAllContentTypes(); HashSet all= new HashSet(); for (IContentType type : cts) { - boolean useit= false; - while (!useit && type != null) { + boolean useIt= false; + while (!useIt && type != null) { String id= type.getId(); if (id.equals(CCorePlugin.CONTENT_TYPE_CHEADER) || id.equals(CCorePlugin.CONTENT_TYPE_CSOURCE) || id.equals(CCorePlugin.CONTENT_TYPE_CXXHEADER) || id.equals(CCorePlugin.CONTENT_TYPE_CXXSOURCE)) { - useit= true; + useIt= true; } else { type= type.getBaseType(); } } - if (useit) { + if (useIt) { String exts[] = type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC); all.addAll(Arrays.asList(exts)); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameGlobalProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameGlobalProcessor.java index ccc62c5d0d2..b12b7562684 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameGlobalProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameGlobalProcessor.java @@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.ui.refactoring.rename; import org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper; - /** * Rename processor that sets up the input page for renaming a global entity. */ @@ -21,11 +20,11 @@ public class CRenameGlobalProcessor extends CRenameProcessorDelegate { public CRenameGlobalProcessor(CRenameProcessor processor, String name) { super(processor, name); - setAvailableOptions(CRefactory.OPTION_ASK_SCOPE | - CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH | - CRefactory.OPTION_IN_CODE | + setAvailableOptions( + CRefactory.OPTION_IN_CODE_REFERENCES | CRefactory.OPTION_IN_COMMENT | - CRefactory.OPTION_IN_MACRO_DEFINITION); + CRefactory.OPTION_IN_MACRO_DEFINITION | + CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH); } @Override diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameIncludeProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameIncludeProcessor.java index 3ebe3d1808f..65eb58d296c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameIncludeProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameIncludeProcessor.java @@ -20,12 +20,12 @@ public class CRenameIncludeProcessor extends CRenameProcessorDelegate { public CRenameIncludeProcessor(CRenameProcessor input, String kind) { super(input, kind); - setAvailableOptions(CRefactory.OPTION_ASK_SCOPE | - CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH | + setAvailableOptions( CRefactory.OPTION_IN_COMMENT | - CRefactory.OPTION_IN_MACRO_DEFINITION); + CRefactory.OPTION_IN_MACRO_DEFINITION | + CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH); setOptionsForcingPreview(-1); - setOptionsEnablingScope(-1); + setOptionsEnablingExhaustiveSearch(-1); } @Override diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java index 6baeebdc024..dee0b02c1ea 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java @@ -40,13 +40,11 @@ public class CRenameLocalProcessor extends CRenameProcessorDelegate { setOptionsForcingPreview(0); } - // overrider @Override protected int getAcceptedLocations(int selectedOptions) { - return CRefactory.OPTION_IN_CODE | CRefactory.OPTION_IN_MACRO_DEFINITION | selectedOptions; + return CRefactory.OPTION_IN_CODE_REFERENCES | CRefactory.OPTION_IN_MACRO_DEFINITION | selectedOptions; } - // overrider @Override protected int getSearchScope() { return TextSearchWrapper.SCOPE_FILE; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMacroProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMacroProcessor.java index 3bebc37ce79..c71e7e15a88 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMacroProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMacroProcessor.java @@ -26,13 +26,13 @@ public class CRenameMacroProcessor extends CRenameGlobalProcessor { public CRenameMacroProcessor(CRenameProcessor processor, String name) { super(processor, name); - setAvailableOptions(CRefactory.OPTION_ASK_SCOPE | - CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH | - CRefactory.OPTION_IN_CODE | + setAvailableOptions( + CRefactory.OPTION_IN_CODE_REFERENCES | CRefactory.OPTION_IN_COMMENT | - CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE); + CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE | + CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH); } - + @Override protected int getAcceptedLocations(int selectedOptions) { return selectedOptions | CRefactory.OPTION_IN_MACRO_DEFINITION; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java index 2b9c0b5b617..408c225c996 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2004, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -52,13 +52,16 @@ public class CRenameProcessor extends RenameProcessor { private final CRefactoringArgument fArgument; private CRenameProcessorDelegate fDelegate; private String fReplacementText; - private String fWorkingSet; - private int fScope; + private String fWorkingSetName; + private int fExhaustiveSearchScope; private int fSelectedOptions; private final CRefactory fManager; private final ASTManager fAstManager; private IIndex fIndex; + private int indexLockCount; private RefactoringStatus fInitialConditionsStatus; + + private Change fChange; public CRenameProcessor(CRefactory refactoringManager, CRefactoringArgument arg) { fManager= refactoringManager; @@ -70,13 +73,11 @@ public class CRenameProcessor extends RenameProcessor { return fArgument; } - // overrider @Override public Object[] getElements() { return new Object[] { fArgument.getBinding() }; } - // overrider @Override public String getProcessorName() { String result= null; @@ -139,15 +140,15 @@ public class CRenameProcessor extends RenameProcessor { private CRenameProcessorDelegate createDelegate() { switch (fArgument.getArgumentKind()) { case CRefactory.ARGUMENT_LOCAL_VAR: - return new CRenameLocalProcessor(this, + return new CRenameLocalProcessor(this, RenameMessages.CRenameTopProcessor_localVar, fArgument.getScope()); case CRefactory.ARGUMENT_PARAMETER: - return new CRenameLocalProcessor(this, + return new CRenameLocalProcessor(this, RenameMessages.CRenameTopProcessor_parameter, fArgument.getScope()); case CRefactory.ARGUMENT_FILE_LOCAL_VAR: - return new CRenameLocalProcessor(this, + return new CRenameLocalProcessor(this, RenameMessages.CRenameTopProcessor_filelocalVar, null); case CRefactory.ARGUMENT_GLOBAL_VAR: @@ -157,7 +158,7 @@ public class CRenameProcessor extends RenameProcessor { case CRefactory.ARGUMENT_FIELD: return new CRenameGlobalProcessor(this, RenameMessages.CRenameTopProcessor_field); case CRefactory.ARGUMENT_FILE_LOCAL_FUNCTION: - return new CRenameLocalProcessor(this, + return new CRenameLocalProcessor(this, RenameMessages.CRenameTopProcessor_filelocalFunction, null); case CRefactory.ARGUMENT_GLOBAL_FUNCTION: @@ -189,10 +190,18 @@ public class CRenameProcessor extends RenameProcessor { @Override public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException { - return fDelegate.createChange(pm); + fChange = fDelegate.createChange(pm); + return fChange; } - @Override + /** + * @return the change if it has been created, or null otherwise. + */ + Change getChange() { + return fChange; + } + + @Override public RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants sharedParticipants) throws CoreException { RenameArguments arguments= new RenameArguments(getReplacementText(), true); @@ -206,7 +215,9 @@ public class CRenameProcessor extends RenameProcessor { return result.toArray(new RefactoringParticipant[result.size()]); } - // options for the input page in the refactoring wizard + /** + * Options for the input page in the refactoring wizard + */ public int getAvailableOptions() { if (fDelegate == null) { return 0; @@ -214,7 +225,9 @@ public class CRenameProcessor extends RenameProcessor { return fDelegate.getAvailableOptions(); } - // options for the input page that trigger the preview + /** + * Options for the input page that trigger the preview + */ public int getOptionsForcingPreview() { if (fDelegate == null) { return 0; @@ -222,12 +235,16 @@ public class CRenameProcessor extends RenameProcessor { return fDelegate.getOptionsForcingPreview(); } - // options for the input page that trigger the preview - public int getOptionsEnablingScope() { + /** + * The options that may need exhaustive file search since index lookup is not guaranteed to + * return all files participating in refactoring. When one of these options is selected, + * the exhaustive file search is enabled. + */ + public int getOptionsEnablingExhaustiveSearch() { if (fDelegate == null) { return 0; } - return fDelegate.getOptionsEnablingScope(); + return fDelegate.getOptionsEnablingExhaustiveSearch(); } @Override @@ -235,12 +252,13 @@ public class CRenameProcessor extends RenameProcessor { return IDENTIFIER; } - public int getScope() { - return fScope; + public int getExhaustiveSearchScope() { + return (fSelectedOptions & CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH) != 0 ? + fExhaustiveSearchScope : TextSearchWrapper.SCOPE_FILE; } - public void setScope(int scope) { - fScope = scope; + public void setExhaustiveSearchScope(int scope) { + fExhaustiveSearchScope = scope; } public int getSelectedOptions() { @@ -251,16 +269,20 @@ public class CRenameProcessor extends RenameProcessor { fSelectedOptions = selectedOptions; } - public String getWorkingSet() { - return fWorkingSet; + public boolean isPreviewRequired() { + return (fSelectedOptions & getOptionsForcingPreview()) != 0; + } + + public String getWorkingSetName() { + return fWorkingSetName; } /** * Sets the name of the working set. If the name of the working set is invalid, * it's set to an empty string. */ - public void setWorkingSet(String workingSet) { - fWorkingSet = checkWorkingSet(workingSet); + public void setWorkingSetName(String workingSet) { + fWorkingSetName = checkWorkingSet(workingSet); } public String getReplacementText() { @@ -280,21 +302,26 @@ public class CRenameProcessor extends RenameProcessor { } public void lockIndex() throws CoreException, InterruptedException { - if (fIndex == null) { - ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects(); - fIndex= CCorePlugin.getIndexManager().getIndex(projects); + if (indexLockCount == 0) { + if (fIndex == null) { + ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects(); + fIndex= CCorePlugin.getIndexManager().getIndex(projects); + } + fIndex.acquireReadLock(); } - fIndex.acquireReadLock(); + indexLockCount++; } public void unlockIndex() { - if (fAstManager != null) { - fAstManager.dispose(); + if (--indexLockCount <= 0) { + if (fAstManager != null) { + fAstManager.dispose(); + } + if (fIndex != null) { + fIndex.releaseReadLock(); + } + fIndex= null; } - if (fIndex != null) { - fIndex.releaseReadLock(); - } - fIndex= null; } public IIndex getIndex() { @@ -307,7 +334,7 @@ public class CRenameProcessor extends RenameProcessor { public int getSaveMode() { return fDelegate.getSaveMode(); } - + private String checkWorkingSet(String workingSet) { if (workingSet != null && workingSet.length() > 0) { IWorkingSetManager wsManager= PlatformUI.getWorkbench().getWorkingSetManager(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java index 4d7fd99504e..f88b03f1f1e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java @@ -47,7 +47,6 @@ import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.ui.refactoring.CTextFileChange; - /** * Abstract base for all different rename processors used by the top processor. */ @@ -55,23 +54,21 @@ public abstract class CRenameProcessorDelegate { private CRenameProcessor fTopProcessor; private ArrayList fMatches; protected String fProcessorBaseName; - private int fAvailableOptions= - CRefactory.OPTION_ASK_SCOPE | - CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH | - CRefactory.OPTION_IN_CODE | + private int fAvailableOptions= + CRefactory.OPTION_IN_CODE_REFERENCES | CRefactory.OPTION_IN_COMMENT | CRefactory.OPTION_IN_MACRO_DEFINITION | - CRefactory.OPTION_IN_STRING_LITERAL; + CRefactory.OPTION_IN_STRING_LITERAL | + CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH; private int fOptionsForcingPreview= - CRefactory.OPTION_IN_INACTIVE_CODE | - CRefactory.OPTION_IN_COMMENT | + CRefactory.OPTION_IN_COMMENT | CRefactory.OPTION_IN_MACRO_DEFINITION | CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE | CRefactory.OPTION_IN_STRING_LITERAL; - - private int fOptionsEnablingScope= fOptionsForcingPreview; + private int fOptionsEnablingExhaustiveSearch= fOptionsForcingPreview | + CRefactory.OPTION_IN_INACTIVE_CODE | CRefactory.OPTION_IN_CODE_REFERENCES; protected CRenameProcessorDelegate(CRenameProcessor topProcessor, String name) { fTopProcessor= topProcessor; @@ -87,7 +84,7 @@ public abstract class CRenameProcessorDelegate { } final public int getSelectedScope() { - return fTopProcessor.getScope(); + return fTopProcessor.getExhaustiveSearchScope(); } final public int getSelectedOptions() { @@ -95,7 +92,7 @@ public abstract class CRenameProcessorDelegate { } final public String getSelectedWorkingSet() { - return fTopProcessor.getWorkingSet(); + return fTopProcessor.getWorkingSetName(); } final public CRefactory getManager() { @@ -142,15 +139,20 @@ public abstract class CRenameProcessorDelegate { } /** - * The options that need the scope definition. When one of them is - * selected, the scope options are enabled. + * Sets the options that enable exhaustive file search. + * @see #getOptionsEnablingExhaustiveSearch() */ - public void setOptionsEnablingScope(int options) { - fOptionsEnablingScope= options; + void setOptionsEnablingExhaustiveSearch(int options) { + fOptionsEnablingExhaustiveSearch= options; } - - final int getOptionsEnablingScope() { - return fOptionsEnablingScope; + + /** + * The options that may need exhaustive file search since index lookup is not guaranteed to + * return all files participating in refactoring. When one of these options is selected, + * the exhaustive file search is enabled. + */ + final int getOptionsEnablingExhaustiveSearch() { + return fOptionsEnablingExhaustiveSearch; } protected int getSearchScope() { @@ -159,17 +161,15 @@ public abstract class CRenameProcessorDelegate { /** * Builds an index-based file filter for the name search. + * * @param bindings bindings being renamed - * @return A set of files containing references to the bindings, or null if - * exhaustive file search is requested. + * @return A set of files containing references to the bindings. */ - private Collection getFileFilter(IBinding[] bindings) { - if ((getSelectedOptions() & CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH) != 0) { - return null; - } + private Collection getReferringFiles(IBinding[] bindings) { + ArrayList files = new ArrayList(); IIndex index = getIndex(); if (index == null) { - return null; + return files; } Set locations = new HashSet(); try { @@ -182,21 +182,21 @@ public abstract class CRenameProcessorDelegate { } } } catch (InterruptedException e) { - return null; + return files; } catch (CoreException e) { - return null; + return files; } finally { index.releaseReadLock(); } - ArrayList files = new ArrayList(locations.size()); + files.ensureCapacity(locations.size()); IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); for (IIndexFileLocation location : locations) { String fullPath= location.getFullPath(); if (fullPath != null) { IResource file= workspaceRoot.findMember(fullPath); - if (file != null) { - files.add(file); + if (file instanceof IFile) { + files.add((IFile) file); } } } @@ -220,13 +220,12 @@ public abstract class CRenameProcessorDelegate { // perform text-search fMatches= new ArrayList(); TextSearchWrapper txtSearch= getManager().getTextSearch(); - Collection fileFilter = getFileFilter(renameBindings); - if (fileFilter != null && !fileFilter.contains(file)) { - fileFilter.add(file); + Collection filesToSearch = getReferringFiles(renameBindings); + if (!filesToSearch.contains(file)) { + filesToSearch.add(file); } - IStatus stat= txtSearch.searchWord(getSearchScope(), file, getSelectedWorkingSet(), - fileFilter != null ? fileFilter.toArray(new IResource[fileFilter.size()]) : null, - getManager().getCCppPatterns(), + IStatus stat= txtSearch.searchWord(filesToSearch.toArray(new IFile[filesToSearch.size()]), + getSearchScope(), file, getSelectedWorkingSet(), getManager().getCCppPatterns(), getArgument().getName(), new SubProgressMonitor(monitor, 1), fMatches); if (monitor.isCanceled()) { throw new OperationCanceledException(); @@ -354,7 +353,7 @@ public abstract class CRenameProcessorDelegate { } if (match.getAstInformation() != CRefactoringMatch.AST_REFERENCE_OTHER) { IFile mfile= match.getFile(); - if (file==null || !file.equals(mfile) || fileEdit == null || fileChange == null) { + if (file == null || !file.equals(mfile) || fileEdit == null || fileChange == null) { file= mfile; fileEdit= new MultiTextEdit(); fileChange = new CTextFileChange(file.getName(), file); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java index b875cf2ecfd..4ff71ad86af 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - * Emanuel Graf (Institute for Software, HSR Hochschule fuer Technik) - * Sergey Prigogin (Google) + * Markus Schorn - initial API and implementation + * Emanuel Graf (Institute for Software, HSR Hochschule fuer Technik) + * Sergey Prigogin (Google) ******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.rename; @@ -45,7 +45,7 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage { private String fSearchString; private int fOptions; private int fForcePreviewOptions= 0; - private int fEnableScopeOptions; + private int fExhaustiveSearchEnablingOptions; private Text fNewName; private Button fDoVirtual; @@ -79,7 +79,7 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage { fSearchString= processor.getArgument().getName(); fOptions= processor.getAvailableOptions(); fForcePreviewOptions= processor.getOptionsForcingPreview(); - fEnableScopeOptions= processor.getOptionsEnablingScope(); + fExhaustiveSearchEnablingOptions= processor.getOptionsEnablingExhaustiveSearch(); Composite top= new Composite(parent, SWT.NONE); initializeDialogUnits(top); @@ -87,7 +87,7 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage { top.setLayout(new GridLayout(2, false)); - // new name + // New name Composite group= top; GridData gd; GridLayout gl; @@ -95,7 +95,11 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage { Label label= new Label(top, SWT.NONE); label.setText(RenameMessages.CRenameRefactoringInputPage_label_newName); fNewName= new Text(top, SWT.BORDER); - fNewName.setText(fSearchString); + String name = processor.getReplacementText(); + if (name == null) { + name = fSearchString; + } + fNewName.setText(name); fNewName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fNewName.selectAll(); @@ -106,52 +110,9 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage { gd.horizontalSpan= 2; } - if (hasOption(CRefactory.OPTION_ASK_SCOPE)) { - // Specify the scope. - skipLine(top); - label = new Label(top, SWT.NONE); - label.setText(RenameMessages.CRenameRefactoringInputPage_label_scope); - label.setLayoutData(gd= new GridData(GridData.FILL_HORIZONTAL)); - gd.horizontalSpan= 2; - - group= new Composite(top, SWT.NONE); - group.setLayoutData(gd= new GridData(GridData.FILL_HORIZONTAL)); - gd.horizontalSpan= 2; - group.setLayout(gl= new GridLayout(4, false)); - gl.marginHeight= 0; - gl.marginLeft = gl.marginWidth; - gl.marginWidth = 0; - - fWorkspace= new Button(group, SWT.RADIO); - fWorkspace.setText(RenameMessages.CRenameRefactoringInputPage_button_workspace); - fWorkspace.setLayoutData(gd= new GridData()); - - fDependent= new Button(group, SWT.RADIO); - fDependent.setText(RenameMessages.CRenameRefactoringInputPage_button_relatedProjects); - fDependent.setLayoutData(gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - gd.horizontalIndent= 8; - - fSingle= new Button(group, SWT.RADIO); - fSingle.setText(RenameMessages.CRenameRefactoringInputPage_button_singleProject); - fSingle.setLayoutData(gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - gd.horizontalIndent= 8; - gd.horizontalSpan= 2; - - fWorkingSet= new Button(group, SWT.RADIO); - fWorkingSet.setText(RenameMessages.CRenameRefactoringInputPage_button_workingSet); - - fWorkingSetSpec= new Text(group, SWT.SINGLE|SWT.BORDER|SWT.READ_ONLY); - fWorkingSetSpec.setLayoutData(gd= new GridData(GridData.FILL_HORIZONTAL)); - gd.horizontalIndent= 8; - gd.horizontalSpan= 2; - fWorkingSetButton= new Button(group, SWT.PUSH); - fWorkingSetButton.setText(RenameMessages.CRenameRefactoringInputPage_button_chooseWorkingSet); - setButtonLayoutData(fWorkingSetButton); - } - boolean skippedLine= false; group= null; - if (hasOption(CRefactory.OPTION_IN_CODE)) { + if (hasOption(CRefactory.OPTION_IN_CODE_REFERENCES)) { group= createLabelAndGroup(group, skippedLine, top); fReferences= new Button(group, SWT.CHECK); fReferences.setText(RenameMessages.CRenameRefactoringInputPage_button_sourceCode); @@ -194,7 +155,43 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage { fExhausiveFileSearch.setLayoutData(gd= new GridData()); gd.horizontalIndent= 5; gd.horizontalSpan= 2; - } + + // Specify the scope. + group= new Composite(top, SWT.NONE); + group.setLayoutData(gd= new GridData(GridData.FILL_HORIZONTAL)); + gd.horizontalSpan= 2; + gd.horizontalIndent= 16; + group.setLayout(gl= new GridLayout(4, false)); + gl.marginHeight= 0; + gl.marginLeft = gl.marginWidth; + gl.marginWidth = 0; + + fWorkspace= new Button(group, SWT.RADIO); + fWorkspace.setText(RenameMessages.CRenameRefactoringInputPage_button_workspace); + fWorkspace.setLayoutData(gd= new GridData()); + + fDependent= new Button(group, SWT.RADIO); + fDependent.setText(RenameMessages.CRenameRefactoringInputPage_button_relatedProjects); + fDependent.setLayoutData(gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); + gd.horizontalIndent= 8; + + fSingle= new Button(group, SWT.RADIO); + fSingle.setText(RenameMessages.CRenameRefactoringInputPage_button_singleProject); + fSingle.setLayoutData(gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); + gd.horizontalIndent= 8; + gd.horizontalSpan= 2; + + fWorkingSet= new Button(group, SWT.RADIO); + fWorkingSet.setText(RenameMessages.CRenameRefactoringInputPage_button_workingSet); + + fWorkingSetSpec= new Text(group, SWT.SINGLE|SWT.BORDER|SWT.READ_ONLY); + fWorkingSetSpec.setLayoutData(gd= new GridData(GridData.FILL_HORIZONTAL)); + gd.horizontalIndent= 8; + gd.horizontalSpan= 2; + fWorkingSetButton= new Button(group, SWT.PUSH); + fWorkingSetButton.setText(RenameMessages.CRenameRefactoringInputPage_button_chooseWorkingSet); + setButtonLayoutData(fWorkingSetButton); + } Dialog.applyDialogFont(top); hookSelectionListeners(); @@ -283,7 +280,7 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage { } protected void onSelectedScope(int scope) { - getRenameProcessor().setScope(scope); + getRenameProcessor().setExhaustiveSearchScope(scope); updateEnablement(); } @@ -328,11 +325,11 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage { fDependent.setSelection(true); break; } - processor.setScope(scope); + processor.setExhaustiveSearchScope(scope); String workingSet= fPreferences.getWorkingSet(); - processor.setWorkingSet(workingSet); // CRenameProcessor validates the working set name. - fWorkingSetSpec.setText(processor.getWorkingSet()); + processor.setWorkingSetName(workingSet); // CRenameProcessor validates the working set name. + fWorkingSetSpec.setText(processor.getWorkingSetName()); } if (fDoVirtual != null) { @@ -343,40 +340,46 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage { boolean val= !fPreferences.getBoolean(CRenameRefactoringPreferences.KEY_REFERENCES_INV); fReferences.setSelection(val); } + initOption(fInInactiveCode, CRenameRefactoringPreferences.KEY_INACTIVE); initOption(fInComment, CRenameRefactoringPreferences.KEY_COMMENT); initOption(fInString, CRenameRefactoringPreferences.KEY_STRING); initOption(fInInclude, CRenameRefactoringPreferences.KEY_INCLUDE); initOption(fInMacro, CRenameRefactoringPreferences.KEY_MACRO_DEFINITION); initOption(fInPreprocessor, CRenameRefactoringPreferences.KEY_PREPROCESSOR); - initOption(fInInactiveCode, CRenameRefactoringPreferences.KEY_INACTIVE); initOption(fExhausiveFileSearch, CRenameRefactoringPreferences.KEY_EXHAUSTIVE_FILE_SEARCH); } private int computeSelectedOptions() { - int options= 0; - options |= computeOption(fDoVirtual, CRefactory.OPTION_DO_VIRTUAL); - options |= computeOption(fReferences, CRefactory.OPTION_IN_CODE); - options |= computeOption(fInComment, CRefactory.OPTION_IN_COMMENT); - options |= computeOption(fInString, CRefactory.OPTION_IN_STRING_LITERAL); - options |= computeOption(fInInclude, CRefactory.OPTION_IN_INCLUDE_DIRECTIVE); - options |= computeOption(fInMacro, CRefactory.OPTION_IN_MACRO_DEFINITION); - options |= computeOption(fInPreprocessor, CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE); - options |= computeOption(fInInactiveCode, CRefactory.OPTION_IN_INACTIVE_CODE); - options |= computeOption(fExhausiveFileSearch, CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH); + int options= fPreferences.getOptions(); + options = updateOptions(options, fDoVirtual, CRefactory.OPTION_DO_VIRTUAL); + options = updateOptions(options, fInInactiveCode, CRefactory.OPTION_IN_INACTIVE_CODE); + options = updateOptions(options, fInComment, CRefactory.OPTION_IN_COMMENT); + options = updateOptions(options, fInString, CRefactory.OPTION_IN_STRING_LITERAL); + options = updateOptions(options, fInInclude, CRefactory.OPTION_IN_INCLUDE_DIRECTIVE); + options = updateOptions(options, fInMacro, CRefactory.OPTION_IN_MACRO_DEFINITION); + options = updateOptions(options, fInPreprocessor, CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE); + options = updateOptions(options, fReferences, CRefactory.OPTION_IN_CODE_REFERENCES); + options = updateOptions(options, fExhausiveFileSearch, CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH); return options; } - private int computeOption(Button button, int option) { - if (button != null && button.getSelection()) { - return option; + private int updateOptions(int options, Button button, int optionMask) { + if (button == null) + return options; + if (button.getSelection()) { + return options | optionMask; + } else { + return options & ~optionMask; } - return 0; } private void initOption(Button button, String key) { - boolean val= false; + initOption(button, key, false); + } + + private void initOption(Button button, String key, boolean defaultValue) { if (button != null) { - val= fPreferences.getBoolean(key); + boolean val= fPreferences.getBoolean(key, defaultValue); button.setSelection(val); } } @@ -444,13 +447,13 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage { fDependent.setSelection(false); fSingle.setSelection(false); fWorkingSet.setSelection(true); - processor.setScope(TextSearchWrapper.SCOPE_WORKING_SET); + processor.setExhaustiveSearchScope(TextSearchWrapper.SCOPE_WORKING_SET); wsName= ws.getName(); } } - processor.setWorkingSet(wsName); // CRenameProcessor validates the working set name. - fWorkingSetSpec.setText(processor.getWorkingSet()); + processor.setWorkingSetName(wsName); // CRenameProcessor validates the working set name. + fWorkingSetSpec.setText(processor.getWorkingSetName()); updateEnablement(); } @@ -469,22 +472,26 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage { } protected void updateEnablement() { - boolean enable= fEnableScopeOptions == -1 || - (computeSelectedOptions() & fEnableScopeOptions) != 0; - - if (fWorkspace != null) { - fWorkspace.setEnabled(enable); - fDependent.setEnabled(enable); - fSingle.setEnabled(enable); - - boolean enableSpec= false; - fWorkingSet.setEnabled(enable); - if (enable && fWorkingSet.getSelection()) { - enableSpec= true; - } - fWorkingSetSpec.setEnabled(enableSpec); - fWorkingSetButton.setEnabled(enable); - } + if (fExhausiveFileSearch != null) { + boolean enable= fExhaustiveSearchEnablingOptions == -1 || + (computeSelectedOptions() & fExhaustiveSearchEnablingOptions) != 0; + + fExhausiveFileSearch.setEnabled(enable); + enable = enable && fExhausiveFileSearch.getSelection(); + if (fWorkspace != null) { + fWorkspace.setEnabled(enable); + fDependent.setEnabled(enable); + fSingle.setEnabled(enable); + + boolean enableSpec= false; + fWorkingSet.setEnabled(enable); + if (enable && fWorkingSet.getSelection()) { + enableSpec= true; + } + fWorkingSetSpec.setEnabled(enableSpec); + fWorkingSetButton.setEnabled(enable); + } + } } private CRenameProcessor getRenameProcessor() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringPreferences.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringPreferences.java index 1aa3681f467..557d30c75d3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringPreferences.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringPreferences.java @@ -45,6 +45,11 @@ public class CRenameRefactoringPreferences { return fDialogSettings.getBoolean(key); } + public boolean getBoolean(String key, boolean defaultValue) { + String value = fDialogSettings.get(key); + return value != null ? Boolean.parseBoolean(value) : defaultValue; + } + public void put(String key, int value) { fDialogSettings.put(key, value); } @@ -74,7 +79,9 @@ public class CRenameRefactoringPreferences { if (!getBoolean(KEY_IGNORE_VIRTUAL)) options |= CRefactory.OPTION_DO_VIRTUAL; if (!getBoolean(KEY_REFERENCES_INV)) - options |= CRefactory.OPTION_IN_CODE; + options |= CRefactory.OPTION_IN_CODE_REFERENCES; + if (getBoolean(KEY_INACTIVE)) + options |= CRefactory.OPTION_IN_INACTIVE_CODE; if (getBoolean(KEY_COMMENT)) options |= CRefactory.OPTION_IN_COMMENT; if (getBoolean(KEY_STRING)) @@ -85,8 +92,6 @@ public class CRenameRefactoringPreferences { options |= CRefactory.OPTION_IN_MACRO_DEFINITION; if (getBoolean(KEY_PREPROCESSOR)) options |= CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE; - if (getBoolean(KEY_INACTIVE)) - options |= CRefactory.OPTION_IN_INACTIVE_CODE; if (getBoolean(KEY_EXHAUSTIVE_FILE_SEARCH)) options |= CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH; return options; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode.java index a8e95920a9a..dfb2d6e86ae 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode.java @@ -334,8 +334,7 @@ public class RenameLinkedMode { if (fShowPreview) { // could have been updated by undoAndCreateRenameSupport(..) executed= renameSupport.openDialog(shell, true); } else { - renameSupport.perform(shell, fEditor.getSite().getWorkbenchWindow()); - executed= true; + executed= renameSupport.perform(shell, fEditor.getSite().getWorkbenchWindow()); } if (executed) { restoreFullSelection(); @@ -429,10 +428,9 @@ public class RenameLinkedMode { processor.setReplacementText(newName); CRenameRefactoringPreferences preferences = new CRenameRefactoringPreferences(); processor.setSelectedOptions(preferences.getOptions()); - processor.setScope(preferences.getScope()); - processor.setWorkingSet(preferences.getWorkingSet()); - RenameSupport renameSupport= RenameSupport.create(processor); - return renameSupport; + processor.setExhaustiveSearchScope(preferences.getScope()); + processor.setWorkingSetName(preferences.getWorkingSet()); + return RenameSupport.create(processor); } private void reconcile() throws CModelException { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.java index b4c6489068e..e570db8fcb4 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.java @@ -77,7 +77,6 @@ public class RenameMessages extends NLS { public static String CRenameRefactoringInputPage_button_workingSet; public static String CRenameRefactoringInputPage_errorInvalidIdentifier; public static String CRenameRefactoringInputPage_label_newName; - public static String CRenameRefactoringInputPage_label_scope; public static String CRenameRefactoringInputPage_label_updateWithin; public static String CRenameRefactoringInputPage_renameBaseAndDerivedMethods; public static String CRenameTopProcessor_enumerator; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.properties index dcd80f152da..e3c27856bd7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.properties @@ -66,15 +66,14 @@ CRenameRefactoringInputPage_button_includes=Include directives CRenameRefactoringInputPage_button_macroDefinitions=Macro definitions CRenameRefactoringInputPage_button_preprocessor=Other preprocessor directives CRenameRefactoringInputPage_button_strings=String literals -CRenameRefactoringInputPage_button_exhaustiveFileSearch=Exhaustive file search (slow) +CRenameRefactoringInputPage_button_exhaustiveFileSearch=Exhaustive (slow) file search in: CRenameRefactoringInputPage_button_singleProject=Project CRenameRefactoringInputPage_button_relatedProjects=Related projects CRenameRefactoringInputPage_button_workspace=All projects CRenameRefactoringInputPage_button_workingSet=Working set: CRenameRefactoringInputPage_errorInvalidIdentifier=''{0}'' is not a valid identifier CRenameRefactoringInputPage_label_newName=New Name: -CRenameRefactoringInputPage_label_scope=Scope of Rename: -CRenameRefactoringInputPage_label_updateWithin=Update within: +CRenameRefactoringInputPage_label_updateWithin=Update occurrences in: CRenameRefactoringInputPage_renameBaseAndDerivedMethods=Rename virtual methods in base and derived classes, also (if any). CRenameTopProcessor_enumerator=enumerator CRenameTopProcessor_error_invalidName=The selected name cannot be renamed. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSupport.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSupport.java index e65517fa5ae..f54d36a7df5 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSupport.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSupport.java @@ -13,19 +13,25 @@ package org.eclipse.cdt.internal.ui.refactoring.rename; import java.lang.reflect.InvocationTargetException; +import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.operation.IRunnableContext; +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.ltk.core.refactoring.Change; import org.eclipse.ltk.core.refactoring.RefactoringCore; import org.eclipse.ltk.core.refactoring.RefactoringStatus; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.ui.refactoring.RefactoringExecutionHelper; +import org.eclipse.cdt.internal.ui.refactoring.RefactoringStarter; /** * Central access point to execute rename refactorings. @@ -49,6 +55,13 @@ public class RenameSupport { /** Flag indicating that the setter method is to be updated as well. */ public static final int UPDATE_SETTER_METHOD= 1 << 5; + /** @see #openDialog(Shell, CRenameRefactoring, DialogMode) */ + private enum DialogMode { ALL_PAGES, PREVIEW_ONLY, CONDITIONAL_PREVIEW } + /** @see #openDialog(Shell, CRenameRefactoring, DialogMode) */ + private enum DialogResult { OK, CANCELED, SKIPPED } + // Same as org.eclipse.ltk.internal.ui.refactoring.IErrorWizardPage#PAGE_NAME + private static final String ERROR_PAGE_NAME = "ErrorPage"; //$NON-NLS-1$ + private CRenameRefactoring fRefactoring; private RefactoringStatus fPreCheckStatus; @@ -67,7 +80,7 @@ public class RenameSupport { * @throws CoreException if an unexpected exception occurs while performing the checking. * * @see #openDialog(Shell) - * @see #perform(Shell, IRunnableContext) + * @see #perform(Shell, IWorkbenchWindow) */ public IStatus preCheck() throws CoreException { ensureChecked(); @@ -80,14 +93,13 @@ public class RenameSupport { /** * Opens the refactoring dialog for this rename support. * - * @param parent a shell used as a parent for the refactoring dialog. - * @throws CoreException if an unexpected exception occurs while opening the - * dialog. + * @param shell a shell used as a parent for the refactoring dialog. + * @throws CoreException if an unexpected exception occurs while opening the dialog. * * @see #openDialog(Shell, boolean) */ - public void openDialog(Shell parent) throws CoreException { - openDialog(parent, false); + public boolean openDialog(Shell shell) throws CoreException { + return openDialog(shell, false); } /** @@ -116,7 +128,88 @@ public class RenameSupport { return false; } - return CRefactory.openDialog(shell, fRefactoring, showPreviewOnly); + DialogMode mode = showPreviewOnly ? DialogMode.PREVIEW_ONLY : DialogMode.ALL_PAGES; + return openDialog(shell, fRefactoring, mode) == DialogResult.OK; + } + + /** + * Opens the refactoring dialog for a given rename refactoring. + * + * @param shell a shell used as a parent for the refactoring dialog. + * @param refactoring the refactoring object. + * + * @see #openDialog(Shell, boolean) + */ + public static void openDialog(Shell shell, CRenameRefactoring refactoring) { + openDialog(shell, refactoring, DialogMode.ALL_PAGES); + } + + /** + * Opens the refactoring dialog. + * + *

+ * This method has to be called from within the UI thread. + *

+ * + * @param shell A shell used as a parent for the refactoring, preview, or error dialog + * @param refactoring The refactoring. + * @param mode One of DialogMode values. ALL_PAGES opens wizard with all pages shown; + * PREVIEW_ONLY opens the preview page only; CONDITIONAL_PREVIEW opens the wizard with + * preview page only and only if a warning was generated during the final conditions check. + * @return One of DialogResult values. OK is returned if the dialog was shown and + * the refactoring change was applied; CANCELED is returned if the refactoring was + * cancelled. SKIPPED is returned if the dialog was skipped in CONDITIONAL_PREVIEW mode and + * the refactoring change has not been applied yet. + */ + static DialogResult openDialog(Shell shell, CRenameRefactoring refactoring, final DialogMode mode) { + try { + final boolean[] dialogSkipped = new boolean[1]; + CRenameRefactoringWizard wizard; + if (mode == DialogMode.ALL_PAGES) { + wizard = new CRenameRefactoringWizard(refactoring); + } else { + wizard = new CRenameRefactoringWizard(refactoring) { + @Override + protected void addUserInputPages() { + // Nothing to add + } + + @Override + public IWizardPage getStartingPage() { + IWizardPage startingPage = super.getStartingPage(); + if (mode == DialogMode.CONDITIONAL_PREVIEW && + !startingPage.getName().equals(ERROR_PAGE_NAME)) { + dialogSkipped[0] = true; + return null; + } + return startingPage; + } + }; + wizard.setForcePreviewReview(mode != DialogMode.ALL_PAGES); + } + RefactoringStarter starter = new RefactoringStarter(); + CRenameProcessor processor = (CRenameProcessor) refactoring.getProcessor(); + processor.lockIndex(); + try { + RefactoringStatus status = processor.checkInitialConditions(new NullProgressMonitor()); + if (status.hasFatalError()) { + showInformation(shell, status); + return DialogResult.CANCELED; + } + if (starter.activate(wizard, shell, RenameMessages.CRefactory_title_rename, + processor.getSaveMode())) { + return DialogResult.OK; + } + return dialogSkipped[0] ? DialogResult.SKIPPED : DialogResult.CANCELED; + } finally { + processor.unlockIndex(); + } + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } catch (CoreException e) { + CUIPlugin.log(e); + } + return DialogResult.CANCELED; } /** @@ -139,26 +232,38 @@ public class RenameSupport { * @see #openDialog(Shell) * @see IRunnableContext#run(boolean, boolean, org.eclipse.jface.operation.IRunnableWithProgress) */ - public void perform(Shell parent, IRunnableContext context) throws InterruptedException, InvocationTargetException { + public boolean perform(Shell parent, IWorkbenchWindow context) throws InterruptedException, InvocationTargetException { try { ensureChecked(); if (fPreCheckStatus.hasFatalError()) { showInformation(parent, fPreCheckStatus); - return; + return false; } CRenameProcessor renameProcessor = getRenameProcessor(); + renameProcessor.lockIndex(); try { - renameProcessor.lockIndex(); fPreCheckStatus = renameProcessor.checkInitialConditions(new NullProgressMonitor()); if (fPreCheckStatus.hasFatalError()) { showInformation(parent, fPreCheckStatus); - return; + return false; + } + DialogResult result = openDialog(context.getShell(), fRefactoring, + DialogMode.CONDITIONAL_PREVIEW); + switch (result) { + case OK: + return true; + case SKIPPED: + RefactoringExecutionHelper helper= new RefactoringExecutionHelper(fRefactoring, + RefactoringCore.getConditionCheckingFailedSeverity(), + renameProcessor.getSaveMode(), parent, context); + Change change = renameProcessor.getChange(); + Assert.isNotNull(change); + helper.performChange(change, true); + return true; + default: + return false; } - RefactoringExecutionHelper helper= new RefactoringExecutionHelper(fRefactoring, - RefactoringCore.getConditionCheckingFailedSeverity(), renameProcessor.getSaveMode(), - parent, context); - helper.perform(true, true); } finally { renameProcessor.unlockIndex(); } @@ -197,7 +302,7 @@ public class RenameSupport { } } - private void showInformation(Shell parent, RefactoringStatus status) { + private static void showInformation(Shell parent, RefactoringStatus status) { String message= status.getMessageMatchingSeverity(RefactoringStatus.FATAL); MessageDialog.openInformation(parent, RenameMessages.RenameSupport_dialog_title, message); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java index 57af2ad3349..6c32f9ece07 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - * Sergey Prigogin (Google) + * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.rename; @@ -42,7 +42,6 @@ import org.eclipse.search.core.text.TextSearchMatchAccess; import org.eclipse.search.core.text.TextSearchRequestor; import org.eclipse.search.core.text.TextSearchScope; import org.eclipse.ui.IWorkingSet; -import org.eclipse.ui.IWorkingSetManager; import org.eclipse.ui.PlatformUI; import org.eclipse.cdt.core.model.CoreModel; @@ -65,28 +64,29 @@ public class TextSearchWrapper { public final static int SCOPE_WORKING_SET = 5; private static class SearchScope extends TextSearchScope { - public static SearchScope newSearchScope(IWorkingSet ws, IResource[] filter) { + public static SearchScope newSearchScope(IFile[] files, IWorkingSet ws) { IAdaptable[] adaptables= ws.getElements(); ArrayList resources = new ArrayList(); for (int i = 0; i < adaptables.length; i++) { IAdaptable adaptable = adaptables[i]; - IResource r= (IResource) adaptable.getAdapter(IResource.class); - if (r != null) { - resources.add(r); + IResource resource= (IResource) adaptable.getAdapter(IResource.class); + if (resource != null) { + resources.add(resource); } } - return newSearchScope(resources.toArray(new IResource[resources.size()]), filter); + return newSearchScope(files, resources.toArray(new IResource[resources.size()])); } - public static SearchScope newSearchScope(IResource[] roots, IResource[] filter) { - if (filter != null) { - ArrayList files = new ArrayList(filter.length); - for (IResource file : filter) { - if (isInForest(file, roots)) { - files.add(file); + public static SearchScope newSearchScope(IFile[] files, IResource[] roots) { + if (files != null) { + ArrayList resources = new ArrayList(files.length + roots.length); + for (IFile file : files) { + if (!isInForest(file, roots)) { + resources.add(file); } } - roots = files.toArray(new IResource[files.size()]); + Collections.addAll(resources, roots); + roots = resources.toArray(new IResource[resources.size()]); } return new SearchScope(roots); } @@ -181,93 +181,88 @@ public class TextSearchWrapper { public TextSearchWrapper() { } - private TextSearchScope createSearchScope(IFile file, int scope, String workingSetName, - IResource[] filter, String[] patterns) { + private TextSearchScope createSearchScope(IFile[] files, int scope, IFile file, + String workingSetName, String[] patterns) { switch (scope) { case SCOPE_WORKSPACE: - return defineSearchScope(file.getWorkspace().getRoot(), filter, patterns); + return defineSearchScope(files, file.getWorkspace().getRoot(), patterns); case SCOPE_SINGLE_PROJECT: - return defineSearchScope(file.getProject(), filter, patterns); + return defineSearchScope(files, file.getProject(), patterns); case SCOPE_FILE: - return defineSearchScope(file, filter, patterns); + return defineSearchScope(files, file, patterns); case SCOPE_WORKING_SET: { - TextSearchScope result= defineWorkingSetAsSearchScope(workingSetName, filter, patterns); - if (result == null) { - result= defineSearchScope(file.getWorkspace().getRoot(), filter, patterns); - } - return result; + return defineWorkingSetAsSearchScope(files, workingSetName, patterns); } } - return defineRelatedProjectsAsSearchScope(file.getProject(), filter, patterns); + return defineRelatedProjectsAsSearchScope(files, file.getProject(), patterns); } - private TextSearchScope defineRelatedProjectsAsSearchScope(IProject project, IResource[] filter, String[] patterns) { + private TextSearchScope defineRelatedProjectsAsSearchScope(IFile[] files, IProject project, String[] patterns) { HashSet projects= new HashSet(); LinkedList workThrough= new LinkedList(); workThrough.add(project); while (!workThrough.isEmpty()) { - IProject prj= workThrough.removeLast(); - if (projects.add(prj)) { + IProject proj= workThrough.removeLast(); + if (projects.add(proj)) { try { - workThrough.addAll(Arrays.asList(prj.getReferencedProjects())); - workThrough.addAll(Arrays.asList(prj.getReferencingProjects())); + workThrough.addAll(Arrays.asList(proj.getReferencedProjects())); + workThrough.addAll(Arrays.asList(proj.getReferencingProjects())); } catch (CoreException e) { // need to ignore } } } IResource[] roots= projects.toArray(new IResource[projects.size()]); - return defineSearchScope(roots, filter, patterns); + return defineSearchScope(files, roots, patterns); } - private TextSearchScope defineWorkingSetAsSearchScope(String workingSetName, IResource[] filter, String[] patterns) { - if (workingSetName == null) { - return null; - } - IWorkingSetManager wsManager= PlatformUI.getWorkbench().getWorkingSetManager(); - IWorkingSet ws= wsManager.getWorkingSet(workingSetName); - if (ws == null) { - return null; - } - SearchScope result= SearchScope.newSearchScope(ws, filter); + private TextSearchScope defineWorkingSetAsSearchScope(IFile[] files, String workingSetName, String[] patterns) { + IWorkingSet workingSet = workingSetName != null ? + PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(workingSetName) : + null; + SearchScope result= workingSet != null ? + SearchScope.newSearchScope(files, workingSet) : + SearchScope.newSearchScope(files, new IResource[0]); applyFilePatterns(result, patterns); return result; } private void applyFilePatterns(SearchScope scope, String[] patterns) { - for (int i = 0; i < patterns.length; i++) { - String pattern = patterns[i]; + for (String pattern : patterns) { scope.addFileNamePattern(pattern); } } - private TextSearchScope defineSearchScope(IResource root, IResource[] filter, String[] patterns) { - SearchScope result= SearchScope.newSearchScope(new IResource[] { root }, filter); + private TextSearchScope defineSearchScope(IFile[] files, IResource root, String[] patterns) { + SearchScope result= SearchScope.newSearchScope(files, new IResource[] { root }); applyFilePatterns(result, patterns); return result; } - private TextSearchScope defineSearchScope(IResource[] roots, IResource[] filter, String[] patterns) { - SearchScope result= SearchScope.newSearchScope(roots, filter); + private TextSearchScope defineSearchScope(IFile[] files, IResource[] roots, String[] patterns) { + SearchScope result= SearchScope.newSearchScope(files, roots); applyFilePatterns(result, patterns); return result; } /** * Searches for a given word. - * - * @param scope One of SCOPE_FILE, SCOPE_WORKSPACE, SCOPE_RELATED_PROJECTS, SCOPE_SINGLE_PROJECT, - * or SCOPE_WORKING_SET. - * @param file The file used as an anchor for the scope. - * @param workingSet The name of a working set. Ignored is scope is not SCOPE_WORKING_SET. - * @param filter If not null, further limits the scope of the search. + * + * @param filesToSearch The files to search. + * @param scope Together with {@code file} and {@code workingSet} defines set of additional + * file to search. One of SCOPE_FILE, SCOPE_WORKSPACE, SCOPE_RELATED_PROJECTS, + * SCOPE_SINGLE_PROJECT, or SCOPE_WORKING_SET. + * @param scopeAnchor The file used as an anchor for the scope. + * @param workingSet The name of a working set. Ignored if {@code scope} is not + * SCOPE_WORKING_SET. * @param patterns File name patterns. * @param word The word to search for. * @param monitor A progress monitor. * @param target The list that gets populated with search results. */ - public IStatus searchWord(int scope, IFile file, String workingSet, IResource[] filter, String[] patterns, - String word, IProgressMonitor monitor, final List target) { + public IStatus searchWord(IFile[] filesToSearch, int scope, IFile scopeAnchor, String workingSet, + String[] patterns, String word, IProgressMonitor monitor, + final List target) { int startPos= target.size(); TextSearchEngine engine= TextSearchEngine.create(); StringBuilder searchPattern= new StringBuilder(word.length() + 8); @@ -279,7 +274,7 @@ public class TextSearchWrapper { Pattern pattern= Pattern.compile(searchPattern.toString()); - TextSearchScope searchscope= createSearchScope(file, scope, workingSet, filter, patterns); + TextSearchScope searchscope= createSearchScope(filesToSearch, scope, scopeAnchor, workingSet, patterns); TextSearchRequestor requestor= new TextSearchRequestor() { @Override public boolean acceptPatternMatch(TextSearchMatchAccess access) { @@ -360,7 +355,7 @@ public class TextSearchWrapper { Token token; int lastState= 0; while ((token= scanner.nextToken()) != null) { - int state= CRefactory.OPTION_IN_CODE; + int state= CRefactory.OPTION_IN_CODE_REFERENCES; switch (token.getType()) { case Token.tLINECOMMENT: case Token.tBLOCKCOMMENT: @@ -382,7 +377,7 @@ public class TextSearchWrapper { break; } if (state != lastState) { - locations.add(new int[] {token.getOffset(), state}); + locations.add(new int[] { token.getOffset(), state }); lastState= state; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java index 52b26bcd1db..67b81215a74 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java @@ -56,6 +56,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexFile; import org.eclipse.cdt.core.index.IIndexFileLocation; +import org.eclipse.cdt.core.index.IIndexManager; import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.index.IndexLocationFactory; import org.eclipse.cdt.core.model.CoreModel; @@ -487,7 +488,8 @@ public abstract class PDOMSearchQuery implements ISearchQuery { result.setIndexerBusy(!CCorePlugin.getIndexManager().isIndexerIdle()); try { - IIndex index= CCorePlugin.getIndexManager().getIndex(projects, 0); + IIndex index= CCorePlugin.getIndexManager().getIndex(projects, + IIndexManager.ADD_EXTENSION_FRAGMENTS); try { index.acquireReadLock(); } catch (InterruptedException e) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java index 4cd34574581..c86b8f11f33 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java @@ -71,7 +71,7 @@ public class PDOMSearchTextSelectionQuery extends PDOMSearchQuery { return Status.OK_STATUS; } } - binding = index.findBinding(searchName); + binding = ast.getIndex().findBinding(searchName); binding= CPPTemplates.findDeclarationForSpecialization(binding); if (binding != null) { label= labelForBinding(index, binding, label); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java index d32891c7e6b..b7662fd085c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java @@ -528,7 +528,7 @@ public final class CIndenter { StringBuilder reference= getLeadingWhitespace(offset); IRegion line= fDocument.getLineInformationOfOffset(offset); String string= fDocument.get(line.getOffset(), offset - line.getOffset()); - if (string.trim().length() == 0) + if (string.trim().isEmpty()) return reference; // Add additional indent return createReusingIndent(reference, fPrefs.prefContinuationIndent, 0); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java index e9122204de5..45193f3c1e8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java @@ -52,7 +52,7 @@ public class CDocHover extends AbstractCEditorTextHover { try { expression = viewer.getDocument().get(region.getOffset(), region.getLength()); expression = expression.trim(); - if (expression.length() == 0) + if (expression.isEmpty()) return null; StringBuilder buffer = new StringBuilder(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java index b5d4541ee4f..89adad07832 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java @@ -268,10 +268,18 @@ public class CSourceHover extends AbstractCEditorTextHover { LocationKind locationKind= LocationKind.LOCATION; if (name instanceof IASTName && !name.isReference()) { IASTName astName= (IASTName)name; - if (astName.getTranslationUnit().getFilePath().equals(fileName) && fTU.getResource() != null) { - // reuse editor buffer for names local to the translation unit - location= fTU.getResource().getFullPath(); - locationKind= LocationKind.IFILE; + if (astName.getTranslationUnit().getFilePath().equals(fileName)) { + int hoverOffset = fTextRegion.getOffset(); + if (hoverOffset <= nodeOffset && nodeOffset < hoverOffset + fTextRegion.getLength() || + hoverOffset >= nodeOffset && hoverOffset < nodeOffset + nodeLength) { + // bug 359352 - don't show source if its the same we are hovering on + return null; + } + if (fTU.getResource() != null) { + // reuse editor buffer for names local to the translation unit + location= fTU.getResource().getFullPath(); + locationKind= LocationKind.IFILE; + } } } else { // try to resolve path to a resource for proper encoding (bug 221029) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java index 4b0716532c1..89cab6fc9d2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java @@ -608,7 +608,7 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary { */ protected String getEncoding() { String encoding= SpellingPreferences.getSpellingUserDictionaryEncoding(); - if (encoding == null || encoding.length() == 0) + if (encoding == null || encoding.isEmpty()) encoding= ResourcesPlugin.getEncoding(); return encoding; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java index 46950694069..8aa74d620e6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -26,6 +26,7 @@ import org.eclipse.ui.progress.IWorkbenchSiteProgressService; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.index.IIndex; +import org.eclipse.cdt.core.index.IIndexManager; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; @@ -53,7 +54,7 @@ class THHierarchyModel { static final int END_OF_COMPUTATION = 0; private static final ISchedulingRule RULE = new THSchedulingRule(); - private static final Object[] NO_CHILDREN= new Object[0]; + private static final Object[] NO_CHILDREN= {}; private ICElement fInput; private int fHierarchyKind; @@ -148,7 +149,7 @@ class THHierarchyModel { THGraph graph= new THGraph(); try { ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects(); - IIndex index= CCorePlugin.getIndexManager().getIndex(scope); + IIndex index= CCorePlugin.getIndexManager().getIndex(scope, IIndexManager.ADD_EXTENSION_FRAGMENTS); index.acquireReadLock(); try { if (monitor.isCanceled()) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java index 9de3a40e54e..d833bea177d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java @@ -20,6 +20,8 @@ import java.util.List; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -203,6 +205,9 @@ public class NewClassCodeGenerator { new SubProgressMonitor(monitor, 50)); if (headerFile != null) { headerTU = (ITranslationUnit) CoreModel.getDefault().create(headerFile); + if (headerTU == null) { + throw new CodeGeneratorException("Failed to create " + headerFile); //$NON-NLS-1$ + } // Create a working copy with a new owner headerWorkingCopy = headerTU.getWorkingCopy(); @@ -246,6 +251,9 @@ public class NewClassCodeGenerator { new SubProgressMonitor(monitor, 50)); if (sourceFile != null) { sourceTU = (ITranslationUnit) CoreModel.getDefault().create(sourceFile); + if (sourceTU == null) { + throw new CodeGeneratorException("Failed to create " + sourceFile); //$NON-NLS-1$ + } monitor.worked(50); // Create a working copy with a new owner @@ -279,6 +287,9 @@ public class NewClassCodeGenerator { new SubProgressMonitor(monitor, 50)); if (testFile != null) { testTU = (ITranslationUnit) CoreModel.getDefault().create(testFile); + if (testTU == null) { + throw new CodeGeneratorException("Failed to create " + testFile); //$NON-NLS-1$ + } monitor.worked(50); // Create a working copy with a new owner @@ -300,6 +311,8 @@ public class NewClassCodeGenerator { fCreatedTestTU = testTU; } + } catch (CodeGeneratorException e) { + deleteAllCreatedFiles(); } finally { if (headerWorkingCopy != null) { headerWorkingCopy.destroy(); @@ -316,6 +329,19 @@ public class NewClassCodeGenerator { return fCreatedClass; } + private void deleteAllCreatedFiles() { + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + for (IPath path : new IPath[] { fHeaderPath, fSourcePath, fSourcePath }) { + if (path != null) { + try { + IFile file = root.getFile(path); + file.delete(true, null); + } catch (CoreException e) { + } + } + } + } + /** * Format given source content according to the project's code style options. * diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java index a479240e672..55f57d0c7f9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java @@ -10,10 +10,12 @@ * IBM Corporation * Markus Schorn (Wind River Systems) * Warren Paul (Nokia) - 174238 + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.ui.wizards.classwizard; import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; @@ -114,31 +116,55 @@ public class NewClassWizardUtil { } return null; } + + //XXX Remove +// /** +// * Returns the parent source folder for the given resource. If the given +// * resource is already a source folder, the corresponding C element is returned. +// * +// * @param resource the resource +// * @return the source folder +// */ +// public static ICContainer getSourceFolder(IResource resource) { +// if (resource != null && resource.exists()) { +// int resType = resource.getType(); +// if (resType == IResource.PROJECT || resType == IResource.FOLDER) { +// ICElement elem = CoreModel.getDefault().create(resource.getFullPath()); +// if (elem != null) { +// ICContainer sourceFolder = getSourceFolder(elem); +// if (sourceFolder != null) +// return sourceFolder; +// } +// } else { +// return getSourceFolder(resource.getParent()); +// } +// } +// return null; +// } /** - * Returns the parent source folder for the given resource. If the given - * resource is already a source folder, the corresponding C element is returned. + * Checks if a given resource is under a source root. * * @param resource the resource - * @return the source folder + * @return true if the resource is under one of the project source roots */ - public static ICContainer getSourceFolder(IResource resource) { - if (resource != null && resource.exists()) { - int resType = resource.getType(); - if (resType == IResource.PROJECT || resType == IResource.FOLDER) { - ICElement elem = CoreModel.getDefault().create(resource.getFullPath()); - if (elem != null) { - ICContainer sourceFolder = getSourceFolder(elem); - if (sourceFolder != null) - return sourceFolder; - } - } else { - return getSourceFolder(resource.getParent()); - } - } - return null; + public static boolean isOnSourceRoot(IResource resource) { + IProject project = resource.getProject(); + ICProject cProject = CoreModel.getDefault().create(project); + return cProject.isOnSourceRoot(resource); } - + + /** + * Checks if a given file path is under a source root. + * + * @param path the file path + * @return true if the resource is under one of the project source roots + */ + public static boolean isOnSourceRoot(IPath path) { + IFile file = getWorkspaceRoot().getFile(path); + return isOnSourceRoot(file); + } + /** * Returns the first source root in the given project. If the project has * no source roots as children, the project itself is returned. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java index ae4f03403c3..fa9f75cf41b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java @@ -1010,27 +1010,14 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } /** - * handles changes to the source folder field + * Handles changes to the source folder field */ private final class SourceFolderFieldAdapter implements IStringButtonAdapter, IDialogFieldListener { public void changeControlPressed(DialogField field) { IPath oldFolderPath = getSourceFolderFullPath(); IPath newFolderPath = chooseSourceFolder(oldFolderPath); if (newFolderPath != null) { - IPath headerPath = getHeaderFileFullPath(); - IPath sourcePath = getSourceFileFullPath(); setSourceFolderFullPath(newFolderPath, false); - if (oldFolderPath != null && oldFolderPath.matchingFirstSegments(newFolderPath) == 0) { - if (headerPath != null) { - headerPath = newFolderPath.append(headerPath.lastSegment()); - } - if (sourcePath != null) { - sourcePath = newFolderPath.append(sourcePath.lastSegment()); - } - } - // adjust the relative paths - setHeaderFileFullPath(headerPath, false); - setSourceFileFullPath(sourcePath, false); handleFieldChanged(SOURCE_FOLDER_ID|ALL_FIELDS); } } @@ -1541,7 +1528,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_NotInACProject); } - if (NewClassWizardUtil.getSourceFolder(res) == null) { + if (!NewClassWizardUtil.isOnSourceRoot(res)) { status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_NotASourceFolder, folderPath)); return status; } @@ -1787,7 +1774,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } // Make sure the file location is under a source root - if (NewClassWizardUtil.getSourceFolder(path) == null) { + if (!NewClassWizardUtil.isOnSourceRoot(path)) { status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_HeaderFileNotInSourceFolder); return status; } @@ -1867,7 +1854,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } // Make sure the file location is under a source root - if (NewClassWizardUtil.getSourceFolder(path) == null) { + if (!NewClassWizardUtil.isOnSourceRoot(path)) { status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_SourceFileNotInSourceFolder); return status; } @@ -1951,7 +1938,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } // Make sure the file location is under a source root - if (NewClassWizardUtil.getSourceFolder(path) == null) { + if (!NewClassWizardUtil.isOnSourceRoot(path)) { status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_TestFileNotInSourceFolder); return status; } @@ -2036,7 +2023,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { fDialogSettings.put(KEY_STUB_SELECTED + i, fMethodStubsDialogField.isChecked(stub)); } - fCreatedClass = null; + fCreatedClass = null; fCreatedHeaderFile = null; fCreatedSourceFile = null; fCreatedTestFile = null; @@ -2044,28 +2031,10 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { IPath headerPath = getHeaderFileFullPath(); IPath sourcePath = getSourceFileFullPath(); IPath testPath = getTestFileFullPath(); - createClass( - headerPath != null ? getCanonicalPath(headerPath) : null, - sourcePath != null ? getCanonicalPath(sourcePath) : null, - testPath != null ? getCanonicalPath(testPath) : null, - getClassName(), - namespace, - getBaseClasses(), - getSelectedMethodStubs(), monitor); + createClass(headerPath, sourcePath, testPath, getClassName(), namespace, getBaseClasses(), + getSelectedMethodStubs(), monitor); } - private IPath getCanonicalPath(IPath path) throws CoreException { - IWorkspaceRoot root = NewClassWizardUtil.getWorkspaceRoot(); - IFile file = root.getFile(path); - URI location = file.getLocationURI(); - URI canonicalLocation = EFS.getStore(location).toURI(); - IFile[] files = root.findFilesForLocationURI(canonicalLocation); - if (files.length > 0) { - return files[0].getFullPath(); - } - return null; - } - /** * Returns whether the generated header and source files should be * opened in editors after the finish button is pressed. diff --git a/cross/org.eclipse.cdt.build.crossgcc-feature/pom.xml b/cross/org.eclipse.cdt.build.crossgcc-feature/pom.xml index 0dbd208747f..4230c430b02 100644 --- a/cross/org.eclipse.cdt.build.crossgcc-feature/pom.xml +++ b/cross/org.eclipse.cdt.build.crossgcc-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/cross/org.eclipse.cdt.build.crossgcc/pom.xml b/cross/org.eclipse.cdt.build.crossgcc/pom.xml index 751c8d5df82..fe3017610c7 100644 --- a/cross/org.eclipse.cdt.build.crossgcc/pom.xml +++ b/cross/org.eclipse.cdt.build.crossgcc/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/cross/org.eclipse.cdt.launch.remote-feature/pom.xml b/cross/org.eclipse.cdt.launch.remote-feature/pom.xml index 3775e72dd3f..7ef4eb50002 100644 --- a/cross/org.eclipse.cdt.launch.remote-feature/pom.xml +++ b/cross/org.eclipse.cdt.launch.remote-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/cross/org.eclipse.cdt.launch.remote/pom.xml b/cross/org.eclipse.cdt.launch.remote/pom.xml index 4ef5706e25c..31a6ee27d5c 100644 --- a/cross/org.eclipse.cdt.launch.remote/pom.xml +++ b/cross/org.eclipse.cdt.launch.remote/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/debug/org.eclipse.cdt.debug.core/.classpath b/debug/org.eclipse.cdt.debug.core/.classpath index 34008fe5ddd..0bc86460ced 100644 --- a/debug/org.eclipse.cdt.debug.core/.classpath +++ b/debug/org.eclipse.cdt.debug.core/.classpath @@ -2,7 +2,7 @@ + - diff --git a/debug/org.eclipse.cdt.debug.core/.settings/org.eclipse.jdt.core.prefs b/debug/org.eclipse.cdt.debug.core/.settings/org.eclipse.jdt.core.prefs index 77e90efa5c1..d9c7656a8e6 100644 --- a/debug/org.eclipse.cdt.debug.core/.settings/org.eclipse.jdt.core.prefs +++ b/debug/org.eclipse.cdt.debug.core/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ -#Wed Apr 08 15:55:48 BST 2009 +#Mon Oct 17 17:40:49 PDT 2011 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -71,4 +71,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF b/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF index e6e7c34ce53..b2cab8ec7a4 100644 --- a/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF @@ -29,5 +29,5 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)", org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", org.eclipse.core.filesystem;bundle-version="1.2.0" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: com.ibm.icu.text diff --git a/debug/org.eclipse.cdt.debug.core/pom.xml b/debug/org.eclipse.cdt.debug.core/pom.xml index a509a43a7ac..f28d99517ab 100644 --- a/debug/org.eclipse.cdt.debug.core/pom.xml +++ b/debug/org.eclipse.cdt.debug.core/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java index 6788bcf51d3..5c90343ef9f 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java @@ -374,11 +374,11 @@ public class CDebugCorePlugin extends Plugin { fCommonSourceLookupDirector = new CommonSourceLookupDirector(); boolean convertingFromLegacyFormat = false; String newMemento = CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugInternalConstants.PREF_DEFAULT_SOURCE_CONTAINERS); - if (newMemento.length() == 0) { + if (newMemento.isEmpty()) { newMemento = CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugInternalConstants.PREF_COMMON_SOURCE_CONTAINERS); convertingFromLegacyFormat = true; } - if (newMemento.length() == 0) { + if (newMemento.isEmpty()) { // Add the participant(s). This happens as part of // initializeFromMemento(), but since we're not calling it, we // need to do this explicitly. See 299583. diff --git a/debug/org.eclipse.cdt.debug.mi.core/.classpath b/debug/org.eclipse.cdt.debug.mi.core/.classpath index e1c2c1cc11a..19ea88e4493 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/.classpath +++ b/debug/org.eclipse.cdt.debug.mi.core/.classpath @@ -4,6 +4,6 @@ - + diff --git a/debug/org.eclipse.cdt.debug.mi.core/.settings/org.eclipse.jdt.core.prefs b/debug/org.eclipse.cdt.debug.mi.core/.settings/org.eclipse.jdt.core.prefs index 5a81e602829..c0c9f276f9a 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/.settings/org.eclipse.jdt.core.prefs +++ b/debug/org.eclipse.cdt.debug.mi.core/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Wed Apr 08 15:56:28 BST 2009 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -71,4 +71,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/debug/org.eclipse.cdt.debug.mi.core/META-INF/MANIFEST.MF b/debug/org.eclipse.cdt.debug.mi.core/META-INF/MANIFEST.MF index 6607628edb9..a49bd04b688 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.cdt.debug.mi.core/META-INF/MANIFEST.MF @@ -18,7 +18,7 @@ Export-Package: org.eclipse.cdt.debug.mi.core, org.eclipse.cdt.debug.mi.core.command.factories.win32, org.eclipse.cdt.debug.mi.core.event, org.eclipse.cdt.debug.mi.core.output -Require-Bundle: org.eclipse.cdt.debug.core;bundle-version="[7.0.0,8.0.0)", +Require-Bundle: org.eclipse.cdt.debug.core;bundle-version="[7.0.0,8.1.0)", org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)", org.eclipse.debug.core;bundle-version="[3.2.0,4.0.0)", org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)", @@ -26,5 +26,5 @@ Require-Bundle: org.eclipse.cdt.debug.core;bundle-version="[7.0.0,8.0.0)", org.eclipse.core.variables;bundle-version="3.2.200", org.eclipse.cdt.gdb;bundle-version="7.0.0" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: com.ibm.icu.text diff --git a/debug/org.eclipse.cdt.debug.mi.core/pom.xml b/debug/org.eclipse.cdt.debug.mi.core/pom.xml index d5abf34fcd2..5eef53c1d55 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/pom.xml +++ b/debug/org.eclipse.cdt.debug.mi.core/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/debug/org.eclipse.cdt.debug.mi.ui/.classpath b/debug/org.eclipse.cdt.debug.mi.ui/.classpath index 472ee29b11e..deb673668e9 100644 --- a/debug/org.eclipse.cdt.debug.mi.ui/.classpath +++ b/debug/org.eclipse.cdt.debug.mi.ui/.classpath @@ -2,6 +2,6 @@ - + diff --git a/debug/org.eclipse.cdt.debug.mi.ui/.settings/org.eclipse.jdt.core.prefs b/debug/org.eclipse.cdt.debug.mi.ui/.settings/org.eclipse.jdt.core.prefs index 692e53d498c..0ddc67b3cfd 100644 --- a/debug/org.eclipse.cdt.debug.mi.ui/.settings/org.eclipse.jdt.core.prefs +++ b/debug/org.eclipse.cdt.debug.mi.ui/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Wed Apr 08 15:57:04 BST 2009 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -71,4 +71,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/debug/org.eclipse.cdt.debug.mi.ui/META-INF/MANIFEST.MF b/debug/org.eclipse.cdt.debug.mi.ui/META-INF/MANIFEST.MF index 1fd6aaa80a0..07a48c66a9d 100644 --- a/debug/org.eclipse.cdt.debug.mi.ui/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.cdt.debug.mi.ui/META-INF/MANIFEST.MF @@ -15,9 +15,9 @@ Export-Package: org.eclipse.cdt.debug.mi.internal.ui;x-internal:=true, org.eclipse.cdt.debug.mi.ui.console Require-Bundle: org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)", org.eclipse.ui;bundle-version="[3.2.0,4.0.0)", - org.eclipse.cdt.debug.mi.core;bundle-version="[7.0.0,8.0.0)", - org.eclipse.cdt.debug.ui;bundle-version="[7.0.0,8.0.0)", - org.eclipse.cdt.debug.core;bundle-version="[7.0.0,8.0.0)", + org.eclipse.cdt.debug.mi.core;bundle-version="[7.0.0,8.1.0)", + org.eclipse.cdt.debug.ui;bundle-version="[7.0.0,8.1.0)", + org.eclipse.cdt.debug.core;bundle-version="[7.0.0,8.1.0)", org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)", org.eclipse.cdt.ui;bundle-version="[5.0.0,6.0.0)", org.eclipse.debug.core;bundle-version="[3.2.0,4.0.0)", @@ -26,5 +26,5 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)", org.eclipse.ui.console;bundle-version="[3.1.100,4.0.0)", org.eclipse.jface.text;bundle-version="[3.2.0,4.0.0)" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: com.ibm.icu.text diff --git a/debug/org.eclipse.cdt.debug.mi.ui/pom.xml b/debug/org.eclipse.cdt.debug.mi.ui/pom.xml index d3f1029a5d1..2039d3348f0 100644 --- a/debug/org.eclipse.cdt.debug.mi.ui/pom.xml +++ b/debug/org.eclipse.cdt.debug.mi.ui/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/debug/org.eclipse.cdt.debug.ui.tests/.classpath b/debug/org.eclipse.cdt.debug.ui.tests/.classpath index feadaca04b3..80d71b380e9 100644 --- a/debug/org.eclipse.cdt.debug.ui.tests/.classpath +++ b/debug/org.eclipse.cdt.debug.ui.tests/.classpath @@ -3,6 +3,6 @@ - + diff --git a/debug/org.eclipse.cdt.debug.ui.tests/.settings/org.eclipse.jdt.core.prefs b/debug/org.eclipse.cdt.debug.ui.tests/.settings/org.eclipse.jdt.core.prefs index 62fe88292b5..64e27dfc148 100644 --- a/debug/org.eclipse.cdt.debug.ui.tests/.settings/org.eclipse.jdt.core.prefs +++ b/debug/org.eclipse.cdt.debug.ui.tests/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Mon Jan 28 09:57:10 CST 2008 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -54,4 +54,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=di org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/debug/org.eclipse.cdt.debug.ui.tests/META-INF/MANIFEST.MF b/debug/org.eclipse.cdt.debug.ui.tests/META-INF/MANIFEST.MF index 479706d6ec7..1c06610c369 100644 --- a/debug/org.eclipse.cdt.debug.ui.tests/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.cdt.debug.ui.tests/META-INF/MANIFEST.MF @@ -19,4 +19,4 @@ Require-Bundle: org.eclipse.ui.ide, Bundle-ActivationPolicy: lazy Plugin-Class: org.eclipse.cdt.debug.testplugin.CTestPlugin Bundle-Vendor: Eclipse CDT -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/debug/org.eclipse.cdt.debug.ui.tests/pom.xml b/debug/org.eclipse.cdt.debug.ui.tests/pom.xml index a364aebe8d1..edf54ddf4f3 100644 --- a/debug/org.eclipse.cdt.debug.ui.tests/pom.xml +++ b/debug/org.eclipse.cdt.debug.ui.tests/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/debug/org.eclipse.cdt.debug.ui/.classpath b/debug/org.eclipse.cdt.debug.ui/.classpath index 304e86186aa..121e527a938 100644 --- a/debug/org.eclipse.cdt.debug.ui/.classpath +++ b/debug/org.eclipse.cdt.debug.ui/.classpath @@ -1,7 +1,7 @@ - + diff --git a/debug/org.eclipse.cdt.debug.ui/.settings/org.eclipse.jdt.core.prefs b/debug/org.eclipse.cdt.debug.ui/.settings/org.eclipse.jdt.core.prefs index 9354fe0eea4..3b1dda80eae 100644 --- a/debug/org.eclipse.cdt.debug.ui/.settings/org.eclipse.jdt.core.prefs +++ b/debug/org.eclipse.cdt.debug.ui/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Wed Apr 08 15:57:22 BST 2009 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -71,4 +71,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF b/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF index f23fbe1a5df..e353bd2dc76 100644 --- a/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF @@ -46,7 +46,7 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)", org.eclipse.ui;bundle-version="[3.2.0,4.0.0)", org.eclipse.debug.ui;bundle-version="[3.7.0,4.0.0)", org.eclipse.debug.core;bundle-version="[3.7.0,4.0.0)", - org.eclipse.cdt.debug.core;bundle-version="[7.0.0,8.0.0)", + org.eclipse.cdt.debug.core;bundle-version="[7.0.0,8.1.0)", org.eclipse.cdt.ui;bundle-version="[5.0.0,6.0.0)", org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)", org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", @@ -55,5 +55,5 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)", org.eclipse.core.filesystem, org.eclipse.core.expressions Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: com.ibm.icu.text diff --git a/debug/org.eclipse.cdt.debug.ui/pom.xml b/debug/org.eclipse.cdt.debug.ui/pom.xml index 987dbda4231..3c06c6e8b8a 100644 --- a/debug/org.eclipse.cdt.debug.ui/pom.xml +++ b/debug/org.eclipse.cdt.debug.ui/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/debug/org.eclipse.cdt.gdb-feature/pom.xml b/debug/org.eclipse.cdt.gdb-feature/pom.xml index 37e0cb11ad3..1f35b48e557 100644 --- a/debug/org.eclipse.cdt.gdb-feature/pom.xml +++ b/debug/org.eclipse.cdt.gdb-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/debug/org.eclipse.cdt.gdb.source-feature/pom.xml b/debug/org.eclipse.cdt.gdb.source-feature/pom.xml index 20ba4cadd25..33cc55c1871 100644 --- a/debug/org.eclipse.cdt.gdb.source-feature/pom.xml +++ b/debug/org.eclipse.cdt.gdb.source-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/debug/org.eclipse.cdt.gdb.ui/.classpath b/debug/org.eclipse.cdt.gdb.ui/.classpath index 64c5e31b7a2..ad32c83a788 100644 --- a/debug/org.eclipse.cdt.gdb.ui/.classpath +++ b/debug/org.eclipse.cdt.gdb.ui/.classpath @@ -1,6 +1,6 @@ - + diff --git a/debug/org.eclipse.cdt.gdb.ui/.settings/org.eclipse.jdt.core.prefs b/debug/org.eclipse.cdt.gdb.ui/.settings/org.eclipse.jdt.core.prefs index 422cbddca57..1858b49d210 100644 --- a/debug/org.eclipse.cdt.gdb.ui/.settings/org.eclipse.jdt.core.prefs +++ b/debug/org.eclipse.cdt.gdb.ui/.settings/org.eclipse.jdt.core.prefs @@ -1,8 +1,8 @@ #Wed Apr 07 17:06:17 CDT 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/debug/org.eclipse.cdt.gdb.ui/META-INF/MANIFEST.MF b/debug/org.eclipse.cdt.gdb.ui/META-INF/MANIFEST.MF index 1b0067fcf9c..eccc85bfba2 100644 --- a/debug/org.eclipse.cdt.gdb.ui/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.cdt.gdb.ui/META-INF/MANIFEST.MF @@ -8,7 +8,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.6.0", org.eclipse.ui;bundle-version="3.6.0", org.eclipse.cdt.debug.ui;bundle-version="7.0.0" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.cdt.gdb.ui.internal;x-internal:=true diff --git a/debug/org.eclipse.cdt.gdb.ui/pom.xml b/debug/org.eclipse.cdt.gdb.ui/pom.xml index 3b672b8e21a..1ec979ed491 100644 --- a/debug/org.eclipse.cdt.gdb.ui/pom.xml +++ b/debug/org.eclipse.cdt.gdb.ui/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/debug/org.eclipse.cdt.gdb/.classpath b/debug/org.eclipse.cdt.gdb/.classpath index 64c5e31b7a2..ad32c83a788 100644 --- a/debug/org.eclipse.cdt.gdb/.classpath +++ b/debug/org.eclipse.cdt.gdb/.classpath @@ -1,6 +1,6 @@ - + diff --git a/debug/org.eclipse.cdt.gdb/.settings/org.eclipse.jdt.core.prefs b/debug/org.eclipse.cdt.gdb/.settings/org.eclipse.jdt.core.prefs index c6c3502d2ee..be72fa06839 100644 --- a/debug/org.eclipse.cdt.gdb/.settings/org.eclipse.jdt.core.prefs +++ b/debug/org.eclipse.cdt.gdb/.settings/org.eclipse.jdt.core.prefs @@ -1,8 +1,8 @@ #Fri Jun 18 10:57:31 CDT 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore @@ -70,4 +70,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/debug/org.eclipse.cdt.gdb/META-INF/MANIFEST.MF b/debug/org.eclipse.cdt.gdb/META-INF/MANIFEST.MF index 24a2b4ec630..4b4abc32eff 100644 --- a/debug/org.eclipse.cdt.gdb/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.cdt.gdb/META-INF/MANIFEST.MF @@ -6,7 +6,7 @@ Bundle-Version: 7.0.0.qualifier Bundle-Activator: org.eclipse.cdt.gdb.internal.Activator Require-Bundle: org.eclipse.core.runtime;bundle-version="3.6.0" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.cdt.gdb.eventbkpts, diff --git a/debug/org.eclipse.cdt.gdb/pom.xml b/debug/org.eclipse.cdt.gdb/pom.xml index a78e30c92ed..ed1c94dd996 100644 --- a/debug/org.eclipse.cdt.gdb/pom.xml +++ b/debug/org.eclipse.cdt.gdb/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/debug/org.eclipse.cdt.gnu.debug-feature/pom.xml b/debug/org.eclipse.cdt.gnu.debug-feature/pom.xml index 75d1005c392..370a8637d70 100644 --- a/debug/org.eclipse.cdt.gnu.debug-feature/pom.xml +++ b/debug/org.eclipse.cdt.gnu.debug-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/debug/org.eclipse.cdt.gnu.debug.source-feature/pom.xml b/debug/org.eclipse.cdt.gnu.debug.source-feature/pom.xml index 43f7cc7e261..74eb61f018a 100644 --- a/debug/org.eclipse.cdt.gnu.debug.source-feature/pom.xml +++ b/debug/org.eclipse.cdt.gnu.debug.source-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/doc/org.eclipse.cdt.doc.isv/pom.xml b/doc/org.eclipse.cdt.doc.isv/pom.xml index e5058f6e8c6..3de5e81be71 100644 --- a/doc/org.eclipse.cdt.doc.isv/pom.xml +++ b/doc/org.eclipse.cdt.doc.isv/pom.xml @@ -6,7 +6,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/doc/org.eclipse.cdt.doc.user/pom.xml b/doc/org.eclipse.cdt.doc.user/pom.xml index 94a9d1369f5..bdf0f4354bc 100644 --- a/doc/org.eclipse.cdt.doc.user/pom.xml +++ b/doc/org.eclipse.cdt.doc.user/pom.xml @@ -6,7 +6,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/.classpath b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/.classpath index 304e86186aa..121e527a938 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/.classpath +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/.classpath @@ -1,7 +1,7 @@ - + diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/.settings/org.eclipse.jdt.core.prefs b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/.settings/org.eclipse.jdt.core.prefs index e2b74ae779a..cee06929381 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/.settings/org.eclipse.jdt.core.prefs +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Tue Jun 24 11:04:56 PDT 2008 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -67,4 +67,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF index ec4f8c32b5d..d4e6cc44ddc 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF @@ -25,7 +25,7 @@ Require-Bundle: org.eclipse.ui, org.eclipse.core.filesystem;bundle-version="1.2.0", org.eclipse.cdt.launch;bundle-version="6.1.0" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Export-Package: org.eclipse.cdt.dsf.gdb.internal.ui;x-internal:=true, org.eclipse.cdt.dsf.gdb.internal.ui.actions;x-internal:=true, org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints;x-internal:=true, diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/pom.xml b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/pom.xml index e21b2378937..f629211b892 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/pom.xml +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/.classpath b/dsf-gdb/org.eclipse.cdt.dsf.gdb/.classpath index 304e86186aa..121e527a938 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/.classpath +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/.classpath @@ -1,7 +1,7 @@ - + diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/.settings/org.eclipse.jdt.core.prefs b/dsf-gdb/org.eclipse.cdt.dsf.gdb/.settings/org.eclipse.jdt.core.prefs index acad5c5fe98..669b0a3caf2 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/.settings/org.eclipse.jdt.core.prefs +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Tue Jun 24 11:04:03 PDT 2008 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -67,4 +67,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF b/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF index 0b29b49d1bb..194a1f188b0 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF @@ -15,7 +15,7 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.cdt.launch;bundle-version="6.1.0", org.eclipse.cdt.gdb;bundle-version="7.0.0" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Export-Package: org.eclipse.cdt.dsf.gdb, org.eclipse.cdt.dsf.gdb.actions, org.eclipse.cdt.dsf.gdb.breakpoints, diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/pom.xml b/dsf-gdb/org.eclipse.cdt.dsf.gdb/pom.xml index 41bde8047f0..021b7e0b196 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/pom.xml +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java index 54b74473a74..9805cecc1bc 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java @@ -414,7 +414,17 @@ public class FinalLaunchSequence extends ReflectionSequence { // Even if binary is null, we must call this to do all the other steps // necessary to create a process. It is possible that the binary is not needed fProcService.debugNewProcess(fCommandControl.getContext(), binary, fAttributes, - new DataRequestMonitor(getExecutor(), rm)); + new DataRequestMonitor(getExecutor(), rm) { + @Override + protected void handleCancel() { + // If this step is cancelled, cancel the current sequence. + // This is to allow the user to press the cancel button + // when prompted for a post-mortem file. + // Bug 362105 + rm.cancel(); + rm.done(); + } + }); } else { rm.done(); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointsManager.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointsManager.java index 029478e7efd..137862e1d12 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointsManager.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointsManager.java @@ -1447,26 +1447,55 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo */ private void clearBreakpointStatus(final ICBreakpoint[] bps, final IBreakpointsTargetDMContext ctx) { + IWorkspaceRunnable wr = new IWorkspaceRunnable() { + public void run(IProgressMonitor monitor) throws CoreException { + // For every platform breakpoint that has at least one target breakpoint installed + // we must decrement the install count, for every target breakpoint. + // Note that we cannot simply call resetInstallCount() because another + // launch may be using the same platform breakpoint. + Map> breakpoints = fBreakpointIDs.get(ctx); + for (ICBreakpoint breakpoint : breakpoints.keySet()) { + Vector targetBps = breakpoints.get(breakpoint); + for (IBreakpointDMContext targetBp : targetBps) { + decrementInstallCount(targetBp, breakpoint, new RequestMonitor(getExecutor(), null)); + } + } + } + }; + + // Create the scheduling rule to clear all bp planted. + ISchedulingRule rule = null; + List markerRules = new ArrayList(); + for (ICBreakpoint bp : bps) { + IMarker marker = bp.getMarker(); + if (marker != null) { + ISchedulingRule markerRule = + ResourcesPlugin.getWorkspace().getRuleFactory().markerRule( + marker.getResource()); + if (markerRule == null) { + markerRules = null; + break; + } else { + markerRules.add(markerRule); + } + } + } + if (markerRules != null) { + rule = MultiRule.combine(markerRules.toArray(new ISchedulingRule[markerRules.size()])); + } + + try { + // Will run the workspace runnable on the current thread, which + // is the DSF executor. + ResourcesPlugin.getWorkspace().run(wr, rule, 0, null); + } catch (CoreException e) { + GdbPlugin.getDefault().getLog().log(e.getStatus()); + } + new Job("Clear Breakpoints Status") { //$NON-NLS-1$ @Override protected IStatus run(IProgressMonitor monitor) { - IWorkspaceRunnable wr = new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - // For every platform breakpoint that has at least one target breakpoint installed - // we must decrement the install count, for every target breakpoint. - // Note that we cannot simply call resetInstallCount() because another - // launch may be using the same platform breakpoint. - Map> breakpoints = fBreakpointIDs.get(ctx); - for (ICBreakpoint breakpoint : breakpoints.keySet()) { - Vector targetBps = breakpoints.get(breakpoint); - for (IBreakpointDMContext targetBp : targetBps) { - decrementInstallCount(targetBp, breakpoint, new RequestMonitor(getExecutor(), null)); - } - } - } - }; - - // First clear any problem markers + // Clear any problem markers for (IMarker marker : fBreakpointMarkerProblems.values()) { if (marker != null) { try { @@ -1477,32 +1506,6 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo } fBreakpointMarkerProblems.clear(); - // Create the scheduling rule to clear all bp planted. - ISchedulingRule rule = null; - List markerRules = new ArrayList(); - for (ICBreakpoint bp : bps) { - IMarker marker = bp.getMarker(); - if (marker != null) { - ISchedulingRule markerRule = - ResourcesPlugin.getWorkspace().getRuleFactory().markerRule( - marker.getResource()); - if (markerRule == null) { - markerRules = null; - break; - } else { - markerRules.add(markerRule); - } - } - } - if (markerRules != null) { - rule = MultiRule.combine(markerRules.toArray(new ISchedulingRule[markerRules.size()])); - } - - try { - ResourcesPlugin.getWorkspace().run(wr, rule, 0, null); - } catch (CoreException e) { - return e.getStatus(); - } return Status.OK_STATUS; } }.schedule(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIDataReadMemory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIDataReadMemory.java index fd243eb7a7e..ef3d6b29c4d 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIDataReadMemory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIDataReadMemory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009, 2007 QNX Software Systems and others. + * Copyright (c) 2000, 2011 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,6 +8,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation * Ericsson AB - Modified for new DSF Reference Implementation + * John Dallaway - Accept word size bigger than 1 (Bug 341762) *******************************************************************************/ package org.eclipse.cdt.dsf.mi.service.command.commands; @@ -74,7 +75,7 @@ public class MIDataReadMemory extends MICommand { fword_size = word_size; if (offset != 0) { - setOptions(new String[] { "-o", Long.toString(offset * word_size)}); //$NON-NLS-1$ + setOptions(new String[] { "-o", Long.toString(offset)}); //$NON-NLS-1$ } String format = "x"; //$NON-NLS-1$ @@ -128,17 +129,17 @@ public class MIDataReadMemory extends MICommand { new String[] { address, format, - Integer.toString(1), // wordSize + Integer.toString(word_size), Integer.toString(rows), - Integer.toString(cols * word_size)}); + Integer.toString(cols)}); } else { setParameters( new String[] { address, format, - Integer.toString(1), // wordSize + Integer.toString(word_size), Integer.toString(rows), - Integer.toString(cols * word_size), + Integer.toString(cols), asChar.toString()}); } } diff --git a/dsf-gdb/org.eclipse.cdt.gnu.dsf-feature/pom.xml b/dsf-gdb/org.eclipse.cdt.gnu.dsf-feature/pom.xml index 15429734414..c57bf72ecfa 100644 --- a/dsf-gdb/org.eclipse.cdt.gnu.dsf-feature/pom.xml +++ b/dsf-gdb/org.eclipse.cdt.gnu.dsf-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/dsf-gdb/org.eclipse.cdt.gnu.dsf.source-feature/pom.xml b/dsf-gdb/org.eclipse.cdt.gnu.dsf.source-feature/pom.xml index e2800dc1574..ed03623de65 100644 --- a/dsf-gdb/org.eclipse.cdt.gnu.dsf.source-feature/pom.xml +++ b/dsf-gdb/org.eclipse.cdt.gnu.dsf.source-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/.classpath b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/.classpath index 304e86186aa..121e527a938 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/.classpath +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/.classpath @@ -1,7 +1,7 @@ - + diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/.settings/org.eclipse.jdt.core.prefs b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/.settings/org.eclipse.jdt.core.prefs index 0c2002c43d4..b3b697db6e8 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/.settings/org.eclipse.jdt.core.prefs +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Tue Jun 24 11:05:41 PDT 2008 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -67,4 +67,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/META-INF/MANIFEST.MF b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/META-INF/MANIFEST.MF index dff569e9337..af079ed2d4f 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/META-INF/MANIFEST.MF +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/META-INF/MANIFEST.MF @@ -14,7 +14,7 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.cdt.launch;bundle-version="6.1.0", org.eclipse.cdt.gdb;bundle-version="7.0.0" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ClassPath: . Fragment-Host: org.eclipse.cdt.dsf.gdb diff --git a/dsf/org.eclipse.cdt.dsf.ui/.classpath b/dsf/org.eclipse.cdt.dsf.ui/.classpath index 304e86186aa..121e527a938 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/.classpath +++ b/dsf/org.eclipse.cdt.dsf.ui/.classpath @@ -1,7 +1,7 @@ - + diff --git a/dsf/org.eclipse.cdt.dsf.ui/.settings/org.eclipse.jdt.core.prefs b/dsf/org.eclipse.cdt.dsf.ui/.settings/org.eclipse.jdt.core.prefs index 5d20faf6545..8c2eaf0dfcc 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/.settings/org.eclipse.jdt.core.prefs +++ b/dsf/org.eclipse.cdt.dsf.ui/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Mon Jun 23 15:02:26 CEST 2008 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -67,4 +67,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/dsf/org.eclipse.cdt.dsf.ui/META-INF/MANIFEST.MF b/dsf/org.eclipse.cdt.dsf.ui/META-INF/MANIFEST.MF index 475ee1b4591..0c22d13ecf0 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/META-INF/MANIFEST.MF +++ b/dsf/org.eclipse.cdt.dsf.ui/META-INF/MANIFEST.MF @@ -76,5 +76,5 @@ Export-Package: org.eclipse.cdt.dsf.debug.internal.ui;x-internal:=true, org.eclipse.cdt.examples.dsf.pda.ui, org.eclipse.cdt.debug.edc.ui", org.eclipse.cdt.dsf.ui.viewmodel.update;x-friends:="org.eclipse.cdt.dsf.gdb.ui,org.eclipse.cdt.examples.dsf,org.eclipse.cdt.examples.dsf.pda.ui" -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: com.ibm.icu.text diff --git a/dsf/org.eclipse.cdt.dsf.ui/pom.xml b/dsf/org.eclipse.cdt.dsf.ui/pom.xml index 8017e50e961..e76938fc888 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/pom.xml +++ b/dsf/org.eclipse.cdt.dsf.ui/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/SteppingController.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/SteppingController.java index d6721dabc02..f49e29cde77 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/SteppingController.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/SteppingController.java @@ -13,6 +13,7 @@ package org.eclipse.cdt.dsf.debug.ui.viewmodel; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -117,6 +118,28 @@ public final class SteppingController { } } + private class TimeOutRunnable extends DsfRunnable{ + + TimeOutRunnable(IExecutionDMContext dmc) { + fDmc = dmc; + } + + private final IExecutionDMContext fDmc; + + public void run() { + fTimedOutFutures.remove(fDmc); + + if (getSession().isActive()) { + fTimedOutFlags.put(fDmc, Boolean.TRUE); + enableStepping(fDmc); + // Issue the stepping time-out event. + getSession().dispatchEvent( + new SteppingTimedOutEvent(fDmc), + null); + } + } + } + private final DsfSession fSession; private final DsfServicesTracker fServicesTracker; @@ -406,6 +429,16 @@ public final class SteppingController { updateLastStepTime(execCtx); getRunControl().step(execCtx, stepType, new RequestMonitor(getExecutor(), null) { + @Override + protected void handleSuccess() { + fTimedOutFlags.remove(execCtx); + ScheduledFuture currentTimeOutFuture = fTimedOutFutures.get(execCtx); + if (currentTimeOutFuture != null) { + currentTimeOutFuture.cancel(false); + } + fTimedOutFutures.put(execCtx, getExecutor().schedule(new TimeOutRunnable(execCtx), fStepTimeout, TimeUnit.MILLISECONDS)); + } + @Override protected void handleFailure() { // in case of a failed step - enable stepping again (bug 265267) @@ -577,15 +610,40 @@ public final class SteppingController { @DsfServiceEventHandler public void eventDispatched(final ISuspendedDMEvent e) { // Take care of the stepping time out + boolean timedOut = false; IExecutionDMContext dmc = e.getDMContext(); - boolean timedout = fTimedOutFlags.remove(dmc) == Boolean.TRUE; - ScheduledFuture future = fTimedOutFutures.remove(dmc); - if (future != null) future.cancel(false); + for (Iterator> itr = fTimedOutFlags.entrySet().iterator(); itr.hasNext();) { + Map.Entry entry = itr.next(); + IExecutionDMContext nextDmc = entry.getKey(); + if (nextDmc.equals(dmc) || DMContexts.isAncestorOf(nextDmc, dmc)) { + if (entry.getValue()) { + // after step timeout do not process queued steps + fStepQueues.remove(dmc); + timedOut = true; + } + itr.remove(); + } + } - if (timedout || e.getReason() != StateChangeReason.STEP) { - // after step timeout or any other suspend reason do not process queued steps + // Cancel all time-out futures related to the event context. I.e. + // - If event is on a container, all child threads are suspended and + // should not issue a stepping time-out event. + // - If event is on a thread, and resumed event was on a container then + // stepping timeout for container should be canceled as it would affect + // suspended thread. + for (Iterator>> itr = fTimedOutFutures.entrySet().iterator(); itr.hasNext();) { + Map.Entry> entry = itr.next(); + IExecutionDMContext nextDmc = entry.getKey(); + if (nextDmc.equals(dmc) || DMContexts.isAncestorOf(nextDmc, dmc) || DMContexts.isAncestorOf(dmc, nextDmc)) { + entry.getValue().cancel(false); + itr.remove(); + } + } + + if (e.getReason() != StateChangeReason.STEP) { + // after any non-step suspend reason do not process queued steps for given context fStepQueues.remove(dmc); - } else { + } else if (!timedOut){ // Check if there's a step pending, if so execute it processStepQueue(dmc); } @@ -595,29 +653,22 @@ public final class SteppingController { public void eventDispatched(final IResumedDMEvent e) { if (e.getReason().equals(StateChangeReason.STEP)) { final IExecutionDMContext dmc = e.getDMContext(); - fTimedOutFlags.put(dmc, Boolean.FALSE); - // We shouldn't have a stepping timeout running unless we get two - // stepping events in a row without a suspended, which would be a - // protocol error. - assert !fTimedOutFutures.containsKey(dmc); - fTimedOutFutures.put( - dmc, - getExecutor().schedule( - new DsfRunnable() { public void run() { - fTimedOutFutures.remove(dmc); - - if (getSession().isActive()) { - fTimedOutFlags.put(dmc, Boolean.TRUE); - enableStepping(dmc); - // Issue the stepping time-out event. - getSession().dispatchEvent( - new SteppingTimedOutEvent(dmc), - null); - } - }}, - fStepTimeout, TimeUnit.MILLISECONDS) - ); + fTimedOutFlags.remove(dmc); + + // Find any time-out futures for contexts that are children of the + // resumed context, and cancel them as they'll be replaced. + if (!fTimedOutFutures.containsKey(dmc)) { + for (Iterator>> itr = fTimedOutFutures.entrySet().iterator(); itr.hasNext();) { + Map.Entry> entry = itr.next(); + if (DMContexts.isAncestorOf(entry.getKey(), dmc)) { + entry.getValue().cancel(false); + itr.remove(); + } + } + + fTimedOutFutures.put(dmc, getExecutor().schedule(new TimeOutRunnable(dmc), fStepTimeout, TimeUnit.MILLISECONDS)); + } } } -} +} \ No newline at end of file diff --git a/dsf/org.eclipse.cdt.dsf/.classpath b/dsf/org.eclipse.cdt.dsf/.classpath index 304e86186aa..121e527a938 100644 --- a/dsf/org.eclipse.cdt.dsf/.classpath +++ b/dsf/org.eclipse.cdt.dsf/.classpath @@ -1,7 +1,7 @@ - + diff --git a/dsf/org.eclipse.cdt.dsf/.settings/org.eclipse.jdt.core.prefs b/dsf/org.eclipse.cdt.dsf/.settings/org.eclipse.jdt.core.prefs index 5ca4ed2212c..7bf5071c758 100644 --- a/dsf/org.eclipse.cdt.dsf/.settings/org.eclipse.jdt.core.prefs +++ b/dsf/org.eclipse.cdt.dsf/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Tue Jun 24 11:02:22 PDT 2008 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -67,4 +67,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/dsf/org.eclipse.cdt.dsf/META-INF/MANIFEST.MF b/dsf/org.eclipse.cdt.dsf/META-INF/MANIFEST.MF index 6710e232d69..3baade410e9 100644 --- a/dsf/org.eclipse.cdt.dsf/META-INF/MANIFEST.MF +++ b/dsf/org.eclipse.cdt.dsf/META-INF/MANIFEST.MF @@ -21,4 +21,4 @@ Export-Package: org.eclipse.cdt.dsf.concurrent, org.eclipse.cdt.dsf.debug.sourcelookup, org.eclipse.cdt.dsf.internal;x-friends:="org.eclipse.cdt.dsf.ui,org.eclipse.cdt.tests.dsf.gdb", org.eclipse.cdt.dsf.service -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/dsf/org.eclipse.cdt.dsf/pom.xml b/dsf/org.eclipse.cdt.dsf/pom.xml index 891b6e5943b..4e14986b49c 100644 --- a/dsf/org.eclipse.cdt.dsf/pom.xml +++ b/dsf/org.eclipse.cdt.dsf/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/dsf/org.eclipse.cdt.examples.dsf-feature/pom.xml b/dsf/org.eclipse.cdt.examples.dsf-feature/pom.xml index dd728c9dbb3..4a4415f3445 100644 --- a/dsf/org.eclipse.cdt.examples.dsf-feature/pom.xml +++ b/dsf/org.eclipse.cdt.examples.dsf-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/pom.xml b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/pom.xml index 3b42aeeb5df..1cc9a3073a7 100644 --- a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/pom.xml +++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda/pom.xml b/dsf/org.eclipse.cdt.examples.dsf.pda/pom.xml index cf7141e1b8d..0a7c200dc56 100644 --- a/dsf/org.eclipse.cdt.examples.dsf.pda/pom.xml +++ b/dsf/org.eclipse.cdt.examples.dsf.pda/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/dsf/org.eclipse.cdt.examples.dsf/pom.xml b/dsf/org.eclipse.cdt.examples.dsf/pom.xml index beeed83f34d..5b68c70079b 100644 --- a/dsf/org.eclipse.cdt.examples.dsf/pom.xml +++ b/dsf/org.eclipse.cdt.examples.dsf/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag-feature/pom.xml b/jtag/org.eclipse.cdt.debug.gdbjtag-feature/pom.xml index a4455f31a81..4038b20cf27 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag-feature/pom.xml +++ b/jtag/org.eclipse.cdt.debug.gdbjtag-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/.classpath b/jtag/org.eclipse.cdt.debug.gdbjtag.core/.classpath index 304e86186aa..ad32c83a788 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/.classpath +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/.classpath @@ -1,7 +1,7 @@ - - + + diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/.settings/org.eclipse.jdt.core.prefs b/jtag/org.eclipse.cdt.debug.gdbjtag.core/.settings/org.eclipse.jdt.core.prefs index d64545053f2..ae1bb6c35e7 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/.settings/org.eclipse.jdt.core.prefs +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/.settings/org.eclipse.jdt.core.prefs @@ -1,6 +1,10 @@ -#Thu May 06 16:30:01 CDT 2010 +#Wed Oct 19 19:35:32 PDT 2011 eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=error +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore org.eclipse.jdt.core.compiler.problem.comparingIdentical=error org.eclipse.jdt.core.compiler.problem.deadCode=error @@ -9,6 +13,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=error org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore @@ -65,3 +70,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error org.eclipse.jdt.core.compiler.problem.unusedWarningToken=error org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/META-INF/MANIFEST.MF b/jtag/org.eclipse.cdt.debug.gdbjtag.core/META-INF/MANIFEST.MF index b86b92d669c..3881195facc 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/META-INF/MANIFEST.MF +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/META-INF/MANIFEST.MF @@ -18,4 +18,4 @@ Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.cdt.debug.gdbjtag.core, org.eclipse.cdt.debug.gdbjtag.core.jtagdevice Bundle-Vendor: %providerName -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/pom.xml b/jtag/org.eclipse.cdt.debug.gdbjtag.core/pom.xml index b7d87308cf6..2fd24720602 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/pom.xml +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/.classpath b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/.classpath index 304e86186aa..ad32c83a788 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/.classpath +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/.classpath @@ -1,7 +1,7 @@ - - + + diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/.settings/org.eclipse.jdt.core.prefs b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/.settings/org.eclipse.jdt.core.prefs index 73f3e47774b..83ed6d2e2aa 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/.settings/org.eclipse.jdt.core.prefs +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/.settings/org.eclipse.jdt.core.prefs @@ -1,6 +1,10 @@ -#Thu May 06 16:31:44 CDT 2010 +#Wed Oct 19 19:35:45 PDT 2011 eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=error +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore org.eclipse.jdt.core.compiler.problem.comparingIdentical=error org.eclipse.jdt.core.compiler.problem.deadCode=error @@ -9,6 +13,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=error org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore @@ -65,3 +70,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error org.eclipse.jdt.core.compiler.problem.unusedWarningToken=error org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/META-INF/MANIFEST.MF b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/META-INF/MANIFEST.MF index 5d75efd6611..71d29637870 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/META-INF/MANIFEST.MF +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/META-INF/MANIFEST.MF @@ -20,4 +20,4 @@ Bundle-ActivationPolicy: lazy Bundle-Vendor: %providerName Export-Package: org.eclipse.cdt.debug.gdbjtag.internal.ui;x-internal:=true, org.eclipse.cdt.debug.gdbjtag.ui -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/pom.xml b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/pom.xml index 5f5142ebdb1..767db59e4ec 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.ui/pom.xml +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.ui/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag/pom.xml b/jtag/org.eclipse.cdt.debug.gdbjtag/pom.xml index 52107cb1621..2c2d3935a6a 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag/pom.xml +++ b/jtag/org.eclipse.cdt.debug.gdbjtag/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/launch/org.eclipse.cdt.launch/.classpath b/launch/org.eclipse.cdt.launch/.classpath index 472ee29b11e..deb673668e9 100644 --- a/launch/org.eclipse.cdt.launch/.classpath +++ b/launch/org.eclipse.cdt.launch/.classpath @@ -2,6 +2,6 @@ - + diff --git a/launch/org.eclipse.cdt.launch/.settings/org.eclipse.jdt.core.prefs b/launch/org.eclipse.cdt.launch/.settings/org.eclipse.jdt.core.prefs index 919e260344d..225f2028807 100644 --- a/launch/org.eclipse.cdt.launch/.settings/org.eclipse.jdt.core.prefs +++ b/launch/org.eclipse.cdt.launch/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ #Wed Apr 22 09:54:58 EDT 2009 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -71,4 +71,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/launch/org.eclipse.cdt.launch/META-INF/MANIFEST.MF b/launch/org.eclipse.cdt.launch/META-INF/MANIFEST.MF index 375119f883e..f8298e26ce6 100644 --- a/launch/org.eclipse.cdt.launch/META-INF/MANIFEST.MF +++ b/launch/org.eclipse.cdt.launch/META-INF/MANIFEST.MF @@ -19,11 +19,11 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)", org.eclipse.ui;bundle-version="[3.2.0,4.0.0)", org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)", org.eclipse.cdt.ui;bundle-version="[5.0.0,6.0.0)", - org.eclipse.cdt.debug.core;bundle-version="[7.0.0,8.0.0)", - org.eclipse.cdt.debug.ui;bundle-version="[7.0.0,8.0.0)", + org.eclipse.cdt.debug.core;bundle-version="[7.0.0,8.1.0)", + org.eclipse.cdt.debug.ui;bundle-version="[7.0.0,8.1.0)", org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)", org.eclipse.ltk.core.refactoring;bundle-version="[3.5.0,4.0.0)" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: com.ibm.icu.text diff --git a/launch/org.eclipse.cdt.launch/pom.xml b/launch/org.eclipse.cdt.launch/pom.xml index efb34217d1f..513efe9ff97 100644 --- a/launch/org.eclipse.cdt.launch/pom.xml +++ b/launch/org.eclipse.cdt.launch/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/lrparser/org.eclipse.cdt.core.lrparser.feature/pom.xml b/lrparser/org.eclipse.cdt.core.lrparser.feature/pom.xml index 8b21a0af49b..975b5862d03 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser.feature/pom.xml +++ b/lrparser/org.eclipse.cdt.core.lrparser.feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/lrparser/org.eclipse.cdt.core.lrparser.sdk.feature/pom.xml b/lrparser/org.eclipse.cdt.core.lrparser.sdk.feature/pom.xml index 43fe2313723..5842f68e186 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser.sdk.feature/pom.xml +++ b/lrparser/org.eclipse.cdt.core.lrparser.sdk.feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/lrparser/org.eclipse.cdt.core.lrparser.source.feature/pom.xml b/lrparser/org.eclipse.cdt.core.lrparser.source.feature/pom.xml index e70437ff8d7..727233a8b71 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser.source.feature/pom.xml +++ b/lrparser/org.eclipse.cdt.core.lrparser.source.feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/pom.xml b/lrparser/org.eclipse.cdt.core.lrparser.tests/pom.xml index 9759f143da6..58f5977ee8b 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/pom.xml +++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Scope.java b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Scope.java index 58251314dd2..9e7b7933f7f 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Scope.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Scope.java @@ -92,6 +92,9 @@ public class C99Scope implements IC99Scope, IASTInternalScope { public void populateCache() { } + public void removeNestedFromCache(IASTNode container) { + } + public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet acceptLocalBindings) { // TODO Auto-generated method stub diff --git a/lrparser/org.eclipse.cdt.core.lrparser/pom.xml b/lrparser/org.eclipse.cdt.core.lrparser/pom.xml index cfcfdf759d2..b58c61069ef 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/pom.xml +++ b/lrparser/org.eclipse.cdt.core.lrparser/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/memory/org.eclipse.cdt.debug.ui.memory-feature/pom.xml b/memory/org.eclipse.cdt.debug.ui.memory-feature/pom.xml index a762d34f0dc..e40322353b2 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory-feature/pom.xml +++ b/memory/org.eclipse.cdt.debug.ui.memory-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/META-INF/MANIFEST.MF b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/META-INF/MANIFEST.MF index bd81ea84c96..df1664041ff 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/META-INF/MANIFEST.MF +++ b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/META-INF/MANIFEST.MF @@ -14,4 +14,5 @@ Require-Bundle: org.eclipse.ui, org.eclipse.cdt.debug.ui;bundle-version="7.0.0" Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-ActivationPolicy: lazy -Export-Package: org.eclipse.cdt.debug.ui.memory.memorybrowser +Export-Package: org.eclipse.cdt.debug.ui.memory.memorybrowser, + org.eclipse.cdt.debug.ui.memory.memorybrowser.api diff --git a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/pom.xml b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/pom.xml index 19481f88b04..8d23afc496d 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/pom.xml +++ b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/GoToAddressBarWidget.java b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/GoToAddressBarWidget.java index 5238a57dce2..c68096d8fa7 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/GoToAddressBarWidget.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/GoToAddressBarWidget.java @@ -62,7 +62,6 @@ public class GoToAddressBarWidget { private Button fOKButton; private Button fOKNewTabButton; private Composite fComposite; - private Object fCurrentDebugContext; protected static int ID_GO_NEW_TAB = 2000; @@ -268,22 +267,20 @@ public class GoToAddressBarWidget { */ public void loadSavedExpressions(Object context, String memorySpace) { - if ( context != null && ! context.equals( fCurrentDebugContext ) ) { - try { - String[] expressions = getSavedExpressions(context, memorySpace); - String currentExpression = fExpression.getText(); - fExpression.removeAll(); - for (String expression : expressions) { - fExpression.add(expression); - } - if (currentExpression != null) { - fExpression.setText(currentExpression); - } - fCurrentDebugContext = context; - } catch (CoreException e) { - // Unexpected snag dealing with launch configuration - MemoryBrowserPlugin.log(e); + try { + String[] expressions = getSavedExpressions(context, memorySpace); + String currentExpression = fExpression.getText(); + fExpression.removeAll(); + for (String expression : expressions) { + fExpression.add(expression); } + if (currentExpression != null) { + fExpression.setText(currentExpression); + } + System.out.println("GoToAddressBarWidget: set context field to " + context); + } catch (CoreException e) { + // Unexpected snag dealing with launch configuration + MemoryBrowserPlugin.log(e); } } diff --git a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/MemoryBrowser.java b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/MemoryBrowser.java index 01224bd3b45..346effcc136 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/MemoryBrowser.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/MemoryBrowser.java @@ -24,6 +24,7 @@ import java.util.Map; import org.eclipse.cdt.debug.core.model.provisional.IMemoryRenderingViewportProvider; import org.eclipse.cdt.debug.core.model.provisional.IMemorySpaceAwareMemoryBlockRetrieval; import org.eclipse.cdt.debug.internal.core.CRequest; +import org.eclipse.cdt.debug.ui.memory.memorybrowser.api.IMemoryBrowser; import org.eclipse.cdt.debug.ui.provisional.IRepositionableMemoryRendering2; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; @@ -125,8 +126,9 @@ import org.eclipse.ui.progress.WorkbenchJob; * */ -@SuppressWarnings("restriction") -public class MemoryBrowser extends ViewPart implements IDebugContextListener, IMemoryRenderingSite, IDebugEventSetListener +@SuppressWarnings("restriction") /* Debug Platform's Flexibile hierarchy is still provisional */ + +public class MemoryBrowser extends ViewPart implements IDebugContextListener, IMemoryRenderingSite, IDebugEventSetListener, IMemoryBrowser { public static final String ID = "org.eclipse.cdt.debug.ui.memory.memorybrowser.MemoryBrowser"; //$NON-NLS-1$ @@ -444,8 +446,12 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM private void handleUnsupportedSelection() { fStackLayout.topControl = fUnsupportedLabel; - fGotoAddressBarControl.setVisible(false); - fGotoMemorySpaceControl.setVisible(false); + if(!fGotoAddressBarControl.isDisposed()) { + fGotoAddressBarControl.setVisible(false); + } + if(!fGotoMemorySpaceControl.isDisposed()) { + fGotoMemorySpaceControl.setVisible(false); + } } private void performGo(boolean inNewTab) { @@ -471,6 +477,17 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM performGo(inNewTab, expression, memorySpace); } } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.ui.memory.memorybrowser.api.IMemoryBrowser#getActiveRetrieval() + */ + public IMemoryBlockRetrieval getActiveRetrieval() { + final CTabFolder activeFolder = (CTabFolder) fStackLayout.topControl; + if (activeFolder == null) + return null; + + return (IMemoryBlockRetrieval) activeFolder.getData(KEY_RETRIEVAL); + } public void performGo(boolean inNewTab, final String expression, final String memorySpaceId) { final CTabFolder activeFolder = (CTabFolder) fStackLayout.topControl; @@ -932,7 +949,7 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM // GUI activity must be on the main thread runOnUIThread(new Runnable(){ public void run() { - if (fGotoAddressBarControl.isDisposed()) { + if (fGotoAddressBarControl.isDisposed() || fGotoMemorySpaceControl.isDisposed()) { return; } @@ -1289,4 +1306,56 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM job.schedule(); } } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.ui.memory.memorybrowser.api.IMemoryBrowser#go(java.lang.String, java.lang.String, boolean) + */ + public void go(String expression, String memorySpaceId, boolean inNewTab) + throws CoreException { + if (expression == null) { + throw new IllegalArgumentException("expression cannot be null"); + } + expression = expression.trim(); + if (expression.length() == 0) { + throw new IllegalArgumentException("expression cannot be empty"); + } + if (!fGotoMemorySpaceControl.isDisposed() && fGotoMemorySpaceControl.isVisible()) { + if (memorySpaceId == null) { + // if caller passed null, use whatever memory space is selected in the control + memorySpaceId = fGotoMemorySpaceControl.getText(); + if (memorySpaceId.equals(NA_MEMORY_SPACE_ID)) { + memorySpaceId = null; + } + } + else { + // if caller passed empty string, it means n/a (same as "----" in the selector) + memorySpaceId = memorySpaceId.trim(); + if (memorySpaceId.length() == 0) { + memorySpaceId = null; + } + else { + // Check that the ID requested by the user is a valid one + if (fGotoMemorySpaceControl.indexOf(memorySpaceId) == -1) { + throw new IllegalArgumentException("unrecognized memory space ID"); + } + } + + fGotoMemorySpaceControl.setText(memorySpaceId == null ? NA_MEMORY_SPACE_ID : memorySpaceId); + } + } + + fGotoAddressBar.setExpressionText(expression); + performGo(inNewTab, expression, memorySpaceId); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.ui.memory.memorybrowser.api.IMemoryBrowser#getSelectedMemorySpace() + */ + public String getSelectedMemorySpace() { + if (!fGotoMemorySpaceControl.isDisposed() && fGotoMemorySpaceControl.isVisible()) { + String id = fGotoMemorySpaceControl.getText(); + return id.equals(NA_MEMORY_SPACE_ID) ? null : id; + } + return null; + } } diff --git a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/api/IMemoryBrowser.java b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/api/IMemoryBrowser.java new file mode 100755 index 00000000000..7731500e7c5 --- /dev/null +++ b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/api/IMemoryBrowser.java @@ -0,0 +1,63 @@ +package org.eclipse.cdt.debug.ui.memory.memorybrowser.api; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.model.IMemoryBlockRetrieval; + +/** + * Public API for accessing the memory browser. + * + *

+ * All methods must be called on the UI thread, unless otherwise noted. + */ +public interface IMemoryBrowser { + /** + * Tells the memory browser to go to a new memory location. Updates the goto + * address bar and memory space selector (if present). + * + *

+ * This operation is a no-op if there is no active memory retrieval object. + * + * @param expression + * the expression to go to. Cannot be null or empty string. + * Expression is trimmed. + * @param memorySpaceId + * optional memory space ID. Argument is ignored if the memory + * browser is not currently showing a memory space selector. If + * selector is showing, this argument is interpreted as follows: + * empty string means no memory space (as if the user selected + * the "----" memory space), and null means use whatever memory + * space is selected. Passing an ID that is not present in the + * selector will result in an IllegalArgumentException + * @param inNewTab + * if true, memory is shown in a new tab + * @throws CoreException + */ + public void go(String expression, String memorySpaceId, boolean inNewTab) throws CoreException; + + /** + * Returns the selected memory space. + * + *

+ * The memory browser exposes a memory space selector when debugging a + * target with multiple memory spaces. The selection provides the context + * for the expression when the user performs a GO action. This method will + * return the currently selected memory space. + * + * @return null if the memory space selector is not shown, or if the n/a + * entry is selected. Otherwise the selected memory space ID. Never + * an empty string. + */ + public String getSelectedMemorySpace(); + + /** + * Returns the active memory retrieval object, or null if none is active. + * + * This is the retrieval object being used to obtain the memory shown in the + * active tab. Note that all simultaneously visible tabs use the same + * retrieval object. The retrieval object is obtained from the active debug + * context. + * + * @return the active memory retrieval object, or null if none is active + */ + public IMemoryBlockRetrieval getActiveRetrieval(); +} diff --git a/memory/org.eclipse.cdt.debug.ui.memory.search/pom.xml b/memory/org.eclipse.cdt.debug.ui.memory.search/pom.xml index 862b6a1c715..d515c6f1bfe 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.search/pom.xml +++ b/memory/org.eclipse.cdt.debug.ui.memory.search/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/memory/org.eclipse.cdt.debug.ui.memory.source-feature/pom.xml b/memory/org.eclipse.cdt.debug.ui.memory.source-feature/pom.xml index b2d166ec30a..9504ab205f6 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.source-feature/pom.xml +++ b/memory/org.eclipse.cdt.debug.ui.memory.source-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/memory/org.eclipse.cdt.debug.ui.memory.traditional/pom.xml b/memory/org.eclipse.cdt.debug.ui.memory.traditional/pom.xml index ab521f27065..8da98e117b2 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.traditional/pom.xml +++ b/memory/org.eclipse.cdt.debug.ui.memory.traditional/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/pom.xml b/memory/org.eclipse.cdt.debug.ui.memory.transport/pom.xml index 89df72ccec8..15c350a214f 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/pom.xml +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/p2/org.eclipse.cdt.p2-feature/pom.xml b/p2/org.eclipse.cdt.p2-feature/pom.xml index 2cbde6f9d5e..81180a2a010 100644 --- a/p2/org.eclipse.cdt.p2-feature/pom.xml +++ b/p2/org.eclipse.cdt.p2-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/p2/org.eclipse.cdt.p2/.classpath b/p2/org.eclipse.cdt.p2/.classpath index c8ff43b0725..3b77185482d 100644 --- a/p2/org.eclipse.cdt.p2/.classpath +++ b/p2/org.eclipse.cdt.p2/.classpath @@ -1,6 +1,6 @@ - + diff --git a/p2/org.eclipse.cdt.p2/.settings/org.eclipse.jdt.core.prefs b/p2/org.eclipse.cdt.p2/.settings/org.eclipse.jdt.core.prefs index aca6ee8c3da..ef5f1c5df0c 100644 --- a/p2/org.eclipse.cdt.p2/.settings/org.eclipse.jdt.core.prefs +++ b/p2/org.eclipse.cdt.p2/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,12 @@ #Sun Nov 30 21:26:19 EST 2008 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/p2/org.eclipse.cdt.p2/META-INF/MANIFEST.MF b/p2/org.eclipse.cdt.p2/META-INF/MANIFEST.MF index 26e1d61a7b5..b83ed5f8334 100644 --- a/p2/org.eclipse.cdt.p2/META-INF/MANIFEST.MF +++ b/p2/org.eclipse.cdt.p2/META-INF/MANIFEST.MF @@ -14,7 +14,7 @@ Require-Bundle: org.eclipse.core.runtime, org.apache.ant;bundle-version="1.7.0", org.eclipse.equinox.p2.touchpoint.natives;bundle-version="1.0.0", org.eclipse.equinox.p2.repository;bundle-version="1.0.0" -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.cdt.internal.p2, org.eclipse.cdt.internal.p2.touchpoint.natives.actions diff --git a/p2/org.eclipse.cdt.p2/pom.xml b/p2/org.eclipse.cdt.p2/pom.xml index b7c5c08cef2..5b555061eba 100644 --- a/p2/org.eclipse.cdt.p2/pom.xml +++ b/p2/org.eclipse.cdt.p2/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index 648f40a742b..366c915af61 100644 --- a/pom.xml +++ b/pom.xml @@ -10,12 +10,12 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT pom CDT Parent - 0.13.0-SNAPSHOT + 0.13.0 3.7 http://download.eclipse.org/eclipse/updates/${platform-version} R20110523182458 @@ -183,19 +183,6 @@ - - - sonatype - https://repository.sonatype.org/content/repositories/public - - true - - - true - - - - diff --git a/releng/org.eclipse.cdt-feature/feature.xml b/releng/org.eclipse.cdt-feature/feature.xml index 63dbe36ae82..0f83a653356 100644 --- a/releng/org.eclipse.cdt-feature/feature.xml +++ b/releng/org.eclipse.cdt-feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/releng/org.eclipse.cdt-feature/pom.xml b/releng/org.eclipse.cdt-feature/pom.xml index 028f479703a..2ce178e15b9 100644 --- a/releng/org.eclipse.cdt-feature/pom.xml +++ b/releng/org.eclipse.cdt-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/releng/org.eclipse.cdt.platform-feature/feature.xml b/releng/org.eclipse.cdt.platform-feature/feature.xml index 6b5d793de01..3ec220dbcc4 100644 --- a/releng/org.eclipse.cdt.platform-feature/feature.xml +++ b/releng/org.eclipse.cdt.platform-feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/releng/org.eclipse.cdt.platform-feature/pom.xml b/releng/org.eclipse.cdt.platform-feature/pom.xml index f42595737f0..8f8da2871d0 100644 --- a/releng/org.eclipse.cdt.platform-feature/pom.xml +++ b/releng/org.eclipse.cdt.platform-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/releng/org.eclipse.cdt.platform.source-feature/feature.xml b/releng/org.eclipse.cdt.platform.source-feature/feature.xml index 11151d339f0..af97e9c227f 100644 --- a/releng/org.eclipse.cdt.platform.source-feature/feature.xml +++ b/releng/org.eclipse.cdt.platform.source-feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/releng/org.eclipse.cdt.platform.source-feature/pom.xml b/releng/org.eclipse.cdt.platform.source-feature/pom.xml index 67d6df2f593..661ffd14f90 100644 --- a/releng/org.eclipse.cdt.platform.source-feature/pom.xml +++ b/releng/org.eclipse.cdt.platform.source-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/releng/org.eclipse.cdt.releng/build.xml b/releng/org.eclipse.cdt.releng/build.xml index f5be799da22..aa281376c14 100644 --- a/releng/org.eclipse.cdt.releng/build.xml +++ b/releng/org.eclipse.cdt.releng/build.xml @@ -22,7 +22,7 @@ - + @@ -37,7 +37,7 @@ - + diff --git a/releng/org.eclipse.cdt.releng/buildsite.xml b/releng/org.eclipse.cdt.releng/buildsite.xml index 8e796a8e8e3..2051876c465 100644 --- a/releng/org.eclipse.cdt.releng/buildsite.xml +++ b/releng/org.eclipse.cdt.releng/buildsite.xml @@ -3,10 +3,10 @@ - + - + @@ -33,13 +33,13 @@ - + - + diff --git a/releng/org.eclipse.cdt.releng/c99/build.properties b/releng/org.eclipse.cdt.releng/c99/build.properties index c2f614d15eb..aece1ea164d 100644 --- a/releng/org.eclipse.cdt.releng/c99/build.properties +++ b/releng/org.eclipse.cdt.releng/c99/build.properties @@ -89,7 +89,7 @@ javacDebugInfo=on javacFailOnError=true # The version of the source code -javacSource=1.5 +javacSource=1.6 # The version of the byte code targeted -javacTarget=1.5 +javacTarget=1.6 diff --git a/releng/org.eclipse.cdt.releng/codan/build.properties b/releng/org.eclipse.cdt.releng/codan/build.properties index c2f614d15eb..aece1ea164d 100644 --- a/releng/org.eclipse.cdt.releng/codan/build.properties +++ b/releng/org.eclipse.cdt.releng/codan/build.properties @@ -89,7 +89,7 @@ javacDebugInfo=on javacFailOnError=true # The version of the source code -javacSource=1.5 +javacSource=1.6 # The version of the byte code targeted -javacTarget=1.5 +javacTarget=1.6 diff --git a/releng/org.eclipse.cdt.releng/crossgcc/build.properties b/releng/org.eclipse.cdt.releng/crossgcc/build.properties index 6409ac04311..7341df96e24 100644 --- a/releng/org.eclipse.cdt.releng/crossgcc/build.properties +++ b/releng/org.eclipse.cdt.releng/crossgcc/build.properties @@ -89,7 +89,7 @@ javacDebugInfo=on javacFailOnError=true # The version of the source code -javacSource=1.5 +javacSource=1.6 # The version of the byte code targeted -javacTarget=1.5 +javacTarget=1.6 diff --git a/releng/org.eclipse.cdt.releng/dsfgdb/build.properties b/releng/org.eclipse.cdt.releng/dsfgdb/build.properties index c2f614d15eb..aece1ea164d 100644 --- a/releng/org.eclipse.cdt.releng/dsfgdb/build.properties +++ b/releng/org.eclipse.cdt.releng/dsfgdb/build.properties @@ -89,7 +89,7 @@ javacDebugInfo=on javacFailOnError=true # The version of the source code -javacSource=1.5 +javacSource=1.6 # The version of the byte code targeted -javacTarget=1.5 +javacTarget=1.6 diff --git a/releng/org.eclipse.cdt.releng/gdbjtag/build.properties b/releng/org.eclipse.cdt.releng/gdbjtag/build.properties index c2f614d15eb..aece1ea164d 100644 --- a/releng/org.eclipse.cdt.releng/gdbjtag/build.properties +++ b/releng/org.eclipse.cdt.releng/gdbjtag/build.properties @@ -89,7 +89,7 @@ javacDebugInfo=on javacFailOnError=true # The version of the source code -javacSource=1.5 +javacSource=1.6 # The version of the byte code targeted -javacTarget=1.5 +javacTarget=1.6 diff --git a/releng/org.eclipse.cdt.releng/launch.remote/build.properties b/releng/org.eclipse.cdt.releng/launch.remote/build.properties index c2f614d15eb..aece1ea164d 100644 --- a/releng/org.eclipse.cdt.releng/launch.remote/build.properties +++ b/releng/org.eclipse.cdt.releng/launch.remote/build.properties @@ -89,7 +89,7 @@ javacDebugInfo=on javacFailOnError=true # The version of the source code -javacSource=1.5 +javacSource=1.6 # The version of the byte code targeted -javacTarget=1.5 +javacTarget=1.6 diff --git a/releng/org.eclipse.cdt.releng/lrparser.sdk/build.properties b/releng/org.eclipse.cdt.releng/lrparser.sdk/build.properties index 6409ac04311..7341df96e24 100644 --- a/releng/org.eclipse.cdt.releng/lrparser.sdk/build.properties +++ b/releng/org.eclipse.cdt.releng/lrparser.sdk/build.properties @@ -89,7 +89,7 @@ javacDebugInfo=on javacFailOnError=true # The version of the source code -javacSource=1.5 +javacSource=1.6 # The version of the byte code targeted -javacTarget=1.5 +javacTarget=1.6 diff --git a/releng/org.eclipse.cdt.releng/lrparser/build.properties b/releng/org.eclipse.cdt.releng/lrparser/build.properties index 953833c8624..dfef384f449 100644 --- a/releng/org.eclipse.cdt.releng/lrparser/build.properties +++ b/releng/org.eclipse.cdt.releng/lrparser/build.properties @@ -89,7 +89,7 @@ javacDebugInfo=on javacFailOnError=true # The version of the source code -javacSource=1.5 +javacSource=1.6 # The version of the byte code targeted -javacTarget=1.5 +javacTarget=1.6 diff --git a/releng/org.eclipse.cdt.releng/master/build.properties b/releng/org.eclipse.cdt.releng/master/build.properties index 5882788fcad..df850a79712 100644 --- a/releng/org.eclipse.cdt.releng/master/build.properties +++ b/releng/org.eclipse.cdt.releng/master/build.properties @@ -104,10 +104,10 @@ javacVerbose=true javacFailOnError=true # The version of the source code -javacSource=1.5 +javacSource=1.6 # The version of the byte code targeted -javacTarget=1.5 +javacTarget=1.6 # Create individual source bundles individualSourceBundles=true diff --git a/releng/org.eclipse.cdt.releng/memory/build.properties b/releng/org.eclipse.cdt.releng/memory/build.properties index 6409ac04311..7341df96e24 100644 --- a/releng/org.eclipse.cdt.releng/memory/build.properties +++ b/releng/org.eclipse.cdt.releng/memory/build.properties @@ -89,7 +89,7 @@ javacDebugInfo=on javacFailOnError=true # The version of the source code -javacSource=1.5 +javacSource=1.6 # The version of the byte code targeted -javacTarget=1.5 +javacTarget=1.6 diff --git a/releng/org.eclipse.cdt.releng/mylyn/build.properties b/releng/org.eclipse.cdt.releng/mylyn/build.properties index 8f20ea14ac9..24dbdebec27 100644 --- a/releng/org.eclipse.cdt.releng/mylyn/build.properties +++ b/releng/org.eclipse.cdt.releng/mylyn/build.properties @@ -88,7 +88,7 @@ javacDebugInfo=on javacFailOnError=true # The version of the source code -javacSource=1.5 +javacSource=1.6 # The version of the byte code targeted -javacTarget=1.5 +javacTarget=1.6 diff --git a/releng/org.eclipse.cdt.releng/p2/build.properties b/releng/org.eclipse.cdt.releng/p2/build.properties index 6409ac04311..7341df96e24 100644 --- a/releng/org.eclipse.cdt.releng/p2/build.properties +++ b/releng/org.eclipse.cdt.releng/p2/build.properties @@ -89,7 +89,7 @@ javacDebugInfo=on javacFailOnError=true # The version of the source code -javacSource=1.5 +javacSource=1.6 # The version of the byte code targeted -javacTarget=1.5 +javacTarget=1.6 diff --git a/releng/org.eclipse.cdt.releng/platform/build.properties b/releng/org.eclipse.cdt.releng/platform/build.properties index 03331d618bf..64db9220f50 100644 --- a/releng/org.eclipse.cdt.releng/platform/build.properties +++ b/releng/org.eclipse.cdt.releng/platform/build.properties @@ -106,7 +106,7 @@ javacVerbose=true javacFailOnError=false # The version of the source code -javacSource=1.5 +javacSource=1.6 # The version of the byte code targeted -javacTarget=1.5 +javacTarget=1.6 diff --git a/releng/org.eclipse.cdt.releng/sdk/build.properties b/releng/org.eclipse.cdt.releng/sdk/build.properties index d5a4d24cea8..49dc6b365ed 100644 --- a/releng/org.eclipse.cdt.releng/sdk/build.properties +++ b/releng/org.eclipse.cdt.releng/sdk/build.properties @@ -108,7 +108,7 @@ javacDebugInfo=on javacFailOnError=true # The version of the source code -javacSource=1.5 +javacSource=1.6 # The version of the byte code targeted -javacTarget=1.5 +javacTarget=1.6 diff --git a/releng/org.eclipse.cdt.releng/testing/build.properties b/releng/org.eclipse.cdt.releng/testing/build.properties index c2f614d15eb..aece1ea164d 100644 --- a/releng/org.eclipse.cdt.releng/testing/build.properties +++ b/releng/org.eclipse.cdt.releng/testing/build.properties @@ -89,7 +89,7 @@ javacDebugInfo=on javacFailOnError=true # The version of the source code -javacSource=1.5 +javacSource=1.6 # The version of the byte code targeted -javacTarget=1.5 +javacTarget=1.6 diff --git a/releng/org.eclipse.cdt.releng/upc.sdk/build.properties b/releng/org.eclipse.cdt.releng/upc.sdk/build.properties index 6409ac04311..7341df96e24 100644 --- a/releng/org.eclipse.cdt.releng/upc.sdk/build.properties +++ b/releng/org.eclipse.cdt.releng/upc.sdk/build.properties @@ -89,7 +89,7 @@ javacDebugInfo=on javacFailOnError=true # The version of the source code -javacSource=1.5 +javacSource=1.6 # The version of the byte code targeted -javacTarget=1.5 +javacTarget=1.6 diff --git a/releng/org.eclipse.cdt.releng/upc/build.properties b/releng/org.eclipse.cdt.releng/upc/build.properties index c2f614d15eb..aece1ea164d 100644 --- a/releng/org.eclipse.cdt.releng/upc/build.properties +++ b/releng/org.eclipse.cdt.releng/upc/build.properties @@ -89,7 +89,7 @@ javacDebugInfo=on javacFailOnError=true # The version of the source code -javacSource=1.5 +javacSource=1.6 # The version of the byte code targeted -javacTarget=1.5 +javacTarget=1.6 diff --git a/releng/org.eclipse.cdt.releng/util/build.properties b/releng/org.eclipse.cdt.releng/util/build.properties index 8f20ea14ac9..24dbdebec27 100644 --- a/releng/org.eclipse.cdt.releng/util/build.properties +++ b/releng/org.eclipse.cdt.releng/util/build.properties @@ -88,7 +88,7 @@ javacDebugInfo=on javacFailOnError=true # The version of the source code -javacSource=1.5 +javacSource=1.6 # The version of the byte code targeted -javacTarget=1.5 +javacTarget=1.6 diff --git a/releng/org.eclipse.cdt.releng/windows/build.properties b/releng/org.eclipse.cdt.releng/windows/build.properties index e728558d3d6..adf11e80567 100644 --- a/releng/org.eclipse.cdt.releng/windows/build.properties +++ b/releng/org.eclipse.cdt.releng/windows/build.properties @@ -89,7 +89,7 @@ javacDebugInfo=on javacFailOnError=true # The version of the source code -javacSource=1.5 +javacSource=1.6 # The version of the byte code targeted -javacTarget=1.5 +javacTarget=1.6 diff --git a/releng/org.eclipse.cdt.releng/xlc.sdk/build.properties b/releng/org.eclipse.cdt.releng/xlc.sdk/build.properties index 8f20ea14ac9..24dbdebec27 100644 --- a/releng/org.eclipse.cdt.releng/xlc.sdk/build.properties +++ b/releng/org.eclipse.cdt.releng/xlc.sdk/build.properties @@ -88,7 +88,7 @@ javacDebugInfo=on javacFailOnError=true # The version of the source code -javacSource=1.5 +javacSource=1.6 # The version of the byte code targeted -javacTarget=1.5 +javacTarget=1.6 diff --git a/releng/org.eclipse.cdt.releng/xlc/build.properties b/releng/org.eclipse.cdt.releng/xlc/build.properties index c2f614d15eb..aece1ea164d 100644 --- a/releng/org.eclipse.cdt.releng/xlc/build.properties +++ b/releng/org.eclipse.cdt.releng/xlc/build.properties @@ -89,7 +89,7 @@ javacDebugInfo=on javacFailOnError=true # The version of the source code -javacSource=1.5 +javacSource=1.6 # The version of the byte code targeted -javacTarget=1.5 +javacTarget=1.6 diff --git a/releng/org.eclipse.cdt.repo/pom.xml b/releng/org.eclipse.cdt.repo/pom.xml index 80042b99d9f..61e7215bca1 100644 --- a/releng/org.eclipse.cdt.repo/pom.xml +++ b/releng/org.eclipse.cdt.repo/pom.xml @@ -7,11 +7,11 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT org.eclipse.cdt.repo eclipse-repository diff --git a/releng/org.eclipse.cdt.sdk-feature/feature.xml b/releng/org.eclipse.cdt.sdk-feature/feature.xml index fb865cfa1f5..73395d078bc 100644 --- a/releng/org.eclipse.cdt.sdk-feature/feature.xml +++ b/releng/org.eclipse.cdt.sdk-feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/releng/org.eclipse.cdt.sdk-feature/pom.xml b/releng/org.eclipse.cdt.sdk-feature/pom.xml index ac901feebff..6df633f1583 100644 --- a/releng/org.eclipse.cdt.sdk-feature/pom.xml +++ b/releng/org.eclipse.cdt.sdk-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/releng/org.eclipse.cdt.sdk/META-INF/MANIFEST.MF b/releng/org.eclipse.cdt.sdk/META-INF/MANIFEST.MF index a0051097a54..444353b3050 100644 --- a/releng/org.eclipse.cdt.sdk/META-INF/MANIFEST.MF +++ b/releng/org.eclipse.cdt.sdk/META-INF/MANIFEST.MF @@ -2,6 +2,6 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.sdk;singleton:=true -Bundle-Version: 8.0.0.qualifier +Bundle-Version: 8.1.0.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/releng/org.eclipse.cdt.sdk/pom.xml b/releng/org.eclipse.cdt.sdk/pom.xml index 9c8f32431ae..691103b99dd 100644 --- a/releng/org.eclipse.cdt.sdk/pom.xml +++ b/releng/org.eclipse.cdt.sdk/pom.xml @@ -7,11 +7,11 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT org.eclipse.cdt.sdk eclipse-plugin diff --git a/releng/org.eclipse.cdt.testing-feature/feature.xml b/releng/org.eclipse.cdt.testing-feature/feature.xml index 770cf7b16f8..996372c73c0 100644 --- a/releng/org.eclipse.cdt.testing-feature/feature.xml +++ b/releng/org.eclipse.cdt.testing-feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/releng/org.eclipse.cdt.testing/META-INF/MANIFEST.MF b/releng/org.eclipse.cdt.testing/META-INF/MANIFEST.MF index b3c716ef598..ab5c26cfe3d 100644 --- a/releng/org.eclipse.cdt.testing/META-INF/MANIFEST.MF +++ b/releng/org.eclipse.cdt.testing/META-INF/MANIFEST.MF @@ -2,6 +2,6 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.testing;singleton:=true -Bundle-Version: 8.0.0.qualifier +Bundle-Version: 8.1.0.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/releng/org.eclipse.cdt/META-INF/MANIFEST.MF b/releng/org.eclipse.cdt/META-INF/MANIFEST.MF index 8d5b2542a1a..45008586bad 100644 --- a/releng/org.eclipse.cdt/META-INF/MANIFEST.MF +++ b/releng/org.eclipse.cdt/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt; singleton:=true -Bundle-Version: 8.0.0.qualifier +Bundle-Version: 8.1.0.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Require-Bundle: org.eclipse.ui.intro;bundle-version="[3.2.0,4.0.0)", diff --git a/releng/org.eclipse.cdt/pom.xml b/releng/org.eclipse.cdt/pom.xml index 5f8da16e010..c661101c5c6 100644 --- a/releng/org.eclipse.cdt/pom.xml +++ b/releng/org.eclipse.cdt/pom.xml @@ -7,11 +7,11 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT org.eclipse.cdt eclipse-plugin diff --git a/upc/org.eclipse.cdt.bupc-feature/pom.xml b/upc/org.eclipse.cdt.bupc-feature/pom.xml index 7dbcecf3fd7..4d21e0f274a 100644 --- a/upc/org.eclipse.cdt.bupc-feature/pom.xml +++ b/upc/org.eclipse.cdt.bupc-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/upc/org.eclipse.cdt.core.parser.upc.feature/pom.xml b/upc/org.eclipse.cdt.core.parser.upc.feature/pom.xml index 22a9645d5ca..678d0f4dfed 100644 --- a/upc/org.eclipse.cdt.core.parser.upc.feature/pom.xml +++ b/upc/org.eclipse.cdt.core.parser.upc.feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/upc/org.eclipse.cdt.core.parser.upc.sdk.feature/pom.xml b/upc/org.eclipse.cdt.core.parser.upc.sdk.feature/pom.xml index fcd12aef9dc..0c552fb7080 100644 --- a/upc/org.eclipse.cdt.core.parser.upc.sdk.feature/pom.xml +++ b/upc/org.eclipse.cdt.core.parser.upc.sdk.feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/upc/org.eclipse.cdt.core.parser.upc.source.feature/pom.xml b/upc/org.eclipse.cdt.core.parser.upc.source.feature/pom.xml index 589c5e15a0c..e22ad884eda 100644 --- a/upc/org.eclipse.cdt.core.parser.upc.source.feature/pom.xml +++ b/upc/org.eclipse.cdt.core.parser.upc.source.feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/upc/org.eclipse.cdt.core.parser.upc.tests/pom.xml b/upc/org.eclipse.cdt.core.parser.upc.tests/pom.xml index 277f442f9a7..bc60d5d65bb 100644 --- a/upc/org.eclipse.cdt.core.parser.upc.tests/pom.xml +++ b/upc/org.eclipse.cdt.core.parser.upc.tests/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/upc/org.eclipse.cdt.core.parser.upc/pom.xml b/upc/org.eclipse.cdt.core.parser.upc/pom.xml index 372b35a0bd6..245c08669d5 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/pom.xml +++ b/upc/org.eclipse.cdt.core.parser.upc/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/upc/org.eclipse.cdt.managedbuilder.bupc.ui/pom.xml b/upc/org.eclipse.cdt.managedbuilder.bupc.ui/pom.xml index 46ea4b0049f..a2b2faab4e1 100644 --- a/upc/org.eclipse.cdt.managedbuilder.bupc.ui/pom.xml +++ b/upc/org.eclipse.cdt.managedbuilder.bupc.ui/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/util/org.eclipse.cdt.util-feature/pom.xml b/util/org.eclipse.cdt.util-feature/pom.xml index 12d34011929..6bc44c0b437 100644 --- a/util/org.eclipse.cdt.util-feature/pom.xml +++ b/util/org.eclipse.cdt.util-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/util/org.eclipse.cdt.util/pom.xml b/util/org.eclipse.cdt.util/pom.xml index da93068898d..1babb24491b 100644 --- a/util/org.eclipse.cdt.util/pom.xml +++ b/util/org.eclipse.cdt.util/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/windows/org.eclipse.cdt.msw-feature/pom.xml b/windows/org.eclipse.cdt.msw-feature/pom.xml index 413e52398ec..47f453bba6c 100644 --- a/windows/org.eclipse.cdt.msw-feature/pom.xml +++ b/windows/org.eclipse.cdt.msw-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/windows/org.eclipse.cdt.msw.build/pom.xml b/windows/org.eclipse.cdt.msw.build/pom.xml index cb1d872e0d9..4e64aed6688 100644 --- a/windows/org.eclipse.cdt.msw.build/pom.xml +++ b/windows/org.eclipse.cdt.msw.build/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/pom.xml b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/pom.xml index 9a4182761ed..52b5a759c3f 100644 --- a/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/pom.xml +++ b/xlc/org.eclipse.cdt.core.lrparser.xlc.tests/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc/pom.xml b/xlc/org.eclipse.cdt.core.lrparser.xlc/pom.xml index 56efe3cff25..9b1858f294e 100644 --- a/xlc/org.eclipse.cdt.core.lrparser.xlc/pom.xml +++ b/xlc/org.eclipse.cdt.core.lrparser.xlc/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc/pom.xml b/xlc/org.eclipse.cdt.errorparsers.xlc/pom.xml index 466a63eec57..cb98ec94243 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc/pom.xml +++ b/xlc/org.eclipse.cdt.errorparsers.xlc/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/xlc/org.eclipse.cdt.make.xlc.core/pom.xml b/xlc/org.eclipse.cdt.make.xlc.core/pom.xml index a7cc50754d9..f2b0e9707c5 100644 --- a/xlc/org.eclipse.cdt.make.xlc.core/pom.xml +++ b/xlc/org.eclipse.cdt.make.xlc.core/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.core/plugin.xml b/xlc/org.eclipse.cdt.managedbuilder.xlc.core/plugin.xml index efdbfcbd13c..e0136162399 100644 --- a/xlc/org.eclipse.cdt.managedbuilder.xlc.core/plugin.xml +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.core/plugin.xml @@ -28,7 +28,7 @@ @@ -65,7 +65,7 @@ diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.core/pom.xml b/xlc/org.eclipse.cdt.managedbuilder.xlc.core/pom.xml index 06f18363fca..c568edaa113 100644 --- a/xlc/org.eclipse.cdt.managedbuilder.xlc.core/pom.xml +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.core/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/pom.xml b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/pom.xml index 349e9a0df69..57de0019f98 100644 --- a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/pom.xml +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlupc.ui/pom.xml b/xlc/org.eclipse.cdt.managedbuilder.xlupc.ui/pom.xml index 0243e2541f6..a9d1c4fcc68 100644 --- a/xlc/org.eclipse.cdt.managedbuilder.xlupc.ui/pom.xml +++ b/xlc/org.eclipse.cdt.managedbuilder.xlupc.ui/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/xlc/org.eclipse.cdt.xlc.feature/pom.xml b/xlc/org.eclipse.cdt.xlc.feature/pom.xml index eaacb699bdc..a74c80c3d7d 100644 --- a/xlc/org.eclipse.cdt.xlc.feature/pom.xml +++ b/xlc/org.eclipse.cdt.xlc.feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/xlc/org.eclipse.cdt.xlc.sdk-feature/pom.xml b/xlc/org.eclipse.cdt.xlc.sdk-feature/pom.xml index e13665a81ed..e8b94c93b4c 100644 --- a/xlc/org.eclipse.cdt.xlc.sdk-feature/pom.xml +++ b/xlc/org.eclipse.cdt.xlc.sdk-feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml diff --git a/xlc/org.eclipse.cdt.xlc.source.feature/pom.xml b/xlc/org.eclipse.cdt.xlc.source.feature/pom.xml index 496cfdee59b..6ed0635c7c8 100644 --- a/xlc/org.eclipse.cdt.xlc.source.feature/pom.xml +++ b/xlc/org.eclipse.cdt.xlc.source.feature/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.0.0-SNAPSHOT + 8.1.0-SNAPSHOT ../../pom.xml