1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Merge remote-tracking branch 'origin/master' into bug_45203

Change-Id: I5ea97f0e6c1e15a72e45f5fbc7407ad6b35e9a64
This commit is contained in:
Sergey Prigogin 2013-02-14 17:21:05 -08:00
commit 3198d038d4
173 changed files with 5130 additions and 1617 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2011 IBM Corporation and others. * Copyright (c) 2004, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -20,8 +20,14 @@ import java.util.List;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IBinaryParser; import org.eclipse.cdt.core.IBinaryParser;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
import org.eclipse.cdt.core.model.CoreModelUtil; import org.eclipse.cdt.core.model.CoreModelUtil;
import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference; import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.internal.core.Cygwin;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.utils.CygPath; import org.eclipse.cdt.utils.CygPath;
import org.eclipse.cdt.utils.ICygwinToolsFactroy; import org.eclipse.cdt.utils.ICygwinToolsFactroy;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -32,15 +38,14 @@ import org.eclipse.core.runtime.Platform;
/** /**
* Use binary parser's 'cygpath' command to translate cygpaths to absolute paths. * Use binary parser's 'cygpath' command to translate cygpaths to absolute paths.
* Note that this class does not support build configurations.
* *
* @author vhirsl * @author vhirsl
*/ */
public class CygpathTranslator { public class CygpathTranslator {
/** Default Cygwin root dir */ private static final String ENV_PATH = "PATH"; //$NON-NLS-1$
private static final String DEFAULT_CYGWIN_ROOT= "C:\\cygwin"; //$NON-NLS-1$
// private static final String CYGPATH_ERROR_MESSAGE = "CygpathTranslator.NotAvailableErrorMessage"; //$NON-NLS-1$
private CygPath cygPath = null; private CygPath cygPath = null;
private boolean isAvailable = false;
public CygpathTranslator(IProject project) { public CygpathTranslator(IProject project) {
try { try {
@ -51,35 +56,13 @@ public class CygpathTranslator {
ICygwinToolsFactroy cygwinToolFactory = (ICygwinToolsFactroy) parser.getAdapter(ICygwinToolsFactroy.class); ICygwinToolsFactroy cygwinToolFactory = (ICygwinToolsFactroy) parser.getAdapter(ICygwinToolsFactroy.class);
if (cygwinToolFactory != null) { if (cygwinToolFactory != null) {
cygPath = cygwinToolFactory.getCygPath(); cygPath = cygwinToolFactory.getCygPath();
if (cygPath != null) {
isAvailable = true;
break;
}
} }
} catch (ClassCastException e) { } catch (ClassCastException e) {
} }
} }
// No CygPath specified in BinaryParser page or not supported.
// Hoping that cygpath is on the path.
if (cygPath == null && Platform.getOS().equals(Platform.OS_WIN32)) {
if (new File(DEFAULT_CYGWIN_ROOT).exists()) {
cygPath = new CygPath(DEFAULT_CYGWIN_ROOT + "\\bin\\cygpath.exe"); //$NON-NLS-1$
} else {
cygPath = new CygPath("cygpath"); //$NON-NLS-1$
}
isAvailable = cygPath.getFileName("test").equals("test"); //$NON-NLS-1$ //$NON-NLS-2$
}
} }
catch (CoreException e) { catch (CoreException e) {
} }
catch (IOException e) {
isAvailable = false;
// Removing markers. if cygpath isn't in your path then you aren't using cygwin.
// Then why are we calling this....
// scMarkerGenerator.addMarker(project, -1,
// MakeMessages.getString(CYGPATH_ERROR_MESSAGE),
// IMarkerGenerator.SEVERITY_WARNING, null);
}
} }
public static List<String> translateIncludePaths(IProject project, List<String> sumIncludes) { public static List<String> translateIncludePaths(IProject project, List<String> sumIncludes) {
@ -99,6 +82,32 @@ public class CygpathTranslator {
} }
CygpathTranslator cygpath = new CygpathTranslator(project); CygpathTranslator cygpath = new CygpathTranslator(project);
boolean useCygPathExtension = cygpath.cygPath != null;
boolean useCygwinFromPath = !useCygPathExtension;
String envPath = null;
if (useCygwinFromPath) {
IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager();
ICProjectDescription prjDes = CCorePlugin.getDefault().getProjectDescription(project, false);
if (prjDes != null) {
// we don't know for sure which configuration needs to be used here, so betting on "DefaultSettingConfiguration"
// considering that scanner discovery uses "DefaultSettingConfiguration" rather than "Active" configuration,
// see org.eclipse.cdt.build.core.scannerconfig.ScannerConfigBuilder.build(CfgInfoContext context, ...)
ICConfigurationDescription cfgDes = prjDes.getDefaultSettingConfiguration();
IEnvironmentVariable envVar = mngr.getVariable(ENV_PATH, cfgDes, true);
if (envVar != null) {
envPath = envVar.getValue();
}
}
if (envPath == null) {
IEnvironmentVariable envVar = mngr.getVariable(ENV_PATH, null, true);
if (envVar != null) {
envPath = envVar.getValue();
}
}
useCygwinFromPath = Cygwin.isAvailable(envPath);
}
List<String> translatedIncludePaths = new ArrayList<String>(); List<String> translatedIncludePaths = new ArrayList<String>();
for (Iterator<String> i = sumIncludes.iterator(); i.hasNext(); ) { for (Iterator<String> i = sumIncludes.iterator(); i.hasNext(); ) {
@ -111,13 +120,20 @@ public class CygpathTranslator {
} }
else { else {
String translatedPath = includePath; String translatedPath = includePath;
if (cygpath.isAvailable) {
if (useCygPathExtension) {
try { try {
translatedPath = cygpath.cygPath.getFileName(includePath); translatedPath = cygpath.cygPath.getFileName(includePath);
} }
catch (IOException e) { catch (IOException e) {
TraceUtil.outputError("CygpathTranslator unable to translate path: ", includePath); //$NON-NLS-1$ TraceUtil.outputError("CygpathTranslator unable to translate path: ", includePath); //$NON-NLS-1$
} }
} else if (useCygwinFromPath) {
try {
translatedPath = Cygwin.cygwinToWindowsPath(includePath, envPath);
} catch (Exception e) {
MakeCorePlugin.log(e);
}
} else if (realPath.segmentCount() >= 2) { } else if (realPath.segmentCount() >= 2) {
// try default conversions // try default conversions
// /cygdrive/x/ --> X:\ // /cygdrive/x/ --> X:\
@ -133,7 +149,7 @@ public class CygpathTranslator {
if (new File(translatedPath).exists()) { if (new File(translatedPath).exists()) {
translatedIncludePaths.add(translatedPath); translatedIncludePaths.add(translatedPath);
} }
else if (cygpath.isAvailable) { else if (useCygPathExtension || useCygwinFromPath) {
// TODO VMIR for now add even if it does not exist // TODO VMIR for now add even if it does not exist
translatedIncludePaths.add(translatedPath); translatedIncludePaths.add(translatedPath);
} }
@ -147,7 +163,7 @@ public class CygpathTranslator {
} }
} }
} }
if (cygpath.cygPath != null) { if (useCygPathExtension) {
cygpath.cygPath.dispose(); cygpath.cygPath.dispose();
} }
return translatedIncludePaths; return translatedIncludePaths;

View file

@ -10,8 +10,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.core.tests; package org.eclipse.cdt.managedbuilder.core.tests;
import java.io.File;
import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
@ -24,7 +22,6 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener; import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
import org.eclipse.cdt.core.parser.IScannerInfoProvider; import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsScannerInfoProvider;
import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
@ -201,26 +198,6 @@ public class ManagedBuildCoreTests20 extends TestCase {
} }
/**
* Convert path to OS specific representation
*/
private String toOSLocation(String path) {
File file = new File(path);
try {
path = file.getCanonicalPath();
} catch (IOException e) {
}
return path;
}
/**
* Convert path to OS specific representation
*/
private String toOSString(String path) {
return new Path(path).toOSString();
}
/** /**
* The purpose of this test is to exercise the build path info interface. * The purpose of this test is to exercise the build path info interface.
* To get to that point, a new project/config has to be created in the test * To get to that point, a new project/config has to be created in the test
@ -241,38 +218,18 @@ public class ManagedBuildCoreTests20 extends TestCase {
} }
//These are the expected path settings //These are the expected path settings
IPath buildCWD = project.getLocation().append("Sub Config"); final String[] expectedPaths = new String[5];
final String[] expectedPaths; // This first path is a built-in, so it will not be manipulated by build manager
if (new Path("C:\\home\\tester/include").isAbsolute()) { expectedPaths[0] = (new Path("/usr/include")).toOSString();
// Windows expectedPaths[1] = (new Path("/opt/gnome/include")).toOSString();
expectedPaths = new String[] { IPath path = new Path("C:\\home\\tester/include");
toOSLocation("/usr/include"), if(path.isAbsolute()) // for win32 path is treated as absolute
toOSLocation("/opt/gnome/include"), expectedPaths[2] = path.toOSString();
toOSLocation("C:\\home\\tester/include"), else // for Linux path is relative
// relative paths from MBS will make 3 entries expectedPaths[2] = project.getLocation().append("Sub Config").append(path).toOSString();
project.getLocation().append("includes").toOSString(), expectedPaths[3] = project.getLocation().append( "includes" ).toOSString();
buildCWD.append("includes").toOSString(), expectedPaths[4] = (new Path("/usr/gnu/include")).toOSString();
toOSString("includes"),
"/usr/gnu/include", // Not converted to OS string due to being flagged as ICSettingEntry.RESOLVED
};
} else {
// Unix
expectedPaths = new String[] {
toOSLocation("/usr/include"),
toOSLocation("/opt/gnome/include"),
// on unix "C:\\home\\tester/include" is relative path
// looks like nonsense but has to be this way as MBS converts entry to keep "Sub Config/C:\\home\\tester/include" in its storage
project.getLocation().append("Sub Config/C:\\home\\tester/include").toOSString(),
buildCWD.append("Sub Config/C:\\home\\tester/include").toOSString(),
toOSString("Sub Config/C:\\home\\tester/include"),
// relative paths from MBS will make 3 entries
project.getLocation().append("includes").toOSString(),
buildCWD.append("includes").toOSString(),
toOSString("includes"),
"/usr/gnu/include", // Not converted to OS string due to being flagged as ICSettingEntry.RESOLVED
};
}
// Create a new managed project based on the sub project type // Create a new managed project based on the sub project type
IProjectType projType = ManagedBuildManager.getExtensionProjectType("test.sub"); IProjectType projType = ManagedBuildManager.getExtensionProjectType("test.sub");
@ -324,7 +281,6 @@ public class ManagedBuildCoreTests20 extends TestCase {
// Find the first IScannerInfoProvider that supplies build info for the project // Find the first IScannerInfoProvider that supplies build info for the project
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project); IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
assertNotNull(provider); assertNotNull(provider);
assertTrue(provider instanceof LanguageSettingsScannerInfoProvider);
// Now subscribe (note that the method will be called after a change // Now subscribe (note that the method will be called after a change
provider.subscribe(project, new IScannerInfoChangeListener () { provider.subscribe(project, new IScannerInfoChangeListener () {

View file

@ -0,0 +1,220 @@
/*******************************************************************************
* Copyright (c) 2012, 2012 Andrew Gvozdev 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:
* Andrew Gvozdev - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.envvar;
import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.internal.core.cdtvariables.DefaultVariableContextInfo;
import org.eclipse.cdt.internal.core.cdtvariables.EnvironmentVariableSupplier;
import org.eclipse.cdt.internal.core.cdtvariables.ICoreVariableContextInfo;
import org.eclipse.cdt.internal.core.envvar.DefaultEnvironmentContextInfo;
import org.eclipse.cdt.internal.core.envvar.EnvVarDescriptor;
import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager;
import org.eclipse.cdt.internal.core.envvar.ICoreEnvironmentVariableSupplier;
import org.eclipse.cdt.internal.core.envvar.IEnvironmentContextInfo;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
import org.eclipse.cdt.utils.cdtvariables.ICdtVariableSupplier;
import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo;
/**
* Helper class to resolve environment variables directly from toolchain. The intention is
* to use that in New Project Wizard scenarios when no configuration is available yet.
*/
public class EnvironmentVariableManagerToolChain extends EnvironmentVariableManager {
private static EnvironmentVariableManagerToolChain fInstance = null;
/**
* Basically, converter from IEnvironmentVariable to ICdtVariable (build macros) which
* is used by EnvironmentVariableManager implementation to resolve variables/macros.
*/
private final class CoreVariableContextInfoToolChain implements ICoreVariableContextInfo {
public final static int CONTEXT_TOOLCHAIN = 1009; // arbitrary value different from ICoreVariableContextInfo.CONTEXT_XXX
private final IToolChain toolChain;
private final IConfigurationEnvironmentVariableSupplier mbsSupplier;
private CoreVariableContextInfoToolChain(IToolChain toolChain) {
this.toolChain = toolChain;
this.mbsSupplier = toolChain.getEnvironmentVariableSupplier();
}
@Override
public ICdtVariableSupplier[] getSuppliers() {
ICdtVariableSupplier sup = new ICdtVariableSupplier() {
@Override
public ICdtVariable getVariable(String macroName, IVariableContextInfo context) {
IEnvironmentVariable var = mbsSupplier.getVariable(macroName, null, ManagedBuildManager.getEnvironmentVariableProvider());
return EnvironmentVariableSupplier.getInstance().createBuildMacro(var);
}
@Override
public ICdtVariable[] getVariables(IVariableContextInfo context) {
IEnvironmentVariable[] vars = mbsSupplier.getVariables(null, ManagedBuildManager.getEnvironmentVariableProvider());
if (vars != null) {
ICdtVariable[] cdtVars = new ICdtVariable[vars.length];
for (int i = 0; i < vars.length; i++) {
cdtVars[i] = EnvironmentVariableSupplier.getInstance().createBuildMacro(vars[i]);
}
}
return null;
}
};
return new ICdtVariableSupplier[] { sup };
}
@Override
public IVariableContextInfo getNext() {
return new DefaultVariableContextInfo(ICoreVariableContextInfo.CONTEXT_WORKSPACE, null);
}
@Override
public int getContextType() {
return CONTEXT_TOOLCHAIN;
}
@Override
public Object getContextData() {
return toolChain;
}
}
private final class EnvironmentContextInfoToolChain implements IEnvironmentContextInfo {
private final IToolChain toolChain;
private EnvironmentContextInfoToolChain(IToolChain toolChain) {
this.toolChain = toolChain;
}
@Override
public IEnvironmentContextInfo getNext() {
return new DefaultEnvironmentContextInfo(null);
}
@Override
public ICoreEnvironmentVariableSupplier[] getSuppliers() {
final IConfigurationEnvironmentVariableSupplier cevSupplier = toolChain.getEnvironmentVariableSupplier();
ICoreEnvironmentVariableSupplier toolchainSupplier = new ICoreEnvironmentVariableSupplier() {
@Override
public IEnvironmentVariable getVariable(String name, Object context) {
IEnvironmentVariableProvider provider = ManagedBuildManager.getEnvironmentVariableProvider();
return cevSupplier.getVariable(name, null, provider);
}
@Override
public IEnvironmentVariable[] getVariables(Object context) {
return cevSupplier.getVariables(null, ManagedBuildManager.getEnvironmentVariableProvider());
}
@Override
public boolean appendEnvironment(Object context) {
// Arbitrary value, it did not appear being used in tested scenarios
return false;
}
};
return new ICoreEnvironmentVariableSupplier[] { EnvironmentVariableManagerToolChain.fUserSupplier, toolchainSupplier };
}
@Override
public Object getContext() {
return toolChain;
}
}
public static EnvironmentVariableManagerToolChain getDefault() {
if (fInstance == null)
fInstance = new EnvironmentVariableManagerToolChain();
return fInstance;
}
@Override
public IEnvironmentContextInfo getContextInfo(Object level) {
if (level instanceof IToolChain) {
return new EnvironmentContextInfoToolChain((IToolChain) level);
}
return super.getContextInfo(level);
}
@Override
protected int getMacroContextTypeFromContext(Object context) {
if (context instanceof IToolChain) {
return CoreVariableContextInfoToolChain.CONTEXT_TOOLCHAIN;
}
return super.getMacroContextTypeFromContext(context);
}
@Override
public ICoreVariableContextInfo getMacroContextInfoForContext(Object context) {
if (context instanceof IToolChain) {
return new CoreVariableContextInfoToolChain((IToolChain) context);
}
return super.getMacroContextInfoForContext(context);
}
/**
* Get environment variable value from toolchain definition.
*
* @param name - name of the variable.
* @param toolChain - toolchain.
* @param resolveMacros - {@code true} to expand macros, {@code false} otherwise.
*
* @return value of the variable.
*/
public IEnvironmentVariable getVariable(String name, IToolChain toolChain, boolean resolveMacros) {
if (name == null || name.isEmpty())
return null;
IEnvironmentContextInfo info = getContextInfo(toolChain);
EnvVarDescriptor var = EnvironmentVariableManagerToolChain.getVariable(name,info,true);
if (var != null && var.getOperation() != IEnvironmentVariable.ENVVAR_REMOVE) {
return resolveMacros ? calculateResolvedVariable(var,info) : var;
}
return null;
}
/**
* Get environment variable value resolved in context of configuration.
* If no configuration available use toolchain definition.
*
* @param name - name of the variable.
* @param toolChain - toolchain.
* @param resolveMacros - {@code true} to expand macros, {@code false} otherwise.
*
* @return value of the variable.
*/
public String getVariableInConfigurationContext(String name, IToolChain toolChain, boolean resolveMacros) {
if (toolChain == null) {
return null;
}
IConfiguration cfg = toolChain.getParent();
ICConfigurationDescription cfgDescription = cfg != null ? ManagedBuildManager.getDescriptionForConfiguration(cfg) : null;
IEnvironmentVariable var = null;
if (cfgDescription != null) {
var = getVariable(name, cfgDescription, resolveMacros);
} else {
var = getVariable(name, toolChain, resolveMacros);
}
String value = var != null ? var.getValue() : null;
return value;
}
}

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2010 Intel Corporation and others. * Copyright (c) 2005, 2013 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -9,6 +9,7 @@
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
* Enrico Ehrich - http://bugs.eclipse.org/233866 * Enrico Ehrich - http://bugs.eclipse.org/233866
* Marc-Andre Laperle - fix for Cygwin GCC is Not detected (bug 303900) * Marc-Andre Laperle - fix for Cygwin GCC is Not detected (bug 303900)
* Andrew Gvozdev - changes to recognize $CYGWIN_HOME
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.gnu.cygwin; package org.eclipse.cdt.managedbuilder.gnu.cygwin;
@ -19,9 +20,8 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.ArrayList; import java.util.ArrayList;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable; import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.internal.core.Cygwin;
import org.eclipse.cdt.managedbuilder.core.IBuildPathResolver; import org.eclipse.cdt.managedbuilder.core.IBuildPathResolver;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
@ -30,40 +30,35 @@ import org.eclipse.cdt.utils.PathUtil;
import org.eclipse.cdt.utils.WindowsRegistry; import org.eclipse.cdt.utils.WindowsRegistry;
import org.eclipse.cdt.utils.spawner.ProcessFactory; import org.eclipse.cdt.utils.spawner.ProcessFactory;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
/** /**
* @noextend This class is not intended to be subclassed by clients. * @noextend This class is not intended to be subclassed by clients.
*/ */
public class CygwinPathResolver implements IBuildPathResolver { public class CygwinPathResolver implements IBuildPathResolver {
private static final String DEFAULT_ROOT = "C:\\cygwin"; //$NON-NLS-1$ private static final String ENV_PATH = "PATH"; //$NON-NLS-1$
private static final String TOOL = "/cygpath -w -p "; //$NON-NLS-1$ private static final String DELIMITER_UNIX = ":"; //$NON-NLS-1$
private static final char BS = '\\'; private static final String DELIMITER_WIN = ";"; //$NON-NLS-1$
private static final char SLASH = '/';
private static final String PROPERTY_OS_NAME = "os.name"; //$NON-NLS-1$ private static final String PROPERTY_OS_NAME = "os.name"; //$NON-NLS-1$
private static final String PROPERTY_OS_VALUE = "windows";//$NON-NLS-1$ private static final String OS_WINDOWS = "windows";//$NON-NLS-1$
private static final String SP = " "; //$NON-NLS-1$ private static final char SLASH = '/';
private static final String REGISTRY_KEY_SETUP = "SOFTWARE\\Cygwin\\setup"; //$NON-NLS-1$ private static final char BACKSLASH = '\\';
private static final String REGISTRY_KEY_SETUP_WIN64 = "SOFTWARE\\Wow6432Node\\Cygwin\\setup"; //$NON-NLS-1$
private static final String CYGPATH_PATH_LIST_TO_WINDOWS = "cygpath -w -p "; //$NON-NLS-1$
// note that in Cygwin 1.7 the mount point storage has been moved out of the registry // note that in Cygwin 1.7 the mount point storage has been moved out of the registry
private static final String REGISTRY_KEY_MOUNTS = "SOFTWARE\\Cygnus Solutions\\Cygwin\\mounts v2\\"; //$NON-NLS-1$ private static final String REGISTRY_KEY_MOUNTS = "SOFTWARE\\Cygnus Solutions\\Cygwin\\mounts v2\\"; //$NON-NLS-1$
private static final String PATH_NAME = "native"; //$NON-NLS-1$ private static final String PATH_NAME = "native"; //$NON-NLS-1$
private static final String SSLASH = "/"; //$NON-NLS-1$
private static final String BSLASH = "\\\\"; //$NON-NLS-1$
private static final String BINPATTERN = "/usr/bin"; //$NON-NLS-1$ private static final String BINPATTERN = "/usr/bin"; //$NON-NLS-1$
private static final String BINPATTERN_ALTERNATE = "/bin"; //$NON-NLS-1$ private static final String BINPATTERN_ALTERNATE = "/bin"; //$NON-NLS-1$
private static final String ETCPATTERN = "/etc"; //$NON-NLS-1$ private static final String ETCPATTERN = "/etc"; //$NON-NLS-1$
private static final String ROOTPATTERN = SSLASH;
private static final String DELIMITER_UNIX = ":"; //$NON-NLS-1$
private static final String DELIMITER_WIN = ";"; //$NON-NLS-1$
private static final String GCC_VERSION_CMD = "gcc --version"; //$NON-NLS-1$ private static final String GCC_VERSION_CMD = "gcc --version"; //$NON-NLS-1$
private static final String MINGW_SPECIAL = "mingw "; //$NON-NLS-1$ private static final String MINGW_SPECIAL = "mingw "; //$NON-NLS-1$
private static final String CYGWIN_SPECIAL = "cygwin "; //$NON-NLS-1$ private static final String CYGWIN_SPECIAL = "cygwin "; //$NON-NLS-1$
private static String envPathValueCached = null;
private static String binCygwin = null;
private static String rootCygwin = null;
private static String etcCygwin = null;
@Override @Override
public String[] resolveBuildPaths(int pathType, String variableName, String variableValue, IConfiguration configuration) { public String[] resolveBuildPaths(int pathType, String variableName, String variableValue, IConfiguration configuration) {
if(!isWindows()) { if(!isWindows()) {
@ -72,58 +67,66 @@ public class CygwinPathResolver implements IBuildPathResolver {
return variableValue.split(DELIMITER_WIN); return variableValue.split(DELIMITER_WIN);
} }
String[] result = variableValue.split(DELIMITER_UNIX); String[] lines = executeInConfigurationContext(CYGPATH_PATH_LIST_TO_WINDOWS + variableValue, configuration);
String exePath = getBinPath();
if (exePath == null) {
return result; // no changes
}
File file = new File(exePath);
if (!file.exists() || !file.isDirectory()) {
return result; // no changes
}
String s = exePath + TOOL + variableValue;
String[] lines = exec(s, configuration);
if (lines != null && lines.length > 0) { if (lines != null && lines.length > 0) {
result = lines[0].replace(BS,SLASH).split(DELIMITER_WIN); String pathList = lines[0].replace(BACKSLASH, SLASH);
return pathList.split(DELIMITER_WIN);
} }
return result;
return variableValue.split(DELIMITER_UNIX);
} }
/** /**
* returns "/etc" path in Windows format * @return "/etc" path in Windows format for workspace.
* @deprecated. Deprecated as of CDT 8.2. Note that Cygwin root path in general may depend on configuration.
* *
* If you use this do not cache results to ensure user preferences are accounted for. * If you use this do not cache results to ensure user preferences are accounted for.
* Please rely on internal caching. * Please rely on internal caching.
*/ */
@Deprecated
public static String getEtcPath() { public static String getEtcPath() {
findPaths(); String etcCygwin = getPathFromRoot(ETCPATTERN);
// Try to find the paths in SOFTWARE\\Cygnus Solutions
if(etcCygwin == null) {
etcCygwin = readValueFromRegistry(REGISTRY_KEY_MOUNTS + ETCPATTERN, PATH_NAME);
}
return etcCygwin; return etcCygwin;
} }
/** /**
* returns "/usr/bin" path in Windows format * @return "/usr/bin" path in Windows format for workspace.
* @deprecated. Deprecated as of CDT 8.2. Note that Cygwin root path in general may depend on configuration.
* *
* If you use this do not cache results to ensure user preferences are accounted for. * If you use this do not cache results to ensure user preferences are accounted for.
* Please rely on internal caching. * Please rely on internal caching.
*/ */
@Deprecated
public static String getBinPath() { public static String getBinPath() {
findPaths(); String binCygwin = getPathFromRoot(BINPATTERN);
if(binCygwin == null) {
binCygwin = getPathFromRoot(BINPATTERN_ALTERNATE);
}
// Try to find the paths in SOFTWARE\\Cygnus Solutions
if(binCygwin == null) {
binCygwin = readValueFromRegistry(REGISTRY_KEY_MOUNTS + BINPATTERN, PATH_NAME);
}
return binCygwin; return binCygwin;
} }
/** /**
* returns Cygwin root ("/") path in Windows format * @return Cygwin root ("/") path in Windows format for workspace.
* @deprecated. Deprecated as of CDT 8.2. Note that Cygwin root path in general may depend on configuration.
* *
* If you use this do not cache results to ensure user preferences are accounted for. * If you use this do not cache results to ensure user preferences are accounted for.
* Please rely on internal caching. * Please rely on internal caching.
*/ */
@Deprecated
public static String getRootPath() { public static String getRootPath() {
findPaths(); return Cygwin.getCygwinHome();
return rootCygwin;
} }
public static boolean isWindows() { public static boolean isWindows() {
return (System.getProperty(PROPERTY_OS_NAME).toLowerCase().startsWith(PROPERTY_OS_VALUE)); return (System.getProperty(PROPERTY_OS_NAME).toLowerCase().startsWith(OS_WINDOWS));
} }
/** /**
@ -136,146 +139,117 @@ public class CygwinPathResolver implements IBuildPathResolver {
*/ */
private static String readValueFromRegistry(String key, String name) { private static String readValueFromRegistry(String key, String name) {
WindowsRegistry registry = WindowsRegistry.getRegistry(); WindowsRegistry registry = WindowsRegistry.getRegistry();
if (null != registry) { if (registry != null) {
String s = registry.getCurrentUserValue(key, name); String value = registry.getCurrentUserValue(key, name);
if(s == null) if (value == null) {
s = registry.getLocalMachineValue(key, name); value = registry.getLocalMachineValue(key, name);
}
if (s != null) if (value != null) {
return (s.replaceAll(BSLASH, SSLASH)); return value.replace(BACKSLASH, SLASH);
}
} }
return null; return null;
} }
/** /**
* Returns the absolute path of the pattern by * Returns the absolute path of the pattern by simply appending the relativePath to the root.
* simply appending the pattern to the root
* *
* @param pattern The pattern to find * @param relativePath - the pattern to find.
* @return The absolute path to the pattern or null if pattern is not found * @return The absolute path to the pattern or {@code null} if path does not exist.
*/ */
private static String getValueFromRoot(String pattern) { private static String getPathFromRoot(String relativePath) {
String rootCygwin = Cygwin.getCygwinHome();
if (rootCygwin != null) { if (rootCygwin != null) {
String path = rootCygwin + pattern; String path = rootCygwin + relativePath;
File file = new File(path); File file = new File(path);
if (file.exists() && file.isDirectory()) if (file.exists() && file.isDirectory()) {
return (path.replaceAll(BSLASH, SSLASH)); return path.replace(BACKSLASH, SLASH);
else }
return null;
} }
return null; return null;
} }
/** /**
* Returns the absolute path to cygwin's root * Resolve and return full path to program in context of configuration.
* *
* @return The absolute path to cygwin's root or null if not found * @param program - program to resolve.
* @param cfg - configuration context.
* @return absolute path to program.
*/ */
private static String findRoot(String paths) { private static String resolveProgram(String program, IConfiguration cfg) {
String rootValue = null; String envPathValue = null;
try {
// 1. Look in PATH values. Look for bin\cygwin1.dll IEnvironmentVariable envPathVar = ManagedBuildManager.getEnvironmentVariableProvider().getVariable(ENV_PATH, cfg, true);
IPath location = PathUtil.findProgramLocation("cygwin1.dll", paths); //$NON-NLS-1$ if (envPathVar != null) {
if (location!=null) { envPathValue = envPathVar.getValue();
rootValue = location.removeLastSegments(2).toOSString(); IPath progPath = PathUtil.findProgramLocation(program, envPathValue);
if (progPath != null) {
program = progPath.toOSString();
} }
// this resolves cygwin symbolic links
// 2. Try to find the root dir in SOFTWARE\Cygwin\setup program = Cygwin.cygwinToWindowsPath(program, envPathValue);
if(rootValue == null) {
rootValue = readValueFromRegistry(REGISTRY_KEY_SETUP, "rootdir"); //$NON-NLS-1$
} }
} catch (Exception e) {
// 3. Try to find the root dir in SOFTWARE\Wow6432Node\Cygwin\setup GnuUIPlugin.getDefault().log(new Status(IStatus.WARNING, GnuUIPlugin.PLUGIN_ID, "Problem trying to find program [" + program + "] in $PATH=[" + envPathValue + "]", e));
if(rootValue == null) {
rootValue = readValueFromRegistry(REGISTRY_KEY_SETUP_WIN64, "rootdir"); //$NON-NLS-1$
} }
return program;
// 4. Try to find the root dir in SOFTWARE\Cygnus Solutions
if (rootValue == null) {
rootValue = readValueFromRegistry(REGISTRY_KEY_MOUNTS + ROOTPATTERN, PATH_NAME);
}
// 5. Try the default Cygwin install dir
if(rootValue == null) {
File file = new File(DEFAULT_ROOT);
if (file.exists() && file.isDirectory())
rootValue = DEFAULT_ROOT;
}
if(rootValue != null)
rootValue = rootValue.replaceAll(BSLASH, SSLASH);
return rootValue;
} }
/** /**
* Finds Cygwin's paths and sets corresponding properties. * Return environment in envp format, see {@link Runtime#exec(String, String[])}.
*
* @param cfg - configuration.
* @return environment as array of strings in format name=value.
*/ */
private static synchronized void findPaths() { private static String[] getEnvp(IConfiguration cfg) {
if (!isWindows()) {
return;
}
IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable("PATH", null, true); //$NON-NLS-1$
String envPathValue = varPath != null ? varPath.getValue() : null;
if (CDataUtil.objectsEqual(envPathValue, envPathValueCached)) {
return;
}
etcCygwin = null;
binCygwin = null;
rootCygwin = null;
rootCygwin = findRoot(envPathValue);
// 1. Try to find the paths by appending the patterns to the root dir
etcCygwin = getValueFromRoot(ETCPATTERN);
binCygwin = getValueFromRoot(BINPATTERN);
if(binCygwin == null)
binCygwin = getValueFromRoot(BINPATTERN_ALTERNATE);
// 2. Try to find the paths in SOFTWARE\\Cygnus Solutions
if(etcCygwin == null)
etcCygwin = readValueFromRegistry(REGISTRY_KEY_MOUNTS + ETCPATTERN, PATH_NAME);
if(binCygwin == null)
binCygwin = readValueFromRegistry(REGISTRY_KEY_MOUNTS + BINPATTERN, PATH_NAME);
envPathValueCached = envPathValue;
}
private static String[] exec(String cmd, IConfiguration cfg) {
try {
IEnvironmentVariable vars[] = ManagedBuildManager.getEnvironmentVariableProvider().getVariables(cfg,true); IEnvironmentVariable vars[] = ManagedBuildManager.getEnvironmentVariableProvider().getVariables(cfg,true);
String env[] = new String[vars.length]; String envp[] = new String[vars.length];
for(int i = 0; i < env.length; i++) { for(int i = 0; i < envp.length; i++) {
env[i] = vars[i].getName() + "="; //$NON-NLS-1$ envp[i] = vars[i].getName() +'=';
String value = vars[i].getValue(); String value = vars[i].getValue();
if(value != null) if(value != null)
env[i] += value; envp[i] += value;
}
return envp;
} }
Process proc = ProcessFactory.getFactory().exec(cmd.split(SP), env);
if (proc != null) {
/**
* Execute command taking in account configuration environment.
*
* @param cmd - command to execute.
* @param cfg - configuration context.
* @return command output as string array.
*/
private static String[] executeInConfigurationContext(String cmd, IConfiguration cfg) {
String[] args = cmd.split(" "); //$NON-NLS-1$
args[0] = resolveProgram(args[0], cfg);
String[] result = null;
try {
String[] envp = getEnvp(cfg);
Process proc = ProcessFactory.getFactory().exec(args, envp);
if (proc != null) {
InputStream ein = proc.getInputStream(); InputStream ein = proc.getInputStream();
try {
BufferedReader d1 = new BufferedReader(new InputStreamReader(ein)); BufferedReader d1 = new BufferedReader(new InputStreamReader(ein));
ArrayList<String> ls = new ArrayList<String>(10); ArrayList<String> ls = new ArrayList<String>(10);
String s; String s;
while ((s = d1.readLine() ) != null ) { while ((s = d1.readLine()) != null ) {
ls.add(s); ls.add(s);
} }
result = ls.toArray(new String[0]);
} finally {
ein.close(); ein.close();
return ls.toArray(new String[0]); }
} }
} catch (IOException e) { } catch (IOException e) {
GnuUIPlugin.getDefault().log(e); GnuUIPlugin.getDefault().log(new Status(IStatus.ERROR, GnuUIPlugin.PLUGIN_ID, "Error executing program [" +cmd + "]", e));
} }
return null; return result;
} }
public static boolean isMinGW(IConfiguration cfg) { public static boolean isMinGW(IConfiguration cfg) {
String versionInfo[] = exec(GCC_VERSION_CMD, cfg); String versionInfo[] = executeInConfigurationContext(GCC_VERSION_CMD, cfg);
if(versionInfo != null) { if(versionInfo != null) {
for(int i = 0; i < versionInfo.length; i++) { for(int i = 0; i < versionInfo.length; i++) {
if(versionInfo[i].indexOf(MINGW_SPECIAL) != -1) if(versionInfo[i].indexOf(MINGW_SPECIAL) != -1)

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2011 Intel Corporation and others. * Copyright (c) 2005, 2012 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,27 +7,32 @@
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
* Andrew Gvozdev - Ability to use different Cygwin versions in different cfg
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.gnu.cygwin; package org.eclipse.cdt.managedbuilder.gnu.cygwin;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.internal.core.Cygwin;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable; import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier; import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider; import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
import org.eclipse.cdt.managedbuilder.internal.envvar.BuildEnvVar; import org.eclipse.cdt.managedbuilder.internal.envvar.BuildEnvVar;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
/** /**
* @noextend This class is not intended to be subclassed by clients. * @noextend This class is not intended to be subclassed by clients.
*/ */
public class GnuCygwinConfigurationEnvironmentSupplier implements IConfigurationEnvironmentVariableSupplier { public class GnuCygwinConfigurationEnvironmentSupplier implements IConfigurationEnvironmentVariableSupplier {
private static final String PATH = "PATH"; //$NON-NLS-1$ private static final String ENV_PATH = "PATH"; //$NON-NLS-1$
private static final String DELIMITER_UNIX = ":"; //$NON-NLS-1$ private static final String ENV_LANG = "LANG"; //$NON-NLS-1$
private static final String PROPERTY_DELIMITER = "path.separator"; //$NON-NLS-1$ private static final String ENV_LC_ALL = "LC_ALL"; //$NON-NLS-1$
private static final String PROPERTY_OSNAME = "os.name"; //$NON-NLS-1$ private static final String ENV_LC_MESSAGES = "LC_MESSAGES"; //$NON-NLS-1$
private static final String LANG = "LANG"; //$NON-NLS-1$ private static final String PROPERTY_OSNAME = "os.name"; //$NON-NLS-1$
private static final String LC_ALL = "LC_ALL"; //$NON-NLS-1$ private static final String BACKSLASH = java.io.File.separator;
private static final String LC_MESSAGES = "LC_MESSAGES"; //$NON-NLS-1$
@Override @Override
public IBuildEnvironmentVariable getVariable(String variableName, IConfiguration configuration, IEnvironmentVariableProvider provider) { public IBuildEnvironmentVariable getVariable(String variableName, IConfiguration configuration, IEnvironmentVariableProvider provider) {
@ -39,19 +44,33 @@ public class GnuCygwinConfigurationEnvironmentSupplier implements IConfiguration
return null; return null;
} }
if (variableName.equalsIgnoreCase(PATH)) { if (variableName.equalsIgnoreCase(ENV_PATH)) {
String p = CygwinPathResolver.getBinPath(); @SuppressWarnings("nls")
if (p != null) { String path = "${" + Cygwin.ENV_CYGWIN_HOME + "}" + BACKSLASH + "bin";
return new BuildEnvVar(PATH, p.replace('/','\\'), IBuildEnvironmentVariable.ENVVAR_PREPEND, System.getProperty(PROPERTY_DELIMITER, DELIMITER_UNIX)); return new BuildEnvVar(ENV_PATH, path, IBuildEnvironmentVariable.ENVVAR_PREPEND);
} else if (variableName.equals(Cygwin.ENV_CYGWIN_HOME)) {
String home = Cygwin.getCygwinHome();
// If the variable is not defined still show it in the environment variables list as a hint to user
if (home == null) {
home = ""; //$NON-NLS-1$
} }
} else if (variableName.equalsIgnoreCase(LANG)) { IPath homePath = new Path(home);
IEnvironmentVariable varCygwinHome = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(Cygwin.ENV_CYGWIN_HOME, null, false);
if (varCygwinHome == null || (!homePath.equals(new Path(varCygwinHome.getValue())))) {
// Contribute if the variable does not already come from workspace environment
return new BuildEnvVar(Cygwin.ENV_CYGWIN_HOME, homePath.toOSString());
}
return null;
} else if (variableName.equalsIgnoreCase(ENV_LANG)) {
// Workaround for not being able to select encoding for CDT console -> change codeset to Latin1 // Workaround for not being able to select encoding for CDT console -> change codeset to Latin1
String langValue = System.getenv(LANG); String langValue = System.getenv(ENV_LANG);
if (langValue == null || langValue.length() == 0) { if (langValue == null || langValue.length() == 0) {
langValue = System.getenv(LC_ALL); langValue = System.getenv(ENV_LC_ALL);
} }
if (langValue == null || langValue.length() == 0) { if (langValue == null || langValue.length() == 0) {
langValue = System.getenv(LC_MESSAGES); langValue = System.getenv(ENV_LC_MESSAGES);
} }
if (langValue != null && langValue.length() > 0) { if (langValue != null && langValue.length() > 0) {
// langValue is [language[_territory][.codeset][@modifier]], i.e. "en_US.UTF-8@dict" // langValue is [language[_territory][.codeset][@modifier]], i.e. "en_US.UTF-8@dict"
@ -61,21 +80,17 @@ public class GnuCygwinConfigurationEnvironmentSupplier implements IConfiguration
} else { } else {
langValue = "C.ISO-8859-1"; //$NON-NLS-1$ langValue = "C.ISO-8859-1"; //$NON-NLS-1$
} }
return new BuildEnvVar(ENV_LANG, langValue);
return new BuildEnvVar(LANG, langValue);
} }
return null; return null;
} }
@Override @Override
public IBuildEnvironmentVariable[] getVariables(IConfiguration configuration, IEnvironmentVariableProvider provider) { public IBuildEnvironmentVariable[] getVariables(IConfiguration configuration, IEnvironmentVariableProvider provider) {
IBuildEnvironmentVariable varLang = getVariable(LANG, configuration, provider); IBuildEnvironmentVariable varHome = getVariable(Cygwin.ENV_CYGWIN_HOME, configuration, provider);
IBuildEnvironmentVariable varPath = getVariable(PATH, configuration, provider); IBuildEnvironmentVariable varLang = getVariable(ENV_LANG, configuration, provider);
IBuildEnvironmentVariable varPath = getVariable(ENV_PATH, configuration, provider);
if (varPath != null) { return new IBuildEnvironmentVariable[] {varHome, varLang, varPath};
return new IBuildEnvironmentVariable[] {varLang, varPath};
} else {
return new IBuildEnvironmentVariable[] {varLang};
}
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2010 Intel Corporation and others. * Copyright (c) 2005, 2013 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,85 +7,28 @@
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
* Andrew Gvozdev - Ability to use different Cygwin versions in different configurations
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.gnu.cygwin; package org.eclipse.cdt.managedbuilder.gnu.cygwin;
import java.io.BufferedReader; import org.eclipse.cdt.internal.core.Cygwin;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.managedbuilder.core.IManagedIsToolChainSupported; import org.eclipse.cdt.managedbuilder.core.IManagedIsToolChainSupported;
import org.eclipse.cdt.managedbuilder.core.IToolChain; import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableManagerToolChain;
import org.osgi.framework.Version; import org.osgi.framework.Version;
/** /**
* This class implements the IManagedIsToolChainSupported for the Gnu Cygwin tool-chain * This class implements the IManagedIsToolChainSupported for the Gnu Cygwin tool-chain
* The class is NOT used currently, because currently the gnu cygwin tool-chain
* is intended to be used not only with Cygwin, but with MinGW also, and there is no
* correct way of determining whether the appropriate packages are installed for MinGW.
*
* For the future MBS/CDT versions we might create the separate tool-chain/configuration/project-type
* for the MinGW and define a set of converters using the tool-chain converter mechanism that MBS will provide,
* that would convert the CygWin to the MinGW projects/tool-chains, and vice a versa.
* *
* @noextend This class is not intended to be subclassed by clients. * @noextend This class is not intended to be subclassed by clients.
*/ */
public class IsGnuCygwinToolChainSupported implements IManagedIsToolChainSupported { public class IsGnuCygwinToolChainSupported implements IManagedIsToolChainSupported {
private static final String[] CHECKED_NAMES = {"gcc", "binutils", "make"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ private static final String ENV_PATH = "PATH"; //$NON-NLS-1$
private static String etcCygwinCached = null;
private static boolean toolchainIsSupported = false;
/**
* @since 8.0
*/
@Override @Override
public boolean isSupported(IToolChain toolChain, Version version, String instance) { public boolean isSupported(IToolChain toolChain, Version version, String instance) {
String etcCygwin = CygwinPathResolver.getEtcPath(); String envPath = EnvironmentVariableManagerToolChain.getDefault().getVariableInConfigurationContext(ENV_PATH, toolChain, true);
if (CDataUtil.objectsEqual(etcCygwin, etcCygwinCached)) { return Cygwin.isAvailable(envPath);
return toolchainIsSupported;
} }
toolchainIsSupported = etcCygwin != null && arePackagesInstalled(etcCygwin);
etcCygwinCached = etcCygwin;
return toolchainIsSupported;
}
/**
* Returns true if all required packages are installed, see CHECKED_NAMES for a list of packages. Cygwin
* maintains a list of packages in /etc/setup/installed.db so we look for packages in this file.
*
* @param etcCygwin the absolute path of /etc containing /setup/installed.db
* @return true if the packages specified in CHECKED_NAMES are installed
*/
private boolean arePackagesInstalled(String etcCygwin) {
boolean arePackagesInstalled = false;
File file = new File(etcCygwin + "/setup/installed.db"); //$NON-NLS-1$
try {
BufferedReader data = new BufferedReader(new FileReader(file));
// All required package names should be found
boolean[] found = new boolean[CHECKED_NAMES.length];
String s;
while ((s = data.readLine()) != null ) {
for (int j = 0; j < CHECKED_NAMES.length; j++) {
if (s.startsWith(CHECKED_NAMES[j])) {
found[j] = true;
}
}
}
arePackagesInstalled = true;
for (int j = 0; j < CHECKED_NAMES.length; j++) {
arePackagesInstalled &= found[j];
}
data.close();
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
return arePackagesInstalled;
}
} }

View file

@ -24,7 +24,7 @@
<configuration> <configuration>
<!-- Need UI harness for quick fix tests --> <!-- Need UI harness for quick fix tests -->
<useUIHarness>true</useUIHarness> <useUIHarness>true</useUIHarness>
<argLine>-Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine> <argLine>-ea -Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
<includes> <includes>
<include>**/AutomatedIntegrationSuite.*</include> <include>**/AutomatedIntegrationSuite.*</include>
</includes> </includes>

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2012 IBM Corporation and others. * Copyright (c) 2005, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -9,6 +9,7 @@
* Devin Steffler (IBM Corporation) - initial API and implementation * Devin Steffler (IBM Corporation) - initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Nathan Ridge
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2; package org.eclipse.cdt.core.parser.tests.ast2;
@ -6060,14 +6061,14 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
BindingAssertionHelper bh= new BindingAssertionHelper(code, true); BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
ICPPTemplateInstance inst; ICPPTemplateInstance inst;
inst= bh.assertNonProblem("f1(v)", 2); inst= bh.assertNonProblem("f1(v)", 2);
assertEquals("<20>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); assertEquals("<int20>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
inst= bh.assertNonProblem("f1<20>(v)", -3); inst= bh.assertNonProblem("f1<20>(v)", -3);
assertEquals("<20>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); assertEquals("<int20>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
bh.assertProblem("f2(v)", 2); bh.assertProblem("f2(v)", 2);
inst= bh.assertNonProblem("f2<10>(v)", -3); inst= bh.assertNonProblem("f2<10>(v)", -3);
assertEquals("<10>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); assertEquals("<int10>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
inst= bh.assertNonProblem("f3(v)", 2); inst= bh.assertNonProblem("f3(v)", 2);
assertEquals("<10>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); assertEquals("<int10>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
} }
// template <int i> class A { }; // template <int i> class A { };
@ -6086,9 +6087,9 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
ICPPTemplateInstance inst; ICPPTemplateInstance inst;
bh.assertProblem("g(a1)", 1); bh.assertProblem("g(a1)", 1);
inst= bh.assertNonProblem("g<0>(a1)", -4); inst= bh.assertNonProblem("g<0>(a1)", -4);
assertEquals("<0>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); assertEquals("<int0>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
inst= bh.assertNonProblem("f(a1, a2)", 1); inst= bh.assertNonProblem("f(a1, a2)", 1);
assertEquals("<1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); assertEquals("<int1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
} }
// template<typename T> class A { // template<typename T> class A {
@ -6134,9 +6135,9 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
ICPPTemplateInstance inst; ICPPTemplateInstance inst;
bh.assertProblem("f(a)", 1); bh.assertProblem("f(a)", 1);
inst= bh.assertNonProblem("f<1>(a)", -3); inst= bh.assertNonProblem("f<1>(a)", -3);
assertEquals("<1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); assertEquals("<short int1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
inst= bh.assertNonProblem("g(b)", 1); inst= bh.assertNonProblem("g(b)", 1);
assertEquals("<1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); assertEquals("<short int1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
} }
// template<class T> void f(void(*)(T,int)); // template<class T> void f(void(*)(T,int));

View file

@ -13,6 +13,7 @@
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Thomas Corbat (IFS) * Thomas Corbat (IFS)
* Nathan Ridge * Nathan Ridge
* Marc-Andre Laperle
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2; package org.eclipse.cdt.core.parser.tests.ast2;
@ -128,6 +129,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable; import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethod; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethod;
@ -7481,6 +7483,14 @@ public class AST2CPPTests extends AST2TestBase {
ba.assertProblem("enum_name", 9); ba.assertProblem("enum_name", 9);
} }
// struct MyStruct {
// enum MyEnum {};
// MyStruct(MyEnum value) {}
// };
public void testEnumRedefinitionInStruct_385144() throws Exception {
parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP);
}
// class CL { // class CL {
// typedef int x; // typedef int x;
// friend void test() { // friend void test() {
@ -10125,4 +10135,64 @@ public class AST2CPPTests extends AST2TestBase {
parseAndCheckBindings(getAboveComment(), CPP, true); parseAndCheckBindings(getAboveComment(), CPP, true);
} }
// template <typename T>
// T bar();
// struct S {
// void waldo();
// };
// int main() {
// auto L = [](S s) { return s; };
// typedef decltype(L) lambda_type;
// decltype(bar<const lambda_type>()(S())) v;
// v.waldo();
// }
public void testDecltypeWithConstantLambda_397494() throws Exception {
parseAndCheckBindings();
}
// template <bool>
// struct enable_if {
// };
// template <>
// struct enable_if<true> {
// typedef void type;
// };
// struct base {};
// struct derived : base {};
// typedef enable_if<__is_base_of(base, derived)>::type T;
public void testIsBaseOf_399353() throws Exception {
parseAndCheckBindings(getAboveComment(), CPP, true);
}
// template <bool> struct B{};
// template <>
// struct B<true> {
// void waldo();
// };
// typedef char& one;
// int main() {
// B<sizeof(one) == 1> b;
// b.waldo();
// }
public void testSizeofReference_397342() throws Exception {
parseAndCheckBindings();
}
// struct A {
// char a[100];
// };
// struct B {
// A& b;
// };
// A* p;
public void testSizeofStructWithReferenceField_397342() throws Exception {
BindingAssertionHelper bh = getAssertionHelper();
IASTName nameB = bh.findName("B");
IASTName namep = bh.findName("p");
ICPPClassType B = (ICPPClassType) nameB.resolveBinding();
IPointerType ptrToA = (IPointerType) ((ICPPVariable) namep.resolveBinding()).getType();
long pointerSize = SizeofCalculator.getSizeAndAlignment(ptrToA, namep).size;
long BSize = SizeofCalculator.getSizeAndAlignment(B, nameB).size;
assertEquals(pointerSize, BSize);
}
} }

View file

@ -4405,6 +4405,17 @@ public class AST2TemplateTests extends AST2TestBase {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// template <typename A>
// void foo(A);
// template <typename A, typename... B>
// void foo(A, B...);
// int main() {
// foo(0);
// }
public void testFunctionTemplatePartialOrdering_388805() throws Exception {
parseAndCheckBindings();
}
// template<typename T> class CT {}; // template<typename T> class CT {};
// template<int I> class CTI {}; // template<int I> class CTI {};
// //
@ -4830,6 +4841,25 @@ public class AST2TemplateTests extends AST2TestBase {
ub= bh.assertNonProblem("f(h(args...) + args...)", 1); ub= bh.assertNonProblem("f(h(args...) + args...)", 1);
} }
// template <typename... Args>
// struct contains_waldo;
// template <>
// struct contains_waldo<> {
// static const bool value = false;
// };
// template <typename First, typename... Rest>
// struct contains_waldo<First, Rest...> {
// static const bool value = contains_waldo<Rest...>::value;
// };
// int main() {
// bool b1 = contains_waldo<int>::value;
// bool b2 = contains_waldo<int, int>::value;
// bool b2 = contains_waldo<int, int, int>::value;
// }
public void testRecursiveVariadicTemplate_397828() throws Exception {
parseAndCheckBindings();
}
// struct Test { // struct Test {
// void Update() {} // void Update() {}
// }; // };
@ -7021,7 +7051,7 @@ public class AST2TemplateTests extends AST2TestBase {
// void test() { // void test() {
// int x = C<bool>::id; // int x = C<bool>::id;
// } // }
public void _testDependentEnumValue_389009() throws Exception { public void testDependentEnumValue_389009() throws Exception {
BindingAssertionHelper ah = getAssertionHelper(); BindingAssertionHelper ah = getAssertionHelper();
IEnumerator binding = ah.assertNonProblem("C<bool>::id", "id"); IEnumerator binding = ah.assertNonProblem("C<bool>::id", "id");
IValue value = binding.getValue(); IValue value = binding.getValue();
@ -7029,4 +7059,110 @@ public class AST2TemplateTests extends AST2TestBase {
assertNotNull(num); assertNotNull(num);
assertEquals(1, num.longValue()); assertEquals(1, num.longValue());
} }
// template <int...> struct A {};
// template <int... I> void foo(A<I...>);
// int main() {
// foo(A<0>());
// }
public void testVariadicNonTypeTemplateParameter_382074() throws Exception {
parseAndCheckBindings();
}
// template <bool...>
// struct ice_or {
// static const bool value = false;
// };
// template <typename T>
// struct is_foo {
// static const bool value = false;
// };
// template <typename... Args>
// struct contains_foo {
// static const bool value = ice_or<is_foo<Args>::value...>::value;
// };
// template <bool>
// struct meta;
// struct S { void bar(); };
// template <>
// struct meta<false> {
// typedef S type;
// };
// int main() {
// meta<contains_foo<>::value>::type t;
// t.bar();
// }
public void testVariadicNonTypeTemplateParameter_399039() throws Exception {
parseAndCheckBindings();
}
// template <typename...>
// struct common_type;
// template <typename T>
// struct common_type<T> {
// typedef int type;
// };
// template <typename T, typename... U>
// struct common_type<T, U...> {
// typedef int type;
// };
// typedef common_type<int>::type type;
public void testClassTemplateSpecializationPartialOrdering_398044a() throws Exception {
parseAndCheckBindings();
}
// template <typename>
// class A;
// template <typename R, typename... Args>
// class A<R(*)(Args...)> {
// };
// template <typename R>
// class A<R*> {
// };
// int main() {
// A<bool(*)()> mf;
// }
public void testClassTemplateSpecializationPartialOrdering_398044b() throws Exception {
parseAndCheckBindings();
}
// template <typename>
// struct meta {
// static const bool value = 1;
// };
// template <bool>
// struct enable_if {};
// template <>
// struct enable_if<true> {
// typedef void type;
// };
// template <class T>
// struct pair {
// template <typename = typename enable_if<meta<T>::value>::type>
// pair(int);
// };
// void push_back(pair<long>&&);
// void push_back(const pair<long>&);
// void test() {
// push_back(0);
// }
public void testRegression_399142() throws Exception {
parseAndCheckBindings();
}
// template <class T>
// struct A {
// struct impl {
// static T x;
// };
// static const int value = sizeof(impl::x);
// };
// template <int> struct W {};
// template <> struct W<1> { typedef int type; };
// int main() {
// W<A<char>::value>::type w;
// }
public void testDependentExpressionInvolvingFieldInNestedClass_399362() throws Exception {
parseAndCheckBindings();
}
} }

View file

@ -110,6 +110,7 @@ public class AST2TestBase extends BaseTestCase {
map.put("__SIZEOF_SHORT__", "2"); map.put("__SIZEOF_SHORT__", "2");
map.put("__SIZEOF_INT__", "4"); map.put("__SIZEOF_INT__", "4");
map.put("__SIZEOF_LONG__", "8"); map.put("__SIZEOF_LONG__", "8");
map.put("__SIZEOF_POINTER__", "8");
return map; return map;
} }
@ -118,6 +119,7 @@ public class AST2TestBase extends BaseTestCase {
map.put("__SIZEOF_SHORT__", "2"); map.put("__SIZEOF_SHORT__", "2");
map.put("__SIZEOF_INT__", "4"); map.put("__SIZEOF_INT__", "4");
map.put("__SIZEOF_LONG__", "8"); map.put("__SIZEOF_LONG__", "8");
map.put("__SIZEOF_POINTER__", "8");
return map; return map;
} }

View file

@ -57,9 +57,11 @@ import org.eclipse.cdt.core.dom.ast.IASTInitializer;
import org.eclipse.cdt.core.dom.ast.IASTInitializerList; import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement; import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression; import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IASTMacroExpansionLocation;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
import org.eclipse.cdt.core.dom.ast.IASTNullStatement; import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator; import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
@ -7426,4 +7428,29 @@ public class AST2Tests extends AST2TestBase {
public void testNoRawStringInPlainC_397127() throws Exception { public void testNoRawStringInPlainC_397127() throws Exception {
parseAndCheckBindings(getAboveComment(), C, true); parseAndCheckBindings(getAboveComment(), C, true);
} }
// #define X
// int a=X-1;X
public void testMacroReferences_399394() throws Exception {
IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment());
assertEquals(2, countMacroRefs(tu));
IASTSimpleDeclaration decl= getDeclaration(tu, 0);
assertEquals(1, countMacroRefs(decl));
IASTEqualsInitializer init= (IASTEqualsInitializer) decl.getDeclarators()[0].getInitializer();
assertEquals(1, countMacroRefs(init));
IASTUnaryExpression expr= (IASTUnaryExpression) init.getInitializerClause();
assertEquals(0, countMacroRefs(expr));
}
private int countMacroRefs(IASTNode node) {
int count = 0;
for (IASTNodeLocation loc : node.getNodeLocations()) {
if (loc instanceof IASTMacroExpansionLocation)
count++;
}
return count;
}
} }

View file

@ -23,12 +23,14 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBasicType; import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.ITypedef;
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.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
@ -2063,6 +2065,27 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
checkBindings(); checkBindings();
} }
// template <typename T>
// struct B {
// enum { value = 1 };
// };
//
// template <typename T>
// struct C {
// enum { id = B<T>::value };
// };
// void test() {
// int x = C<bool>::id;
// }
public void testDependentEnumValue_389009() throws Exception {
IEnumerator binding = getBindingFromASTName("id;", 2, IEnumerator.class);
IValue value = binding.getValue();
Long num = value.numericalValue();
assertNotNull(num);
assertEquals(1, num.longValue());
}
// template<typename U> // template<typename U>
// struct A { // struct A {
// typedef U type1; // typedef U type1;

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2012 Symbian Software Systems and others. * Copyright (c) 2007, 2013 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,13 +7,13 @@
* *
* Contributors: * Contributors:
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
* Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.index.tests; package org.eclipse.cdt.internal.index.tests;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -46,6 +46,56 @@ import org.eclipse.core.runtime.Path;
* Tests the behavior of the IIndex API when dealing with multiple projects * Tests the behavior of the IIndex API when dealing with multiple projects
*/ */
public class IndexCompositeTests extends BaseTestCase { public class IndexCompositeTests extends BaseTestCase {
/*
* Convenience class for setting up projects.
*/
private static class ProjectBuilder {
private final String name;
private final boolean cpp;
private List<IProject> dependencies = new ArrayList<IProject>();
private Map<String, String> path2content = new HashMap<String, String>();
ProjectBuilder(String name, boolean cpp) {
this.name = name;
this.cpp = cpp;
}
ProjectBuilder addDependency(IProject project) {
dependencies.add(project);
return this;
}
ProjectBuilder addFile(String relativePath, CharSequence content) {
path2content.put(relativePath, content.toString());
return this;
}
ICProject create() throws Exception {
ICProject result = cpp ?
CProjectHelper.createCCProject(name, "bin", IPDOMManager.ID_NO_INDEXER) :
CProjectHelper.createCProject(name, "bin", IPDOMManager.ID_NO_INDEXER);
IFile lastFile= null;
for (Map.Entry<String, String> entry : path2content.entrySet()) {
lastFile= TestSourceReader.createFile(result.getProject(), new Path(entry.getKey()), entry.getValue());
}
IProjectDescription desc = result.getProject().getDescription();
desc.setReferencedProjects(dependencies.toArray(new IProject[dependencies.size()]));
result.getProject().setDescription(desc, new NullProgressMonitor());
IIndexManager indexManager = CCorePlugin.getIndexManager();
indexManager.setIndexerId(result, IPDOMManager.ID_FAST_INDEXER);
if (lastFile != null) {
// Call reindex explicitly since setting indexer ID doesn't trigger reindexing.
indexManager.reindex(result);
IIndex index= indexManager.getIndex(result);
TestSourceReader.waitUntilFileIsIndexed(index, lastFile, INDEXER_TIMEOUT_SEC * 1000);
}
BaseTestCase.waitForIndexer(result);
return result;
}
}
public static Test suite() { public static Test suite() {
return suite(IndexCompositeTests.class); return suite(IndexCompositeTests.class);
@ -101,10 +151,11 @@ public class IndexCompositeTests extends BaseTestCase {
setIndex(cprojA, REFD); assertBCount(1, 1); setIndex(cprojA, REFD); assertBCount(1, 1);
setIndex(cprojA, BOTH); assertBCount(2, 2); setIndex(cprojA, BOTH); assertBCount(2, 2);
} finally { } finally {
for (ICProject project : projects) for (ICProject project : projects) {
project.getProject().delete(true, true, new NullProgressMonitor()); project.getProject().delete(true, true, new NullProgressMonitor());
} }
} }
}
// class C1 {public: int i;}; // class C1 {public: int i;};
// namespace X { class C2 {}; } // namespace X { class C2 {}; }
@ -175,7 +226,6 @@ public class IndexCompositeTests extends BaseTestCase {
assertNamespaceXMemberCount(5); assertNamespaceXMemberCount(5);
assertFieldCount("C1", 1); assertFieldCount("C1", 1);
setIndex(cprojB, NONE); setIndex(cprojB, NONE);
assertBCount(gBC, aBC); assertBCount(gBC, aBC);
assertNamespaceXMemberCount(2); assertNamespaceXMemberCount(2);
@ -196,7 +246,6 @@ public class IndexCompositeTests extends BaseTestCase {
assertNamespaceXMemberCount(5); assertNamespaceXMemberCount(5);
assertFieldCount("C1", 1); assertFieldCount("C1", 1);
setIndex(cprojA, NONE); setIndex(cprojA, NONE);
assertBCount(gABC, aABC); assertBCount(gABC, aABC);
assertNamespaceXMemberCount(5); assertNamespaceXMemberCount(5);
@ -217,10 +266,11 @@ public class IndexCompositeTests extends BaseTestCase {
assertNamespaceXMemberCount(5); assertNamespaceXMemberCount(5);
assertFieldCount("C1", 1); assertFieldCount("C1", 1);
} finally { } finally {
for (ICProject project : projects) for (ICProject project : projects) {
project.getProject().delete(true, true, new NullProgressMonitor()); project.getProject().delete(true, true, new NullProgressMonitor());
} }
} }
}
// class B1 {}; // class B1 {};
// namespace X { class B2 {}; } // namespace X { class B2 {}; }
@ -259,7 +309,6 @@ public class IndexCompositeTests extends BaseTestCase {
ICProject cprojC = pb.create(); ICProject cprojC = pb.create();
projects.add(cprojC); projects.add(cprojC);
/* A C | /* A C |
* \ / | Depends On / References * \ / | Depends On / References
* B V * B V
@ -278,7 +327,6 @@ public class IndexCompositeTests extends BaseTestCase {
final int gAB= gA + gB - 1, aAB= aA + aB - 1; final int gAB= gA + gB - 1, aAB= aA + aB - 1;
final int gABC= gA + gBC - 1, aABC= aA + aBC - 1; final int gABC= gA + gBC - 1, aABC= aA + aBC - 1;
setIndex(cprojC, NONE); setIndex(cprojC, NONE);
assertBCount(gBC, aBC); assertBCount(gBC, aBC);
assertNamespaceXMemberCount(3); assertNamespaceXMemberCount(3);
@ -318,10 +366,11 @@ public class IndexCompositeTests extends BaseTestCase {
assertBCount(gABC, aABC); assertBCount(gABC, aABC);
assertNamespaceXMemberCount(4); assertNamespaceXMemberCount(4);
} finally { } finally {
for (ICProject project : projects) for (ICProject project : projects) {
project.getProject().delete(true, true, new NullProgressMonitor()); project.getProject().delete(true, true, new NullProgressMonitor());
} }
} }
}
// class C1 {}; // class C1 {};
// namespace X { class C2 {}; } // namespace X { class C2 {}; }
@ -415,10 +464,11 @@ public class IndexCompositeTests extends BaseTestCase {
assertBCount(gABC, aABC); assertBCount(gABC, aABC);
assertNamespaceXMemberCount(4); assertNamespaceXMemberCount(4);
} finally { } finally {
for (ICProject project : projects) for (ICProject project : projects) {
project.getProject().delete(true, true, new NullProgressMonitor()); project.getProject().delete(true, true, new NullProgressMonitor());
} }
} }
}
/** /**
* Asserts binding counts, and returns the index tested against * Asserts binding counts, and returns the index tested against
@ -438,13 +488,13 @@ public class IndexCompositeTests extends BaseTestCase {
private void assertNamespaceXMemberCount(int count) throws CoreException, DOMException { private void assertNamespaceXMemberCount(int count) throws CoreException, DOMException {
IBinding[] bindings = index.findBindings(Pattern.compile("X"), true, FILTER, new NullProgressMonitor()); IBinding[] bindings = index.findBindings(Pattern.compile("X"), true, FILTER, new NullProgressMonitor());
assertEquals(1, bindings.length); assertEquals(1, bindings.length);
assertEquals(count, ((ICPPNamespace)bindings[0]).getMemberBindings().length); assertEquals(count, ((ICPPNamespace) bindings[0]).getMemberBindings().length);
} }
private void assertFieldCount(String qnPattern, int count) throws CoreException, DOMException { private void assertFieldCount(String qnPattern, int count) throws CoreException, DOMException {
IBinding[] bindings = index.findBindings(Pattern.compile(qnPattern), true, FILTER, new NullProgressMonitor()); IBinding[] bindings = index.findBindings(Pattern.compile(qnPattern), true, FILTER, new NullProgressMonitor());
assertEquals(1, bindings.length); assertEquals(1, bindings.length);
assertEquals(count, ((ICompositeType)bindings[0]).getFields().length); assertEquals(count, ((ICompositeType) bindings[0]).getFields().length);
} }
private void setIndex(ICProject project, int options) throws CoreException, InterruptedException { private void setIndex(ICProject project, int options) throws CoreException, InterruptedException {
@ -463,53 +513,3 @@ public class IndexCompositeTests extends BaseTestCase {
super.tearDown(); super.tearDown();
} }
} }
/*
* Convenience class for setting up projects.
*/
class ProjectBuilder {
private static final int INDEXER_TIMEOUT_SEC = 10;
private final String name;
private final boolean cpp;
private List dependencies = new ArrayList();
private Map path2content = new HashMap();
ProjectBuilder(String name, boolean cpp) {
this.name = name;
this.cpp = cpp;
}
ProjectBuilder addDependency(IProject project) {
dependencies.add(project);
return this;
}
ProjectBuilder addFile(String relativePath, CharSequence content) {
path2content.put(relativePath, content.toString());
return this;
}
ICProject create() throws Exception {
ICProject result = cpp ?
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();
lastFile= TestSourceReader.createFile(result.getProject(), new Path((String)entry.getKey()), (String) entry.getValue());
}
IProjectDescription desc = result.getProject().getDescription();
desc.setReferencedProjects((IProject[]) dependencies.toArray(new IProject[dependencies.size()]));
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, INDEXER_TIMEOUT_SEC * 1000);
}
BaseTestCase.waitForIndexer(result);
return result;
}
}

View file

@ -240,7 +240,8 @@ public class IndexUpdateTests extends IndexTestBase {
for (int i = 0; i < nchars.length; i++) { for (int i = 0; i < nchars.length; i++) {
nchars[i]= names[i].toCharArray(); nchars[i]= names[i].toCharArray();
} }
return fIndex.findBindings(nchars, IndexFilter.ALL_DECLARED, npm())[0]; IIndexBinding[] bindings = fIndex.findBindings(nchars, IndexFilter.ALL_DECLARED, npm());
return bindings.length > 0 ? bindings[0] : null;
} }
private String msg() { private String msg() {
@ -256,7 +257,6 @@ public class IndexUpdateTests extends IndexTestBase {
// short globalVar; // short globalVar;
// register int globalVar; // register int globalVar;
public void testGlobalCppVariable() throws Exception { public void testGlobalCppVariable() throws Exception {
setupFile(3, true); setupFile(3, true);
checkCppVariable("globalVar", INT, new String[]{}); checkCppVariable("globalVar", INT, new String[]{});
@ -345,7 +345,6 @@ public class IndexUpdateTests extends IndexTestBase {
// struct my_struct {int fField;}; // struct my_struct {int fField;};
// struct my_struct {short fField;}; // struct my_struct {short fField;};
public void testCField() throws Exception { public void testCField() throws Exception {
setupFile(2, false); setupFile(2, false);
checkVariable("my_struct::fField", INT, new String[]{}); checkVariable("my_struct::fField", INT, new String[]{});
@ -402,7 +401,6 @@ public class IndexUpdateTests extends IndexTestBase {
checkModifier(modifiers, PRIVATE, visibility == ICPPMember.v_private); checkModifier(modifiers, PRIVATE, visibility == ICPPMember.v_private);
} }
// class MyClass {int method(int a, int b);}; // class MyClass {int method(int a, int b);};
// class MyClass {short method(int a, int b);}; // class MyClass {short method(int a, int b);};
@ -422,7 +420,6 @@ public class IndexUpdateTests extends IndexTestBase {
// class MyClass {int method(char a){};}; // class MyClass {int method(char a){};};
// class MyClass {virtual int method(char a) = 0;}; // class MyClass {virtual int method(char a) = 0;};
public void testCppMethod() throws Exception { public void testCppMethod() throws Exception {
setupFile(10, true); setupFile(10, true);
checkCppMethod("MyClass::method", new String[] {INT, INT, INT}, new String[]{PRIVATE}); checkCppMethod("MyClass::method", new String[] {INT, INT, INT}, new String[]{PRIVATE});
@ -453,7 +450,6 @@ public class IndexUpdateTests extends IndexTestBase {
// #include "header.h" // #include "header.h"
// char MyClass::method(int a, int b); // char MyClass::method(int a, int b);
public void testFixedCppMethod() throws Exception { public void testFixedCppMethod() throws Exception {
setupHeader(3, true); setupHeader(3, true);
checkCppMethod("MyClass::method", new String[] {INT, INT, INT}, new String[]{PROTECTED}); checkCppMethod("MyClass::method", new String[] {INT, INT, INT}, new String[]{PROTECTED});
@ -493,7 +489,6 @@ public class IndexUpdateTests extends IndexTestBase {
// class MyClass {protected: MyClass(char a, int b);}; // class MyClass {protected: MyClass(char a, int b);};
// class MyClass {private: MyClass(char a, int b);}; // class MyClass {private: MyClass(char a, int b);};
public void testCppConstructor() throws Exception { public void testCppConstructor() throws Exception {
setupFile(6, true); setupFile(6, true);
checkCppConstructor("MyClass::MyClass", new String[] {"", INT, INT}, new String[]{PRIVATE}); checkCppConstructor("MyClass::MyClass", new String[] {"", INT, INT}, new String[]{PRIVATE});
@ -587,7 +582,8 @@ public class IndexUpdateTests extends IndexTestBase {
} }
checkCppConstructor((ICPPConstructor) ctors[0], new String[]{"", constRefType}, m2); checkCppConstructor((ICPPConstructor) ctors[0], new String[]{"", constRefType}, m2);
IIndexBinding[] assignmentOps= fIndex.findBindings(new char[][]{nchars, "operator =".toCharArray()}, IndexFilter.ALL_DECLARED_OR_IMPLICIT, npm()); IIndexBinding[] assignmentOps= fIndex.findBindings(
new char[][] {nchars, "operator =".toCharArray() }, IndexFilter.ALL_DECLARED_OR_IMPLICIT, npm());
count= 0; count= 0;
for (int i = 0; i < assignmentOps.length; i++) { for (int i = 0; i < assignmentOps.length; i++) {
IIndexBinding assignmentOp= assignmentOps[i]; IIndexBinding assignmentOp= assignmentOps[i];
@ -717,7 +713,6 @@ public class IndexUpdateTests extends IndexTestBase {
} }
} }
// class myType { // class myType {
// int a; // int a;
// }; // };
@ -1183,7 +1178,6 @@ public class IndexUpdateTests extends IndexTestBase {
} }
} }
// void funcTypeDeletion(int); // void funcTypeDeletion(int);
// #include "header.h" // #include "header.h"

View file

@ -32,7 +32,7 @@
<version>${tycho-version}</version> <version>${tycho-version}</version>
<configuration> <configuration>
<useUIHarness>false</useUIHarness> <useUIHarness>false</useUIHarness>
<argLine>-Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine> <argLine>-ea -Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
<includes> <includes>
<include>**/AutomatedIntegrationSuite.*</include> <include>**/AutomatedIntegrationSuite.*</include>
</includes> </includes>

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2011 Andrew Gvozdev and others. * Copyright (c) 2009, 2013 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -23,6 +23,8 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.internal.core.LocalProjectScope; import org.eclipse.cdt.internal.core.LocalProjectScope;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsExtensionManager; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsExtensionManager;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer;
import org.eclipse.cdt.internal.core.language.settings.providers.ScannerInfoExtensionLanguageSettingsProvider;
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.core.runtime.preferences.InstanceScope;
import org.osgi.service.prefs.BackingStoreException; import org.osgi.service.prefs.BackingStoreException;
@ -42,6 +44,8 @@ public class ScannerDiscoveryLegacySupport {
public static final String USER_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.ui.UserLanguageSettingsProvider"; //$NON-NLS-1$ public static final String USER_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.ui.UserLanguageSettingsProvider"; //$NON-NLS-1$
/** ID of MBS language settings provider (from org.eclipse.cdt.managedbuilder.core) */ /** ID of MBS language settings provider (from org.eclipse.cdt.managedbuilder.core) */
public static final String MBS_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider"; //$NON-NLS-1$ public static final String MBS_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider"; //$NON-NLS-1$
/** ID of ScannerInfo language settings provider wrapping ScannerInfoProvider defined by org.eclipse.cdt.core.ScannerInfoProvider extension point */
private static final String SI_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.core.LegacyScannerInfoLanguageSettingsProvider"; //$NON-NLS-1$
private static String DISABLE_LSP_PREFERENCE = "language.settings.providers.disabled"; //$NON-NLS-1$ private static String DISABLE_LSP_PREFERENCE = "language.settings.providers.disabled"; //$NON-NLS-1$
// the default for project needs to be "disabled" - for legacy projects to be open with old SD enabled for MBS provider // the default for project needs to be "disabled" - for legacy projects to be open with old SD enabled for MBS provider
@ -156,15 +160,60 @@ public class ScannerDiscoveryLegacySupport {
} }
/** /**
* Return list containing MBS and User provider. Used to initialize for unaware tool-chains (backward compatibility). * Return list containing User provider and one of wrapper providers to support legacy projects (backward compatibility).
*
* @noreference This is internal helper method to support compatibility with previous versions
* which is not intended to be referenced by clients.
* @since 5.5
*/
public static String[] getDefaultProviderIdsLegacy(ICConfigurationDescription cfgDescription) {
boolean useScannerInfoProviderExtension = new ScannerInfoExtensionLanguageSettingsProvider().getScannerInfoProvider(cfgDescription) != null;
if (useScannerInfoProviderExtension) {
return new String[] {USER_LANGUAGE_SETTINGS_PROVIDER_ID, SI_LANGUAGE_SETTINGS_PROVIDER_ID};
}
if (CProjectDescriptionManager.getInstance().isNewStyleCfg(cfgDescription)) {
return new String[] {USER_LANGUAGE_SETTINGS_PROVIDER_ID, MBS_LANGUAGE_SETTINGS_PROVIDER_ID};
}
return null;
}
/**
* Checks if the provider is applicable for configuration from backward compatibility point of view
*
* @noreference This is internal helper method to support compatibility with previous versions
* which is not intended to be referenced by clients.
* @since 5.5
*/
public static boolean isProviderCompatible(String providerId, ICConfigurationDescription cfgDescription) {
if (cfgDescription != null) {
boolean useScannerInfoProviderExtension = new ScannerInfoExtensionLanguageSettingsProvider().getScannerInfoProvider(cfgDescription) != null;
if (SI_LANGUAGE_SETTINGS_PROVIDER_ID.equals(providerId)) {
return useScannerInfoProviderExtension;
}
if (MBS_LANGUAGE_SETTINGS_PROVIDER_ID.equals(providerId)) {
boolean isNewStyleCfg = CProjectDescriptionManager.getInstance().isNewStyleCfg(cfgDescription);
return !useScannerInfoProviderExtension && isNewStyleCfg;
}
}
return true;
}
/**
* Return list containing User and MBS providers. Used to initialize older MBS tool-chains (backward compatibility).
*
* @noreference This is internal helper method to support compatibility with previous versions
* which is not intended to be referenced by clients.
*/ */
public static List<ILanguageSettingsProvider> getDefaultProvidersLegacy() { public static List<ILanguageSettingsProvider> getDefaultProvidersLegacy() {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(2); List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(2);
ILanguageSettingsProvider provider = LanguageSettingsExtensionManager.getExtensionProviderCopy((ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID), false); ILanguageSettingsProvider provider = LanguageSettingsExtensionManager.getExtensionProviderCopy((USER_LANGUAGE_SETTINGS_PROVIDER_ID), false);
if (provider != null) { if (provider != null) {
providers.add(provider); providers.add(provider);
} }
providers.add(LanguageSettingsProvidersSerializer.getWorkspaceProvider(ScannerDiscoveryLegacySupport.MBS_LANGUAGE_SETTINGS_PROVIDER_ID)); providers.add(LanguageSettingsProvidersSerializer.getWorkspaceProvider(MBS_LANGUAGE_SETTINGS_PROVIDER_ID));
return providers; return providers;
} }

View file

@ -20,6 +20,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CProjectNature; import org.eclipse.cdt.core.CProjectNature;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.core.resources.IPathEntryStore; import org.eclipse.cdt.core.resources.IPathEntryStore;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSetting; import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
@ -1253,11 +1254,12 @@ public class CoreModel {
if(des != null){ if(des != null){
ICConfigurationDescription indexCfg = des.getDefaultSettingConfiguration(); ICConfigurationDescription indexCfg = des.getDefaultSettingConfiguration();
if(indexCfg != null){ if(indexCfg != null){
if(!mngr.isNewStyleCfg(indexCfg)){ if (!mngr.isNewStyleCfg(indexCfg)) {
return oldIsScannerInformationEmpty(resource); return oldIsScannerInformationEmpty(resource);
} }
if (indexCfg instanceof ILanguageSettingsProvidersKeeper) { if (ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(project) &&
indexCfg instanceof ILanguageSettingsProvidersKeeper) {
List<String> languageIds = LanguageSettingsManager.getLanguages(resource, indexCfg); List<String> languageIds = LanguageSettingsManager.getLanguages(resource, indexCfg);
for (String langId : languageIds) { for (String langId : languageIds) {
List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(indexCfg, resource, langId, List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(indexCfg, resource, langId,

View file

@ -38,7 +38,8 @@ public interface ICSettingEntry {
/** /**
* Flag {@code LOCAL} is used during creation of {@link IIncludeEntry} * Flag {@code LOCAL} is used during creation of {@link IIncludeEntry}
* to indicate that an include path is not a system path. * to indicate that an include path is not a system path.
* It does not appear it is used anywhere else. * "System" path is denoted by angle brackets as in #include <x.h>
* "Local" path is denoted by quotes as in #include "x.h"
*/ */
int LOCAL = 1 << 2; int LOCAL = 1 << 2;

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2011 Andrew Gvozdev and others. * Copyright (c) 2009, 2013 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -82,7 +82,7 @@ public class LanguageSettingsProvidersSerializer {
public static final String JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE = "CDT_JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE"; //$NON-NLS-1$ public static final String JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE = "CDT_JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE"; //$NON-NLS-1$
private static final String PREFERENCE_WORSPACE_PROVIDERS_SET = "language.settings.providers.workspace.prefs.toggle"; //$NON-NLS-1$ private static final String PREFERENCE_WORSPACE_PROVIDERS_SET = "language.settings.providers.workspace.prefs.toggle"; //$NON-NLS-1$
private static final String CPROJECT_STORAGE_MODULE = "org.eclipse.cdt.core.LanguageSettingsProviders"; //$NON-NLS-1$ private static final String CPROJECT_STORAGE_MODULE_LANGUAGE_SETTINGS_PROVIDERS = "org.eclipse.cdt.core.LanguageSettingsProviders"; //$NON-NLS-1$
private static final String STORAGE_WORKSPACE_LANGUAGE_SETTINGS = "language.settings.xml"; //$NON-NLS-1$ private static final String STORAGE_WORKSPACE_LANGUAGE_SETTINGS = "language.settings.xml"; //$NON-NLS-1$
private static final String STORAGE_PROJECT_PATH = ".settings/language.settings.xml"; //$NON-NLS-1$ private static final String STORAGE_PROJECT_PATH = ".settings/language.settings.xml"; //$NON-NLS-1$
@ -827,8 +827,13 @@ public class LanguageSettingsProvidersSerializer {
public static void serializeLanguageSettings(ICProjectDescription prjDescription) throws CoreException { public static void serializeLanguageSettings(ICProjectDescription prjDescription) throws CoreException {
IProject project = prjDescription.getProject(); IProject project = prjDescription.getProject();
try { try {
// Using side effect of adding the module to the storage // Add the storage module to .cpoject and persist on disk as a side effect of adding
prjDescription.getStorage(CPROJECT_STORAGE_MODULE, true); prjDescription.getStorage(CPROJECT_STORAGE_MODULE_LANGUAGE_SETTINGS_PROVIDERS, true);
if (!ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityDefined(project)) {
// set the flag if was not previously set by the user - to the default value
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project,
ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(project));
}
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log("Internal error while trying to serialize language settings", e); //$NON-NLS-1$ CCorePlugin.log("Internal error while trying to serialize language settings", e); //$NON-NLS-1$
} }
@ -1125,7 +1130,9 @@ public class LanguageSettingsProvidersSerializer {
public static void loadLanguageSettings(ICProjectDescription prjDescription) { public static void loadLanguageSettings(ICProjectDescription prjDescription) {
IProject project = prjDescription.getProject(); IProject project = prjDescription.getProject();
IFile storeInPrjArea = getStoreInProjectArea(project); IFile storeInPrjArea = getStoreInProjectArea(project);
if (storeInPrjArea.exists()) { boolean isStoreInProjectAreaExist = storeInPrjArea.exists();
boolean enableLSP = isStoreInProjectAreaExist;
if (isStoreInProjectAreaExist) {
Document doc = null; Document doc = null;
try { try {
doc = XmlUtil.loadXml(storeInPrjArea); doc = XmlUtil.loadXml(storeInPrjArea);
@ -1150,19 +1157,18 @@ public class LanguageSettingsProvidersSerializer {
CCorePlugin.log("Can't load preferences from file " + storeInPrjArea.getLocation(), e); //$NON-NLS-1$ CCorePlugin.log("Can't load preferences from file " + storeInPrjArea.getLocation(), e); //$NON-NLS-1$
} }
} else { } else { // Storage in project area does not exist
// Storage in project area does not exist ICStorageElement lspStorageModule = null;
ICStorageElement storageElement = null;
try { try {
storageElement = prjDescription.getStorage(CPROJECT_STORAGE_MODULE, false); lspStorageModule = prjDescription.getStorage(CPROJECT_STORAGE_MODULE_LANGUAGE_SETTINGS_PROVIDERS, false);
} catch (CoreException e) { } catch (CoreException e) {
String msg = "Internal error while trying to load language settings"; //$NON-NLS-1$ String msg = "Internal error while trying to load language settings"; //$NON-NLS-1$
CCorePlugin.log(msg, e); CCorePlugin.log(msg, e);
} }
if (storageElement != null) {
// set default providers defined in the tool-chain // set default providers defined in the tool-chain
for (ICConfigurationDescription cfgDescription : prjDescription.getConfigurations()) { for (ICConfigurationDescription cfgDescription : prjDescription.getConfigurations()) {
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
String[] ids = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds(); String[] ids = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds();
if (ids != null) { if (ids != null) {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(ids.length); List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(ids.length);
@ -1176,24 +1182,17 @@ public class LanguageSettingsProvidersSerializer {
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
} }
} }
}
} else { enableLSP = lspStorageModule != null;
// Older existing legacy projects unaware of Language Settings Providers and their persistence store
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
for (ICConfigurationDescription cfgDescription : cfgDescriptions) {
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(ScannerDiscoveryLegacySupport.getDefaultProvidersLegacy());
}
}
} }
if (!ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityDefined(project)) { if (!ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityDefined(project)) {
// if not yet defined by user - set preference to tell if this is legacy .cproject (i.e. no LSP storageElement) // set the flag if was not previously set by the user
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, storageElement != null); ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, enableLSP);
} }
} }
}
/** /**
* Get Language Settings Provider from the list of workspace providers, * Get Language Settings Provider from the list of workspace providers,

View file

@ -0,0 +1,158 @@
/*******************************************************************************
* Copyright (c) 2013, 2013 Andrew Gvozdev 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:
* Andrew Gvozdev - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.language.settings.providers;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
import org.eclipse.cdt.core.AbstractCExtension;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider;
import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.core.settings.model.util.CExtensionUtil;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
/**
* Wrapper class intended to provide backward compatibility with ScannerInfoProvider defined by org.eclipse.cdt.core.ScannerInfoProvider extension point
*/
public class ScannerInfoExtensionLanguageSettingsProvider extends LanguageSettingsBaseProvider {
@Override
public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
IScannerInfoProvider scannerInfoProvider = getScannerInfoProvider(cfgDescription);
if (scannerInfoProvider != null) {
IScannerInfo si = scannerInfoProvider.getScannerInformation(rc);
if (si != null) {
if (si instanceof IExtendedScannerInfo) {
addLocalIncludePaths(entries, (IExtendedScannerInfo) si);
}
addSystemIncludePaths(entries, si);
addDefinedSymbols(entries, si);
if (si instanceof IExtendedScannerInfo) {
addIncludeFiles(entries, (IExtendedScannerInfo) si);
addMacroFiles(entries, (IExtendedScannerInfo) si);
}
if (!entries.isEmpty()) {
return LanguageSettingsSerializableStorage.getPooledList(entries);
}
}
}
return null;
}
/**
* Return ScannerInfoProvider defined in configuration metadata in .cproject.
*
* @param cfgDescription - configuration description.
* @return an instance of ScannerInfoProvider or {@code null}.
*/
public IScannerInfoProvider getScannerInfoProvider(ICConfigurationDescription cfgDescription) {
if (cfgDescription == null) {
return null;
}
IScannerInfoProvider scannerInfoProvider = null;
ICConfigExtensionReference[] refs = cfgDescription.get(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID);
if (refs != null && refs.length > 0) {
ICConfigExtensionReference ref = refs[0];
try {
AbstractCExtension cExtension = null;
IConfigurationElement el = CExtensionUtil.getFirstConfigurationElement(ref, "cextension", false); //$NON-NLS-1$
cExtension = (AbstractCExtension)el.createExecutableExtension("run"); //$NON-NLS-1$
cExtension.setExtensionReference(ref);
cExtension.setProject(ref.getConfiguration().getProjectDescription().getProject());
if (cExtension instanceof IScannerInfoProvider) {
scannerInfoProvider = (IScannerInfoProvider) cExtension;
}
} catch (CoreException e) {
CCorePlugin.log(e);
}
}
return scannerInfoProvider;
}
/**
* Add local include paths to the list of entries.
*/
private void addLocalIncludePaths(List<ICLanguageSettingEntry> entries, IExtendedScannerInfo esi) {
String[] localIncludePaths = esi.getLocalIncludePath();
if (localIncludePaths != null) {
for (String path : localIncludePaths) {
entries.add(CDataUtil.createCIncludePathEntry(path, ICSettingEntry.LOCAL));
}
}
}
/**
* Add system include paths to the list of entries.
*/
private void addSystemIncludePaths(List<ICLanguageSettingEntry> entries, IScannerInfo si) {
String[] includePaths = si.getIncludePaths();
if (includePaths != null) {
for (String path : includePaths) {
entries.add(CDataUtil.createCIncludePathEntry(path, 0));
}
}
}
/**
* Add defined macros to the list of entries.
*/
private void addDefinedSymbols(List<ICLanguageSettingEntry> entries, IScannerInfo si) {
Map<String, String> definedSymbols = si.getDefinedSymbols();
if (definedSymbols != null) {
for (Entry<String, String> entry : new TreeMap<String, String>(definedSymbols).entrySet()) {
String name = entry.getKey();
String value = entry.getValue();
entries.add(CDataUtil.createCMacroEntry(name, value, 0));
}
}
}
/**
* Add include files to the list of entries.
*/
private void addIncludeFiles(List<ICLanguageSettingEntry> entries, IExtendedScannerInfo esi) {
String[] includeFiles = esi.getIncludeFiles();
if (includeFiles != null) {
for (String path : includeFiles) {
entries.add(CDataUtil.createCIncludeFileEntry(path, 0));
}
}
}
/**
* Add macro files to the list of entries.
*/
private void addMacroFiles(List<ICLanguageSettingEntry> entries, IExtendedScannerInfo esi) {
String[] macroFiles = esi.getMacroFiles();
if (macroFiles != null) {
for (String path : macroFiles) {
entries.add(CDataUtil.createCMacroFileEntry(path, 0));
}
}
}
}

View file

@ -38,6 +38,7 @@ import org.eclipse.cdt.core.model.IPathEntryContainer;
import org.eclipse.cdt.core.model.IProjectEntry; import org.eclipse.cdt.core.model.IProjectEntry;
import org.eclipse.cdt.core.model.ISourceEntry; import org.eclipse.cdt.core.model.ISourceEntry;
import org.eclipse.cdt.core.resources.IPathEntryVariableManager; import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
import org.eclipse.cdt.utils.UNCPathConverter;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
@ -513,6 +514,9 @@ public class PathEntryUtil {
private static boolean isValidExternalPath(IPath path) { private static boolean isValidExternalPath(IPath path) {
if (path != null) { if (path != null) {
if (path.isUNC()) {
return true;
}
File file = path.toFile(); File file = path.toFile();
if (file != null) { if (file != null) {
return file.exists(); return file.exists();

View file

@ -52,6 +52,7 @@ import javax.xml.transform.stream.StreamResult;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICElementDelta; import org.eclipse.cdt.core.model.ICElementDelta;
@ -1141,7 +1142,15 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();
CConfigurationDataProvider provider = getProvider(des); CConfigurationDataProvider provider = getProvider(des);
return provider.loadConfiguration(des, monitor); CConfigurationData data = provider.loadConfiguration(des, monitor);
if (des instanceof ILanguageSettingsProvidersKeeper && ! des.isPreferenceConfiguration()) {
String[] defaultIds = ((ILanguageSettingsProvidersKeeper) des).getDefaultLanguageSettingsProvidersIds();
if (defaultIds == null) {
((ILanguageSettingsProvidersKeeper) des).setDefaultLanguageSettingsProvidersIds(ScannerDiscoveryLegacySupport.getDefaultProviderIdsLegacy(des));
}
}
return data;
} }
CConfigurationData applyData(CConfigurationDescriptionCache des, ICConfigurationDescription baseDescription, CConfigurationData base, SettingsContext context, IProgressMonitor monitor) throws CoreException { CConfigurationData applyData(CConfigurationDescriptionCache des, ICConfigurationDescription baseDescription, CConfigurationData base, SettingsContext context, IProgressMonitor monitor) throws CoreException {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2012 IBM Corporation and others. * Copyright (c) 2005, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -9,6 +9,7 @@
* Rational Software - initial implementation * Rational Software - initial implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Nathan Ridge
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
@ -45,6 +46,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownMemberClassInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownMemberClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.TypeOfDependentExpression;
/** /**
* This is a utility class to help convert AST elements to Strings corresponding to * This is a utility class to help convert AST elements to Strings corresponding to
@ -182,6 +184,7 @@ public class ASTTypeUtil {
private static void appendArgument(ICPPTemplateArgument arg, boolean normalize, StringBuilder buf) { private static void appendArgument(ICPPTemplateArgument arg, boolean normalize, StringBuilder buf) {
IValue val= arg.getNonTypeValue(); IValue val= arg.getNonTypeValue();
if (val != null) { if (val != null) {
appendType(arg.getTypeOfNonTypeValue(), normalize, buf);
buf.append(val.getSignature()); buf.append(val.getSignature());
} else { } else {
IType type = normalize ? arg.getTypeValue() : arg.getOriginalTypeValue(); IType type = normalize ? arg.getTypeValue() : arg.getOriginalTypeValue();
@ -408,6 +411,8 @@ public class ASTTypeUtil {
IQualifierType qt= (IQualifierType) type; IQualifierType qt= (IQualifierType) type;
needSpace= appendCVQ(result, needSpace, qt.isConst(), qt.isVolatile(), false); needSpace= appendCVQ(result, needSpace, qt.isConst(), qt.isVolatile(), false);
} else if (type instanceof TypeOfDependentExpression) {
result.append(((TypeOfDependentExpression) type).getSignature());
} else if (type instanceof ISemanticProblem) { } else if (type instanceof ISemanticProblem) {
result.append('?'); result.append('?');
} else if (type != null) { } else if (type != null) {
@ -584,7 +589,7 @@ public class ASTTypeUtil {
if (parenthesis == null) { if (parenthesis == null) {
parenthesis= new BitSet(); parenthesis= new BitSet();
} }
parenthesis.set(postfix.size()-1); parenthesis.set(postfix.size() - 1);
} }
appendTypeString(tj, normalize, result); appendTypeString(tj, normalize, result);
needParenthesis= false; needParenthesis= false;

View file

@ -18,9 +18,8 @@ package org.eclipse.cdt.core.dom.ast;
public interface IEnumeration extends IBinding, IType { public interface IEnumeration extends IBinding, IType {
/** /**
* Returns an array of the IEnumerators declared in this enumeration * Returns an array of the IEnumerators declared in this enumeration
* @throws DOMException
*/ */
IEnumerator[] getEnumerators() throws DOMException; IEnumerator[] getEnumerators();
/** /**
* @since 5.2 * @since 5.2

View file

@ -0,0 +1,27 @@
/*******************************************************************************
* Copyright (c) 2013 Nathan Ridge.
* 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:
* Nathan Ridge - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
/**
* @since 5.5
*/
public interface ICPPEnumerationSpecialization extends ICPPEnumeration, ICPPSpecialization {
@Override
ICPPEnumeration getSpecializedBinding();
/**
* Return a specialized version of the given enumerator. The enumerator must be one
* of the enumerators of the enumeration being specialized.
*/
IEnumerator specializeEnumerator(IEnumerator enumerator);
}

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2011 Google, Inc and others. * Copyright (c) 2011, 2013 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Sergey Prigogin (Google) - initial API and implementation * Sergey Prigogin (Google) - initial API and implementation
* Nathan Ridge
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser; package org.eclipse.cdt.internal.core.dom.parser;
@ -182,7 +183,12 @@ public class SizeofCalculator {
if (type instanceof IBasicType) { if (type instanceof IBasicType) {
return sizeAndAlignment((IBasicType) type); return sizeAndAlignment((IBasicType) type);
} }
if (type instanceof IPointerType || type instanceof ICPPReferenceType) { // [expr.sizeof]/2: "When applied to a reference or a reference type, the
// result is the size of the referenced type."
if (type instanceof ICPPReferenceType) {
return sizeAndAlignment(((ICPPReferenceType) type).getType());
}
if (type instanceof IPointerType) {
if (type instanceof ICPPPointerToMemberType) if (type instanceof ICPPPointerToMemberType)
return null; return null;
return sizeof_pointer; return sizeof_pointer;
@ -314,14 +320,24 @@ public class SizeofCalculator {
if (field.isStatic()) if (field.isStatic())
continue; continue;
IType fieldType = field.getType(); IType fieldType = field.getType();
SizeAndAlignment info = sizeAndAlignment(fieldType); SizeAndAlignment info;
// sizeof() on a reference type returns the size of the referenced type.
// However, a reference field in a structure only occupies as much space
// as a pointer.
if (fieldType instanceof ICPPReferenceType) {
info = sizeof_pointer;
} else {
info = sizeAndAlignment(fieldType);
}
if (info == null) if (info == null)
return null; return null;
if (union) { if (union) {
if (size < info.size) if (size < info.size)
size = info.size; size = info.size;
} else { } else {
size += info.alignment - (size - 1) % info.alignment - 1 + info.size; if (size > 0)
size += info.alignment - (size - 1) % info.alignment - 1;
size += info.size;
} }
if (maxAlignment < info.alignment) if (maxAlignment < info.alignment)
maxAlignment = info.alignment; maxAlignment = info.alignment;

View file

@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Andrew Niefer (IBM Corporation) - initial API and implementation * Andrew Niefer (IBM Corporation) - initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Nathan Ridge
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c; package org.eclipse.cdt.internal.core.dom.parser.c;
@ -25,18 +26,17 @@ import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTEnumerationSpecifier; import org.eclipse.cdt.core.dom.ast.c.ICASTEnumerationSpecifier;
import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.internal.core.dom.Linkage; import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
import org.eclipse.core.runtime.PlatformObject; import org.eclipse.core.runtime.PlatformObject;
/** /**
* Binding for enumerations in C. * Binding for enumerations in C.
*/ */
public class CEnumeration extends PlatformObject implements IEnumeration, ICInternalBinding { public class CEnumeration extends PlatformObject implements IEnumeration, ICInternalBinding {
private IASTName[] declarations = null; private IASTName[] declarations = null;
private IASTName definition = null; private IASTName definition = null;
private Long fMinValue; private Long fMinValue;
@ -204,20 +204,7 @@ public class CEnumeration extends PlatformObject implements IEnumeration, ICInte
if (fMinValue != null) if (fMinValue != null)
return fMinValue.longValue(); return fMinValue.longValue();
long minValue = Long.MAX_VALUE; long minValue = SemanticUtil.computeMinValue(this);
IEnumerator[] enumerators = getEnumerators();
for (IEnumerator enumerator : enumerators) {
IValue value = enumerator.getValue();
if (value != null) {
Long val = value.numericalValue();
if (val != null) {
long v = val.longValue();
if (v < minValue) {
minValue = v;
}
}
}
}
fMinValue= minValue; fMinValue= minValue;
return minValue; return minValue;
} }
@ -227,20 +214,7 @@ public class CEnumeration extends PlatformObject implements IEnumeration, ICInte
if (fMaxValue != null) if (fMaxValue != null)
return fMaxValue.longValue(); return fMaxValue.longValue();
long maxValue = Long.MIN_VALUE; long maxValue = SemanticUtil.computeMaxValue(this);
IEnumerator[] enumerators = getEnumerators();
for (IEnumerator enumerator : enumerators) {
IValue value = enumerator.getValue();
if (value != null) {
Long val = value.numericalValue();
if (val != null) {
long v = val.longValue();
if (v > maxValue) {
maxValue = v;
}
}
}
}
fMaxValue= maxValue; fMaxValue= maxValue;
return maxValue; return maxValue;
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2011 Symbian Software Systems and others. * Copyright (c) 2008, 2013 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -9,6 +9,7 @@
* Andrew Ferguson (Symbian) - Initial Implementation * Andrew Ferguson (Symbian) - Initial Implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* IBM Corporation * IBM Corporation
* Nathan Ridge
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -68,13 +69,19 @@ public class CPPASTAmbiguousTemplateArgument extends ASTAmbiguousNode implements
name.setBinding(null); name.setBinding(null);
namedTypeSpec.setName(name); namedTypeSpec.setName(name);
} }
} else if (node instanceof IASTIdExpression) { } else {
// Unwrap variadic pack expansion if necessary.
if (node instanceof ICPPASTPackExpansionExpression)
node= ((ICPPASTPackExpansionExpression) node).getPattern();
if (node instanceof IASTIdExpression) {
IASTIdExpression id= (IASTIdExpression) node; IASTIdExpression id= (IASTIdExpression) node;
final IASTName name = id.getName(); final IASTName name = id.getName();
name.setBinding(null); name.setBinding(null);
id.setName(name); id.setName(name);
} }
} }
}
@Override @Override
protected void afterResolution(ASTVisitor resolver, IASTNode best) { protected void afterResolution(ASTVisitor resolver, IASTNode best) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2011 IBM Corporation and others. * Copyright (c) 2004, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -124,7 +124,7 @@ public class CPPASTBinaryTypeIdExpression extends ASTNode implements ICPPASTExpr
fEvaluation= EvalFixed.INCOMPLETE; fEvaluation= EvalFixed.INCOMPLETE;
} else { } else {
IType t1= CPPVisitor.createType(fOperand1); IType t1= CPPVisitor.createType(fOperand1);
IType t2= CPPVisitor.createType(fOperand1); IType t2= CPPVisitor.createType(fOperand2);
if (t1 == null || t2 == null) { if (t1 == null || t2 == null) {
fEvaluation= EvalFixed.INCOMPLETE; fEvaluation= EvalFixed.INCOMPLETE;
} else { } else {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2011 Wind River Systems, Inc. and others. * Copyright (c) 2009, 2013 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
* Natan Ridge
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -16,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
@ -74,7 +76,7 @@ public class CPPASTPackExpansionExpression extends ASTNode implements ICPPASTPac
} else { } else {
type= new CPPParameterPackType(type); type= new CPPParameterPackType(type);
} }
fEvaluation= new EvalFixed(type, PRVALUE, Value.UNKNOWN); fEvaluation= new EvalFixed(type, PRVALUE, Value.create(((ICPPASTExpression) fPattern).getEvaluation()));
} }
return fEvaluation; return fEvaluation;
} }

View file

@ -55,16 +55,12 @@ public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateI
@Override @Override
public CPPASTTemplateId copy(CopyStyle style) { public CPPASTTemplateId copy(CopyStyle style) {
CPPASTTemplateId copy = new CPPASTTemplateId(templateName == null ? CPPASTTemplateId copy =
null : templateName.copy(style)); new CPPASTTemplateId(templateName == null ? null : templateName.copy(style));
for (IASTNode arg : getTemplateArguments()) { for (IASTNode arg : getTemplateArguments()) {
copy.internalAddTemplateArgument(arg == null ? null : arg.copy(style)); copy.internalAddTemplateArgument(arg == null ? null : arg.copy(style));
} }
copy.setOffsetAndLength(this); return copy(copy, style);
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
}
return copy;
} }
@Override @Override

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2010 IBM Corporation and others. * Copyright (c) 2004, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -9,6 +9,7 @@
* Andrew Niefer (IBM Corporation) - initial API and implementation * Andrew Niefer (IBM Corporation) - initial API and implementation
* Bryan Wilkinson (QNX) * Bryan Wilkinson (QNX)
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Nathan Ridge
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -47,8 +48,10 @@ public class CPPBaseClause implements ICPPBase, ICPPInternalBase {
public IType getBaseClassType() { public IType getBaseClassType() {
if (baseClass == null) { if (baseClass == null) {
IBinding b = base.getName().resolveBinding(); IBinding b = base.getName().resolveBinding();
if (b instanceof IProblemBinding || ! (b instanceof IType)) { if (b instanceof IProblemBinding) {
baseClass = new CPPClassType.CPPClassTypeProblem(base.getName(), ((IProblemBinding) b).getID()); baseClass = new CPPClassType.CPPClassTypeProblem(base.getName(), ((IProblemBinding) b).getID());
} else if (!(b instanceof IType)) {
baseClass = new CPPClassType.CPPClassTypeProblem(base.getName(), ISemanticProblem.BINDING_NO_CLASS);
} else { } else {
baseClass= (IType) b; baseClass= (IType) b;
IType check= getNestedType(baseClass, TDEF); IType check= getNestedType(baseClass, TDEF);

View file

@ -103,7 +103,7 @@ public class CPPClosureType extends PlatformObject implements ICPPClassType, ICP
// Function call operator // Function call operator
final IType returnType= getReturnType(); final IType returnType= getReturnType();
final IType[] parameterTypes= getParameterTypes(); final IType[] parameterTypes= getParameterTypes();
ft= new CPPFunctionType(returnType, parameterTypes, isMutable(), false, false); ft= new CPPFunctionType(returnType, parameterTypes, !isMutable(), false, false);
ICPPParameter[] params = new ICPPParameter[parameterTypes.length]; ICPPParameter[] params = new ICPPParameter[parameterTypes.length];
for (int i = 0; i < params.length; i++) { for (int i = 0; i < params.length; i++) {

View file

@ -9,6 +9,7 @@
* Andrew Niefer (IBM Corporation) - initial API and implementation * Andrew Niefer (IBM Corporation) - initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Nathan Ridge
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -29,7 +30,6 @@ import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTEnumerationSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTEnumerationSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
@ -42,6 +42,7 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.Linkage; import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
import org.eclipse.core.runtime.PlatformObject; import org.eclipse.core.runtime.PlatformObject;
/** /**
@ -220,20 +221,7 @@ public class CPPEnumeration extends PlatformObject implements ICPPEnumeration, I
if (fMinValue != null) if (fMinValue != null)
return fMinValue.longValue(); return fMinValue.longValue();
long minValue = Long.MAX_VALUE; long minValue = SemanticUtil.computeMinValue(this);
IEnumerator[] enumerators = getEnumerators();
for (IEnumerator enumerator : enumerators) {
IValue value = enumerator.getValue();
if (value != null) {
Long val = value.numericalValue();
if (val != null) {
long v = val.longValue();
if (v < minValue) {
minValue = v;
}
}
}
}
fMinValue= minValue; fMinValue= minValue;
return minValue; return minValue;
} }
@ -243,20 +231,7 @@ public class CPPEnumeration extends PlatformObject implements ICPPEnumeration, I
if (fMaxValue != null) if (fMaxValue != null)
return fMaxValue.longValue(); return fMaxValue.longValue();
long maxValue = Long.MIN_VALUE; long maxValue = SemanticUtil.computeMaxValue(this);
IEnumerator[] enumerators = getEnumerators();
for (IEnumerator enumerator : enumerators) {
IValue value = enumerator.getValue();
if (value != null) {
Long val = value.numericalValue();
if (val != null) {
long v = val.longValue();
if (v > maxValue) {
maxValue = v;
}
}
}
}
fMaxValue= maxValue; fMaxValue= maxValue;
return maxValue; return maxValue;
} }
@ -278,10 +253,7 @@ public class CPPEnumeration extends PlatformObject implements ICPPEnumeration, I
if (definition == null) { if (definition == null) {
ICPPEnumeration typeInIndex= getIndexBinding(); ICPPEnumeration typeInIndex= getIndexBinding();
if (typeInIndex != null) { if (typeInIndex != null) {
try {
return typeInIndex.getEnumerators(); return typeInIndex.getEnumerators();
} catch (DOMException e) {
}
} }
return EMPTY_ENUMERATORS; return EMPTY_ENUMERATORS;
} }

View file

@ -0,0 +1,105 @@
/*******************************************************************************
* Copyright (c) 2013 Nathan Ridge.
* 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:
* Nathan Ridge - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumerationSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
/**
* Binding for a specialization of an enumeration.
*/
public class CPPEnumerationSpecialization extends CPPSpecialization implements ICPPEnumerationSpecialization {
private IEnumerator[] fEnumerators;
private final IType fFixedType;
public CPPEnumerationSpecialization(ICPPEnumeration specialized, IBinding owner,
ICPPTemplateParameterMap argumentMap, IType fixedType) {
super(specialized, owner, argumentMap);
fFixedType = fixedType;
}
public void setEnumerators(IEnumerator[] enumerators) {
fEnumerators = enumerators;
}
@Override
public ICPPEnumeration getSpecializedBinding() {
return (ICPPEnumeration) super.getSpecializedBinding();
}
@Override
public IEnumerator[] getEnumerators() {
return fEnumerators;
}
@Override
public long getMinValue() {
return SemanticUtil.computeMinValue(this);
}
@Override
public long getMaxValue() {
return SemanticUtil.computeMaxValue(this);
}
@Override
public boolean isSameType(IType type) {
if (type == this)
return true;
if (type instanceof ITypedef)
return type.isSameType(this);
if (!(type instanceof ICPPEnumerationSpecialization))
return false;
ICPPEnumerationSpecialization otherEnumSpec = (ICPPEnumerationSpecialization) type;
return getSpecializedBinding().isSameType(otherEnumSpec.getSpecializedBinding())
&& ((IType) getOwner()).isSameType((IType) otherEnumSpec.getOwner());
}
@Override
public boolean isScoped() {
return getSpecializedBinding().isScoped();
}
@Override
public IType getFixedType() {
return fFixedType;
}
@Override
public ICPPScope asScope() {
// TODO(nathanridge): Do we need a CPPEnumSpecializationScope?
return getSpecializedBinding().asScope();
}
@Override
public Object clone() {
throw new IllegalArgumentException("Enums must not be cloned"); //$NON-NLS-1$
}
@Override
public IEnumerator specializeEnumerator(IEnumerator enumerator) {
// The specialized enumerators are already computed, just need
// to look up the right one.
IEnumerator[] unspecializedEnumerators = getSpecializedBinding().getEnumerators();
for (int i = 0; i < fEnumerators.length; ++i) {
if (enumerator.equals(unspecializedEnumerators[i]))
return fEnumerators[i];
}
return null;
}
}

View file

@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright (c) 2013 Nathan Ridge.
* 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:
* Nathan Ridge - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumerationSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
/**
* Binding for a specialization of an enumerator.
*/
public class CPPEnumeratorSpecialization extends CPPSpecialization implements IEnumerator {
private final IValue fValue;
public CPPEnumeratorSpecialization(IEnumerator specialized, ICPPEnumerationSpecialization owner,
ICPPTemplateParameterMap argumentMap, IValue value) {
super(specialized, owner, argumentMap);
fValue = value;
}
@Override
public ICPPEnumerationSpecialization getOwner() {
return (ICPPEnumerationSpecialization) super.getOwner();
}
@Override
public IType getType() {
return getOwner();
}
@Override
public IValue getValue() {
return fValue;
}
}

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Wind River Systems, Inc. and others. * Copyright (c) 2012, 2013 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Nathan Ridge
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -38,23 +39,25 @@ public interface ICPPEvaluation extends ISerializableEvaluation {
boolean isValueDependent(); boolean isValueDependent();
/** /**
* TODO Add description * Returns the type of the expression, or a {@code FunctionSetType} if the expression evaluates
* to a function set.
* *
* @param point determines the scope for name lookups * @param point the point of instantiation, determines the scope for name lookups
*/ */
IType getTypeOrFunctionSet(IASTNode point); IType getTypeOrFunctionSet(IASTNode point);
/** /**
* TODO Add description * Returns the value of the expression.
* *
* @param point determines the scope for name lookups * @param point the point of instantiation, determines the scope for name lookups
*/ */
IValue getValue(IASTNode point); IValue getValue(IASTNode point);
/** /**
* TODO Add description * Returns the category of the expression value.
* @see ValueCategory
* *
* @param point determines the scope for name lookups * @param point the point of instantiation, determines the scope for name lookups
*/ */
ValueCategory getValueCategory(IASTNode point); ValueCategory getValueCategory(IASTNode point);
@ -77,16 +80,22 @@ public interface ICPPEvaluation extends ISerializableEvaluation {
* *
* @param parameterMap maps function parameters to their values * @param parameterMap maps function parameters to their values
* @param maxdepth allowed recursion depth * @param maxdepth allowed recursion depth
* @param point determines the scope for name lookups * @param point the point of instantiation, determines the scope for name lookups
* @return the computed evaluation * @return the computed evaluation
*/ */
ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, int maxdepth, ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, int maxdepth,
IASTNode point); IASTNode point);
/** /**
* Determines size of the template parameter pack. * Searches the evaluation for a usage of a template parameter which is a parameter pack,
* and returns the number of arguments bound to that parameter pack in the given
* template parameter map.
* *
* @noreference This method is not intended to be referenced by clients. * Can also return one of the special values CPPTemplates.PACK_SIZE_DEFER,
* CPPTemplates.PACK_SIZE_FAIL, and CPPTemplates.PACK_SIZE_NOT_FOUND. See their
* declarations for their meanings.
*
* See also {@code CPPTemplates.determinePackSize()}.
*/ */
int determinePackSize(ICPPTemplateParameterMap tpMap); int determinePackSize(ICPPTemplateParameterMap tpMap);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Google, Inc and others. * Copyright (c) 2012, 2013 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,211 +7,23 @@
* *
* Contributors: * Contributors:
* Sergey Prigogin (Google) - initial API and implementation * Sergey Prigogin (Google) - initial API and implementation
* Nathan Ridge
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; 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.ISerializableEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
public abstract class CPPEvaluation implements ICPPEvaluation { public abstract class CPPEvaluation implements ICPPEvaluation {
private static class SignatureBuilder implements ITypeMarshalBuffer {
private static final byte NULL_TYPE= 0;
private static final byte UNSTORABLE_TYPE= (byte) -1;
private final StringBuilder fBuffer;
/**
* Constructor for input buffer.
*/
public SignatureBuilder() {
fBuffer= new StringBuilder();
}
@Override
public String toString() {
return fBuffer.toString();
}
public char[] getSignature() {
return CharArrayUtils.extractChars(fBuffer);
}
@Override
public void marshalBinding(IBinding binding) throws CoreException {
if (binding instanceof ISerializableType) {
((ISerializableType) binding).marshal(this);
} else if (binding == null) {
putByte(NULL_TYPE);
} else {
appendSeparator();
if (binding instanceof ICPPBinding) {
if (binding instanceof ICPPTemplateParameter) {
ICPPTemplateParameter param = (ICPPTemplateParameter) binding;
fBuffer.append(param.isParameterPack() ? '*' : '#');
fBuffer.append(param.getParameterID());
} else {
fBuffer.append(ASTTypeUtil.getQualifiedName((ICPPBinding) binding));
}
} else {
fBuffer.append(binding.getNameCharArray());
}
}
}
@Override
public void marshalType(IType type) throws CoreException {
if (type instanceof ISerializableType) {
((ISerializableType) type).marshal(this);
} else if (type == null) {
putByte(NULL_TYPE);
} else if (type instanceof IBinding) {
marshalBinding((IBinding) type);
} else {
assert false : "Cannot serialize " + ASTTypeUtil.getType(type) + " (" + type.getClass().getName() + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
putByte(UNSTORABLE_TYPE);
}
}
@Override
public void marshalEvaluation(ISerializableEvaluation eval, boolean includeValues) throws CoreException {
if (eval == null) {
putByte(NULL_TYPE);
} else {
eval.marshal(this, includeValues);
}
}
@Override
public void marshalValue(IValue value) throws CoreException {
if (value instanceof Value) {
((Value) value).marshall(this);
} else {
putByte(NULL_TYPE);
}
}
@Override
public void marshalTemplateArgument(ICPPTemplateArgument arg) throws CoreException {
if (arg.isNonTypeValue()) {
putByte(VALUE);
arg.getNonTypeEvaluation().marshal(this, true);
} else {
marshalType(arg.getTypeValue());
}
}
@Override
public void putByte(byte value) {
appendSeparator();
fBuffer.append(value);
}
@Override
public void putFixedInt(int value) {
appendSeparator();
fBuffer.append(value);
}
@Override
public void putInt(int value) {
appendSeparator();
fBuffer.append(value);
}
@Override
public void putLong(long value) {
appendSeparator();
fBuffer.append(value);
}
@Override
public void putCharArray(char[] chars) {
appendSeparator();
for (char c : chars) {
fBuffer.append(c);
}
}
private void appendSeparator() {
if (fBuffer.length() != 0)
fBuffer.append(' ');
}
@Override
public IBinding unmarshalBinding() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public IType unmarshalType() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public ISerializableEvaluation unmarshalEvaluation() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public IValue unmarshalValue() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public ICPPTemplateArgument unmarshalTemplateArgument() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public int getByte() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public CoreException unmarshallingError() {
throw new UnsupportedOperationException();
}
@Override
public int getFixedInt() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public int getInt() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public long getLong() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public char[] getCharArray() throws CoreException {
throw new UnsupportedOperationException();
}
}
CPPEvaluation() { CPPEvaluation() {
} }
@ -246,4 +58,14 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
} }
return args; return args;
} }
protected static IBinding instantiateBinding(IBinding binding, ICPPTemplateParameterMap tpMap, int packOffset,
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
try {
return CPPTemplates.instantiateBinding(binding, tpMap, packOffset, within, maxdepth, point);
} catch (DOMException e) {
CCorePlugin.log(e);
}
return binding;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2012 IBM Corporation and others. * Copyright (c) 2005, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -42,7 +42,6 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IArrayType; import org.eclipse.cdt.core.dom.ast.IArrayType;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IPointerType;
@ -76,11 +75,14 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumerationSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType; 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.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
@ -119,6 +121,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPConstructorSpecialization
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPConstructorTemplateSpecialization; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPConstructorTemplateSpecialization;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredFunction; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredFunction;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPEnumerationSpecialization;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPEnumeratorSpecialization;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFieldSpecialization; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFieldSpecialization;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionSpecialization; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionSpecialization;
@ -161,9 +165,23 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.UDCMod
* type instantiation. * type instantiation.
*/ */
public class CPPTemplates { public class CPPTemplates {
// The three constants below are used as special return values for the various overloads
// of CPPTemplates.determinePackSize() and for ICPPEvaluation.determinePackSize(), which
// search a type, template argument, or value for a usage of a template parameter pack
// and return the number of arguments bound to that parameter pack in an
// ICPPTemplateParameterMap.
// Used to indicate that the parameter pack is not bound to any arguments in the
// template parameter map. Computation of the pack size needs to be deferred until
// arguments for it become available.
static final int PACK_SIZE_DEFER = -1; static final int PACK_SIZE_DEFER = -1;
// Used to indicate that two different packs with different sizes were found.
static final int PACK_SIZE_FAIL = -2; static final int PACK_SIZE_FAIL = -2;
// Used to indicate that no template parameter packs were found.
static final int PACK_SIZE_NOT_FOUND = Integer.MAX_VALUE; static final int PACK_SIZE_NOT_FOUND = Integer.MAX_VALUE;
static enum TypeSelection { PARAMETERS, RETURN_TYPE, PARAMETERS_AND_RETURN_TYPE } static enum TypeSelection { PARAMETERS, RETURN_TYPE, PARAMETERS_AND_RETURN_TYPE }
/** /**
@ -837,9 +855,29 @@ public class CPPTemplates {
ICPPAliasTemplate aliasTemplate = (ICPPAliasTemplate) decl; ICPPAliasTemplate aliasTemplate = (ICPPAliasTemplate) decl;
IType type= instantiateType(aliasTemplate.getType(), tpMap, -1, getSpecializationContext(owner), point); IType type= instantiateType(aliasTemplate.getType(), tpMap, -1, getSpecializationContext(owner), point);
spec = new CPPAliasTemplateInstance(decl.getNameCharArray(), aliasTemplate, type); spec = new CPPAliasTemplateInstance(decl.getNameCharArray(), aliasTemplate, type);
} else if (decl instanceof IEnumeration || decl instanceof IEnumerator) { } else if (decl instanceof ICPPEnumeration) {
// TODO(sprigogin): Deal with a case when an enumerator value depends on a template parameter. ICPPClassSpecialization within = getSpecializationContext(owner);
spec = decl; ICPPEnumeration enumeration = (ICPPEnumeration) decl;
IType fixedType = instantiateType(enumeration.getFixedType(), tpMap, -1, within, point);
CPPEnumerationSpecialization specializedEnumeration =
new CPPEnumerationSpecialization(enumeration, owner, tpMap, fixedType);
IEnumerator[] enumerators = enumeration.getEnumerators();
IEnumerator[] specializedEnumerators = new IEnumerator[enumerators.length];
for (int i = 0; i < enumerators.length; ++i) {
IEnumerator enumerator = enumerators[i];
IValue specializedValue =
instantiateValue(enumerator.getValue(), tpMap, -1, within, Value.MAX_RECURSION_DEPTH, point);
specializedEnumerators[i] =
new CPPEnumeratorSpecialization(enumerator, specializedEnumeration, tpMap, specializedValue);
}
specializedEnumeration.setEnumerators(specializedEnumerators);
spec = specializedEnumeration;
} else if (decl instanceof IEnumerator) {
IEnumerator enumerator = (IEnumerator) decl;
ICPPEnumeration enumeration = (ICPPEnumeration) enumerator.getOwner();
ICPPEnumerationSpecialization enumSpec =
(ICPPEnumerationSpecialization) owner.specializeMember(enumeration, point);
spec = enumSpec.specializeEnumerator(enumerator);
} else if (decl instanceof ICPPUsingDeclaration) { } else if (decl instanceof ICPPUsingDeclaration) {
IBinding[] delegates= ((ICPPUsingDeclaration) decl).getDelegates(); IBinding[] delegates= ((ICPPUsingDeclaration) decl).getDelegates();
List<IBinding> result= new ArrayList<IBinding>(); List<IBinding> result= new ArrayList<IBinding>();
@ -1290,6 +1328,53 @@ public class CPPTemplates {
} }
} }
public static IBinding instantiateBinding(IBinding binding, ICPPTemplateParameterMap tpMap, int packOffset,
ICPPClassSpecialization within, int maxdepth, IASTNode point) throws DOMException {
if (binding instanceof ICPPClassTemplate) {
binding = createDeferredInstance((ICPPClassTemplate) binding);
}
if (binding instanceof ICPPUnknownBinding) {
return resolveUnknown((ICPPUnknownBinding) binding, tpMap, packOffset, within, point);
} else if (binding instanceof IEnumerator
|| binding instanceof ICPPMethod
|| binding instanceof ICPPField
|| binding instanceof ICPPEnumeration
|| binding instanceof ICPPClassType) {
IBinding owner = binding.getOwner();
if (!(owner instanceof ICPPSpecialization)) {
owner = instantiateBinding(owner, tpMap, packOffset, within, maxdepth, point);
}
if (binding instanceof IEnumerator) {
if (owner instanceof ICPPEnumerationSpecialization) {
return ((ICPPEnumerationSpecialization) owner).specializeEnumerator((IEnumerator) binding);
}
} else {
if (owner instanceof ICPPClassSpecialization) {
return ((ICPPClassSpecialization) owner).specializeMember(binding, point);
}
}
} else if (binding instanceof CPPFunctionInstance) {
// TODO(nathanridge):
// Maybe we should introduce a CPPDeferredFunctionInstance and have things that can return
// a dependent CPPFunctionInstance (like instantiateForAddressOfFunction) return that when
// appropriate?
CPPFunctionInstance origInstance = (CPPFunctionInstance) binding;
ICPPTemplateArgument[] origArgs = origInstance.getTemplateArguments();
ICPPTemplateArgument[] newArgs = instantiateArguments(origArgs, tpMap, packOffset, within, point, false);
if (origArgs != newArgs) {
CPPTemplateParameterMap newMap = instantiateArgumentMap(origInstance.getTemplateParameterMap(),
tpMap, packOffset, within, point);
IType newType = instantiateType(origInstance.getType(), tpMap, packOffset, within, point);
IType[] newExceptionSpecs = instantiateTypes(origInstance.getExceptionSpecification(),
tpMap, packOffset, within, point);
return new CPPFunctionInstance((ICPPFunction) origInstance.getTemplateDefinition(), origInstance.getOwner(),
newMap, newArgs, (ICPPFunctionType) newType, newExceptionSpecs);
}
}
return binding;
}
public static IType resolveTemplateTypeParameter(final ICPPTemplateParameter tpar, public static IType resolveTemplateTypeParameter(final ICPPTemplateParameter tpar,
ICPPTemplateParameterMap tpMap, int packOffset, IASTNode point) { ICPPTemplateParameterMap tpMap, int packOffset, IASTNode point) {
ICPPTemplateArgument arg= null; ICPPTemplateArgument arg= null;
@ -1958,13 +2043,34 @@ public class CPPTemplates {
return arg; return arg;
} }
private static ICPPFunctionType getFunctionTypeIgnoringParametersWithDefaults(ICPPFunction function) {
ICPPParameter[] parameters = function.getParameters();
IType[] parameterTypes = new IType[parameters.length];
int i;
for (i = 0; i < parameters.length; ++i) {
ICPPParameter parameter = parameters[i];
if (!parameter.hasDefaultValue()) {
parameterTypes[i] = parameter.getType();
} else {
break;
}
}
ICPPFunctionType originalType = function.getType();
if (i == parameters.length) // no parameters with default arguments
return originalType;
return new CPPFunctionType(originalType.getReturnType(), ArrayUtil.trim(parameterTypes),
originalType.isConst(), originalType.isVolatile(), originalType.takesVarArgs());
}
private static int compareSpecialization(ICPPFunctionTemplate f1, ICPPFunctionTemplate f2, TypeSelection mode, IASTNode point) throws DOMException { private static int compareSpecialization(ICPPFunctionTemplate f1, ICPPFunctionTemplate f2, TypeSelection mode, IASTNode point) throws DOMException {
ICPPFunction transF1 = transferFunctionTemplate(f1, point); ICPPFunction transF1 = transferFunctionTemplate(f1, point);
if (transF1 == null) if (transF1 == null)
return -1; return -1;
final ICPPFunctionType ft2 = f2.getType(); final ICPPFunctionType ft2 = f2.getType();
final ICPPFunctionType transFt1 = transF1.getType(); // Ignore parameters with default arguments in the transformed function template
// as per [temp.func.order] p5.
final ICPPFunctionType transFt1 = getFunctionTypeIgnoringParametersWithDefaults(transF1);
IType[] pars; IType[] pars;
IType[] args; IType[] args;
switch(mode) { switch(mode) {
@ -2118,8 +2224,6 @@ public class CPPTemplates {
final ICPPTemplateParameter[] tpars2 = f2.getTemplateParameters(); final ICPPTemplateParameter[] tpars2 = f2.getTemplateParameters();
final ICPPTemplateArgument[] targs1 = f1.getTemplateArguments(); final ICPPTemplateArgument[] targs1 = f1.getTemplateArguments();
final ICPPTemplateArgument[] targs2 = f2.getTemplateArguments(); final ICPPTemplateArgument[] targs2 = f2.getTemplateArguments();
if (targs1.length != targs2.length)
return false;
// Transfer arguments of specialization 1 // Transfer arguments of specialization 1
final int tpars1Len = tpars1.length; final int tpars1Len = tpars1.length;
@ -2129,22 +2233,17 @@ public class CPPTemplates {
final ICPPTemplateParameter param = tpars1[i]; final ICPPTemplateParameter param = tpars1[i];
final ICPPTemplateArgument arg = uniqueArg(param); final ICPPTemplateArgument arg = uniqueArg(param);
args[i]= arg; args[i]= arg;
if (param.isParameterPack()) {
transferMap.put(param, new ICPPTemplateArgument[] { arg });
} else {
transferMap.put(param, arg); transferMap.put(param, arg);
} }
}
final ICPPTemplateArgument[] transferredArgs1 = instantiateArguments(targs1, transferMap, -1, null, point, false); final ICPPTemplateArgument[] transferredArgs1 = instantiateArguments(targs1, transferMap, -1, null, point, false);
// Deduce arguments for specialization 2 // Deduce arguments for specialization 2
final CPPTemplateParameterMap deductionMap= new CPPTemplateParameterMap(2); final CPPTemplateParameterMap deductionMap= new CPPTemplateParameterMap(2);
if (!TemplateArgumentDeduction.fromTemplateArguments(tpars2, targs2, transferredArgs1, deductionMap, point)) return TemplateArgumentDeduction.fromTemplateArguments(tpars2, targs2, transferredArgs1, deductionMap, point);
return false;
// Compare
for (int i = 0; i < targs2.length; i++) {
ICPPTemplateArgument transferredArg2= instantiateArgument(targs2[i], deductionMap, -1, null, point);
if (!transferredArg2.isSameValue(transferredArgs1[i]))
return false;
}
return true;
} }
static boolean isValidType(IType t) { static boolean isValidType(IType t) {
@ -2226,6 +2325,9 @@ public class CPPTemplates {
pType= instantiateType(pType, map, -1, null, point); pType= instantiateType(pType, map, -1, null, point);
} }
if (argType instanceof ICPPParameterPackType) {
argType = ((ICPPParameterPackType) argType).getType();
}
if (argType instanceof ICPPUnknownType) { if (argType instanceof ICPPUnknownType) {
return new CPPTemplateNonTypeArgument(arg.getNonTypeValue(), pType); return new CPPTemplateNonTypeArgument(arg.getNonTypeValue(), pType);
} }
@ -2378,7 +2480,8 @@ public class CPPTemplates {
if (arg.isTypeValue()) if (arg.isTypeValue())
return isDependentType(arg.getTypeValue()); return isDependentType(arg.getTypeValue());
return arg.getNonTypeEvaluation().isValueDependent(); ICPPEvaluation evaluation = arg.getNonTypeEvaluation();
return evaluation.isTypeDependent() || evaluation.isValueDependent();
} }
public static boolean containsDependentType(List<IType> ts) { public static boolean containsDependentType(List<IType> ts) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2012 IBM Corporation and others. * Copyright (c) 2004, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -12,6 +12,7 @@
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Thomas Corbat (IFS) * Thomas Corbat (IFS)
* Nathan Ridge * Nathan Ridge
* Marc-Andre Laperle
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
@ -405,6 +406,9 @@ public class CPPVisitor extends ASTQueries {
IBinding binding = scope.getBinding(name, false); IBinding binding = scope.getBinding(name, false);
if (binding instanceof CPPEnumeration) { if (binding instanceof CPPEnumeration) {
CPPEnumeration e= (CPPEnumeration) binding; CPPEnumeration e= (CPPEnumeration) binding;
if (name.equals(e.getDefinition())) {
return e;
}
if (e.isScoped() == specifier.isScoped()) { if (e.isScoped() == specifier.isScoped()) {
IType ft2= e.getFixedType(); IType ft2= e.getFixedType();
if (fixedType == ft2 || (fixedType != null && fixedType.isSameType(ft2))) { if (fixedType == ft2 || (fixedType != null && fixedType.isSameType(ft2))) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Wind River Systems, Inc. and others. * Copyright (c) 2012, 2013 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -25,10 +25,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
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.ICPPParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
@ -241,20 +238,14 @@ public class EvalBinding extends CPPEvaluation {
} }
if (binding instanceof ICPPTemplateNonTypeParameter) { if (binding instanceof ICPPTemplateNonTypeParameter) {
IType type= ((ICPPTemplateNonTypeParameter) binding).getType(); IType type= ((ICPPTemplateNonTypeParameter) binding).getType();
if (CPPTemplates.isDependentType(type))
return new TypeOfDependentExpression(this);
return prvalueType(type); return prvalueType(type);
} }
if (binding instanceof IVariable) { if (binding instanceof IVariable) {
final IType type = ((IVariable) binding).getType(); final IType type = ((IVariable) binding).getType();
if (CPPTemplates.isDependentType(type))
return new TypeOfDependentExpression(this);
return SemanticUtil.mapToAST(glvalueType(type), point); return SemanticUtil.mapToAST(glvalueType(type), point);
} }
if (binding instanceof IFunction) { if (binding instanceof IFunction) {
final IFunctionType type = ((IFunction) binding).getType(); final IFunctionType type = ((IFunction) binding).getType();
if (CPPTemplates.isDependentType(type))
return new TypeOfDependentExpression(this);
return SemanticUtil.mapToAST(type, point); return SemanticUtil.mapToAST(type, point);
} }
return ProblemType.UNKNOWN_FOR_EXPRESSION; return ProblemType.UNKNOWN_FOR_EXPRESSION;
@ -325,55 +316,26 @@ public class EvalBinding extends CPPEvaluation {
@Override @Override
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
ICPPClassSpecialization within, int maxdepth, IASTNode point) { ICPPClassSpecialization within, int maxdepth, IASTNode point) {
IBinding binding = getBinding(); IBinding origBinding = getBinding();
if (binding instanceof IEnumerator) { if (origBinding instanceof ICPPTemplateNonTypeParameter) {
IEnumerator enumerator = (IEnumerator) binding; ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) origBinding);
IType originalType = enumerator.getType();
IType type = CPPTemplates.instantiateType(originalType, tpMap, packOffset, within, point);
IValue originalValue = enumerator.getValue();
IValue value = CPPTemplates.instantiateValue(originalValue, tpMap, packOffset, within, maxdepth, point);
// TODO(sprigogin): Not sure if following condition is correct.
if (type != originalType || value != originalValue)
return new EvalFixed(type, ValueCategory.PRVALUE, value);
} else if (binding instanceof ICPPTemplateNonTypeParameter) {
ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) binding);
if (argument != null && argument.isNonTypeValue()) { if (argument != null && argument.isNonTypeValue()) {
return argument.getNonTypeEvaluation(); return argument.getNonTypeEvaluation();
} }
// TODO(sprigogin): Do we need something similar for pack expansion? // TODO(sprigogin): Do we need something similar for pack expansion?
} else if (binding instanceof ICPPUnknownBinding) { } else if (origBinding instanceof ICPPParameter) {
binding = resolveUnknown((ICPPUnknownBinding) binding, tpMap, packOffset, within, point); ICPPParameter parameter = (ICPPParameter) origBinding;
} else if (binding instanceof ICPPMethod) { IType origType = parameter.getType();
IBinding owner = binding.getOwner(); IType instantiatedType = CPPTemplates.instantiateType(origType, tpMap, packOffset, within, point);
if (owner instanceof ICPPClassTemplate) { if (origType != instantiatedType) {
owner = resolveUnknown(CPPTemplates.createDeferredInstance((ICPPClassTemplate) owner), return new EvalFixed(instantiatedType, ValueCategory.LVALUE, Value.create(this));
tpMap, packOffset, within, point);
} }
if (owner instanceof ICPPClassSpecialization) { } else {
binding = CPPTemplates.createSpecialization((ICPPClassSpecialization) owner, IBinding instantiatedBinding = instantiateBinding(origBinding, tpMap, packOffset, within, maxdepth, point);
binding, point); if (instantiatedBinding != origBinding)
return new EvalBinding(instantiatedBinding, null);
} }
} else if (binding instanceof ICPPField) {
IBinding owner = binding.getOwner();
if (owner instanceof ICPPClassTemplate) {
owner = resolveUnknown(CPPTemplates.createDeferredInstance((ICPPClassTemplate) owner),
tpMap, packOffset, within, point);
}
if (owner instanceof ICPPClassSpecialization) {
binding = CPPTemplates.createSpecialization((ICPPClassSpecialization) owner,
binding, point);
}
} else if (binding instanceof ICPPParameter) {
ICPPParameter parameter = (ICPPParameter) binding;
IType originalType = parameter.getType();
IType type = CPPTemplates.instantiateType(originalType, tpMap, packOffset, within, point);
if (originalType != type) {
return new EvalFixed(type, ValueCategory.LVALUE, Value.create(this));
}
}
if (binding == fBinding)
return this; return this;
return new EvalBinding(binding, getFixedType());
} }
@Override @Override

View file

@ -360,9 +360,14 @@ public class EvalID extends CPPEvaluation {
@Override @Override
public int determinePackSize(ICPPTemplateParameterMap tpMap) { public int determinePackSize(ICPPTemplateParameterMap tpMap) {
int r = fFieldOwner != null ? fFieldOwner.determinePackSize(tpMap) : CPPTemplates.PACK_SIZE_NOT_FOUND; int r = fFieldOwner != null ? fFieldOwner.determinePackSize(tpMap) : CPPTemplates.PACK_SIZE_NOT_FOUND;
if (fNameOwner instanceof ICPPUnknownBinding) {
r = CPPTemplates.combinePackSize(r, CPPTemplates.determinePackSize((ICPPUnknownBinding) fNameOwner, tpMap));
}
if (fTemplateArgs != null) {
for (ICPPTemplateArgument arg : fTemplateArgs) { for (ICPPTemplateArgument arg : fTemplateArgs) {
r = CPPTemplates.combinePackSize(r, CPPTemplates.determinePackSize(arg, tpMap)); r = CPPTemplates.combinePackSize(r, CPPTemplates.determinePackSize(arg, tpMap));
} }
}
return r; return r;
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2012 IBM Corporation and others. * Copyright (c) 2004, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -11,6 +11,7 @@
* Bryan Wilkinson (QNX) * Bryan Wilkinson (QNX)
* Andrew Ferguson (Symbian) * Andrew Ferguson (Symbian)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Nathan Ridge
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
@ -33,12 +34,15 @@ import org.eclipse.cdt.core.dom.ast.IArrayType;
import org.eclipse.cdt.core.dom.ast.IBasicType; import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IQualifierType; import org.eclipse.cdt.core.dom.ast.IQualifierType;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.ITypedef;
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.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
@ -49,7 +53,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.parser.Keywords; import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
@ -663,49 +666,46 @@ public class SemanticUtil {
return -1; return -1;
} }
public static boolean containsUniqueTypeForParameterPack(IType type) { public static boolean isUniqueTypeForParameterPack(IType type) {
if (type instanceof ICPPFunctionType) {
final ICPPFunctionType ft = (ICPPFunctionType) type;
if (containsUniqueTypeForParameterPack(ft.getReturnType()))
return true;
for (IType pt : ft.getParameterTypes()) {
if (containsUniqueTypeForParameterPack(pt))
return true;
}
return false;
}
if (type instanceof ICPPPointerToMemberType) {
if (containsUniqueTypeForParameterPack(((ICPPPointerToMemberType) type).getMemberOfClass()))
return true;
}
if (type instanceof IBinding) {
IBinding owner = ((IBinding) type).getOwner();
if (owner instanceof IType) {
if (containsUniqueTypeForParameterPack((IType) owner))
return true;
}
}
if (type instanceof ICPPTemplateInstance) {
ICPPTemplateArgument[] args = ((ICPPTemplateInstance) type).getTemplateArguments();
for (ICPPTemplateArgument arg : args) {
if (containsUniqueTypeForParameterPack(arg.getTypeValue()))
return true;
}
}
if (type instanceof ITypeContainer) {
final ITypeContainer tc = (ITypeContainer) type;
final IType nestedType= tc.getType();
return containsUniqueTypeForParameterPack(nestedType);
}
if (type instanceof UniqueType) { if (type instanceof UniqueType) {
return ((UniqueType) type).isForParameterPack(); return ((UniqueType) type).isForParameterPack();
} }
return false; return false;
} }
public static long computeMaxValue(IEnumeration enumeration) {
long maxValue = Long.MIN_VALUE;
IEnumerator[] enumerators = enumeration.getEnumerators();
for (IEnumerator enumerator : enumerators) {
IValue value = enumerator.getValue();
if (value != null) {
Long val = value.numericalValue();
if (val != null) {
long v = val.longValue();
if (v > maxValue) {
maxValue = v;
}
}
}
}
return maxValue;
}
public static long computeMinValue(IEnumeration enumeration) {
long minValue = Long.MAX_VALUE;
IEnumerator[] enumerators = enumeration.getEnumerators();
for (IEnumerator enumerator : enumerators) {
IValue value = enumerator.getValue();
if (value != null) {
Long val = value.numericalValue();
if (val != null) {
long v = val.longValue();
if (v < minValue) {
minValue = v;
}
}
}
}
return minValue;
}
} }

View file

@ -0,0 +1,204 @@
/*******************************************************************************
* Copyright (c) 2012, 2013 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.cpp.semantics;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.core.runtime.CoreException;
class SignatureBuilder implements ITypeMarshalBuffer {
private static final byte NULL_TYPE= 0;
private static final byte UNSTORABLE_TYPE= (byte) -1;
private final StringBuilder fBuffer;
/**
* Constructor for input buffer.
*/
public SignatureBuilder() {
fBuffer= new StringBuilder();
}
@Override
public String toString() {
return fBuffer.toString();
}
public char[] getSignature() {
return CharArrayUtils.extractChars(fBuffer);
}
@Override
public void marshalBinding(IBinding binding) throws CoreException {
if (binding instanceof ISerializableType) {
((ISerializableType) binding).marshal(this);
} else if (binding == null) {
putByte(NULL_TYPE);
} else {
appendSeparator();
if (binding instanceof ICPPBinding) {
if (binding instanceof ICPPTemplateParameter) {
ICPPTemplateParameter param = (ICPPTemplateParameter) binding;
fBuffer.append(param.isParameterPack() ? '*' : '#');
fBuffer.append(param.getParameterID());
} else {
fBuffer.append(ASTTypeUtil.getQualifiedName((ICPPBinding) binding));
}
} else {
fBuffer.append(binding.getNameCharArray());
}
}
}
@Override
public void marshalType(IType type) throws CoreException {
if (type instanceof ISerializableType) {
((ISerializableType) type).marshal(this);
} else if (type == null) {
putByte(NULL_TYPE);
} else if (type instanceof IBinding) {
marshalBinding((IBinding) type);
} else {
assert false : "Cannot serialize " + ASTTypeUtil.getType(type) + " (" + type.getClass().getName() + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
putByte(UNSTORABLE_TYPE);
}
}
@Override
public void marshalEvaluation(ISerializableEvaluation eval, boolean includeValues) throws CoreException {
if (eval == null) {
putByte(NULL_TYPE);
} else {
eval.marshal(this, includeValues);
}
}
@Override
public void marshalValue(IValue value) throws CoreException {
if (value instanceof Value) {
((Value) value).marshall(this);
} else {
putByte(NULL_TYPE);
}
}
@Override
public void marshalTemplateArgument(ICPPTemplateArgument arg) throws CoreException {
if (arg.isNonTypeValue()) {
putByte(VALUE);
arg.getNonTypeEvaluation().marshal(this, true);
} else {
marshalType(arg.getTypeValue());
}
}
@Override
public void putByte(byte value) {
appendSeparator();
fBuffer.append(value);
}
@Override
public void putFixedInt(int value) {
appendSeparator();
fBuffer.append(value);
}
@Override
public void putInt(int value) {
appendSeparator();
fBuffer.append(value);
}
@Override
public void putLong(long value) {
appendSeparator();
fBuffer.append(value);
}
@Override
public void putCharArray(char[] chars) {
appendSeparator();
for (char c : chars) {
fBuffer.append(c);
}
}
private void appendSeparator() {
if (fBuffer.length() != 0)
fBuffer.append(' ');
}
@Override
public IBinding unmarshalBinding() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public IType unmarshalType() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public ISerializableEvaluation unmarshalEvaluation() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public IValue unmarshalValue() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public ICPPTemplateArgument unmarshalTemplateArgument() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public int getByte() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public CoreException unmarshallingError() {
throw new UnsupportedOperationException();
}
@Override
public int getFixedInt() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public int getInt() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public long getLong() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public char[] getCharArray() throws CoreException {
throw new UnsupportedOperationException();
}
}

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2012 Wind River Systems, Inc. and others. * Copyright (c) 2009, 2013 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Nathan Ridge
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
@ -36,7 +37,6 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IQualifierType; import org.eclipse.cdt.core.dom.ast.IQualifierType;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.IValue;
@ -431,7 +431,7 @@ public class TemplateArgumentDeduction {
deduct.incPackOffset(); deduct.incPackOffset();
} else { } else {
if (j >= fnParCount) if (j >= fnParCount)
return result; return -1;
par= fnPars[j]; par= fnPars[j];
if (par instanceof ICPPParameterPackType) { if (par instanceof ICPPParameterPackType) {
@ -606,15 +606,37 @@ public class TemplateArgumentDeduction {
final ICPPTemplateArgument[] p, final ICPPTemplateArgument[] a, CPPTemplateParameterMap map, final ICPPTemplateArgument[] p, final ICPPTemplateArgument[] a, CPPTemplateParameterMap map,
IASTNode point) throws DOMException { IASTNode point) throws DOMException {
TemplateArgumentDeduction deduct= new TemplateArgumentDeduction(pars, null, map, 0); TemplateArgumentDeduction deduct= new TemplateArgumentDeduction(pars, null, map, 0);
final int len= a.length; if (p == null) {
if (p == null || p.length != len) {
return false; return false;
} }
for (int j= 0; j < len; j++) { boolean containsPackExpansion= false;
for (int j= 0; j < p.length; j++) {
if (p[j].isPackExpansion()) {
deduct = new TemplateArgumentDeduction(deduct, a.length - j);
containsPackExpansion= true;
if (j != p.length - 1) {
return false; // A pack expansion must be the last argument to the specialization.
}
ICPPTemplateArgument pattern = p[j].getExpansionPattern();
for (int i= j; i < a.length; i++) {
if (i != j)
deduct.incPackOffset();
if (!deduct.fromTemplateArgument(pattern, a[i], point)) {
return false;
}
}
break;
} else {
if (j >= a.length) {
return false; // Not enough arguments.
}
if (!deduct.fromTemplateArgument(p[j], a[j], point)) { if (!deduct.fromTemplateArgument(p[j], a[j], point)) {
return false; return false;
} }
} }
}
if (!containsPackExpansion && p.length < a.length)
return false; // Too many arguments.
return verifyDeduction(pars, map, false, point); return verifyDeduction(pars, map, false, point);
} }
@ -636,17 +658,9 @@ public class TemplateArgumentDeduction {
deducedArg= tpar.getDefaultValue(); deducedArg= tpar.getDefaultValue();
if (deducedArg != null) { if (deducedArg != null) {
deducedArg= CPPTemplates.instantiateArgument(deducedArg, tpMap, -1, null, point); deducedArg= CPPTemplates.instantiateArgument(deducedArg, tpMap, -1, null, point);
if (deducedArg != null) { if (CPPTemplates.isValidArgument(deducedArg)) {
if (deducedArg instanceof CPPTemplateTypeArgument) {
CPPTemplateTypeArgument deducedTypeArg = (CPPTemplateTypeArgument) deducedArg;
if (!(deducedTypeArg.getTypeValue() instanceof ISemanticProblem)) {
tpMap.put(tpar, deducedArg); tpMap.put(tpar, deducedArg);
} }
} else {
// TODO: Check for problems in non-type or template template parameters?
tpMap.put(tpar, deducedArg);
}
}
} }
} }
if (deducedArg == null) if (deducedArg == null)
@ -957,7 +971,7 @@ public class TemplateArgumentDeduction {
return false; return false;
return fDeducedArgs.putPackElement(parID, fPackOffset, arg, fPackSize); return fDeducedArgs.putPackElement(parID, fPackOffset, arg, fPackSize);
} }
if (SemanticUtil.containsUniqueTypeForParameterPack(arg.getTypeValue())) if (SemanticUtil.isUniqueTypeForParameterPack(arg.getTypeValue()))
return false; return false;
fDeducedArgs.put(parID, arg); fDeducedArgs.put(parID, arg);
return true; return true;

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Wind River Systems, Inc. and others. * Copyright (c) 2012, 2013 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,9 +7,11 @@
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType; import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
@ -48,6 +50,17 @@ public class TypeOfDependentExpression implements ICPPUnknownType, ISerializable
} }
} }
public char[] getSignature() {
SignatureBuilder buf = new SignatureBuilder();
try {
marshal(buf);
} catch (CoreException e) {
CCorePlugin.log(e);
return new char[] { '?' };
}
return buf.getSignature();
}
@Override @Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
buffer.putByte(ITypeMarshalBuffer.DEPENDENT_EXPRESSION_TYPE); buffer.putByte(ITypeMarshalBuffer.DEPENDENT_EXPRESSION_TYPE);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2009 Symbian Software Systems and others. * Copyright (c) 2007, 2013 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -9,6 +9,7 @@
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Thomas Corbat (IFS) * Thomas Corbat (IFS)
* Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index; package org.eclipse.cdt.internal.core.index;
@ -62,4 +63,6 @@ public interface IIndexCPPBindingConstants {
int CPP_USING_DECLARATION_SPECIALIZATION= IIndexBindingConstants.LAST_CONSTANT + 49; int CPP_USING_DECLARATION_SPECIALIZATION= IIndexBindingConstants.LAST_CONSTANT + 49;
int CPP_UNKNOWN_METHOD = IIndexBindingConstants.LAST_CONSTANT + 50; int CPP_UNKNOWN_METHOD = IIndexBindingConstants.LAST_CONSTANT + 50;
int CPP_TEMPLATE_ALIAS = IIndexBindingConstants.LAST_CONSTANT + 51; int CPP_TEMPLATE_ALIAS = IIndexBindingConstants.LAST_CONSTANT + 51;
int CPP_ENUMERATION_SPECIALIZATION = IIndexBindingConstants.LAST_CONSTANT + 52;
int CPP_ENUMERATOR_SPECIALIZATION = IIndexBindingConstants.LAST_CONSTANT + 53;
} }

View file

@ -11,7 +11,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.c; package org.eclipse.cdt.internal.core.index.composite.c;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
@ -25,7 +24,7 @@ class CompositeCEnumeration extends CompositeCBinding implements IEnumeration, I
} }
@Override @Override
public IEnumerator[] getEnumerators() throws DOMException { public IEnumerator[] getEnumerators() {
IEnumerator[] result = ((IEnumeration)rbinding).getEnumerators(); IEnumerator[] result = ((IEnumeration)rbinding).getEnumerators();
for (int i= 0; i < result.length; i++) for (int i= 0; i < result.length; i++)
result[i] = (IEnumerator) cf.getCompositeBinding((IIndexFragmentBinding) result[i]); result[i] = (IEnumerator) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);

View file

@ -11,7 +11,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp; package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
@ -27,7 +26,7 @@ class CompositeCPPEnumeration extends CompositeCPPBinding implements ICPPEnumera
} }
@Override @Override
public IEnumerator[] getEnumerators() throws DOMException { public IEnumerator[] getEnumerators() {
IEnumerator[] result = ((IEnumeration)rbinding).getEnumerators(); IEnumerator[] result = ((IEnumeration)rbinding).getEnumerators();
for (int i= 0; i < result.length; i++) for (int i= 0; i < result.length; i++)
result[i] = (IEnumerator) cf.getCompositeBinding((IIndexFragmentBinding) result[i]); result[i] = (IEnumerator) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);

View file

@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.parser;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -159,21 +158,9 @@ public class InternalParserUtil extends ParserFactory {
IFileStore store = EFS.getStore(file.getLocationURI()); IFileStore store = EFS.getStore(file.getLocationURI());
IFileInfo fileInfo = store.fetchInfo(); IFileInfo fileInfo = store.fetchInfo();
input= file.getContents(true); input= file.getContents(true);
if (!(input instanceof FileInputStream)) { if (input instanceof FileInputStream) {
/*
* In general, non-local file-systems will not use FileInputStream.
* Instead make a cached copy of the file and open an input stream to that.
*/
File fileCache = store.toLocalFile(EFS.CACHE, null);
try { try {
input = new FileInputStream(fileCache); return createFileContent(path, null, file.getCharset(), input,
} catch (FileNotFoundException e) {
CCorePlugin.log(e);
return null;
}
}
try {
return createFileContent(path, file.getCharset(), input,
fileInfo.getLastModified(), fileInfo.getLength(), fileReadTime); fileInfo.getLastModified(), fileInfo.getLength(), fileReadTime);
} finally { } finally {
try { try {
@ -181,6 +168,7 @@ public class InternalParserUtil extends ParserFactory {
} catch (IOException e) { } catch (IOException e) {
} }
} }
}
} catch (CoreException e) { } catch (CoreException e) {
switch (e.getStatus().getCode()) { switch (e.getStatus().getCode()) {
case IResourceStatus.NOT_FOUND_LOCAL: case IResourceStatus.NOT_FOUND_LOCAL:
@ -193,18 +181,19 @@ public class InternalParserUtil extends ParserFactory {
CCorePlugin.log(e); CCorePlugin.log(e);
break; break;
} }
return null;
} }
return null;
} }
/** /**
* Creates a code reader for an external location, normalizing path to * Creates a code reader for an external location, normalizing path to
* canonical path. * canonical path.
*/ */
public static InternalFileContent createExternalFileContent(String externalLocation, String encoding) { public static InternalFileContent createExternalFileContent(final String externalLocation, String encoding) {
long fileReadTime = System.currentTimeMillis(); long fileReadTime = System.currentTimeMillis();
File includeFile = null; File includeFile = null;
String path = null; String path = null;
String localPath = null;
if (!UNCPathConverter.isUNC(externalLocation)) { if (!UNCPathConverter.isUNC(externalLocation)) {
includeFile = new File(externalLocation); includeFile = new File(externalLocation);
// Use the canonical path so that in case of non-case-sensitive OSs // Use the canonical path so that in case of non-case-sensitive OSs
@ -216,6 +205,7 @@ public class InternalParserUtil extends ParserFactory {
IFileStore store = EFS.getStore(UNCPathConverter.getInstance().toURI(externalLocation)); IFileStore store = EFS.getStore(UNCPathConverter.getInstance().toURI(externalLocation));
includeFile = store.toLocalFile(EFS.CACHE, null); includeFile = store.toLocalFile(EFS.CACHE, null);
path = externalLocation; path = externalLocation;
localPath = includeFile.getAbsolutePath();
} catch (CoreException e) { } catch (CoreException e) {
} }
} }
@ -230,7 +220,7 @@ public class InternalParserUtil extends ParserFactory {
return null; return null;
} }
try { try {
return createFileContent(path, encoding, in, timestamp, fileSize, fileReadTime); return createFileContent(path, localPath, encoding, in, timestamp, fileSize, fileReadTime);
} finally { } finally {
try { try {
in.close(); in.close();
@ -241,10 +231,13 @@ public class InternalParserUtil extends ParserFactory {
return null; return null;
} }
private static InternalFileContent createFileContent(String path, String charset, InputStream in, private static InternalFileContent createFileContent(String path, String localPath, String charset, InputStream in,
long fileTimestamp, long fileSize, long fileReadTime) { long fileTimestamp, long fileSize, long fileReadTime) {
if (localPath == null) {
localPath = path;
}
try { try {
AbstractCharArray chars= FileCharArray.create(path, charset, in); AbstractCharArray chars= FileCharArray.create(localPath, charset, in);
if (chars == null) if (chars == null)
return null; return null;

View file

@ -28,6 +28,10 @@ import org.eclipse.cdt.internal.core.dom.IIncludeFileResolutionHeuristics;
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile; import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
import org.eclipse.cdt.internal.core.parser.IMacroDictionary; import org.eclipse.cdt.internal.core.parser.IMacroDictionary;
import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.InclusionKind; import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.InclusionKind;
import org.eclipse.cdt.utils.UNCPathConverter;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.runtime.CoreException;
/** /**
* Internal implementation of the file content providers * Internal implementation of the file content providers
@ -49,7 +53,16 @@ public abstract class InternalFileContentProvider extends IncludeFileContentProv
/** /**
* Checks whether the specified inclusion exists. * Checks whether the specified inclusion exists.
*/ */
public boolean getInclusionExists(String path) { public boolean getInclusionExists(final String path) {
if (UNCPathConverter.isUNC(path)) {
try {
IFileStore store = EFS.getStore(UNCPathConverter.getInstance().toURI(path));
return store.fetchInfo().exists();
} catch (CoreException e) {
return false;
}
}
return new File(path).exists(); return new File(path).exists();
} }

View file

@ -130,7 +130,7 @@ abstract class LocationCtx implements ILocationCtx {
* Returns the sequence of file locations spanning the given range. * Returns the sequence of file locations spanning the given range.
* Assumes that the range starts within this context. * Assumes that the range starts within this context.
*/ */
public abstract boolean collectLocations(int sequenceNumber, int length, ArrayList<IASTNodeLocation> sofar); public abstract void collectLocations(int sequenceNumber, int length, ArrayList<IASTNodeLocation> sofar);
/** /**
* Support for the dependency tree, add inclusion statements found in this context. * Support for the dependency tree, add inclusion statements found in this context.

View file

@ -32,7 +32,7 @@ class LocationCtxContainer extends LocationCtx {
private int fChildSequenceLength; private int fChildSequenceLength;
private ArrayList<LocationCtx> fChildren; private ArrayList<LocationCtx> fChildren;
private AbstractCharArray fSource; private final AbstractCharArray fSource;
private int[] fLineOffsets; private int[] fLineOffsets;
public LocationCtxContainer(LocationCtxContainer parent, AbstractCharArray source, public LocationCtxContainer(LocationCtxContainer parent, AbstractCharArray source,
@ -138,47 +138,55 @@ class LocationCtxContainer extends LocationCtx {
} }
@Override @Override
public boolean collectLocations(int sequenceNumber, final int length, ArrayList<IASTNodeLocation> locations) { public void collectLocations(int sequenceNumber, final int length, ArrayList<IASTNodeLocation> locations) {
if (length < 1)
return;
final int endSequenceNumber= sequenceNumber + length; final int endSequenceNumber= sequenceNumber + length;
if (fChildren != null) { if (fChildren != null) {
int childIdx= Math.max(0, findChildIdxLessOrEqualThan(sequenceNumber, false)); int childIdx= Math.max(0, findChildIdxLessOrEqualThan(sequenceNumber, false));
for (; childIdx < fChildren.size(); childIdx++) { for (; childIdx < fChildren.size(); childIdx++) {
final LocationCtx child= fChildren.get(childIdx); final LocationCtx child= fChildren.get(childIdx);
// create the location between start and the child // Create the location between start and the child
if (sequenceNumber < child.fSequenceNumber) { if (sequenceNumber < child.fSequenceNumber) {
// compute offset backwards from the child's offset // Compute offset backwards from the child's offset in this location
final int offset= child.fEndOffsetInParent - (child.fSequenceNumber - sequenceNumber); final int offset= child.fEndOffsetInParent - (child.fSequenceNumber - sequenceNumber);
// it the child is not affected, we are done.
// Requested range ends before the child.
if (endSequenceNumber <= child.fSequenceNumber) { if (endSequenceNumber <= child.fSequenceNumber) {
addFileLocation(offset, endSequenceNumber - sequenceNumber, locations); addFileLocation(offset, endSequenceNumber - sequenceNumber, locations);
return true; return;
} }
if (offset < child.fOffsetInParent)
final int gapLen = child.fOffsetInParent - offset;
if (gapLen > 0)
addFileLocation(offset, child.fOffsetInParent - offset, locations); addFileLocation(offset, child.fOffsetInParent - offset, locations);
sequenceNumber= child.fSequenceNumber; sequenceNumber= child.fSequenceNumber;
assert sequenceNumber < endSequenceNumber;
} }
// let the child create locations // Let the child create locations
final int childEndSequenceNumber= child.fSequenceNumber + child.getSequenceLength(); final int childEndSequenceNumber= child.fSequenceNumber + child.getSequenceLength();
if (sequenceNumber < childEndSequenceNumber) { if (sequenceNumber < childEndSequenceNumber
if (child.collectLocations(sequenceNumber, endSequenceNumber - sequenceNumber, locations)) { || (sequenceNumber == childEndSequenceNumber && !locations.isEmpty())) {
return true; child.collectLocations(sequenceNumber, endSequenceNumber - sequenceNumber, locations);
}
sequenceNumber= childEndSequenceNumber; sequenceNumber= childEndSequenceNumber;
if (sequenceNumber >= endSequenceNumber)
return;
} }
} }
} }
// create the location after the last child. // Create the location after the last child.
final int myEndNumber = fSequenceNumber + getSequenceLength(); final int myEndNumber = fSequenceNumber + getSequenceLength();
final int offset= fSource.getLength() - (myEndNumber - sequenceNumber); final int offset= fSource.getLength() - (myEndNumber - sequenceNumber);
if (endSequenceNumber <= myEndNumber) { if (endSequenceNumber <= myEndNumber) {
addFileLocation(offset, endSequenceNumber - sequenceNumber, locations); addFileLocation(offset, endSequenceNumber - sequenceNumber, locations);
return true; } else {
}
addFileLocation(offset, fSource.getLength() - offset, locations); addFileLocation(offset, fSource.getLength() - offset, locations);
return false; }
} }
private ArrayList<IASTNodeLocation> addFileLocation(int offset, int length, ArrayList<IASTNodeLocation> sofar) { private ArrayList<IASTNodeLocation> addFileLocation(int offset, int length, ArrayList<IASTNodeLocation> sofar) {

View file

@ -25,7 +25,7 @@ class LocationCtxMacroExpansion extends LocationCtx {
private final LocationMap fLocationMap; private final LocationMap fLocationMap;
private final int fLength; private final int fLength;
private final ImageLocationInfo[] fLocationInfos; private final ImageLocationInfo[] fLocationInfos;
private ASTMacroReferenceName fExpansionName; private final ASTMacroReferenceName fExpansionName;
public LocationCtxMacroExpansion(LocationMap map, LocationCtxContainer parent, int parentOffset, int parentEndOffset, public LocationCtxMacroExpansion(LocationMap map, LocationCtxContainer parent, int parentOffset, int parentEndOffset,
int sequenceNumber, int length, ImageLocationInfo[] imageLocations, ASTMacroReferenceName expansionName) { int sequenceNumber, int length, ImageLocationInfo[] imageLocations, ASTMacroReferenceName expansionName) {
@ -45,17 +45,15 @@ class LocationCtxMacroExpansion extends LocationCtx {
} }
@Override @Override
public boolean collectLocations(int start, int length, ArrayList<IASTNodeLocation> locations) { public void collectLocations(int start, int length, ArrayList<IASTNodeLocation> locations) {
final int offset= start - fSequenceNumber; final int offset= start - fSequenceNumber;
assert offset >= 0 && length >= 0; assert offset >= 0 && length >= 0;
if (offset + length <= fLength) { if (offset + length <= fLength) {
locations.add(new ASTMacroExpansionLocation(this, offset, length)); locations.add(new ASTMacroExpansionLocation(this, offset, length));
return true; } else {
}
locations.add(new ASTMacroExpansionLocation(this, offset, fLength-offset)); locations.add(new ASTMacroExpansionLocation(this, offset, fLength-offset));
return false; }
} }
public ASTMacroExpansion getExpansion() { public ASTMacroExpansion getExpansion() {

View file

@ -229,10 +229,11 @@ public class PDOM extends PlatformObject implements IPDOM {
* 137.0 - Fixed serialization of very large types and template arguments, bug 392278. * 137.0 - Fixed serialization of very large types and template arguments, bug 392278.
* 138.0 - Constexpr functions, bug 395238. * 138.0 - Constexpr functions, bug 395238.
* 139.0 - More efficient and robust storage of types and template arguments, bug 395243. * 139.0 - More efficient and robust storage of types and template arguments, bug 395243.
* 140.0 - Enumerators with dependent values, bug 389009.
*/ */
private static final int MIN_SUPPORTED_VERSION= version(139, 0); private static final int MIN_SUPPORTED_VERSION= version(140, 0);
private static final int MAX_SUPPORTED_VERSION= version(139, Short.MAX_VALUE); private static final int MAX_SUPPORTED_VERSION= version(140, Short.MAX_VALUE);
private static final int DEFAULT_VERSION = version(139, 0); private static final int DEFAULT_VERSION = version(140, 0);
private static int version(int major, int minor) { private static int version(int major, int minor) {
return (major << 16) + minor; return (major << 16) + minor;

View file

@ -309,7 +309,7 @@ public class PDOMASTAdapter {
} }
@Override @Override
public IEnumerator[] getEnumerators() throws DOMException { public IEnumerator[] getEnumerators() {
return fDelegate.getEnumerators(); return fDelegate.getEnumerators();
} }
@ -507,7 +507,7 @@ public class PDOMASTAdapter {
} }
@Override @Override
public IEnumerator[] getEnumerators() throws DOMException { public IEnumerator[] getEnumerators() {
return ((IEnumeration) fDelegate).getEnumerators(); return ((IEnumeration) fDelegate).getEnumerators();
} }

View file

@ -24,7 +24,6 @@ import org.eclipse.core.runtime.CoreException;
/** /**
* @author Doug Schaefer * @author Doug Schaefer
*
*/ */
public abstract class PDOMNamedNode extends PDOMNode { public abstract class PDOMNamedNode extends PDOMNode {
/** /**
@ -104,7 +103,6 @@ public abstract class PDOMNamedNode extends PDOMNode {
fName= nameCharArray; fName= nameCharArray;
} }
@Override @Override
public void delete(PDOMLinkage linkage) throws CoreException { public void delete(PDOMLinkage linkage) throws CoreException {
final Database db = getDB(); final Database db = getDB();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010 Wind River Systems, Inc. and others. * Copyright (c) 2010, 2013 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -23,7 +24,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.IPDOMBinding;
*/ */
public interface IPDOMCPPEnumType extends ICPPEnumeration, IPDOMBinding, IIndexType { public interface IPDOMCPPEnumType extends ICPPEnumeration, IPDOMBinding, IIndexType {
/** /**
* Return the scope name, for use in {@link IScope#getScopeName()} * Returns the scope name, for use in {@link IScope#getScopeName()}
*/ */
IIndexName getScopeName(); IIndexName getScopeName();
@ -33,5 +34,5 @@ public interface IPDOMCPPEnumType extends ICPPEnumeration, IPDOMBinding, IIndexT
/** /**
* Called by the scope to access the enumerators. * Called by the scope to access the enumerators.
*/ */
void loadEnumerators(CharArrayMap<PDOMCPPEnumerator> map); void loadEnumerators(CharArrayMap<IPDOMCPPEnumerator> map);
} }

View file

@ -0,0 +1,20 @@
/*******************************************************************************
* Copyright (c) 2013 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.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMBinding;
/**
* Interface for a c++ enumerator stored in the index.
*/
public interface IPDOMCPPEnumerator extends IEnumerator, IPDOMBinding {
}

View file

@ -65,7 +65,7 @@ class PDOMCPPEnumScope implements ICPPScope, IIndexScope {
@Override @Override
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) { public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) {
try { try {
CharArrayMap<PDOMCPPEnumerator> map= getBindingMap(fBinding); CharArrayMap<IPDOMCPPEnumerator> map= getBindingMap(fBinding);
return map.get(name.toCharArray()); return map.get(name.toCharArray());
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
@ -81,7 +81,7 @@ class PDOMCPPEnumScope implements ICPPScope, IIndexScope {
@Override @Override
public IBinding[] getBindings(ScopeLookupData lookup) { public IBinding[] getBindings(ScopeLookupData lookup) {
try { try {
CharArrayMap<PDOMCPPEnumerator> map= getBindingMap(fBinding); CharArrayMap<IPDOMCPPEnumerator> map= getBindingMap(fBinding);
if (lookup.isPrefixLookup()) { if (lookup.isPrefixLookup()) {
final List<IBinding> result= new ArrayList<IBinding>(); final List<IBinding> result= new ArrayList<IBinding>();
final char[] nc= lookup.getLookupKey(); final char[] nc= lookup.getLookupKey();
@ -135,36 +135,36 @@ class PDOMCPPEnumScope implements ICPPScope, IIndexScope {
return fBinding.hashCode(); return fBinding.hashCode();
} }
private static CharArrayMap<PDOMCPPEnumerator> getBindingMap(IPDOMCPPEnumType enumeration) throws CoreException { private static CharArrayMap<IPDOMCPPEnumerator> getBindingMap(IPDOMCPPEnumType enumeration) throws CoreException {
final Long key= enumeration.getRecord() + PDOMCPPLinkage.CACHE_MEMBERS; final Long key= enumeration.getRecord() + PDOMCPPLinkage.CACHE_MEMBERS;
final PDOM pdom = enumeration.getPDOM(); final PDOM pdom = enumeration.getPDOM();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Reference<CharArrayMap<PDOMCPPEnumerator>> cached= (Reference<CharArrayMap<PDOMCPPEnumerator>>) pdom.getCachedResult(key); Reference<CharArrayMap<IPDOMCPPEnumerator>> cached= (Reference<CharArrayMap<IPDOMCPPEnumerator>>) pdom.getCachedResult(key);
CharArrayMap<PDOMCPPEnumerator> map= cached == null ? null : cached.get(); CharArrayMap<IPDOMCPPEnumerator> map= cached == null ? null : cached.get();
if (map == null) { if (map == null) {
// there is no cache, build it: // there is no cache, build it:
map= new CharArrayMap<PDOMCPPEnumerator>(); map= new CharArrayMap<IPDOMCPPEnumerator>();
enumeration.loadEnumerators(map); enumeration.loadEnumerators(map);
pdom.putCachedResult(key, new SoftReference<CharArrayMap<?>>(map)); pdom.putCachedResult(key, new SoftReference<CharArrayMap<?>>(map));
} }
return map; return map;
} }
public static void updateCache(PDOMCPPEnumeration enumType, PDOMCPPEnumerator enumItem) { public static void updateCache(IPDOMCPPEnumType enumType, IPDOMCPPEnumerator enumItem) {
final Long key= enumType.getRecord() + PDOMCPPLinkage.CACHE_MEMBERS; final Long key= enumType.getRecord() + PDOMCPPLinkage.CACHE_MEMBERS;
final PDOM pdom = enumType.getPDOM(); final PDOM pdom = enumType.getPDOM();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Reference<CharArrayMap<PDOMCPPEnumerator>> cached= (Reference<CharArrayMap<PDOMCPPEnumerator>>) pdom.getCachedResult(key); Reference<CharArrayMap<IPDOMCPPEnumerator>> cached= (Reference<CharArrayMap<IPDOMCPPEnumerator>>) pdom.getCachedResult(key);
CharArrayMap<PDOMCPPEnumerator> map= cached == null ? null : cached.get(); CharArrayMap<IPDOMCPPEnumerator> map= cached == null ? null : cached.get();
if (map != null) { if (map != null) {
map.put(enumType.getNameCharArray(), enumItem); map.put(enumType.getNameCharArray(), enumItem);
} }
} }
public static IEnumerator[] getEnumerators(PDOMCPPEnumeration enumType) { public static IEnumerator[] getEnumerators(IPDOMCPPEnumType enumType) {
try { try {
CharArrayMap<PDOMCPPEnumerator> map = getBindingMap(enumType); CharArrayMap<IPDOMCPPEnumerator> map = getBindingMap(enumType);
List<IEnumerator> result= new ArrayList<IEnumerator>(); List<IEnumerator> result= new ArrayList<IEnumerator>();
for (IEnumerator value : map.values()) { for (IEnumerator value : map.values()) {
if (IndexFilter.ALL_DECLARED.acceptBinding(value)) { if (IndexFilter.ALL_DECLARED.acceptBinding(value)) {
@ -179,10 +179,10 @@ class PDOMCPPEnumScope implements ICPPScope, IIndexScope {
return new IEnumerator[0]; return new IEnumerator[0];
} }
public static void acceptViaCache(PDOMCPPEnumeration enumType, IPDOMVisitor visitor) { public static void acceptViaCache(IPDOMCPPEnumType enumType, IPDOMVisitor visitor) {
try { try {
CharArrayMap<PDOMCPPEnumerator> map = getBindingMap(enumType); CharArrayMap<IPDOMCPPEnumerator> map = getBindingMap(enumType);
for (PDOMCPPEnumerator enumItem : map.values()) { for (IPDOMCPPEnumerator enumItem : map.values()) {
visitor.visit(enumItem); visitor.visit(enumItem);
visitor.leave(enumItem); visitor.leave(enumItem);
} }

View file

@ -114,7 +114,7 @@ class PDOMCPPEnumeration extends PDOMCPPBinding implements IPDOMCPPEnumType, IPD
if (node instanceof PDOMCPPEnumerator) { if (node instanceof PDOMCPPEnumerator) {
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + OFFSET_ENUMERATOR_LIST); PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + OFFSET_ENUMERATOR_LIST);
list.addMember(node); list.addMember(node);
PDOMCPPEnumScope.updateCache(this, (PDOMCPPEnumerator) node); PDOMCPPEnumScope.updateCache(this, (IPDOMCPPEnumerator) node);
} }
} }
@ -218,14 +218,14 @@ class PDOMCPPEnumeration extends PDOMCPPBinding implements IPDOMCPPEnumType, IPD
} }
@Override @Override
public void loadEnumerators(final CharArrayMap<PDOMCPPEnumerator> map) { public void loadEnumerators(final CharArrayMap<IPDOMCPPEnumerator> map) {
try { try {
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + OFFSET_ENUMERATOR_LIST); PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + OFFSET_ENUMERATOR_LIST);
list.accept(new IPDOMVisitor() { list.accept(new IPDOMVisitor() {
@Override @Override
public boolean visit(IPDOMNode node) throws CoreException { public boolean visit(IPDOMNode node) throws CoreException {
if (node instanceof PDOMCPPEnumerator) { if (node instanceof IPDOMCPPEnumerator) {
final PDOMCPPEnumerator item = (PDOMCPPEnumerator) node; final IPDOMCPPEnumerator item = (IPDOMCPPEnumerator) node;
map.put(item.getNameCharArray(), item); map.put(item.getNameCharArray(), item);
} }
return true; return true;

View file

@ -0,0 +1,258 @@
/*******************************************************************************
* Copyright (c) 2013 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.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumerationSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.parser.util.CharArrayMap;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
/**
* Enumeration specialization in the index.
*/
class PDOMCPPEnumerationSpecialization extends PDOMCPPSpecialization
implements IPDOMCPPEnumType, IPDOMMemberOwner, ICPPEnumerationSpecialization {
private static final int OFFSET_ENUMERATOR_LIST = PDOMCPPSpecialization.RECORD_SIZE;
private static final int OFFSET_MIN_VALUE= OFFSET_ENUMERATOR_LIST + Database.PTR_SIZE;
private static final int OFFSET_MAX_VALUE= OFFSET_MIN_VALUE + 8;
private static final int OFFSET_FIXED_TYPE = OFFSET_MAX_VALUE + 8;
private static final int OFFSET_FLAGS = OFFSET_FIXED_TYPE + Database.TYPE_SIZE;
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = OFFSET_FLAGS + 1;
private Long fMinValue; // No need for volatile, all fields of Long are final.
private Long fMaxValue; // No need for volatile, all fields of Long are final.
private volatile IType fFixedType= ProblemBinding.NOT_INITIALIZED;
private PDOMCPPEnumScope fScope; // No need for volatile, all fields of PDOMCPPEnumScope are final.
public PDOMCPPEnumerationSpecialization(PDOMLinkage linkage, PDOMNode parent,
ICPPEnumeration enumeration, PDOMBinding specialized) throws CoreException {
super(linkage, parent, (ICPPSpecialization) enumeration, specialized);
storeProperties(enumeration);
}
public PDOMCPPEnumerationSpecialization(PDOMLinkage linkage, long record) {
super(linkage, record);
}
@Override
public ICPPEnumeration getSpecializedBinding() {
return (ICPPEnumeration) super.getSpecializedBinding();
}
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
storeProperties((ICPPEnumeration) newBinding);
}
private void storeProperties(ICPPEnumeration enumeration) throws CoreException {
final Database db= getDB();
db.putByte(record + OFFSET_FLAGS, enumeration.isScoped() ? (byte) 1 : (byte) 0);
getLinkage().storeType(record + OFFSET_FIXED_TYPE, enumeration.getFixedType());
if (enumeration instanceof ICPPInternalBinding) {
if (((ICPPInternalBinding) enumeration).getDefinition() != null) {
final long minValue = enumeration.getMinValue();
final long maxValue = enumeration.getMaxValue();
db.putLong(record + OFFSET_MIN_VALUE, minValue);
db.putLong(record + OFFSET_MAX_VALUE, maxValue);
fMinValue= minValue;
fMaxValue= maxValue;
}
}
}
@Override
protected int getRecordSize() {
return RECORD_SIZE;
}
@Override
public int getNodeType() {
return IIndexCPPBindingConstants.CPP_ENUMERATION_SPECIALIZATION;
}
@Override
public IEnumerator[] getEnumerators() {
return PDOMCPPEnumScope.getEnumerators(this);
}
@Override
public void accept(IPDOMVisitor visitor) throws CoreException {
PDOMCPPEnumScope.acceptViaCache(this, visitor);
}
@Override
public void addChild(PDOMNode node) throws CoreException {
if (node instanceof IPDOMCPPEnumerator) {
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + OFFSET_ENUMERATOR_LIST);
list.addMember(node);
PDOMCPPEnumScope.updateCache(this, (IPDOMCPPEnumerator) node);
}
}
@Override
public boolean mayHaveChildren() {
return true;
}
@Override
public boolean isSameType(IType type) {
if (type instanceof ITypedef) {
return type.isSameType(this);
}
if (type instanceof PDOMNode) {
PDOMNode node= (PDOMNode) type;
if (node.getPDOM() == getPDOM()) {
return node.getRecord() == getRecord();
}
}
if (type instanceof IEnumeration) {
IEnumeration etype= (IEnumeration) type;
char[] nchars = etype.getNameCharArray();
if (nchars.length == 0) {
nchars= ASTTypeUtil.createNameForAnonymous(etype);
}
if (nchars == null || !CharArrayUtils.equals(nchars, getNameCharArray()))
return false;
return SemanticUtil.isSameOwner(getOwner(), etype.getOwner());
}
return false;
}
@Override
public long getMinValue() {
if (fMinValue != null) {
return fMinValue.longValue();
}
long minValue= 0;
try {
minValue= getDB().getLong(record + OFFSET_MIN_VALUE);
} catch (CoreException e) {
}
fMinValue= minValue;
return minValue;
}
@Override
public long getMaxValue() {
if (fMaxValue != null) {
return fMaxValue.longValue();
}
long maxValue= 0;
try {
maxValue= getDB().getLong(record + OFFSET_MAX_VALUE);
} catch (CoreException e) {
}
fMaxValue= maxValue;
return maxValue;
}
@Override
public Object clone() {
throw new IllegalArgumentException("Enums must not be cloned"); //$NON-NLS-1$
}
@Override
public boolean isScoped() {
try {
return getDB().getByte(record + OFFSET_FLAGS) != 0;
} catch (CoreException e) {
return false;
}
}
@Override
public IType getFixedType() {
if (fFixedType == ProblemBinding.NOT_INITIALIZED) {
fFixedType= loadFixedType();
}
return fFixedType;
}
private IType loadFixedType() {
try {
return getLinkage().loadType(record + OFFSET_FIXED_TYPE);
} catch (CoreException e) {
CCorePlugin.log(e);
return null;
}
}
@Override
public ICPPScope asScope() {
if (fScope == null) {
fScope= new PDOMCPPEnumScope(this);
}
return fScope;
}
@Override
public void loadEnumerators(final CharArrayMap<IPDOMCPPEnumerator> map) {
try {
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + OFFSET_ENUMERATOR_LIST);
list.accept(new IPDOMVisitor() {
@Override
public boolean visit(IPDOMNode node) throws CoreException {
if (node instanceof IPDOMCPPEnumerator) {
final IPDOMCPPEnumerator item = (IPDOMCPPEnumerator) node;
map.put(item.getNameCharArray(), item);
}
return true;
}
@Override
public void leave(IPDOMNode node) {}
});
} catch (CoreException e) {
CCorePlugin.log(e);
}
}
@Override
public IEnumerator specializeEnumerator(IEnumerator enumerator) {
// The specialized enumerators are already computed, just need to look up the right one.
IEnumerator[] unspecializedEnumerators = getSpecializedBinding().getEnumerators();
for (int i = 0; i < unspecializedEnumerators.length; ++i) {
if (enumerator.equals(unspecializedEnumerators[i])) {
IEnumerator[] enumerators = getEnumerators();
return i < enumerators.length ? enumerators[i] : enumerator;
}
}
return null;
}
}

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2010 QNX Software Systems and others. * Copyright (c) 2006, 2013 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Doug Schaefer (QNX) - Initial API and implementation * Doug Schaefer (QNX) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -19,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage; import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -26,11 +28,11 @@ import org.eclipse.core.runtime.CoreException;
/** /**
* Binding for a c++ enumerator in the index. * Binding for a c++ enumerator in the index.
*/ */
class PDOMCPPEnumerator extends PDOMCPPBinding implements IEnumerator { class PDOMCPPEnumerator extends PDOMCPPBinding implements IPDOMCPPEnumerator {
private static final int VALUE= PDOMCPPBinding.RECORD_SIZE; private static final int VALUE= PDOMCPPBinding.RECORD_SIZE;
@SuppressWarnings("hiding") @SuppressWarnings("hiding")
protected static final int RECORD_SIZE = VALUE + 4; protected static final int RECORD_SIZE = VALUE + Database.VALUE_SIZE;
public PDOMCPPEnumerator(PDOMLinkage linkage, PDOMNode parent, IEnumerator enumerator) public PDOMCPPEnumerator(PDOMLinkage linkage, PDOMNode parent, IEnumerator enumerator)
throws CoreException { throws CoreException {
@ -55,8 +57,7 @@ class PDOMCPPEnumerator extends PDOMCPPBinding implements IEnumerator {
private void storeValue(IEnumerator enumerator) throws CoreException { private void storeValue(IEnumerator enumerator) throws CoreException {
IValue value= enumerator.getValue(); IValue value= enumerator.getValue();
if (value != null) { if (value != null) {
Long val= value.numericalValue(); getLinkage().storeValue(record + VALUE, value);
getDB().putInt(record + VALUE, val == null ? -1 : val.intValue());
} }
} }
@ -77,8 +78,7 @@ class PDOMCPPEnumerator extends PDOMCPPBinding implements IEnumerator {
@Override @Override
public IValue getValue() { public IValue getValue() {
try { try {
int val= getDB().getInt(record + VALUE); return getLinkage().loadValue(record + VALUE);
return Value.create(val);
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
} }

View file

@ -0,0 +1,87 @@
/*******************************************************************************
* Copyright (c) 2013 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.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
/**
* Binding for a specialization of an enumerator in the index.
*/
class PDOMCPPEnumeratorSpecialization extends PDOMCPPSpecialization implements IPDOMCPPEnumerator {
private static final int VALUE= PDOMCPPSpecialization.RECORD_SIZE;
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = VALUE + Database.VALUE_SIZE;
public PDOMCPPEnumeratorSpecialization(PDOMLinkage linkage, PDOMNode parent,
IEnumerator enumerator, PDOMBinding specialized) throws CoreException {
super(linkage, parent, (ICPPSpecialization) enumerator, specialized);
storeValue(enumerator);
}
public PDOMCPPEnumeratorSpecialization(PDOMLinkage linkage, long record) {
super(linkage, record);
}
@Override
protected int getRecordSize() {
return RECORD_SIZE;
}
@Override
public int getNodeType() {
return IIndexCPPBindingConstants.CPP_ENUMERATOR_SPECIALIZATION;
}
private void storeValue(IEnumerator enumerator) throws CoreException {
IValue value= enumerator.getValue();
if (value != null) {
getLinkage().storeValue(record + VALUE, value);
}
}
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
if (newBinding instanceof IEnumerator)
storeValue((IEnumerator) newBinding);
}
@Override
public IType getType() {
IIndexFragmentBinding owner = getOwner();
if (owner instanceof IType)
return (IType) owner;
return null;
}
@Override
public IValue getValue() {
try {
return getLinkage().loadValue(record + VALUE);
} catch (CoreException e) {
CCorePlugin.log(e);
}
return Value.UNKNOWN;
}
}

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2012 QNX Software Systems and others. * Copyright (c) 2005, 2013 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -534,6 +534,10 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
result= new PDOMCPPTypedefSpecialization(this, parent, (ITypedef) special, orig); result= new PDOMCPPTypedefSpecialization(this, parent, (ITypedef) special, orig);
} else if (special instanceof ICPPUsingDeclaration) { } else if (special instanceof ICPPUsingDeclaration) {
result= new PDOMCPPUsingDeclarationSpecialization(this, parent, (ICPPUsingDeclaration) special, orig); result= new PDOMCPPUsingDeclarationSpecialization(this, parent, (ICPPUsingDeclaration) special, orig);
} else if (special instanceof ICPPEnumeration) {
result= new PDOMCPPEnumerationSpecialization(this, parent, (ICPPEnumeration) special, orig);
} else if (special instanceof IEnumerator) {
result= new PDOMCPPEnumeratorSpecialization(this, parent, (IEnumerator) special, orig);
} }
return result; return result;
@ -893,6 +897,10 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
return new PDOMCPPUsingDeclarationSpecialization(this, record); return new PDOMCPPUsingDeclarationSpecialization(this, record);
case CPP_TEMPLATE_ALIAS: case CPP_TEMPLATE_ALIAS:
return new PDOMCPPAliasTemplate(this, record); return new PDOMCPPAliasTemplate(this, record);
case CPP_ENUMERATION_SPECIALIZATION:
return new PDOMCPPEnumerationSpecialization(this, record);
case CPP_ENUMERATOR_SPECIALIZATION:
return new PDOMCPPEnumeratorSpecialization(this, record);
} }
assert false : "nodeid= " + nodeType; //$NON-NLS-1$ assert false : "nodeid= " + nodeType; //$NON-NLS-1$
return null; return null;

View file

@ -133,3 +133,4 @@ scannerInfoProvider2.name = Scanner Info Provider
efsExtensionProvider.name = EFSExtensionProvider efsExtensionProvider.name = EFSExtensionProvider
refreshExclusionFactory.name = Refresh Exclusion Factory refreshExclusionFactory.name = Refresh Exclusion Factory
uncPathConverter.name = UNC Path Converter uncPathConverter.name = UNC Path Converter
ScannerInfoExtensionLanguageSettingsProvider.name=Contributed ScannerInfo Entries

View file

@ -268,7 +268,7 @@
<pattern description-expr="make: $3" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="(.*):(\d*): (\*\*\* .*)" severity="Error"/> <pattern description-expr="make: $3" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="(.*):(\d*): (\*\*\* .*)" severity="Error"/>
<pattern description-expr="$0" eat-processed-line="true" file-expr="" line-expr="" regex=".*make.*: \*\*\* .*" severity="Error"/> <pattern description-expr="$0" eat-processed-line="true" file-expr="" line-expr="" regex=".*make.*: \*\*\* .*" severity="Error"/>
<pattern description-expr="$0" eat-processed-line="true" file-expr="" line-expr="" regex=".*make.*: Target (.*) not remade because of errors." severity="Error"/> <pattern description-expr="$0" eat-processed-line="true" file-expr="" line-expr="" regex=".*make.*: Target (.*) not remade because of errors." severity="Error"/>
<pattern description-expr="$0" eat-processed-line="true" file-expr="" line-expr="" regex=".*command not found.*" severity="Error"/> <pattern description-expr="$0" eat-processed-line="true" file-expr="" line-expr="" regex=".*[Cc]ommand not found.*" severity="Error"/>
<pattern description-expr="$1" eat-processed-line="true" file-expr="" line-expr="" regex="Error:\s*(.*)" severity="Error"/> <pattern description-expr="$1" eat-processed-line="true" file-expr="" line-expr="" regex="Error:\s*(.*)" severity="Error"/>
<pattern description-expr="make: $3" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="(.*[Mm]akefile):(\d*): warning: (.*)" severity="Warning"/> <pattern description-expr="make: $3" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="(.*[Mm]akefile):(\d*): warning: (.*)" severity="Warning"/>
<pattern description-expr="$0" eat-processed-line="true" file-expr="" line-expr="" regex=".*make.*\[.*\] Error [-]{0,1}\d*.*" severity="Warning"/> <pattern description-expr="$0" eat-processed-line="true" file-expr="" line-expr="" regex=".*make.*\[.*\] Error [-]{0,1}\d*.*" severity="Warning"/>
@ -806,5 +806,13 @@
factoryClass="org.eclipse.cdt.internal.core.resources.ResourceExclusionFactory"> factoryClass="org.eclipse.cdt.internal.core.resources.ResourceExclusionFactory">
</exclusionFactory> </exclusionFactory>
</extension> </extension>
<extension
point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider
class="org.eclipse.cdt.internal.core.language.settings.providers.ScannerInfoExtensionLanguageSettingsProvider"
id="org.eclipse.cdt.core.LegacyScannerInfoLanguageSettingsProvider"
name="%ScannerInfoExtensionLanguageSettingsProvider.name">
</provider>
</extension>
</plugin> </plugin>

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012, 2012 Andrew Gvozdev and others. * Copyright (c) 2012, 2013 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -11,24 +11,74 @@
package org.eclipse.cdt.internal.core; package org.eclipse.cdt.internal.core;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.Collections;
import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.utils.PathUtil; import org.eclipse.cdt.utils.PathUtil;
import org.eclipse.cdt.utils.WindowsRegistry;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
/** /**
* A collection of cygwin-related utilities. * A collection of cygwin-related utilities.
*/ */
public class Cygwin { public class Cygwin {
public static final String ENV_CYGWIN_HOME = "CYGWIN_HOME"; //$NON-NLS-1$
private static final String ENV_PATH = "PATH"; //$NON-NLS-1$
private static IPath findCygpathLocation(String envPath) { private static final String CYGPATH = "cygpath"; //$NON-NLS-1$
return PathUtil.findProgramLocation("cygpath", envPath); //$NON-NLS-1$ private static final String DEFAULT_ROOT = "C:\\cygwin"; //$NON-NLS-1$
private static final String CYGWIN_DLL = "cygwin1.dll"; //$NON-NLS-1$
private static final String REGISTRY_KEY_SETUP = "SOFTWARE\\Cygwin\\setup"; //$NON-NLS-1$
private static final String REGISTRY_KEY_SETUP_WIN64 = "SOFTWARE\\Wow6432Node\\Cygwin\\setup"; //$NON-NLS-1$
// note that in Cygwin 1.7 the mount point storage has been moved out of the registry
private static final String REGISTRY_KEY_MOUNTS = "SOFTWARE\\Cygnus Solutions\\Cygwin\\mounts v2\\"; //$NON-NLS-1$
private static final String PATH_NAME = "native"; //$NON-NLS-1$
private static final String ROOTPATTERN = "/"; //$NON-NLS-1$
private static final char SLASH = '/';
private static final char BACKSLASH = '\\';
private static final boolean isWindowsPlatform = Platform.getOS().equals(Platform.OS_WIN32);
private static String envPathValueCached = null;
private static String envCygwinHomeValueCached = null;
private static String cygwinLocation = null;
private static boolean isCygwinLocationCached = false;
private final static Map<String/*envPath*/, String /*cygpathLocation*/> cygpathLocationCache = Collections.synchronizedMap(new LRUCache<String, String>(1,20));
private final static Map<String/*command*/, String /*translatedPath*/> translatedPathsCache = Collections.synchronizedMap(new LRUCache<String, String>(10,500));
/**
* Find location of "cygpath" utility on the file system.
*/
private static String findCygpathLocation(String envPath) {
if (envPath == null) {
// $PATH from user preferences
IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_PATH, null, true);
if (varPath != null) {
envPath = varPath.getValue();
}
}
String cygpathLocation = cygpathLocationCache.get(envPath);
if (cygpathLocation == null) {
IPath loc = PathUtil.findProgramLocation(CYGPATH, envPath);
cygpathLocation = loc != null ? loc.toOSString() : null;
cygpathLocationCache.put(envPath, cygpathLocation);
}
return cygpathLocation;
} }
/** /**
* Check if cygwin path conversion utilities are available in the path. * Check if cygwin path conversion utilities are available in the path.
* Tells whether cygwin is installed in the path.
* *
* @param envPath - list of directories to search for cygwin utilities separated * @param envPath - list of directories to search for cygwin utilities separated
* by path separator (format of environment variable $PATH) * by path separator (format of environment variable $PATH)
@ -36,22 +86,60 @@ public class Cygwin {
* @return {@code true} if cygwin is available, {@code false} otherwise. * @return {@code true} if cygwin is available, {@code false} otherwise.
*/ */
public static boolean isAvailable(String envPath) { public static boolean isAvailable(String envPath) {
return Platform.getOS().equals(Platform.OS_WIN32) && findCygpathLocation(envPath) != null; return isWindowsPlatform && findCygpathLocation(envPath) != null;
} }
/** /**
* Check if cygwin path conversion utilities are available in $PATH. * Check if cygwin path conversion utilities are available in $PATH.
* Tells whether cygwin is installed in the path.
* *
* @return {@code true} if cygwin is available, {@code false} otherwise. * @return {@code true} if cygwin is available, {@code false} otherwise.
*/ */
public static boolean isAvailable() { public static boolean isAvailable() {
return Platform.getOS().equals(Platform.OS_WIN32) && findCygpathLocation(null) != null; return isWindowsPlatform && findCygpathLocation(null) != null;
}
/**
* Run program (assuming cygpath) and return the translated path which is the first line of output.
*/
private static String runCygpath(String[] args) throws IOException {
String command = getCommand(args);
String translatedPath = translatedPathsCache.get(command);
if (translatedPath == null) {
Process cygpathProcess = Runtime.getRuntime().exec(args);
BufferedReader stdout = new BufferedReader(new InputStreamReader(cygpathProcess.getInputStream()));
String firstLine = null;
try {
firstLine = stdout.readLine();
} finally {
stdout.close();
}
if (firstLine == null) {
throw new IOException("Unable read output from command=[" + command + "]"); //$NON-NLS-1$ //$NON-NLS-2$
}
translatedPath = firstLine.trim();
translatedPathsCache.put(command, translatedPath);
}
return translatedPath;
}
/**
* Construct a command from arguments array.
*/
private static String getCommand(String[] args) {
String command = ""; //$NON-NLS-1$
for (String arg : args) {
command = command + arg + ' ';
}
return command.trim();
} }
/** /**
* Conversion from Cygwin path to Windows path. * Conversion from Cygwin path to Windows path.
* Note that there is no need to cache results, they are already cached internally.
* *
* @param cygwinPath - Cygwin path. * @param cygwinPath - cygwin path.
* @param envPath - list of directories to search for cygwin utilities separated * @param envPath - list of directories to search for cygwin utilities separated
* by path separator (format of environment variable $PATH). * by path separator (format of environment variable $PATH).
* @return Windows style converted path. Note that that also converts cygwin links to their targets. * @return Windows style converted path. Note that that also converts cygwin links to their targets.
@ -63,31 +151,24 @@ public class Cygwin {
if (cygwinPath == null || cygwinPath.trim().length() == 0) if (cygwinPath == null || cygwinPath.trim().length() == 0)
return cygwinPath; return cygwinPath;
if (!Platform.getOS().equals(Platform.OS_WIN32)) { if (!isWindowsPlatform) {
// Don't run this on non-windows platforms
throw new UnsupportedOperationException("Not a Windows system, Cygwin is unavailable."); //$NON-NLS-1$ throw new UnsupportedOperationException("Not a Windows system, Cygwin is unavailable."); //$NON-NLS-1$
} }
IPath cygpathLocation = findCygpathLocation(envPath); String cygpathLocation = findCygpathLocation(envPath);
if (cygpathLocation == null) { if (cygpathLocation == null) {
throw new UnsupportedOperationException("Cygwin utility cygpath is not in the system search path."); //$NON-NLS-1$ throw new UnsupportedOperationException(CYGPATH + " is not in the system search path."); //$NON-NLS-1$
} }
String[] args = {cygpathLocation.toOSString(), "-w", cygwinPath}; //$NON-NLS-1$ String windowsPath = runCygpath(new String[] {cygpathLocation, "-w", cygwinPath}); //$NON-NLS-1$
Process cygpathProcess = Runtime.getRuntime().exec(args); return windowsPath;
BufferedReader stdout = new BufferedReader(new InputStreamReader(cygpathProcess.getInputStream()));
String windowsPath = stdout.readLine();
if (windowsPath == null) {
throw new IOException("Unexpected output from Cygwin utility cygpath."); //$NON-NLS-1$
}
return windowsPath.trim();
} }
/** /**
* Conversion from Cygwin path to Windows path. * Conversion from Cygwin path to Windows path.
* Note that there is no need to cache results, they are already cached internally.
* *
* @param cygwinPath - Cygwin path. * @param cygwinPath - cygwin path.
* @return Windows style converted path. Note that that also converts cygwin links to their targets. * @return Windows style converted path. Note that that also converts cygwin links to their targets.
* *
* @throws UnsupportedOperationException if Cygwin is unavailable. * @throws UnsupportedOperationException if Cygwin is unavailable.
@ -99,6 +180,7 @@ public class Cygwin {
/** /**
* Conversion from Windows path to Cygwin path. * Conversion from Windows path to Cygwin path.
* Note that there is no need to cache results, they are already cached internally.
* *
* @param windowsPath - Windows path. * @param windowsPath - Windows path.
* @param envPath - list of directories to search for cygwin utilities (value of environment variable $PATH). * @param envPath - list of directories to search for cygwin utilities (value of environment variable $PATH).
@ -111,28 +193,22 @@ public class Cygwin {
if (windowsPath == null || windowsPath.trim().length() == 0) if (windowsPath == null || windowsPath.trim().length() == 0)
return windowsPath; return windowsPath;
if (!Platform.getOS().equals(Platform.OS_WIN32)) { if (!isWindowsPlatform) {
// Don't run this on non-windows platforms
throw new UnsupportedOperationException("Not a Windows system, Cygwin is unavailable."); //$NON-NLS-1$ throw new UnsupportedOperationException("Not a Windows system, Cygwin is unavailable."); //$NON-NLS-1$
} }
IPath cygpathLocation = findCygpathLocation(envPath);
String cygpathLocation = findCygpathLocation(envPath);
if (cygpathLocation == null) { if (cygpathLocation == null) {
throw new UnsupportedOperationException("Cygwin utility cygpath is not in the system search path."); //$NON-NLS-1$ throw new UnsupportedOperationException(CYGPATH + " is not in the system search path."); //$NON-NLS-1$
} }
String[] args = {cygpathLocation.toOSString(), "-u", windowsPath}; //$NON-NLS-1$ String cygwinPath = runCygpath(new String[] {cygpathLocation, "-u", windowsPath}); //$NON-NLS-1$
Process cygpath = Runtime.getRuntime().exec(args); return cygwinPath;
BufferedReader stdout = new BufferedReader(new InputStreamReader(cygpath.getInputStream()));
String cygwinPath = stdout.readLine();
if (cygwinPath == null) {
throw new IOException("Unexpected output from Cygwin utility cygpath."); //$NON-NLS-1$
}
return cygwinPath.trim();
} }
/** /**
* Conversion from Windows path to Cygwin path. * Conversion from Windows path to Cygwin path.
* Note that there is no need to cache results, they are already cached internally.
* *
* @param windowsPath - Windows path. * @param windowsPath - Windows path.
* @return Cygwin style converted path. * @return Cygwin style converted path.
@ -143,4 +219,114 @@ public class Cygwin {
public static String windowsToCygwinPath(String windowsPath) throws IOException, UnsupportedOperationException { public static String windowsToCygwinPath(String windowsPath) throws IOException, UnsupportedOperationException {
return windowsToCygwinPath(windowsPath, null); return windowsToCygwinPath(windowsPath, null);
} }
/**
* Find location where Cygwin is installed. A number of locations is being checked,
* such as environment variable $CYGWIN_HOME, $PATH, Windows registry et al.
* <br><br>
* If you use this do not cache results to ensure user preferences are accounted for.
* Please rely on internal caching.
*
* @return Location of Cygwin root folder "/" on file system in Windows format.
*/
public static String getCygwinHome() {
if (!isWindowsPlatform) {
return null;
}
IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_PATH, null, true);
String envPathValue = varPath != null ? varPath.getValue() : null;
IEnvironmentVariable varCygwinHome = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_CYGWIN_HOME, null, true);
String envCygwinHomeValue = varCygwinHome != null ? varCygwinHome.getValue() : null;
// isCygwinLocationCached is used to figure fact of caching when all cached objects are null
if (isCygwinLocationCached && CDataUtil.objectsEqual(envPathValue, envPathValueCached) && CDataUtil.objectsEqual(envCygwinHomeValue, envCygwinHomeValueCached)) {
return cygwinLocation;
}
cygwinLocation = findCygwinRoot(envPathValue, envCygwinHomeValue);
envPathValueCached = envPathValue;
envCygwinHomeValueCached = envCygwinHomeValue;
isCygwinLocationCached = true;
return cygwinLocation;
}
/**
* Reads required value from registry. Looks in both
* HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE
*
* @param key Registry key
* @param name Registry value to read
* @return corresponding string value or null if nothing found
*/
private static String readValueFromRegistry(String key, String name) {
WindowsRegistry registry = WindowsRegistry.getRegistry();
if (registry != null) {
String s = registry.getCurrentUserValue(key, name);
if(s == null) {
s = registry.getLocalMachineValue(key, name);
}
if (s != null) {
return (s.replace(BACKSLASH, SLASH));
}
}
return null;
}
/**
* @return The absolute path to cygwin's root or null if not found
*/
private static String findCygwinRoot(String envPathValue, String envCygwinHomeValue) {
String rootValue = null;
// Check $CYGWIN_HOME
if (envCygwinHomeValue != null && !envCygwinHomeValue.isEmpty()) {
IPath location = new Path(envCygwinHomeValue + "/bin/" + CYGWIN_DLL); //$NON-NLS-1$
if (location.toFile().exists()) {
// get rootValue from "rootValue\bin\cygwin1.dll"
rootValue = location.removeLastSegments(2).toOSString();
}
}
// Look in PATH values. Look for cygwin1.dll
if(rootValue == null) {
IPath location = PathUtil.findProgramLocation(CYGWIN_DLL, envPathValue);
if (location != null) {
// get rootValue from "rootValue\bin\cygwin1.dll"
rootValue = location.removeLastSegments(2).toOSString();
}
}
// Try to find the root dir in SOFTWARE\Cygwin\setup
if(rootValue == null) {
rootValue = readValueFromRegistry(REGISTRY_KEY_SETUP, "rootdir"); //$NON-NLS-1$
}
// Try to find the root dir in SOFTWARE\Wow6432Node\Cygwin\setup
if(rootValue == null) {
rootValue = readValueFromRegistry(REGISTRY_KEY_SETUP_WIN64, "rootdir"); //$NON-NLS-1$
}
// Try to find the root dir in SOFTWARE\Cygnus Solutions
if (rootValue == null) {
rootValue = readValueFromRegistry(REGISTRY_KEY_MOUNTS + ROOTPATTERN, PATH_NAME);
}
// Try the default Cygwin install dir
if(rootValue == null) {
File file = new File(DEFAULT_ROOT);
if (file.exists() && file.isDirectory())
rootValue = DEFAULT_ROOT;
}
if(rootValue != null) {
rootValue = rootValue.replace(BACKSLASH, SLASH);
}
return rootValue;
}
} }

View file

@ -0,0 +1,50 @@
/*******************************************************************************
* Copyright (c) 2013 Andrew Gvozdev 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:
* Andrew Gvozdev - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
/**
* A simple cache with limited number of items in the cache. LRUCache discards the Least Recently Used items first.
* Based on {@link LinkedHashMap}. Note that {@link LinkedHashMap} has built-in facility to support cache like that
* which is described in its JavaDoc.
*/
public class LRUCache<K, V> extends LinkedHashMap<K, V> {
private int fLimit;
/**
* Constructs an empty LRUCache with the specified limit on the number of items in the cache.
*
* @param limit - the maximum number of items to keep in the cache.
*/
public LRUCache(int limit) {
super(limit, 0.75f, true);
fLimit= limit;
}
/**
* Constructs an empty LRUCache with the specified initial capacity and limit on the number of items in the cache.
*
* @param initialCapacity - initial capacity.
* @param limit - the maximum number of items to keep in the cache.
*/
public LRUCache(int initialCapacity, int limit) {
super(initialCapacity, 0.75f, true);
fLimit= limit;
}
@Override
protected boolean removeEldestEntry(Entry<K, V> eldest) {
return size() >= fLimit;
}
}

View file

@ -32,7 +32,7 @@
<version>${tycho-version}</version> <version>${tycho-version}</version>
<configuration> <configuration>
<useUIHarness>true</useUIHarness> <useUIHarness>true</useUIHarness>
<argLine>-Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine> <argLine>-ea -Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
<includes> <includes>
<include>**/AutomatedSuite.*</include> <include>**/AutomatedSuite.*</include>
</includes> </includes>

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2010 IBM Corporation and others. * Copyright (c) 2004, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Nathan Ridge
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.tests.text.selection; package org.eclipse.cdt.ui.tests.text.selection;
@ -75,7 +76,6 @@ import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
* @author dsteffle * @author dsteffle
*/ */
public class CPPSelectionTestsNoIndexer extends BaseUITestCase { public class CPPSelectionTestsNoIndexer extends BaseUITestCase {
private static final String INDEX_FILE_ID = "2946365241"; //$NON-NLS-1$ private static final String INDEX_FILE_ID = "2946365241"; //$NON-NLS-1$
static NullProgressMonitor monitor; static NullProgressMonitor monitor;
static IWorkspace workspace; static IWorkspace workspace;
@ -1205,4 +1205,23 @@ public class CPPSelectionTestsNoIndexer extends BaseUITestCase {
assertEquals(offsetV, ((ASTNode) decl).getOffset()); assertEquals(offsetV, ((ASTNode) decl).getOffset());
} }
// template <typename>
// struct A {
// struct S {
// void foo();
// };
// void test() {
// S s;
// s.foo();
// }
// };
public void testBug399142() throws Exception {
String code = getAboveComment();
IFile file = importFile("testBug399142.cpp", code); //$NON-NLS-1$
int offset = code.indexOf("s.foo()") + 2;
IASTNode decl = testF3(file, offset);
assertTrue(decl instanceof IASTName);
}
} }

View file

@ -4,7 +4,7 @@
<filter id="305365105"> <filter id="305365105">
<message_arguments> <message_arguments>
<message_argument value="org.eclipse.cdt.ui.refactoring.actions.Messages"/> <message_argument value="org.eclipse.cdt.ui.refactoring.actions.Messages"/>
<message_argument value="org.eclipse.cdt.ui_5.5.0"/> <message_argument value="org.eclipse.cdt.ui_5.6.0"/>
</message_arguments> </message_arguments>
</filter> </filter>
</resource> </resource>

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: %pluginName Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.ui; singleton:=true Bundle-SymbolicName: org.eclipse.cdt.ui; singleton:=true
Bundle-Version: 5.5.0.qualifier Bundle-Version: 5.6.0.qualifier
Bundle-Activator: org.eclipse.cdt.ui.CUIPlugin Bundle-Activator: org.eclipse.cdt.ui.CUIPlugin
Bundle-Vendor: %providerName Bundle-Vendor: %providerName
Bundle-Localization: plugin Bundle-Localization: plugin

View file

@ -648,4 +648,6 @@ RefreshExclusionContributorExtensionPoint = Refresh Exclusion Contributor
newProjectWizard.name = C/C++ Project (prototype) newProjectWizard.name = C/C++ Project (prototype)
projectTypePages = Project Type Pages projectTypePages = Project Type Pages
semanticHighlightingExtensionPoint = Semantic Highlighting Extension Point
UserSettingEntries.name = CDT User Setting Entries UserSettingEntries.name = CDT User Setting Entries

View file

@ -29,6 +29,7 @@
<extension-point id="LanguageSettingsProviderAssociation" name="%LanguageSettingsProviderAssociationExtensionPoint" schema="schema/LanguageSettingsProviderAssociation.exsd"/> <extension-point id="LanguageSettingsProviderAssociation" name="%LanguageSettingsProviderAssociationExtensionPoint" schema="schema/LanguageSettingsProviderAssociation.exsd"/>
<extension-point id="RefreshExclusionContributor" name="%RefreshExclusionContributorExtensionPoint" schema="schema/RefreshExclusionContributor.exsd"/> <extension-point id="RefreshExclusionContributor" name="%RefreshExclusionContributorExtensionPoint" schema="schema/RefreshExclusionContributor.exsd"/>
<extension-point id="projectTypePages" name="%projectTypePages" schema="schema/projectTypePages.exsd"/> <extension-point id="projectTypePages" name="%projectTypePages" schema="schema/projectTypePages.exsd"/>
<extension-point id="semanticHighlighting" name="%semanticHighlightingExtensionPoint" schema="schema/semanticHighlighting.exsd"/>
<extension <extension
point="org.eclipse.core.runtime.adapters"> point="org.eclipse.core.runtime.adapters">

View file

@ -11,7 +11,7 @@
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<version>5.5.0-SNAPSHOT</version> <version>5.6.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.ui</artifactId> <artifactId>org.eclipse.cdt.ui</artifactId>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>
</project> </project>

View file

@ -0,0 +1,245 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.cdt.ui" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<meta.schema plugin="org.eclipse.cdt.ui" id="semanticHighligher" name="Semantic Highlighting"/>
</appInfo>
<documentation>
This extension point allows extensions to contribute to the semantic highlighting.
&lt;p&gt;
Extensions specify the priority of the highlighting, which determines the order in which the highlighting is invoked.
&lt;/p&gt;
&lt;p&gt;
This extension point supports the &lt;code&gt;enablement&lt;/code&gt; tag. Properties to test on are:
&lt;dl&gt;
&lt;li&gt;projectNatures: type Collection; all project natures of the current project&lt;/li&gt;
&lt;li&gt;languageId: type String; the result if ILanguage.getId on the token&apos;s ITranslationUnit&lt;/li&gt;
&lt;/dl&gt;
&lt;/p&gt;
&lt;p&gt;
Contributed highlightings will be visible in the Code tree of the &apos;C/C++ - Editor - Syntax Colouring&apos; preference page.
&lt;/p&gt;
</documentation>
</annotation>
<include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
<element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
</annotation>
<complexType>
<sequence>
<element ref="semanticHighlighting" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
a fully qualified identifier of the target extension point
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
an optional identifier of the extension instance
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
an optional name of the extension instance
</documentation>
<appInfo>
<meta.attribute translatable="true"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="semanticHighlighting">
<complexType>
<sequence>
<element ref="enablement" minOccurs="0" maxOccurs="1"/>
</sequence>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
a unique identifier for the Quick Fix processor
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
a localized name of the Quick Fix processor
</documentation>
<appInfo>
<meta.attribute translatable="true"/>
</appInfo>
</annotation>
</attribute>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
The name of the class that implements this Semantic Highlighting. The
class must be public and implement
&lt;samp&gt;org.eclipse.cdt.ui.text.ISemanticHighlighter&lt;/samp&gt;
with a public 0-argument constructor.
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.ui.text.ISemanticHighlighting"/>
</appInfo>
</annotation>
</attribute>
<attribute name="priority" type="string" use="required">
<annotation>
<documentation>
The priority determines the order in which highlightings are given the opportunity to highlight a token. Lower values are more important.
The priorities of the built-in highlightings are available in org.eclipse.cdt.internal.ui.editor.SemanticHighlightings.loadBuiltInSemanticHighlightings.
</documentation>
</annotation>
</attribute>
<attribute name="preferenceKey" type="string" use="required">
<annotation>
<documentation>
A key to uniquely identify the highlighting&apos;s settings in the preference store.
</documentation>
</annotation>
</attribute>
<attribute name="displayName" type="string" use="required">
<annotation>
<documentation>
The name that is displayed for the highlighter in the Preferences window.
</documentation>
<appInfo>
<meta.attribute translatable="true"/>
</appInfo>
</annotation>
</attribute>
<attribute name="defaultTextColor" type="string">
<annotation>
<documentation>
The default text color of the contributed highlighting. The value must be the integer RGB values (0-255) separated by commas. E.g., &quot;127,0,85&quot;. Defaults to &quot;0,0,0&quot; (black).
</documentation>
</annotation>
</attribute>
<attribute name="defaultBold" type="boolean">
<annotation>
<documentation>
false by default
</documentation>
</annotation>
</attribute>
<attribute name="defaultItalic" type="boolean">
<annotation>
<documentation>
false by default
</documentation>
</annotation>
</attribute>
<attribute name="defaultStrikethrough" type="boolean">
<annotation>
<documentation>
false by default
</documentation>
</annotation>
</attribute>
<attribute name="defaultUnderline" type="boolean">
<annotation>
<documentation>
false by default
</documentation>
</annotation>
</attribute>
<attribute name="defaultEnabled" type="boolean">
<annotation>
<documentation>
false by default
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appInfo>
<meta.section type="since"/>
</appInfo>
<documentation>
8.2
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="examples"/>
</appInfo>
<documentation>
The following is an example of a Semantic Highligher contribution:
&lt;p&gt;
&lt;pre&gt;
&lt;extension
point=&quot;org.eclipse.cdt.ui.semanticHighlighting&quot;
name=&quot;%extensionName&quot;
id=&quot;com.example.ui.semanticHighlightings&quot;&gt;
&lt;semanticHighlighting
id=&quot;com.example.ui.keywordHighlighting&quot;
priority=&quot;5&quot;
class=&quot;com.example.internal.ui.ExampleHighlighting&quot;
preferenceKey=&quot;example-keywords&quot;
displayName=&quot;%exampleHighlighting.displayName&quot;
defaultTextColor=&quot;127,0,85&quot;
defaultBold=&quot;true&quot;
defaultEnabled=&quot;true&quot;&gt;
&lt;enablement&gt;
&lt;with variable=&quot;projectNatures&quot;&gt;
&lt;iterate operator=&quot;or&quot;&gt;
&lt;equals value=&quot;org.eclipse.cdt.core.ccnature&quot;/&gt;
&lt;/iterate&gt;
&lt;/with&gt;
&lt;with variable=&quot;languageId&quot;&gt;
&lt;or&gt;
&lt;equals value=&quot;org.eclipse.cdt.core.g++&quot;/&gt;
&lt;equals value=&quot;org.eclipse.cdt.core.gcc&quot;/&gt;
&lt;/or&gt;
&lt;/with&gt;
&lt;/enablement&gt;
&lt;/semanticHighlighting&gt;
&lt;/extension&gt;
&lt;/pre&gt;
&lt;/p&gt;
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="apiInfo"/>
</appInfo>
<documentation>
The contributed class must implement &lt;code&gt;org.eclipse.cdt.ui.text.ISemanticHighlighter&lt;/code&gt;
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="copyright"/>
</appInfo>
<documentation>
Copyright (c) 2013 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
http://www.eclipse.org/legal/epl-v10.html
</documentation>
</annotation>
</schema>

View file

@ -0,0 +1,272 @@
/*
* Copyright (c) 2013 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
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.cdt.internal.ui.editor;
import java.util.Arrays;
import org.eclipse.core.expressions.EvaluationContext;
import org.eclipse.core.expressions.EvaluationResult;
import org.eclipse.core.expressions.Expression;
import org.eclipse.core.expressions.ExpressionConverter;
import org.eclipse.core.expressions.ExpressionTagNames;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.jface.resource.DataFormatException;
import org.eclipse.jface.resource.StringConverter;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
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.ui.CUIPlugin;
import org.eclipse.cdt.ui.text.ISemanticHighlighter;
import org.eclipse.cdt.ui.text.ISemanticToken;
public class ContributedSemanticHighlighting extends SemanticHighlighting {
/**
* The configuration element needs to be cached until the class is instantiated. Instantiation is deferred
* to avoid loading the contributing plugin when the highlighter is not actually needed.
*/
private IConfigurationElement configurationElement;
private Boolean fStatus = null;
private ISemanticHighlighter semanticHighlighter;
private final Expression enablementExpression;
private final int priority;
private final String id;
private final String preferenceKey;
private final String displayName;
private final RGB defaultTextColor;
private final boolean defaultBold;
private final boolean defaultItalic;
private final boolean defaultStrikethrough;
private final boolean defaultUnderline;
private final boolean defaultEnabled;
private static final String Attr_Class = "class"; //$NON-NLS-1$
private static final String Attr_Priority = "priority"; //$NON-NLS-1$
private static final String Attr_PrefKey = "preferenceKey"; //$NON-NLS-1$
private static final String Attr_DisplayName = "displayName"; //$NON-NLS-1$
private static final String Attr_DefaultTextColor = "defaultTextColor"; //$NON-NLS-1$
private static final String Attr_DefaultBold = "defaultBold"; //$NON-NLS-1$
private static final String Attr_DefaultItalic = "defaultItalic"; //$NON-NLS-1$
private static final String Attr_DefaultStrikethrough = "defaultStrikethrough"; //$NON-NLS-1$
private static final String Attr_DefaultUnderline = "defaultUnderline"; //$NON-NLS-1$
private static final String Attr_DefaultEnabled = "defaultEnabled"; //$NON-NLS-1$
private static final String Var_projectNature = "projectNatures"; //$NON-NLS-1$
private static final String Var_languageId = "languageId"; //$NON-NLS-1$
private static final int Default_Priority = 1000;
public ContributedSemanticHighlighting(IConfigurationElement element) {
configurationElement = element;
// required
id = element.getDeclaringExtension().getNamespaceIdentifier() + '.'
+ element.getDeclaringExtension().getSimpleIdentifier();
int pri = Default_Priority;
String priStr = element.getAttribute(Attr_Priority);
if (priStr != null)
try {
pri = Integer.parseInt(priStr);
} catch (NumberFormatException e) {
CUIPlugin.log("Error in priority attribute of " + id + " was " + priStr, e); //$NON-NLS-1$ //$NON-NLS-2$
}
priority = pri;
Expression expr = null;
IConfigurationElement[] children = element.getChildren(ExpressionTagNames.ENABLEMENT);
switch (children.length) {
case 0:
fStatus = Boolean.TRUE;
break;
case 1:
try {
ExpressionConverter parser = ExpressionConverter.getDefault();
expr = parser.perform(children[0]);
} catch (CoreException e) {
CUIPlugin.log("Error in enablement expression of " + id, e); //$NON-NLS-1$
}
break;
default:
CUIPlugin.logError("Too many enablement expressions for " + id); //$NON-NLS-1$
fStatus = Boolean.FALSE;
break;
}
enablementExpression = expr;
preferenceKey = element.getAttribute(Attr_PrefKey);
displayName = element.getAttribute(Attr_DisplayName);
// optional
defaultTextColor = getRGBAttribute(element, id, Attr_DefaultTextColor);
defaultBold = Boolean.parseBoolean(element.getAttribute(Attr_DefaultBold));
defaultItalic = Boolean.parseBoolean(element.getAttribute(Attr_DefaultItalic));
defaultStrikethrough = Boolean.parseBoolean(element.getAttribute(Attr_DefaultStrikethrough));
defaultUnderline = Boolean.parseBoolean(element.getAttribute(Attr_DefaultUnderline));
defaultEnabled = Boolean.parseBoolean(element.getAttribute(Attr_DefaultEnabled));
}
public String getId() {
return id;
}
public int getPriority() {
return priority;
}
private static RGB getRGBAttribute(IConfigurationElement element, String extensionId, String key) {
String val = element.getAttribute(key);
if (val != null)
try {
return StringConverter.asRGB(val);
} catch (DataFormatException e) {
CUIPlugin
.log("Error in " + Attr_DefaultTextColor + " attribute of " + extensionId + ' ' + val + " is not a RGB value", e); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
// black by default
return new RGB(0, 0, 0);
}
private ISemanticHighlighter createSemanticHighlighter() {
// only one try at creating the class
if (configurationElement == null)
return null;
IConfigurationElement element = configurationElement;
configurationElement = null;
try {
return (ISemanticHighlighter) element.createExecutableExtension(Attr_Class);
} catch (CoreException e) {
CUIPlugin.log("Error in class attribute of " + id, e); //$NON-NLS-1$
}
return null;
}
@Override
public String getPreferenceKey() {
return preferenceKey;
}
@Override
public RGB getDefaultDefaultTextColor() {
return defaultTextColor;
}
@Override
public boolean isBoldByDefault() {
return defaultBold;
}
@Override
public boolean isItalicByDefault() {
return defaultItalic;
}
@Override
public boolean isStrikethroughByDefault() {
return defaultStrikethrough;
}
@Override
public boolean isUnderlineByDefault() {
return defaultUnderline;
}
@Override
public boolean isEnabledByDefault() {
return defaultEnabled;
}
@Override
public String getDisplayName() {
return displayName;
}
@Override
public boolean requiresImplicitNames() {
return false;
}
private boolean matches(ITranslationUnit tu) {
// if the enablement expression is missing or structurally invalid, then return immediately
if (fStatus != null)
return fStatus.booleanValue();
if (enablementExpression != null)
try {
EvaluationContext evalContext = new EvaluationContext(null, tu);
ICProject cProject = tu.getCProject();
String[] natures = cProject.getProject().getDescription().getNatureIds();
evalContext.addVariable(Var_projectNature, Arrays.asList(natures));
ILanguage language = tu.getLanguage();
if( language != null )
evalContext.addVariable(Var_languageId, language.getId());
return enablementExpression.evaluate(evalContext) == EvaluationResult.TRUE;
} catch (CoreException e) {
CUIPlugin.log("Error while evaluating enablement expression for " + id, e); //$NON-NLS-1$
}
fStatus = Boolean.FALSE;
return false;
}
/**
* Return the contributed ISemanticHighlighter if the receiver should be applied to the specified TU and
* null otherwise.
*/
private ISemanticHighlighter getSemanticHighlighter(ITranslationUnit tu) {
if (!matches(tu))
return null;
if (semanticHighlighter == null)
synchronized (this) {
if (semanticHighlighter == null) {
semanticHighlighter = createSemanticHighlighter();
}
}
return semanticHighlighter;
}
@Override
public boolean consumes(ISemanticToken token) {
if (token == null)
return false;
IASTTranslationUnit astTU = token.getRoot();
if (astTU == null)
return false;
ITranslationUnit tu = astTU.getOriginatingTranslationUnit();
if (tu == null)
return false;
ISemanticHighlighter highlighter = getSemanticHighlighter(tu);
if (highlighter == null)
return false;
return highlighter.consumes(token);
}
}

View file

@ -17,6 +17,7 @@ import org.eclipse.swt.graphics.RGB;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.text.ISemanticToken;
/** /**
* Semantic highlighting. * Semantic highlighting.
@ -100,7 +101,7 @@ public abstract class SemanticHighlighting {
* @param token the semantic token for a {@link org.eclipse.cdt.core.dom.ast.IASTName} * @param token the semantic token for a {@link org.eclipse.cdt.core.dom.ast.IASTName}
* @return <code>true</code> iff the semantic highlighting consumes the semantic token * @return <code>true</code> iff the semantic highlighting consumes the semantic token
*/ */
public abstract boolean consumes(SemanticToken token); public abstract boolean consumes(ISemanticToken token);
private String getThemeColorKey() { private String getThemeColorKey() {
return CUIPlugin.PLUGIN_ID + "." + getPreferenceKey() + "Highlighting"; //$NON-NLS-1$//$NON-NLS-2$ return CUIPlugin.PLUGIN_ID + "." + getPreferenceKey() + "Highlighting"; //$NON-NLS-1$//$NON-NLS-2$

View file

@ -11,7 +11,11 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.editor; package org.eclipse.cdt.internal.ui.editor;
import java.util.Map;
import java.util.TreeMap;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.preference.PreferenceConverter;
@ -56,6 +60,7 @@ import org.eclipse.cdt.core.index.IIndexFile;
import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.index.IIndexName;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.ui.text.ISemanticToken;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator; import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
@ -228,7 +233,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IASTNode node= token.getNode(); IASTNode node= token.getNode();
if (node instanceof IASTName) { if (node instanceof IASTName) {
IASTName name= (IASTName) node; IASTName name= (IASTName) node;
@ -279,7 +284,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IASTNode node= token.getNode(); IASTNode node= token.getNode();
if (node instanceof IASTName) { if (node instanceof IASTName) {
IASTName name= (IASTName) node; IASTName name= (IASTName) node;
@ -330,7 +335,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IASTNode node= token.getNode(); IASTNode node= token.getNode();
if (node instanceof IASTImplicitName) if (node instanceof IASTImplicitName)
return false; return false;
@ -407,7 +412,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IASTNode node= token.getNode(); IASTNode node= token.getNode();
if (node instanceof IASTName) { if (node instanceof IASTName) {
IASTName name= (IASTName) node; IASTName name= (IASTName) node;
@ -461,7 +466,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IASTNode node= token.getNode(); IASTNode node= token.getNode();
if (node instanceof IASTImplicitName) if (node instanceof IASTImplicitName)
return false; return false;
@ -514,7 +519,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IASTNode node= token.getNode(); IASTNode node= token.getNode();
if (node instanceof IASTImplicitName) if (node instanceof IASTImplicitName)
return false; return false;
@ -585,7 +590,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IASTNode node= token.getNode(); IASTNode node= token.getNode();
if (node instanceof IASTImplicitName) if (node instanceof IASTImplicitName)
return false; return false;
@ -638,7 +643,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IASTNode node= token.getNode(); IASTNode node= token.getNode();
if (node instanceof IASTName) { if (node instanceof IASTName) {
IASTName name= (IASTName) node; IASTName name= (IASTName) node;
@ -698,7 +703,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IASTNode node= token.getNode(); IASTNode node= token.getNode();
if (node instanceof IASTName) { if (node instanceof IASTName) {
IASTName name= (IASTName) node; IASTName name= (IASTName) node;
@ -774,7 +779,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IASTNode node= token.getNode(); IASTNode node= token.getNode();
if (node instanceof IASTName) { if (node instanceof IASTName) {
IASTName name= (IASTName) node; IASTName name= (IASTName) node;
@ -836,7 +841,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IBinding binding= token.getBinding(); IBinding binding= token.getBinding();
if (binding instanceof IParameter) { if (binding instanceof IParameter) {
return true; return true;
@ -880,7 +885,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IASTNode node= token.getNode(); IASTNode node= token.getNode();
if (node instanceof IASTName) { if (node instanceof IASTName) {
IBinding binding= token.getBinding(); IBinding binding= token.getBinding();
@ -927,7 +932,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IASTNode node= token.getNode(); IASTNode node= token.getNode();
if (node instanceof ICPPASTQualifiedName || node instanceof ICPPASTTemplateId) { if (node instanceof ICPPASTQualifiedName || node instanceof ICPPASTTemplateId) {
return false; return false;
@ -977,7 +982,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IASTNode node= token.getNode(); IASTNode node= token.getNode();
if (node instanceof IASTName) { if (node instanceof IASTName) {
IBinding binding= token.getBinding(); IBinding binding= token.getBinding();
@ -1024,7 +1029,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IBinding binding= token.getBinding(); IBinding binding= token.getBinding();
if (binding instanceof IMacroBinding) { if (binding instanceof IMacroBinding) {
IASTName name= (IASTName)token.getNode(); IASTName name= (IASTName)token.getNode();
@ -1071,7 +1076,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IBinding binding= token.getBinding(); IBinding binding= token.getBinding();
if (binding instanceof IMacroBinding) { if (binding instanceof IMacroBinding) {
IASTName name= (IASTName)token.getNode(); IASTName name= (IASTName)token.getNode();
@ -1118,7 +1123,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IASTNode node= token.getNode(); IASTNode node= token.getNode();
if (node instanceof IASTName) { if (node instanceof IASTName) {
IASTName name= (IASTName) node; IASTName name= (IASTName) node;
@ -1169,7 +1174,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IBinding binding= token.getBinding(); IBinding binding= token.getBinding();
if (binding instanceof ICPPNamespace) { if (binding instanceof ICPPNamespace) {
return true; return true;
@ -1213,7 +1218,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IBinding binding= token.getBinding(); IBinding binding= token.getBinding();
if (binding instanceof ILabel) { if (binding instanceof ILabel) {
return true; return true;
@ -1257,7 +1262,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IASTNode node= token.getNode(); IASTNode node= token.getNode();
if (node instanceof IASTName) { if (node instanceof IASTName) {
IASTName name= (IASTName) node; IASTName name= (IASTName) node;
@ -1313,7 +1318,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IASTNode node= token.getNode(); IASTNode node= token.getNode();
if (node.getTranslationUnit().isBasedOnIncompleteIndex()) { if (node.getTranslationUnit().isBasedOnIncompleteIndex()) {
// Do not highlight problems is the AST is unreliable. // Do not highlight problems is the AST is unreliable.
@ -1370,7 +1375,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IASTNode node= token.getNode(); IASTNode node= token.getNode();
if (node instanceof IASTName) { if (node instanceof IASTName) {
IASTName name= (IASTName) node; IASTName name= (IASTName) node;
@ -1459,7 +1464,7 @@ public class SemanticHighlightings {
} }
@Override @Override
public boolean consumes(SemanticToken token) { public boolean consumes(ISemanticToken token) {
IASTNode node = token.getNode(); IASTNode node = token.getNode();
// So far we only have implicit names for overloaded operators and destructors, // So far we only have implicit names for overloaded operators and destructors,
// so this works. // so this works.
@ -1545,36 +1550,106 @@ public class SemanticHighlightings {
return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX; return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX;
} }
private static class Key implements Comparable<Key> {
public final int priority;
public final String id;
public Key(int priority) {
this(priority, null);
}
public Key(int priority, String id) {
this.priority = priority;
this.id = id;
}
@Override
public int compareTo(Key o) {
if (priority < o.priority)
return -1;
if (o.priority < priority)
return 1;
if (id == null)
return o.id == null ? 0 : -1;
return o.id == null ? 1 : id.compareTo(o.id);
}
@Override
public String toString() {
StringBuilder str = new StringBuilder();
str.append(priority);
if (id != null) {
str.append(' ');
str.append(id);
}
return str.toString();
}
}
private static void loadBuiltInSemanticHighlightings(Map<Key, SemanticHighlighting> highlightings) {
highlightings.put(new Key(10), new MacroReferenceHighlighting()); // before all others!
highlightings.put(new Key(20), new ProblemHighlighting());
highlightings.put(new Key(30), new ExternalSDKHighlighting());
highlightings.put(new Key(40), new ClassHighlighting());
highlightings.put(new Key(50), new StaticFieldHighlighting());
highlightings.put(new Key(60), new FieldHighlighting()); // after all other fields
highlightings.put(new Key(70), new MethodDeclarationHighlighting());
highlightings.put(new Key(80), new StaticMethodInvocationHighlighting());
highlightings.put(new Key(90), new ParameterVariableHighlighting()); // before local variables
highlightings.put(new Key(100), new LocalVariableDeclarationHighlighting());
highlightings.put(new Key(110), new LocalVariableHighlighting());
highlightings.put(new Key(120), new GlobalVariableHighlighting());
highlightings.put(new Key(130), new TemplateParameterHighlighting()); // before template arguments!
highlightings.put(new Key(140), new OverloadedOperatorHighlighting()); // before both method and function
highlightings.put(new Key(150), new MethodHighlighting()); // before types to get ctors
highlightings.put(new Key(160), new EnumHighlighting());
highlightings.put(new Key(170), new MacroDefinitionHighlighting());
highlightings.put(new Key(180), new FunctionDeclarationHighlighting());
highlightings.put(new Key(190), new FunctionHighlighting());
highlightings.put(new Key(200), new TypedefHighlighting());
highlightings.put(new Key(210), new NamespaceHighlighting());
highlightings.put(new Key(220), new LabelHighlighting());
highlightings.put(new Key(230), new EnumeratorHighlighting());
}
private static final String ExtensionPoint = "semanticHighlighting"; //$NON-NLS-1$
private static SemanticHighlighting[] loadSemanticHighlightings() {
Map<Key, SemanticHighlighting> highlightings = new TreeMap<SemanticHighlightings.Key, SemanticHighlighting>();
// load the built-in highlightings
loadBuiltInSemanticHighlightings(highlightings);
// load the extensions
IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
CUIPlugin.getPluginId(), ExtensionPoint);
for (IConfigurationElement element : elements) {
ContributedSemanticHighlighting contributedHighlighting = new ContributedSemanticHighlighting(
element);
Key key = new Key(contributedHighlighting.getPriority(), contributedHighlighting.getId());
highlightings.put(key, contributedHighlighting);
}
return highlightings.values().toArray(new SemanticHighlighting[highlightings.size()]);
}
private static final Object SemanticHighlightingsLock = new Object();
/** /**
* @return The semantic highlightings, the order defines the precedence of matches, the first match wins. * @return The semantic highlightings, the order defines the precedence of matches, the first match wins.
*/ */
public static SemanticHighlighting[] getSemanticHighlightings() { public static SemanticHighlighting[] getSemanticHighlightings() {
if (fgSemanticHighlightings == null) if (fgSemanticHighlightings == null)
fgSemanticHighlightings= new SemanticHighlighting[] { synchronized (SemanticHighlightingsLock) {
new MacroReferenceHighlighting(), // before all others! if (fgSemanticHighlightings == null)
new ProblemHighlighting(), fgSemanticHighlightings = loadSemanticHighlightings();
new ExternalSDKHighlighting(), }
new ClassHighlighting(),
new StaticFieldHighlighting(),
new FieldHighlighting(), // after all other fields
new MethodDeclarationHighlighting(),
new StaticMethodInvocationHighlighting(),
new ParameterVariableHighlighting(), // before local variables
new LocalVariableDeclarationHighlighting(),
new LocalVariableHighlighting(),
new GlobalVariableHighlighting(),
new TemplateParameterHighlighting(), // before template arguments!
new OverloadedOperatorHighlighting(), // before both method and function
new MethodHighlighting(), // before types to get ctors
new EnumHighlighting(),
new MacroDefinitionHighlighting(),
new FunctionDeclarationHighlighting(),
new FunctionHighlighting(),
new TypedefHighlighting(),
new NamespaceHighlighting(),
new LabelHighlighting(),
new EnumeratorHighlighting(),
};
return fgSemanticHighlightings; return fgSemanticHighlightings;
} }

View file

@ -15,6 +15,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.ui.text.ISemanticToken;
/** /**
* Semantic token. * Semantic token.
@ -22,7 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
* *
* @since 4.0 * @since 4.0
*/ */
public final class SemanticToken { public final class SemanticToken implements ISemanticToken {
/** AST node */ /** AST node */
private IASTNode fNode; private IASTNode fNode;
@ -38,6 +39,7 @@ public final class SemanticToken {
/** /**
* @return Returns the binding, can be <code>null</code>. * @return Returns the binding, can be <code>null</code>.
*/ */
@Override
public IBinding getBinding() { public IBinding getBinding() {
if (!fIsBindingResolved) { if (!fIsBindingResolved) {
fIsBindingResolved= true; fIsBindingResolved= true;
@ -51,6 +53,7 @@ public final class SemanticToken {
/** /**
* @return the AST node * @return the AST node
*/ */
@Override
public IASTNode getNode() { public IASTNode getNode() {
return fNode; return fNode;
} }
@ -58,6 +61,7 @@ public final class SemanticToken {
/** /**
* @return the AST root * @return the AST root
*/ */
@Override
public IASTTranslationUnit getRoot() { public IASTTranslationUnit getRoot() {
if (!fIsRootResolved) { if (!fIsRootResolved) {
fIsRootResolved= true; fIsRootResolved= true;

View file

@ -378,9 +378,9 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
tableProvidersViewer.refresh(); tableProvidersViewer.refresh();
tableProvidersViewer.setChecked(newProvider, isChecked); tableProvidersViewer.setChecked(newProvider, isChecked);
tableProviders.setSelection(pos); tableProviders.setSelection(pos);
tableProvidersViewer.refresh(newProvider);
saveCheckedProviders(); saveCheckedProviders();
tableProvidersViewer.refresh(newProvider);
} }
/** /**
@ -460,8 +460,8 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
replaceSelectedProvider(newProvider); // will refresh and save checked providers replaceSelectedProvider(newProvider); // will refresh and save checked providers
createOptionsPage(newProvider); createOptionsPage(newProvider);
} else { } else {
tableProvidersViewer.refresh(checkedProvider);
saveCheckedProviders(); saveCheckedProviders();
tableProvidersViewer.refresh(checkedProvider);
// option page is reused // option page is reused
} }
@ -483,7 +483,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
} else { } else {
// Toggle to configuration-owned provider // Toggle to configuration-owned provider
newProvider = getInitialProvider(id); newProvider = getInitialProvider(id);
if(newProvider == null) { if(newProvider == null || LanguageSettingsManager.isWorkspaceProvider(newProvider)) {
try { try {
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider); ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
if (rawProvider instanceof ILanguageSettingsEditableProvider) { if (rawProvider instanceof ILanguageSettingsEditableProvider) {
@ -926,7 +926,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
for (ILanguageSettingsProvider provider : allAvailableProvidersSet) { for (ILanguageSettingsProvider provider : allAvailableProvidersSet) {
String id = provider.getId(); String id = provider.getId();
if (!idsList.contains(id)) { if (!idsList.contains(id) && ScannerDiscoveryLegacySupport.isProviderCompatible(id, cfgDescription)) {
providers.add(provider); providers.add(provider);
idsList.add(id); idsList.add(id);
} }

View file

@ -29,6 +29,7 @@ import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.ui.CDTSharedImages; import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.utils.UNCPathConverter;
/** /**
* Helper class to provide unified images for {@link ICLanguageSettingEntry}. * Helper class to provide unified images for {@link ICLanguageSettingEntry}.
@ -168,6 +169,8 @@ public class LanguageSettingsImages {
IPath path = new Path(entry.getValue()); IPath path = new Path(entry.getValue());
IResource rc = ResourcesPlugin.getWorkspace().getRoot().findMember(path); IResource rc = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
exists = (rc !=null) && rc.isAccessible(); exists = (rc !=null) && rc.isAccessible();
} else if (UNCPathConverter.isUNC(entry.getName())) {
return true;
} else { } else {
String pathname = entry.getName(); String pathname = entry.getName();
java.io.File file = new java.io.File(pathname); java.io.File file = new java.io.File(pathname);

View file

@ -12,7 +12,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.text; package org.eclipse.cdt.internal.ui.text;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

View file

@ -10,7 +10,6 @@
# Anton Leherbauer (Wind River Systems) # Anton Leherbauer (Wind River Systems)
# Sergey Prigogin (Google) # Sergey Prigogin (Google)
############################################################################### ###############################################################################
AbstractAnnotationHover_action_configureAnnotationPreferences= Configure Annotation Preferences AbstractAnnotationHover_action_configureAnnotationPreferences= Configure Annotation Preferences
AbstractAnnotationHover_message_singleQuickFix= 1 quick fix available: AbstractAnnotationHover_message_singleQuickFix= 1 quick fix available:
AbstractAnnotationHover_message_multipleQuickFix= {0} quick fixes available: AbstractAnnotationHover_message_multipleQuickFix= {0} quick fixes available:

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -19,8 +19,6 @@ import java.util.List;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IEnumeration;
@ -39,7 +37,7 @@ import org.eclipse.cdt.internal.core.model.ext.ICElementHandle;
import org.eclipse.cdt.internal.ui.viewsupport.IndexUI; import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
class THGraph { class THGraph {
private static final ICElement[] NO_MEMBERS = new ICElement[0]; private static final ICElement[] NO_MEMBERS = {};
private THGraphNode fInputNode= null; private THGraphNode fInputNode= null;
private HashSet<THGraphNode> fRootNodes= new HashSet<THGraphNode>(); private HashSet<THGraphNode> fRootNodes= new HashSet<THGraphNode>();
private HashSet<THGraphNode> fLeaveNodes= new HashSet<THGraphNode>(); private HashSet<THGraphNode> fLeaveNodes= new HashSet<THGraphNode>();
@ -251,7 +249,6 @@ class THGraph {
private void addMembers(IIndex index, THGraphNode graphNode, IBinding binding) throws CoreException { private void addMembers(IIndex index, THGraphNode graphNode, IBinding binding) throws CoreException {
if (graphNode.getMembers(false) == null) { if (graphNode.getMembers(false) == null) {
ArrayList<ICElement> memberList= new ArrayList<ICElement>(); ArrayList<ICElement> memberList= new ArrayList<ICElement>();
try {
if (binding instanceof ICPPClassType) { if (binding instanceof ICPPClassType) {
ICPPClassType ct= (ICPPClassType) binding; ICPPClassType ct= (ICPPClassType) binding;
IBinding[] members= ct.getDeclaredFields(); IBinding[] members= ct.getDeclaredFields();
@ -267,9 +264,7 @@ class THGraph {
IBinding[] members= ct.getEnumerators(); IBinding[] members= ct.getEnumerators();
addMemberElements(index, members, memberList); addMemberElements(index, members, memberList);
} }
} catch (DOMException e) {
// Problem bindings should not be reported to the log.
}
if (memberList.isEmpty()) { if (memberList.isEmpty()) {
graphNode.setMembers(NO_MEMBERS); graphNode.setMembers(NO_MEMBERS);
} else { } else {

View file

@ -2219,7 +2219,7 @@ public class PreferenceConstants {
* the workspace setting should be taken. Note that passing {@code null} should be avoided. * the workspace setting should be taken. Note that passing {@code null} should be avoided.
* @param defaultValue The default value if not specified in the preferences. * @param defaultValue The default value if not specified in the preferences.
* @return Returns the current value of the preference. * @return Returns the current value of the preference.
* @since 5.5 * @since 5.6
*/ */
public static String getPreference(String key, ICProject project, String defaultValue) { public static String getPreference(String key, ICProject project, String defaultValue) {
return getPreferenceNode(key, project).get(key, defaultValue); return getPreferenceNode(key, project).get(key, defaultValue);

View file

@ -979,8 +979,11 @@ implements
} }
protected void cfgChanged(ICConfigurationDescription _cfgd) { protected void cfgChanged(ICConfigurationDescription _cfgd) {
CConfigurationStatus st = _cfgd.getConfigurationStatus(); CConfigurationStatus st = _cfgd.getConfigurationStatus();
if (st.getCode() == CConfigurationStatus.TOOLCHAIN_NOT_SUPPORTED) {
// Re-check, maybe user got the problem fixed
st = _cfgd.getConfigurationData().getStatus();
}
if (errPane != null && errMessage != null) { if (errPane != null && errMessage != null) {
if (st.isOK()) { if (st.isOK()) {
errPane.setVisible(false); errPane.setVisible(false);

View file

@ -276,11 +276,17 @@ public class ManageConfigDialog extends Dialog {
for (int i=0; i<cfgds.length; i++ ) { for (int i=0; i<cfgds.length; i++ ) {
TableItem t = new TableItem(table, 0); TableItem t = new TableItem(table, 0);
t.setText(0, cfgds[i].getName()); t.setText(0, cfgds[i].getName());
t.setText(1, cfgds[i].getDescription()); String description = cfgds[i].getDescription();
if (description == null) {
description = ""; //$NON-NLS-1$
}
t.setText(1, description);
t.setText(2, cfgds[i].isActive() ? Messages.ManageConfigDialog_5 : ""); //$NON-NLS-1$ t.setText(2, cfgds[i].isActive() ? Messages.ManageConfigDialog_5 : ""); //$NON-NLS-1$
t.setData(cfgds[i]); t.setData(cfgds[i]);
} }
if (table.getItemCount() > 0) table.select(0); if (table.getItemCount() > 0) {
table.select(0);
}
table.setFocus(); table.setFocus();
updateButtons(); updateButtons();
} }

View file

@ -0,0 +1,31 @@
/*
* Copyright (c) 2013 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
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.cdt.ui.text;
/**
* Interface that must be implemented by contributors to the org.eclipse.cdt.ui.semanticHighlighting extension
* point.
*
* @since 5.6
*/
public interface ISemanticHighlighter {
/**
* Returns <code>true</code> iff the semantic highlighting consumes the semantic token.
* <p>
* NOTE: Implementors are not allowed to keep a reference on the token or on any object retrieved from the
* token.
* </p>
*
* @param token
* the semantic token for a {@link org.eclipse.cdt.core.dom.ast.IASTName}
* @return <code>true</code> iff the semantic highlighting consumes the semantic token
*/
public boolean consumes(ISemanticToken token);
}

View file

@ -0,0 +1,27 @@
package org.eclipse.cdt.ui.text;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding;
/**
* An interface for accessing details of the token that is being highlighted.
*
* @since 5.6
*/
public interface ISemanticToken {
/**
* @return Returns the binding, can be <code>null</code>.
*/
public IBinding getBinding();
/**
* @return the AST node
*/
public IASTNode getNode();
/**
* @return the AST root
*/
public IASTTranslationUnit getRoot();
}

View file

@ -89,10 +89,13 @@ import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugModelPresentation; import org.eclipse.debug.ui.IDebugModelPresentation;
import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.ISourcePresentation;
import org.eclipse.debug.ui.IValueDetailListener; import org.eclipse.debug.ui.IValueDetailListener;
import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IEditorDescriptor; import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorInput;
@ -105,7 +108,7 @@ import com.ibm.icu.text.MessageFormat;
/** /**
* @see IDebugModelPresentation * @see IDebugModelPresentation
*/ */
public class CDebugModelPresentation extends LabelProvider implements IDebugModelPresentation { public class CDebugModelPresentation extends LabelProvider implements IDebugModelPresentation, IColorProvider {
public final static String DISPLAY_FULL_PATHS = "DISPLAY_FULL_PATHS"; //$NON-NLS-1$ public final static String DISPLAY_FULL_PATHS = "DISPLAY_FULL_PATHS"; //$NON-NLS-1$
@ -194,6 +197,14 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
} }
if ( file != null ) if ( file != null )
return new FileEditorInput( file ); return new FileEditorInput( file );
// There is no file associated with this breakpoint. See if another editor is available from an adapter
ISourcePresentation srcPres = (ISourcePresentation) Platform.getAdapterManager().getAdapter(b, ISourcePresentation.class);
if ( srcPres != null ) {
IEditorInput editor = srcPres.getEditorInput(b);
if ( editor != null ) {
return editor;
}
}
} }
if ( element instanceof FileStorage || element instanceof LocalFileStorage ) { if ( element instanceof FileStorage || element instanceof LocalFileStorage ) {
return new ExternalEditorInput( ((IStorage) element).getFullPath() ); return new ExternalEditorInput( ((IStorage) element).getFullPath() );
@ -220,7 +231,20 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
if ( input != null ) { if ( input != null ) {
IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
IEditorDescriptor descriptor = registry.getDefaultEditor( input.getName() ); IEditorDescriptor descriptor = registry.getDefaultEditor( input.getName() );
id = (descriptor != null) ? descriptor.getId() : CUIPlugin.EDITOR_ID; id = CUIPlugin.EDITOR_ID;
if ( descriptor != null ) {
id = descriptor.getId();
}
else if ( element instanceof ICBreakpoint ) {
// There is no associated editor ID for this breakpoint, see if an alternative can be supplied from an adapter.
ISourcePresentation sourcePres = (ISourcePresentation) Platform.getAdapterManager().getAdapter(element, ISourcePresentation.class);
if ( sourcePres != null ) {
String lid = sourcePres.getEditorId(input, element);
if ( lid != null ) {
id = lid;
}
}
}
} }
return id; return id;
} }
@ -797,4 +821,21 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
return MessageFormat.format( string, (Object[]) args ); return MessageFormat.format( string, (Object[]) args );
} }
@Override
public Color getForeground(Object element) {
IColorProvider colorProv = (IColorProvider) Platform.getAdapterManager().getAdapter(element, IColorProvider.class);
if ( colorProv != null ) {
return colorProv.getForeground(element);
}
return null;
}
@Override
public Color getBackground(Object element) {
IColorProvider colorProv = (IColorProvider) Platform.getAdapterManager().getAdapter(element, IColorProvider.class);
if ( colorProv != null ) {
return colorProv.getBackground(element);
}
return null;
}
} }

View file

@ -124,6 +124,12 @@ public class ReverseToggleCommandHandler extends DebugCommandHandler implements
return adapter; return adapter;
} }
/*
* (non-Javadoc)
* @see org.eclipse.debug.ui.actions.DebugCommandHandler#postExecute(org.eclipse.debug.core.IRequest, java.lang.Object[])
*
* We keep this logic for users that may not do the refresh themselves.
*/
@Override @Override
protected void postExecute(IRequest request, Object[] targets) { protected void postExecute(IRequest request, Object[] targets) {
super.postExecute(request, targets); super.postExecute(request, targets);

View file

@ -16,10 +16,13 @@ import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.internal.ui.breakpoints.CBreakpointContext; import org.eclipse.cdt.debug.internal.ui.breakpoints.CBreakpointContext;
import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.Assert;
import org.eclipse.debug.ui.contexts.IDebugContextProvider; import org.eclipse.debug.ui.contexts.IDebugContextProvider;
import org.eclipse.jface.preference.IPreferenceNode;
import org.eclipse.jface.preference.PreferenceDialog; import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.window.IShellProvider; import org.eclipse.jface.window.IShellProvider;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.SelectionProviderAction; import org.eclipse.ui.actions.SelectionProviderAction;
@ -56,10 +59,7 @@ public class CBreakpointPropertyDialogAction extends SelectionProviderAction {
private IDebugContextProvider fDebugContextProvider; private IDebugContextProvider fDebugContextProvider;
/** private static final String PAGE_ID_COMMON = "org.eclipse.cdt.debug.ui.propertypages.breakpoint.common"; //$NON-NLS-1$
* The id of the page to open up on.
*/
private String fInitialPageId = "org.eclipse.cdt.debug.ui.propertypages.breakpoint.common"; //$NON-NLS-1$
public CBreakpointPropertyDialogAction(IShellProvider shell, ISelectionProvider selectionProvider, IDebugContextProvider debugContextProvider) { public CBreakpointPropertyDialogAction(IShellProvider shell, ISelectionProvider selectionProvider, IDebugContextProvider debugContextProvider) {
super(selectionProvider, WorkbenchMessages.PropertyDialog_text); super(selectionProvider, WorkbenchMessages.PropertyDialog_text);
@ -133,7 +133,6 @@ public class CBreakpointPropertyDialogAction extends SelectionProviderAction {
return true; return true;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.action.IAction#run() * @see org.eclipse.jface.action.IAction#run()
*/ */
@ -143,8 +142,31 @@ public class CBreakpointPropertyDialogAction extends SelectionProviderAction {
PreferenceDialog dialog = createDialog(bpContext); PreferenceDialog dialog = createDialog(bpContext);
if (dialog != null) { if (dialog != null) {
TreeViewer viewer = dialog.getTreeViewer();
if (viewer != null) {
viewer.setComparator(new ViewerComparator() {
@Override
public int category(Object element) {
if (element instanceof IPreferenceNode) {
IPreferenceNode node = (IPreferenceNode)element;
if ( PAGE_ID_COMMON.equals(node.getId()) ) {
return 0;
} else if (node.getSubNodes() == null || node.getSubNodes().length == 0) {
// Pages without children (not categories)
return super.category(element) + 1;
}
}
// Categories last.
return super.category(element) + 2;
}
});
// Expand all categories
viewer.expandToLevel(TreeViewer.ALL_LEVELS);
}
dialog.open(); dialog.open();
} }
} }
} }
@ -168,7 +190,7 @@ public class CBreakpointPropertyDialogAction extends SelectionProviderAction {
if (ss.isEmpty()) if (ss.isEmpty())
return null; return null;
return PreferencesUtil.createPropertyDialogOn(fShellProvider.getShell(), bpContext, fInitialPageId, null, null); return PreferencesUtil.createPropertyDialogOn(fShellProvider.getShell(), bpContext, null, null, null);
} }

View file

@ -1,3 +1,4 @@
.metadata .metadata
cdtconvert.txt cdtconvert.txt
reference reference
/doc.bin.log

View file

@ -0,0 +1,187 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui" version="2">
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/MulticoreVisualizerUIPlugin.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.MulticoreVisualizerUIPlugin">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.MulticoreVisualizerUIPlugin"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/actions/RefreshAction.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.actions.RefreshAction">
<filter comment="The Multicore Visualizer code was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.actions.RefreshAction"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/actions/SelectAllAction.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.actions.SelectAllAction">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.actions.SelectAllAction"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/model/VisualizerCPU.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerCPU">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerCPU"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/model/VisualizerCore.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerCore">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerCore"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/model/VisualizerExecutionState.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerExecutionState">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerExecutionState"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/model/VisualizerModel.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerModel">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerModel"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/model/VisualizerThread.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerThread">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerThread"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/IMulticoreVisualizerConstants.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.IMulticoreVisualizerConstants">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.IMulticoreVisualizerConstants"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizer.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.MulticoreVisualizer">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.MulticoreVisualizer"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerCPU.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.MulticoreVisualizerCPU">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.MulticoreVisualizerCPU"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerCanvas.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.MulticoreVisualizerCanvas">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.MulticoreVisualizerCanvas"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerCore.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.MulticoreVisualizerCore">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.MulticoreVisualizerCore"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerEventListener.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.MulticoreVisualizerEventListener">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.MulticoreVisualizerEventListener"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerGraphicObject.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.MulticoreVisualizerGraphicObject">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.MulticoreVisualizerGraphicObject"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerMarquee.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.MulticoreVisualizerMarquee">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.MulticoreVisualizerMarquee"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerSelectionFinder.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.MulticoreVisualizerSelectionFinder">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.MulticoreVisualizerSelectionFinder"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerThread.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.MulticoreVisualizerThread">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view.MulticoreVisualizerThread"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/utils/DSFDebugModel.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils.DSFDebugModel">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils.DSFDebugModel"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/utils/DSFDebugModelListener.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils.DSFDebugModelListener">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils.DSFDebugModelListener"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/utils/DSFSessionState.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils.DSFSessionState">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils.DSFSessionState"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/utils/DebugViewTreeWalker.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils.DebugViewTreeWalker">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils.DebugViewTreeWalker"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/utils/DebugViewUtils.java" type="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils.DebugViewUtils">
<filter comment="Multicore Visualizer was meant to be internal" id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils.DebugViewUtils"/>
<message_argument value="org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui_1.1.0"/>
</message_arguments>
</filter>
</resource>
</component>

View file

@ -18,8 +18,8 @@ Require-Bundle: org.eclipse.ui,
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: com.ibm.icu.text Import-Package: com.ibm.icu.text
Export-Package: org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui, Export-Package: org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui;x-internal:=true,
org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.actions, org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.actions;x-internal:=true,
org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model, org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model;x-internal:=true,
org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view, org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;x-internal:=true,
org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils;x-internal:=true

View file

@ -8,6 +8,7 @@
* Contributors: * Contributors:
* William R. Swanson (Tilera Corporation) - initial API and implementation * William R. Swanson (Tilera Corporation) - initial API and implementation
* IBM Corporation * IBM Corporation
* Marc Dumais (Ericsson) - Bug 399281
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view; package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;
@ -705,10 +706,11 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
protected void setCanvasModel(VisualizerModel model) { protected void setCanvasModel(VisualizerModel model) {
final VisualizerModel model_f = model; final VisualizerModel model_f = model;
GUIUtils.exec(new Runnable() { @Override public void run() { GUIUtils.exec(new Runnable() { @Override public void run() {
if(m_canvas != null) {
m_canvas.setModel(model_f); m_canvas.setModel(model_f);
// Update the canvas's selection from the current workbench selection. // Update the canvas's selection from the current workbench selection.
updateCanvasSelectionInternal(); updateCanvasSelectionInternal();
}
}}); }});
} }

View file

@ -11,6 +11,7 @@
* Marc Dumais (Ericsson) - Bug 396184 * Marc Dumais (Ericsson) - Bug 396184
* Marc Dumais (Ericsson) - Bug 396200 * Marc Dumais (Ericsson) - Bug 396200
* Marc Dumais (Ericsson) - Bug 396293 * Marc Dumais (Ericsson) - Bug 396293
* Marc Dumais (Ericsson) - Bug 399281
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view; package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;
@ -303,7 +304,9 @@ public class MulticoreVisualizerCanvas extends GraphicCanvas
*/ */
public void requestUpdate() { public void requestUpdate() {
GUIUtils.exec(new Runnable() { @Override public void run() { GUIUtils.exec(new Runnable() { @Override public void run() {
if (m_updateTimer != null) {
m_updateTimer.start(); m_updateTimer.start();
}
}}); }});
} }
@ -867,8 +870,10 @@ public class MulticoreVisualizerCanvas extends GraphicCanvas
/** Removes external listener for selection change events. */ /** Removes external listener for selection change events. */
@Override @Override
public void removeSelectionChangedListener(ISelectionChangedListener listener) { public void removeSelectionChangedListener(ISelectionChangedListener listener) {
if (m_selectionManager != null) {
m_selectionManager.removeSelectionChangedListener(listener); m_selectionManager.removeSelectionChangedListener(listener);
} }
}
/** Raises selection changed event. */ /** Raises selection changed event. */
public void raiseSelectionChangedEvent() { public void raiseSelectionChangedEvent() {

Some files were not shown because too many files have changed in this diff Show more