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:
commit
3198d038d4
173 changed files with 5130 additions and 1617 deletions
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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.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.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.ICygwinToolsFactroy;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -32,125 +38,135 @@ import org.eclipse.core.runtime.Platform;
|
|||
|
||||
/**
|
||||
* Use binary parser's 'cygpath' command to translate cygpaths to absolute paths.
|
||||
* Note that this class does not support build configurations.
|
||||
*
|
||||
* @author vhirsl
|
||||
*/
|
||||
public class CygpathTranslator {
|
||||
/** Default Cygwin root dir */
|
||||
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 boolean isAvailable = false;
|
||||
|
||||
public CygpathTranslator(IProject project) {
|
||||
try {
|
||||
ICConfigExtensionReference[] parserRef = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(project);
|
||||
for (int i = 0; i < parserRef.length; i++) {
|
||||
try {
|
||||
IBinaryParser parser = CoreModelUtil.getBinaryParser(parserRef[i]);
|
||||
ICygwinToolsFactroy cygwinToolFactory = (ICygwinToolsFactroy) parser.getAdapter(ICygwinToolsFactroy.class);
|
||||
if (cygwinToolFactory != null) {
|
||||
cygPath = cygwinToolFactory.getCygPath();
|
||||
if (cygPath != null) {
|
||||
isAvailable = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} 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 (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) {
|
||||
// first check if cygpath translation is needed at all
|
||||
boolean translationNeeded = false;
|
||||
if (Platform.getOS().equals(Platform.OS_WIN32)) {
|
||||
for (Iterator<String> i = sumIncludes.iterator(); i.hasNext(); ) {
|
||||
private static final String ENV_PATH = "PATH"; //$NON-NLS-1$
|
||||
|
||||
private CygPath cygPath = null;
|
||||
|
||||
public CygpathTranslator(IProject project) {
|
||||
try {
|
||||
ICConfigExtensionReference[] parserRef = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(project);
|
||||
for (int i = 0; i < parserRef.length; i++) {
|
||||
try {
|
||||
IBinaryParser parser = CoreModelUtil.getBinaryParser(parserRef[i]);
|
||||
ICygwinToolsFactroy cygwinToolFactory = (ICygwinToolsFactroy) parser.getAdapter(ICygwinToolsFactroy.class);
|
||||
if (cygwinToolFactory != null) {
|
||||
cygPath = cygwinToolFactory.getCygPath();
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> translateIncludePaths(IProject project, List<String> sumIncludes) {
|
||||
// first check if cygpath translation is needed at all
|
||||
boolean translationNeeded = false;
|
||||
if (Platform.getOS().equals(Platform.OS_WIN32)) {
|
||||
for (Iterator<String> i = sumIncludes.iterator(); i.hasNext(); ) {
|
||||
String include = i.next();
|
||||
if (include.startsWith("/")) { //$NON-NLS-1$
|
||||
translationNeeded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!translationNeeded) {
|
||||
return sumIncludes;
|
||||
}
|
||||
|
||||
CygpathTranslator cygpath = new CygpathTranslator(project);
|
||||
|
||||
List<String> translatedIncludePaths = new ArrayList<String>();
|
||||
for (Iterator<String> i = sumIncludes.iterator(); i.hasNext(); ) {
|
||||
String includePath = i.next();
|
||||
IPath realPath = new Path(includePath);
|
||||
// only allow native pathes if they have a device prefix
|
||||
// to avoid matches on the current drive, e.g. /usr/bin = C:\\usr\\bin
|
||||
if (realPath.getDevice() != null && realPath.toFile().exists()) {
|
||||
translatedIncludePaths.add(includePath);
|
||||
}
|
||||
else {
|
||||
String translatedPath = includePath;
|
||||
if (cygpath.isAvailable) {
|
||||
try {
|
||||
translatedPath = cygpath.cygPath.getFileName(includePath);
|
||||
}
|
||||
catch (IOException e) {
|
||||
TraceUtil.outputError("CygpathTranslator unable to translate path: ", includePath); //$NON-NLS-1$
|
||||
}
|
||||
} else if (realPath.segmentCount() >= 2) {
|
||||
// try default conversions
|
||||
// /cygdrive/x/ --> X:\
|
||||
if ("cygdrive".equals(realPath.segment(0))) { //$NON-NLS-1$
|
||||
String drive= realPath.segment(1);
|
||||
if (drive.length() == 1) {
|
||||
translatedPath= realPath.removeFirstSegments(2).makeAbsolute().setDevice(drive.toUpperCase() + ':').toOSString();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!translatedPath.equals(includePath)) {
|
||||
// Check if the translated path exists
|
||||
if (new File(translatedPath).exists()) {
|
||||
translatedIncludePaths.add(translatedPath);
|
||||
}
|
||||
else if (cygpath.isAvailable) {
|
||||
// TODO VMIR for now add even if it does not exist
|
||||
translatedIncludePaths.add(translatedPath);
|
||||
}
|
||||
else {
|
||||
translatedIncludePaths.add(includePath);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// TODO VMIR for now add even if it does not exist
|
||||
translatedIncludePaths.add(translatedPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cygpath.cygPath != null) {
|
||||
cygpath.cygPath.dispose();
|
||||
}
|
||||
return translatedIncludePaths;
|
||||
}
|
||||
}
|
||||
if (!translationNeeded) {
|
||||
return sumIncludes;
|
||||
}
|
||||
|
||||
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>();
|
||||
for (Iterator<String> i = sumIncludes.iterator(); i.hasNext(); ) {
|
||||
String includePath = i.next();
|
||||
IPath realPath = new Path(includePath);
|
||||
// only allow native pathes if they have a device prefix
|
||||
// to avoid matches on the current drive, e.g. /usr/bin = C:\\usr\\bin
|
||||
if (realPath.getDevice() != null && realPath.toFile().exists()) {
|
||||
translatedIncludePaths.add(includePath);
|
||||
}
|
||||
else {
|
||||
String translatedPath = includePath;
|
||||
|
||||
if (useCygPathExtension) {
|
||||
try {
|
||||
translatedPath = cygpath.cygPath.getFileName(includePath);
|
||||
}
|
||||
catch (IOException e) {
|
||||
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) {
|
||||
// try default conversions
|
||||
// /cygdrive/x/ --> X:\
|
||||
if ("cygdrive".equals(realPath.segment(0))) { //$NON-NLS-1$
|
||||
String drive= realPath.segment(1);
|
||||
if (drive.length() == 1) {
|
||||
translatedPath= realPath.removeFirstSegments(2).makeAbsolute().setDevice(drive.toUpperCase() + ':').toOSString();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!translatedPath.equals(includePath)) {
|
||||
// Check if the translated path exists
|
||||
if (new File(translatedPath).exists()) {
|
||||
translatedIncludePaths.add(translatedPath);
|
||||
}
|
||||
else if (useCygPathExtension || useCygwinFromPath) {
|
||||
// TODO VMIR for now add even if it does not exist
|
||||
translatedIncludePaths.add(translatedPath);
|
||||
}
|
||||
else {
|
||||
translatedIncludePaths.add(includePath);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// TODO VMIR for now add even if it does not exist
|
||||
translatedIncludePaths.add(translatedPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (useCygPathExtension) {
|
||||
cygpath.cygPath.dispose();
|
||||
}
|
||||
return translatedIncludePaths;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.core.tests;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
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.IScannerInfoChangeListener;
|
||||
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.IConfiguration;
|
||||
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.
|
||||
* 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
|
||||
IPath buildCWD = project.getLocation().append("Sub Config");
|
||||
final String[] expectedPaths = new String[5];
|
||||
|
||||
final String[] expectedPaths;
|
||||
if (new Path("C:\\home\\tester/include").isAbsolute()) {
|
||||
// Windows
|
||||
expectedPaths = new String[] {
|
||||
toOSLocation("/usr/include"),
|
||||
toOSLocation("/opt/gnome/include"),
|
||||
toOSLocation("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
|
||||
};
|
||||
} 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
|
||||
};
|
||||
}
|
||||
// This first path is a built-in, so it will not be manipulated by build manager
|
||||
expectedPaths[0] = (new Path("/usr/include")).toOSString();
|
||||
expectedPaths[1] = (new Path("/opt/gnome/include")).toOSString();
|
||||
IPath path = new Path("C:\\home\\tester/include");
|
||||
if(path.isAbsolute()) // for win32 path is treated as absolute
|
||||
expectedPaths[2] = path.toOSString();
|
||||
else // for Linux path is relative
|
||||
expectedPaths[2] = project.getLocation().append("Sub Config").append(path).toOSString();
|
||||
expectedPaths[3] = project.getLocation().append( "includes" ).toOSString();
|
||||
expectedPaths[4] = (new Path("/usr/gnu/include")).toOSString();
|
||||
|
||||
// Create a new managed project based on the sub project type
|
||||
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
|
||||
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
|
||||
assertNotNull(provider);
|
||||
assertTrue(provider instanceof LanguageSettingsScannerInfoProvider);
|
||||
|
||||
// Now subscribe (note that the method will be called after a change
|
||||
provider.subscribe(project, new IScannerInfoChangeListener () {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -9,6 +9,7 @@
|
|||
* Intel Corporation - Initial API and implementation
|
||||
* Enrico Ehrich - http://bugs.eclipse.org/233866
|
||||
* 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;
|
||||
|
||||
|
@ -19,9 +20,8 @@ import java.io.InputStream;
|
|||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
|
||||
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.internal.core.Cygwin;
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildPathResolver;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
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.spawner.ProcessFactory;
|
||||
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.
|
||||
*/
|
||||
public class CygwinPathResolver implements IBuildPathResolver {
|
||||
private static final String DEFAULT_ROOT = "C:\\cygwin"; //$NON-NLS-1$
|
||||
private static final String TOOL = "/cygpath -w -p "; //$NON-NLS-1$
|
||||
private static final char BS = '\\';
|
||||
private static final char SLASH = '/';
|
||||
private static final String ENV_PATH = "PATH"; //$NON-NLS-1$
|
||||
private static final String DELIMITER_UNIX = ":"; //$NON-NLS-1$
|
||||
private static final String DELIMITER_WIN = ";"; //$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 SP = " "; //$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$
|
||||
private static final String OS_WINDOWS = "windows";//$NON-NLS-1$
|
||||
private static final char SLASH = '/';
|
||||
private static final char BACKSLASH = '\\';
|
||||
|
||||
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
|
||||
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 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_ALTERNATE = "/bin"; //$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 MINGW_SPECIAL = "mingw "; //$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
|
||||
public String[] resolveBuildPaths(int pathType, String variableName, String variableValue, IConfiguration configuration) {
|
||||
if(!isWindows()) {
|
||||
|
@ -72,58 +67,66 @@ public class CygwinPathResolver implements IBuildPathResolver {
|
|||
return variableValue.split(DELIMITER_WIN);
|
||||
}
|
||||
|
||||
String[] result = variableValue.split(DELIMITER_UNIX);
|
||||
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);
|
||||
String[] lines = executeInConfigurationContext(CYGPATH_PATH_LIST_TO_WINDOWS + variableValue, configuration);
|
||||
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.
|
||||
* Please rely on internal caching.
|
||||
*/
|
||||
@Deprecated
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Please rely on internal caching.
|
||||
*/
|
||||
@Deprecated
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Please rely on internal caching.
|
||||
*/
|
||||
@Deprecated
|
||||
public static String getRootPath() {
|
||||
findPaths();
|
||||
return rootCygwin;
|
||||
return Cygwin.getCygwinHome();
|
||||
}
|
||||
|
||||
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) {
|
||||
WindowsRegistry registry = WindowsRegistry.getRegistry();
|
||||
if (null != registry) {
|
||||
String s = registry.getCurrentUserValue(key, name);
|
||||
if(s == null)
|
||||
s = registry.getLocalMachineValue(key, name);
|
||||
|
||||
if (s != null)
|
||||
return (s.replaceAll(BSLASH, SSLASH));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the absolute path of the pattern by
|
||||
* simply appending the pattern to the root
|
||||
*
|
||||
* @param pattern The pattern to find
|
||||
* @return The absolute path to the pattern or null if pattern is not found
|
||||
*/
|
||||
private static String getValueFromRoot(String pattern) {
|
||||
if (rootCygwin != null) {
|
||||
String path = rootCygwin + pattern;
|
||||
File file = new File(path);
|
||||
if (file.exists() && file.isDirectory())
|
||||
return (path.replaceAll(BSLASH, SSLASH));
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the absolute path to cygwin's root
|
||||
*
|
||||
* @return The absolute path to cygwin's root or null if not found
|
||||
*/
|
||||
private static String findRoot(String paths) {
|
||||
String rootValue = null;
|
||||
|
||||
// 1. Look in PATH values. Look for bin\cygwin1.dll
|
||||
IPath location = PathUtil.findProgramLocation("cygwin1.dll", paths); //$NON-NLS-1$
|
||||
if (location!=null) {
|
||||
rootValue = location.removeLastSegments(2).toOSString();
|
||||
}
|
||||
|
||||
// 2. Try to find the root dir in SOFTWARE\Cygwin\setup
|
||||
if(rootValue == null) {
|
||||
rootValue = readValueFromRegistry(REGISTRY_KEY_SETUP, "rootdir"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
// 3. Try to find the root dir in SOFTWARE\Wow6432Node\Cygwin\setup
|
||||
if(rootValue == null) {
|
||||
rootValue = readValueFromRegistry(REGISTRY_KEY_SETUP_WIN64, "rootdir"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
// 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.
|
||||
*/
|
||||
private static synchronized void findPaths() {
|
||||
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);
|
||||
String env[] = new String[vars.length];
|
||||
for(int i = 0; i < env.length; i++) {
|
||||
env[i] = vars[i].getName() + "="; //$NON-NLS-1$
|
||||
String value = vars[i].getValue();
|
||||
if(value != null)
|
||||
env[i] += value;
|
||||
if (registry != null) {
|
||||
String value = registry.getCurrentUserValue(key, name);
|
||||
if (value == null) {
|
||||
value = registry.getLocalMachineValue(key, name);
|
||||
}
|
||||
Process proc = ProcessFactory.getFactory().exec(cmd.split(SP), env);
|
||||
if (proc != null) {
|
||||
if (value != null) {
|
||||
return value.replace(BACKSLASH, SLASH);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
InputStream ein = proc.getInputStream();
|
||||
BufferedReader d1 = new BufferedReader(new InputStreamReader(ein));
|
||||
ArrayList<String> ls = new ArrayList<String>(10);
|
||||
String s;
|
||||
while ((s = d1.readLine() ) != null ) {
|
||||
ls.add(s);
|
||||
/**
|
||||
* Returns the absolute path of the pattern by simply appending the relativePath to the root.
|
||||
*
|
||||
* @param relativePath - the pattern to find.
|
||||
* @return The absolute path to the pattern or {@code null} if path does not exist.
|
||||
*/
|
||||
private static String getPathFromRoot(String relativePath) {
|
||||
String rootCygwin = Cygwin.getCygwinHome();
|
||||
if (rootCygwin != null) {
|
||||
String path = rootCygwin + relativePath;
|
||||
File file = new File(path);
|
||||
if (file.exists() && file.isDirectory()) {
|
||||
return path.replace(BACKSLASH, SLASH);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve and return full path to program in context of configuration.
|
||||
*
|
||||
* @param program - program to resolve.
|
||||
* @param cfg - configuration context.
|
||||
* @return absolute path to program.
|
||||
*/
|
||||
private static String resolveProgram(String program, IConfiguration cfg) {
|
||||
String envPathValue = null;
|
||||
try {
|
||||
IEnvironmentVariable envPathVar = ManagedBuildManager.getEnvironmentVariableProvider().getVariable(ENV_PATH, cfg, true);
|
||||
if (envPathVar != null) {
|
||||
envPathValue = envPathVar.getValue();
|
||||
IPath progPath = PathUtil.findProgramLocation(program, envPathValue);
|
||||
if (progPath != null) {
|
||||
program = progPath.toOSString();
|
||||
}
|
||||
// this resolves cygwin symbolic links
|
||||
program = Cygwin.cygwinToWindowsPath(program, envPathValue);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
GnuUIPlugin.getDefault().log(new Status(IStatus.WARNING, GnuUIPlugin.PLUGIN_ID, "Problem trying to find program [" + program + "] in $PATH=[" + envPathValue + "]", e));
|
||||
}
|
||||
return program;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 String[] getEnvp(IConfiguration cfg) {
|
||||
IEnvironmentVariable vars[] = ManagedBuildManager.getEnvironmentVariableProvider().getVariables(cfg,true);
|
||||
String envp[] = new String[vars.length];
|
||||
for(int i = 0; i < envp.length; i++) {
|
||||
envp[i] = vars[i].getName() +'=';
|
||||
String value = vars[i].getValue();
|
||||
if(value != null)
|
||||
envp[i] += value;
|
||||
}
|
||||
return envp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
try {
|
||||
BufferedReader d1 = new BufferedReader(new InputStreamReader(ein));
|
||||
ArrayList<String> ls = new ArrayList<String>(10);
|
||||
String s;
|
||||
while ((s = d1.readLine()) != null ) {
|
||||
ls.add(s);
|
||||
}
|
||||
result = ls.toArray(new String[0]);
|
||||
} finally {
|
||||
ein.close();
|
||||
}
|
||||
ein.close();
|
||||
return ls.toArray(new String[0]);
|
||||
}
|
||||
} 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) {
|
||||
String versionInfo[] = exec(GCC_VERSION_CMD, cfg);
|
||||
String versionInfo[] = executeInConfigurationContext(GCC_VERSION_CMD, cfg);
|
||||
if(versionInfo != null) {
|
||||
for(int i = 0; i < versionInfo.length; i++) {
|
||||
if(versionInfo[i].indexOf(MINGW_SPECIAL) != -1)
|
||||
|
|
|
@ -1,33 +1,38 @@
|
|||
/*******************************************************************************
|
||||
* 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
|
||||
* 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:
|
||||
* 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;
|
||||
|
||||
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.envvar.IBuildEnvironmentVariable;
|
||||
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
|
||||
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
|
||||
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.
|
||||
*/
|
||||
public class GnuCygwinConfigurationEnvironmentSupplier implements IConfigurationEnvironmentVariableSupplier {
|
||||
private static final String PATH = "PATH"; //$NON-NLS-1$
|
||||
private static final String DELIMITER_UNIX = ":"; //$NON-NLS-1$
|
||||
private static final String PROPERTY_DELIMITER = "path.separator"; //$NON-NLS-1$
|
||||
private static final String PROPERTY_OSNAME = "os.name"; //$NON-NLS-1$
|
||||
private static final String ENV_PATH = "PATH"; //$NON-NLS-1$
|
||||
private static final String ENV_LANG = "LANG"; //$NON-NLS-1$
|
||||
private static final String ENV_LC_ALL = "LC_ALL"; //$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 LC_ALL = "LC_ALL"; //$NON-NLS-1$
|
||||
private static final String LC_MESSAGES = "LC_MESSAGES"; //$NON-NLS-1$
|
||||
private static final String PROPERTY_OSNAME = "os.name"; //$NON-NLS-1$
|
||||
private static final String BACKSLASH = java.io.File.separator;
|
||||
|
||||
@Override
|
||||
public IBuildEnvironmentVariable getVariable(String variableName, IConfiguration configuration, IEnvironmentVariableProvider provider) {
|
||||
|
@ -39,19 +44,33 @@ public class GnuCygwinConfigurationEnvironmentSupplier implements IConfiguration
|
|||
return null;
|
||||
}
|
||||
|
||||
if (variableName.equalsIgnoreCase(PATH)) {
|
||||
String p = CygwinPathResolver.getBinPath();
|
||||
if (p != null) {
|
||||
return new BuildEnvVar(PATH, p.replace('/','\\'), IBuildEnvironmentVariable.ENVVAR_PREPEND, System.getProperty(PROPERTY_DELIMITER, DELIMITER_UNIX));
|
||||
if (variableName.equalsIgnoreCase(ENV_PATH)) {
|
||||
@SuppressWarnings("nls")
|
||||
String path = "${" + Cygwin.ENV_CYGWIN_HOME + "}" + BACKSLASH + "bin";
|
||||
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
|
||||
String langValue = System.getenv(LANG);
|
||||
String langValue = System.getenv(ENV_LANG);
|
||||
if (langValue == null || langValue.length() == 0) {
|
||||
langValue = System.getenv(LC_ALL);
|
||||
langValue = System.getenv(ENV_LC_ALL);
|
||||
}
|
||||
if (langValue == null || langValue.length() == 0) {
|
||||
langValue = System.getenv(LC_MESSAGES);
|
||||
langValue = System.getenv(ENV_LC_MESSAGES);
|
||||
}
|
||||
if (langValue != null && langValue.length() > 0) {
|
||||
// langValue is [language[_territory][.codeset][@modifier]], i.e. "en_US.UTF-8@dict"
|
||||
|
@ -61,21 +80,17 @@ public class GnuCygwinConfigurationEnvironmentSupplier implements IConfiguration
|
|||
} else {
|
||||
langValue = "C.ISO-8859-1"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
return new BuildEnvVar(LANG, langValue);
|
||||
return new BuildEnvVar(ENV_LANG, langValue);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBuildEnvironmentVariable[] getVariables(IConfiguration configuration, IEnvironmentVariableProvider provider) {
|
||||
IBuildEnvironmentVariable varLang = getVariable(LANG, configuration, provider);
|
||||
IBuildEnvironmentVariable varPath = getVariable(PATH, configuration, provider);
|
||||
IBuildEnvironmentVariable varHome = getVariable(Cygwin.ENV_CYGWIN_HOME, configuration, provider);
|
||||
IBuildEnvironmentVariable varLang = getVariable(ENV_LANG, configuration, provider);
|
||||
IBuildEnvironmentVariable varPath = getVariable(ENV_PATH, configuration, provider);
|
||||
|
||||
if (varPath != null) {
|
||||
return new IBuildEnvironmentVariable[] {varLang, varPath};
|
||||
} else {
|
||||
return new IBuildEnvironmentVariable[] {varLang};
|
||||
}
|
||||
return new IBuildEnvironmentVariable[] {varHome, varLang, varPath};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,85 +7,28 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
* Andrew Gvozdev - Ability to use different Cygwin versions in different configurations
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.gnu.cygwin;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
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.internal.core.Cygwin;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedIsToolChainSupported;
|
||||
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
||||
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableManagerToolChain;
|
||||
import org.osgi.framework.Version;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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
|
||||
public boolean isSupported(IToolChain toolChain, Version version, String instance) {
|
||||
String etcCygwin = CygwinPathResolver.getEtcPath();
|
||||
if (CDataUtil.objectsEqual(etcCygwin, etcCygwinCached)) {
|
||||
return toolchainIsSupported;
|
||||
}
|
||||
|
||||
toolchainIsSupported = etcCygwin != null && arePackagesInstalled(etcCygwin);
|
||||
etcCygwinCached = etcCygwin;
|
||||
|
||||
return toolchainIsSupported;
|
||||
String envPath = EnvironmentVariableManagerToolChain.getDefault().getVariableInConfigurationContext(ENV_PATH, toolChain, true);
|
||||
return Cygwin.isAvailable(envPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<configuration>
|
||||
<!-- Need UI harness for quick fix tests -->
|
||||
<useUIHarness>true</useUIHarness>
|
||||
<argLine>-Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
|
||||
<argLine>-ea -Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
|
||||
<includes>
|
||||
<include>**/AutomatedIntegrationSuite.*</include>
|
||||
</includes>
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -9,6 +9,7 @@
|
|||
* Devin Steffler (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||
|
||||
|
@ -6060,14 +6061,14 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
|
|||
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
|
||||
ICPPTemplateInstance inst;
|
||||
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);
|
||||
assertEquals("<20>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
||||
assertEquals("<int20>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
||||
bh.assertProblem("f2(v)", 2);
|
||||
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);
|
||||
assertEquals("<10>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
||||
assertEquals("<int10>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
||||
}
|
||||
|
||||
// template <int i> class A { };
|
||||
|
@ -6086,9 +6087,9 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
|
|||
ICPPTemplateInstance inst;
|
||||
bh.assertProblem("g(a1)", 1);
|
||||
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);
|
||||
assertEquals("<1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
||||
assertEquals("<int1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
||||
}
|
||||
|
||||
// template<typename T> class A {
|
||||
|
@ -6134,9 +6135,9 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
|
|||
ICPPTemplateInstance inst;
|
||||
bh.assertProblem("f(a)", 1);
|
||||
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);
|
||||
assertEquals("<1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
||||
assertEquals("<short int1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
|
||||
}
|
||||
|
||||
// template<class T> void f(void(*)(T,int));
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* Sergey Prigogin (Google)
|
||||
* Thomas Corbat (IFS)
|
||||
* Nathan Ridge
|
||||
* Marc-Andre Laperle
|
||||
*******************************************************************************/
|
||||
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.parser.ParserLanguage;
|
||||
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.CPPClassType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethod;
|
||||
|
@ -7480,6 +7482,14 @@ public class AST2CPPTests extends AST2TestBase {
|
|||
BindingAssertionHelper ba= getAssertionHelper();
|
||||
ba.assertProblem("enum_name", 9);
|
||||
}
|
||||
|
||||
// struct MyStruct {
|
||||
// enum MyEnum {};
|
||||
// MyStruct(MyEnum value) {}
|
||||
// };
|
||||
public void testEnumRedefinitionInStruct_385144() throws Exception {
|
||||
parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP);
|
||||
}
|
||||
|
||||
// class CL {
|
||||
// typedef int x;
|
||||
|
@ -10125,4 +10135,64 @@ public class AST2CPPTests extends AST2TestBase {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4405,6 +4405,17 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
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<int I> class CTI {};
|
||||
//
|
||||
|
@ -4830,6 +4841,25 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
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 {
|
||||
// void Update() {}
|
||||
// };
|
||||
|
@ -7021,7 +7051,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// void test() {
|
||||
// int x = C<bool>::id;
|
||||
// }
|
||||
public void _testDependentEnumValue_389009() throws Exception {
|
||||
public void testDependentEnumValue_389009() throws Exception {
|
||||
BindingAssertionHelper ah = getAssertionHelper();
|
||||
IEnumerator binding = ah.assertNonProblem("C<bool>::id", "id");
|
||||
IValue value = binding.getValue();
|
||||
|
@ -7029,4 +7059,110 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
assertNotNull(num);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,6 +110,7 @@ public class AST2TestBase extends BaseTestCase {
|
|||
map.put("__SIZEOF_SHORT__", "2");
|
||||
map.put("__SIZEOF_INT__", "4");
|
||||
map.put("__SIZEOF_LONG__", "8");
|
||||
map.put("__SIZEOF_POINTER__", "8");
|
||||
return map;
|
||||
}
|
||||
|
||||
|
@ -118,6 +119,7 @@ public class AST2TestBase extends BaseTestCase {
|
|||
map.put("__SIZEOF_SHORT__", "2");
|
||||
map.put("__SIZEOF_INT__", "4");
|
||||
map.put("__SIZEOF_LONG__", "8");
|
||||
map.put("__SIZEOF_POINTER__", "8");
|
||||
return map;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.IASTLabelStatement;
|
||||
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.IASTNamedTypeSpecifier;
|
||||
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.IASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
||||
|
@ -7426,4 +7428,29 @@ public class AST2Tests extends AST2TestBase {
|
|||
public void testNoRawStringInPlainC_397127() throws Exception {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.Kind;
|
||||
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.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
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.ICPPBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
|
@ -2063,6 +2065,27 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
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>
|
||||
// struct A {
|
||||
// typedef U type1;
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,13 +7,13 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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
|
||||
*/
|
||||
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() {
|
||||
return suite(IndexCompositeTests.class);
|
||||
|
@ -101,8 +151,9 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
setIndex(cprojA, REFD); assertBCount(1, 1);
|
||||
setIndex(cprojA, BOTH); assertBCount(2, 2);
|
||||
} finally {
|
||||
for (ICProject project : projects)
|
||||
for (ICProject project : projects) {
|
||||
project.getProject().delete(true, true, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,7 +226,6 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
assertNamespaceXMemberCount(5);
|
||||
assertFieldCount("C1", 1);
|
||||
|
||||
|
||||
setIndex(cprojB, NONE);
|
||||
assertBCount(gBC, aBC);
|
||||
assertNamespaceXMemberCount(2);
|
||||
|
@ -195,7 +245,6 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
assertBCount(gABC, aABC);
|
||||
assertNamespaceXMemberCount(5);
|
||||
assertFieldCount("C1", 1);
|
||||
|
||||
|
||||
setIndex(cprojA, NONE);
|
||||
assertBCount(gABC, aABC);
|
||||
|
@ -217,8 +266,9 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
assertNamespaceXMemberCount(5);
|
||||
assertFieldCount("C1", 1);
|
||||
} finally {
|
||||
for (ICProject project : projects)
|
||||
for (ICProject project : projects) {
|
||||
project.getProject().delete(true, true, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -259,7 +309,6 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
ICProject cprojC = pb.create();
|
||||
projects.add(cprojC);
|
||||
|
||||
|
||||
/* A C |
|
||||
* \ / | Depends On / References
|
||||
* B V
|
||||
|
@ -278,7 +327,6 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
final int gAB= gA + gB - 1, aAB= aA + aB - 1;
|
||||
final int gABC= gA + gBC - 1, aABC= aA + aBC - 1;
|
||||
|
||||
|
||||
setIndex(cprojC, NONE);
|
||||
assertBCount(gBC, aBC);
|
||||
assertNamespaceXMemberCount(3);
|
||||
|
@ -318,8 +366,9 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
assertBCount(gABC, aABC);
|
||||
assertNamespaceXMemberCount(4);
|
||||
} finally {
|
||||
for (ICProject project : projects)
|
||||
for (ICProject project : projects) {
|
||||
project.getProject().delete(true, true, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -415,8 +464,9 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
assertBCount(gABC, aABC);
|
||||
assertNamespaceXMemberCount(4);
|
||||
} finally {
|
||||
for (ICProject project : projects)
|
||||
for (ICProject project : projects) {
|
||||
project.getProject().delete(true, true, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -438,13 +488,13 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
private void assertNamespaceXMemberCount(int count) throws CoreException, DOMException {
|
||||
IBinding[] bindings = index.findBindings(Pattern.compile("X"), true, FILTER, new NullProgressMonitor());
|
||||
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 {
|
||||
IBinding[] bindings = index.findBindings(Pattern.compile(qnPattern), true, FILTER, new NullProgressMonitor());
|
||||
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 {
|
||||
|
@ -463,53 +513,3 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -240,7 +240,8 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
for (int i = 0; i < nchars.length; i++) {
|
||||
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() {
|
||||
|
@ -256,7 +257,6 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
// short globalVar;
|
||||
|
||||
// register int globalVar;
|
||||
|
||||
public void testGlobalCppVariable() throws Exception {
|
||||
setupFile(3, true);
|
||||
checkCppVariable("globalVar", INT, new String[]{});
|
||||
|
@ -345,7 +345,6 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
// struct my_struct {int fField;};
|
||||
|
||||
// struct my_struct {short fField;};
|
||||
|
||||
public void testCField() throws Exception {
|
||||
setupFile(2, false);
|
||||
checkVariable("my_struct::fField", INT, new String[]{});
|
||||
|
@ -402,7 +401,6 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
checkModifier(modifiers, PRIVATE, visibility == ICPPMember.v_private);
|
||||
}
|
||||
|
||||
|
||||
// class MyClass {int 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 {virtual int method(char a) = 0;};
|
||||
|
||||
public void testCppMethod() throws Exception {
|
||||
setupFile(10, true);
|
||||
checkCppMethod("MyClass::method", new String[] {INT, INT, INT}, new String[]{PRIVATE});
|
||||
|
@ -453,7 +450,6 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
|
||||
// #include "header.h"
|
||||
// char MyClass::method(int a, int b);
|
||||
|
||||
public void testFixedCppMethod() throws Exception {
|
||||
setupHeader(3, true);
|
||||
checkCppMethod("MyClass::method", new String[] {INT, INT, INT}, new String[]{PROTECTED});
|
||||
|
@ -493,7 +489,6 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
// class MyClass {protected: MyClass(char a, int b);};
|
||||
|
||||
// class MyClass {private: MyClass(char a, int b);};
|
||||
|
||||
public void testCppConstructor() throws Exception {
|
||||
setupFile(6, true);
|
||||
checkCppConstructor("MyClass::MyClass", new String[] {"", INT, INT}, new String[]{PRIVATE});
|
||||
|
@ -587,7 +582,8 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
}
|
||||
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;
|
||||
for (int i = 0; i < assignmentOps.length; i++) {
|
||||
IIndexBinding assignmentOp= assignmentOps[i];
|
||||
|
@ -717,7 +713,6 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// class myType {
|
||||
// int a;
|
||||
// };
|
||||
|
@ -1183,7 +1178,6 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// void funcTypeDeletion(int);
|
||||
|
||||
// #include "header.h"
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<version>${tycho-version}</version>
|
||||
<configuration>
|
||||
<useUIHarness>false</useUIHarness>
|
||||
<argLine>-Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
|
||||
<argLine>-ea -Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
|
||||
<includes>
|
||||
<include>**/AutomatedIntegrationSuite.*</include>
|
||||
</includes>
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Norbert Ploett (Siemens AG)
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Norbert Ploett (Siemens AG)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.suite;
|
||||
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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.language.settings.providers.LanguageSettingsExtensionManager;
|
||||
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.runtime.preferences.InstanceScope;
|
||||
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$
|
||||
/** 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$
|
||||
/** 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$
|
||||
// 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() {
|
||||
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) {
|
||||
providers.add(provider);
|
||||
}
|
||||
providers.add(LanguageSettingsProvidersSerializer.getWorkspaceProvider(ScannerDiscoveryLegacySupport.MBS_LANGUAGE_SETTINGS_PROVIDER_ID));
|
||||
providers.add(LanguageSettingsProvidersSerializer.getWorkspaceProvider(MBS_LANGUAGE_SETTINGS_PROVIDER_ID));
|
||||
return providers;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.CProjectNature;
|
||||
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.ScannerDiscoveryLegacySupport;
|
||||
import org.eclipse.cdt.core.resources.IPathEntryStore;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
|
||||
|
@ -1253,11 +1254,12 @@ public class CoreModel {
|
|||
if(des != null){
|
||||
ICConfigurationDescription indexCfg = des.getDefaultSettingConfiguration();
|
||||
if(indexCfg != null){
|
||||
if(!mngr.isNewStyleCfg(indexCfg)){
|
||||
if (!mngr.isNewStyleCfg(indexCfg)) {
|
||||
return oldIsScannerInformationEmpty(resource);
|
||||
}
|
||||
|
||||
if (indexCfg instanceof ILanguageSettingsProvidersKeeper) {
|
||||
if (ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(project) &&
|
||||
indexCfg instanceof ILanguageSettingsProvidersKeeper) {
|
||||
List<String> languageIds = LanguageSettingsManager.getLanguages(resource, indexCfg);
|
||||
for (String langId : languageIds) {
|
||||
List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(indexCfg, resource, langId,
|
||||
|
|
|
@ -38,7 +38,8 @@ public interface ICSettingEntry {
|
|||
/**
|
||||
* Flag {@code LOCAL} is used during creation of {@link IIncludeEntry}
|
||||
* 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;
|
||||
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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$
|
||||
|
||||
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_PROJECT_PATH = ".settings/language.settings.xml"; //$NON-NLS-1$
|
||||
|
||||
|
@ -827,8 +827,13 @@ public class LanguageSettingsProvidersSerializer {
|
|||
public static void serializeLanguageSettings(ICProjectDescription prjDescription) throws CoreException {
|
||||
IProject project = prjDescription.getProject();
|
||||
try {
|
||||
// Using side effect of adding the module to the storage
|
||||
prjDescription.getStorage(CPROJECT_STORAGE_MODULE, true);
|
||||
// Add the storage module to .cpoject and persist on disk as a side effect of adding
|
||||
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) {
|
||||
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) {
|
||||
IProject project = prjDescription.getProject();
|
||||
IFile storeInPrjArea = getStoreInProjectArea(project);
|
||||
if (storeInPrjArea.exists()) {
|
||||
boolean isStoreInProjectAreaExist = storeInPrjArea.exists();
|
||||
boolean enableLSP = isStoreInProjectAreaExist;
|
||||
if (isStoreInProjectAreaExist) {
|
||||
Document doc = null;
|
||||
try {
|
||||
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$
|
||||
}
|
||||
|
||||
} else {
|
||||
// Storage in project area does not exist
|
||||
ICStorageElement storageElement = null;
|
||||
} else { // Storage in project area does not exist
|
||||
ICStorageElement lspStorageModule = null;
|
||||
try {
|
||||
storageElement = prjDescription.getStorage(CPROJECT_STORAGE_MODULE, false);
|
||||
lspStorageModule = prjDescription.getStorage(CPROJECT_STORAGE_MODULE_LANGUAGE_SETTINGS_PROVIDERS, false);
|
||||
} catch (CoreException e) {
|
||||
String msg = "Internal error while trying to load language settings"; //$NON-NLS-1$
|
||||
CCorePlugin.log(msg, e);
|
||||
}
|
||||
|
||||
if (storageElement != null) {
|
||||
// set default providers defined in the tool-chain
|
||||
for (ICConfigurationDescription cfgDescription : prjDescription.getConfigurations()) {
|
||||
// set default providers defined in the tool-chain
|
||||
for (ICConfigurationDescription cfgDescription : prjDescription.getConfigurations()) {
|
||||
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
|
||||
String[] ids = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds();
|
||||
if (ids != null) {
|
||||
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(ids.length);
|
||||
|
@ -1176,23 +1182,16 @@ public class LanguageSettingsProvidersSerializer {
|
|||
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// 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 not yet defined by user - set preference to tell if this is legacy .cproject (i.e. no LSP storageElement)
|
||||
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, storageElement != null);
|
||||
}
|
||||
|
||||
enableLSP = lspStorageModule != null;
|
||||
}
|
||||
|
||||
if (!ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityDefined(project)) {
|
||||
// set the flag if was not previously set by the user
|
||||
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, enableLSP);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -38,6 +38,7 @@ import org.eclipse.cdt.core.model.IPathEntryContainer;
|
|||
import org.eclipse.cdt.core.model.IProjectEntry;
|
||||
import org.eclipse.cdt.core.model.ISourceEntry;
|
||||
import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
|
||||
import org.eclipse.cdt.utils.UNCPathConverter;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -513,6 +514,9 @@ public class PathEntryUtil {
|
|||
|
||||
private static boolean isValidExternalPath(IPath path) {
|
||||
if (path != null) {
|
||||
if (path.isUNC()) {
|
||||
return true;
|
||||
}
|
||||
File file = path.toFile();
|
||||
if (file != null) {
|
||||
return file.exists();
|
||||
|
|
|
@ -52,6 +52,7 @@ import javax.xml.transform.stream.StreamResult;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
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.ScannerDiscoveryLegacySupport;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||
|
@ -1141,7 +1142,15 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
|||
monitor = new NullProgressMonitor();
|
||||
|
||||
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 {
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -9,6 +9,7 @@
|
|||
* Rational Software - initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
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.semantics.CPPVisitor;
|
||||
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
|
||||
|
@ -182,6 +184,7 @@ public class ASTTypeUtil {
|
|||
private static void appendArgument(ICPPTemplateArgument arg, boolean normalize, StringBuilder buf) {
|
||||
IValue val= arg.getNonTypeValue();
|
||||
if (val != null) {
|
||||
appendType(arg.getTypeOfNonTypeValue(), normalize, buf);
|
||||
buf.append(val.getSignature());
|
||||
} else {
|
||||
IType type = normalize ? arg.getTypeValue() : arg.getOriginalTypeValue();
|
||||
|
@ -408,6 +411,8 @@ public class ASTTypeUtil {
|
|||
|
||||
IQualifierType qt= (IQualifierType) type;
|
||||
needSpace= appendCVQ(result, needSpace, qt.isConst(), qt.isVolatile(), false);
|
||||
} else if (type instanceof TypeOfDependentExpression) {
|
||||
result.append(((TypeOfDependentExpression) type).getSignature());
|
||||
} else if (type instanceof ISemanticProblem) {
|
||||
result.append('?');
|
||||
} else if (type != null) {
|
||||
|
@ -584,7 +589,7 @@ public class ASTTypeUtil {
|
|||
if (parenthesis == null) {
|
||||
parenthesis= new BitSet();
|
||||
}
|
||||
parenthesis.set(postfix.size()-1);
|
||||
parenthesis.set(postfix.size() - 1);
|
||||
}
|
||||
appendTypeString(tj, normalize, result);
|
||||
needParenthesis= false;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Doug Schaefer (IBM) - Initial API and implementation
|
||||
* Contributors:
|
||||
* Doug Schaefer (IBM) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast;
|
||||
|
||||
|
|
|
@ -18,9 +18,8 @@ package org.eclipse.cdt.core.dom.ast;
|
|||
public interface IEnumeration extends IBinding, IType {
|
||||
/**
|
||||
* Returns an array of the IEnumerators declared in this enumeration
|
||||
* @throws DOMException
|
||||
*/
|
||||
IEnumerator[] getEnumerators() throws DOMException;
|
||||
IEnumerator[] getEnumerators();
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -1,15 +1,15 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser;
|
||||
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser;
|
||||
|
||||
|
@ -182,7 +183,12 @@ public class SizeofCalculator {
|
|||
if (type instanceof IBasicType) {
|
||||
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)
|
||||
return null;
|
||||
return sizeof_pointer;
|
||||
|
@ -314,14 +320,24 @@ public class SizeofCalculator {
|
|||
if (field.isStatic())
|
||||
continue;
|
||||
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)
|
||||
return null;
|
||||
if (union) {
|
||||
if (size < info.size)
|
||||
size = info.size;
|
||||
} 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)
|
||||
maxAlignment = info.alignment;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
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.IType;
|
||||
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.ICASTEnumerationSpecifier;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Binding for enumerations in C.
|
||||
*/
|
||||
public class CEnumeration extends PlatformObject implements IEnumeration, ICInternalBinding {
|
||||
|
||||
private IASTName[] declarations = null;
|
||||
private IASTName definition = null;
|
||||
private Long fMinValue;
|
||||
|
@ -204,20 +204,7 @@ public class CEnumeration extends PlatformObject implements IEnumeration, ICInte
|
|||
if (fMinValue != null)
|
||||
return fMinValue.longValue();
|
||||
|
||||
long minValue = Long.MAX_VALUE;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
long minValue = SemanticUtil.computeMinValue(this);
|
||||
fMinValue= minValue;
|
||||
return minValue;
|
||||
}
|
||||
|
@ -227,20 +214,7 @@ public class CEnumeration extends PlatformObject implements IEnumeration, ICInte
|
|||
if (fMaxValue != null)
|
||||
return fMaxValue.longValue();
|
||||
|
||||
long maxValue = Long.MIN_VALUE;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
long maxValue = SemanticUtil.computeMaxValue(this);
|
||||
fMaxValue= maxValue;
|
||||
return maxValue;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2012 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2006, 2012 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Contributors:
|
||||
* Mike Kucera (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -9,6 +9,7 @@
|
|||
* Andrew Ferguson (Symbian) - Initial Implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* IBM Corporation
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -68,12 +69,18 @@ public class CPPASTAmbiguousTemplateArgument extends ASTAmbiguousNode implements
|
|||
name.setBinding(null);
|
||||
namedTypeSpec.setName(name);
|
||||
}
|
||||
} else if (node instanceof IASTIdExpression) {
|
||||
IASTIdExpression id= (IASTIdExpression) node;
|
||||
final IASTName name = id.getName();
|
||||
name.setBinding(null);
|
||||
id.setName(name);
|
||||
}
|
||||
} else {
|
||||
// Unwrap variadic pack expansion if necessary.
|
||||
if (node instanceof ICPPASTPackExpansionExpression)
|
||||
node= ((ICPPASTPackExpansionExpression) node).getPattern();
|
||||
|
||||
if (node instanceof IASTIdExpression) {
|
||||
IASTIdExpression id= (IASTIdExpression) node;
|
||||
final IASTName name = id.getName();
|
||||
name.setBinding(null);
|
||||
id.setName(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2004, 2013 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Contributors:
|
||||
* John Camelon (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
@ -124,7 +124,7 @@ public class CPPASTBinaryTypeIdExpression extends ASTNode implements ICPPASTExpr
|
|||
fEvaluation= EvalFixed.INCOMPLETE;
|
||||
} else {
|
||||
IType t1= CPPVisitor.createType(fOperand1);
|
||||
IType t2= CPPVisitor.createType(fOperand1);
|
||||
IType t2= CPPVisitor.createType(fOperand2);
|
||||
if (t1 == null || t2 == null) {
|
||||
fEvaluation= EvalFixed.INCOMPLETE;
|
||||
} else {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Contributors:
|
||||
* John Camelon (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* John Camelon (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Contributors:
|
||||
* John Camelon (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* 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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Natan Ridge
|
||||
*******************************************************************************/
|
||||
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.IASTNode;
|
||||
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.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
@ -74,7 +76,7 @@ public class CPPASTPackExpansionExpression extends ASTNode implements ICPPASTPac
|
|||
} else {
|
||||
type= new CPPParameterPackType(type);
|
||||
}
|
||||
fEvaluation= new EvalFixed(type, PRVALUE, Value.UNKNOWN);
|
||||
fEvaluation= new EvalFixed(type, PRVALUE, Value.create(((ICPPASTExpression) fPattern).getEvaluation()));
|
||||
}
|
||||
return fEvaluation;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Contributors:
|
||||
* John Camelon (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
|
|
@ -55,16 +55,12 @@ public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateI
|
|||
|
||||
@Override
|
||||
public CPPASTTemplateId copy(CopyStyle style) {
|
||||
CPPASTTemplateId copy = new CPPASTTemplateId(templateName == null ?
|
||||
null : templateName.copy(style));
|
||||
CPPASTTemplateId copy =
|
||||
new CPPASTTemplateId(templateName == null ? null : templateName.copy(style));
|
||||
for (IASTNode arg : getTemplateArguments()) {
|
||||
copy.internalAddTemplateArgument(arg == null ? null : arg.copy(style));
|
||||
}
|
||||
copy.setOffsetAndLength(this);
|
||||
if (style == CopyStyle.withLocations) {
|
||||
copy.setCopyLocation(this);
|
||||
}
|
||||
return copy;
|
||||
return copy(copy, style);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* John Camelon (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Contributors:
|
||||
* John Camelon (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Contributors:
|
||||
* John Camelon (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
/*******************************************************************************
|
||||
* 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
|
||||
* 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 Niefer (IBM Corporation) - initial API and implementation
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -47,8 +48,10 @@ public class CPPBaseClause implements ICPPBase, ICPPInternalBase {
|
|||
public IType getBaseClassType() {
|
||||
if (baseClass == null) {
|
||||
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());
|
||||
} else if (!(b instanceof IType)) {
|
||||
baseClass = new CPPClassType.CPPClassTypeProblem(base.getName(), ISemanticProblem.BINDING_NO_CLASS);
|
||||
} else {
|
||||
baseClass= (IType) b;
|
||||
IType check= getNestedType(baseClass, TDEF);
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ public class CPPClosureType extends PlatformObject implements ICPPClassType, ICP
|
|||
// Function call operator
|
||||
final IType returnType= getReturnType();
|
||||
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];
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
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.IType;
|
||||
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.ICPPASTQualifiedName;
|
||||
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.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.SemanticUtil;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
|
@ -220,20 +221,7 @@ public class CPPEnumeration extends PlatformObject implements ICPPEnumeration, I
|
|||
if (fMinValue != null)
|
||||
return fMinValue.longValue();
|
||||
|
||||
long minValue = Long.MAX_VALUE;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
long minValue = SemanticUtil.computeMinValue(this);
|
||||
fMinValue= minValue;
|
||||
return minValue;
|
||||
}
|
||||
|
@ -243,20 +231,7 @@ public class CPPEnumeration extends PlatformObject implements ICPPEnumeration, I
|
|||
if (fMaxValue != null)
|
||||
return fMaxValue.longValue();
|
||||
|
||||
long maxValue = Long.MIN_VALUE;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
long maxValue = SemanticUtil.computeMaxValue(this);
|
||||
fMaxValue= maxValue;
|
||||
return maxValue;
|
||||
}
|
||||
|
@ -278,10 +253,7 @@ public class CPPEnumeration extends PlatformObject implements ICPPEnumeration, I
|
|||
if (definition == null) {
|
||||
ICPPEnumeration typeInIndex= getIndexBinding();
|
||||
if (typeInIndex != null) {
|
||||
try {
|
||||
return typeInIndex.getEnumerators();
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return typeInIndex.getEnumerators();
|
||||
}
|
||||
return EMPTY_ENUMERATORS;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2011 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2011 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Contributors:
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -38,23 +39,25 @@ public interface ICPPEvaluation extends ISerializableEvaluation {
|
|||
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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
|
@ -77,16 +80,22 @@ public interface ICPPEvaluation extends ISerializableEvaluation {
|
|||
*
|
||||
* @param parameterMap maps function parameters to their values
|
||||
* @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
|
||||
*/
|
||||
ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, int maxdepth,
|
||||
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);
|
||||
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,211 +7,23 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
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.IASTNode;
|
||||
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.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
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.ICPPUnknownBinding;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
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() {
|
||||
}
|
||||
|
||||
|
@ -246,4 +58,14 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
|||
}
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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.IArrayType;
|
||||
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.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.ICPPClassType;
|
||||
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.ICPPFunction;
|
||||
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.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.ICPPPointerToMemberType;
|
||||
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.CPPDeferredClassInstance;
|
||||
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.CPPFunctionInstance;
|
||||
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.
|
||||
*/
|
||||
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;
|
||||
|
||||
// Used to indicate that two different packs with different sizes were found.
|
||||
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 enum TypeSelection { PARAMETERS, RETURN_TYPE, PARAMETERS_AND_RETURN_TYPE }
|
||||
|
||||
/**
|
||||
|
@ -837,9 +855,29 @@ public class CPPTemplates {
|
|||
ICPPAliasTemplate aliasTemplate = (ICPPAliasTemplate) decl;
|
||||
IType type= instantiateType(aliasTemplate.getType(), tpMap, -1, getSpecializationContext(owner), point);
|
||||
spec = new CPPAliasTemplateInstance(decl.getNameCharArray(), aliasTemplate, type);
|
||||
} else if (decl instanceof IEnumeration || decl instanceof IEnumerator) {
|
||||
// TODO(sprigogin): Deal with a case when an enumerator value depends on a template parameter.
|
||||
spec = decl;
|
||||
} else if (decl instanceof ICPPEnumeration) {
|
||||
ICPPClassSpecialization within = getSpecializationContext(owner);
|
||||
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) {
|
||||
IBinding[] delegates= ((ICPPUsingDeclaration) decl).getDelegates();
|
||||
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,
|
||||
ICPPTemplateParameterMap tpMap, int packOffset, IASTNode point) {
|
||||
ICPPTemplateArgument arg= null;
|
||||
|
@ -1958,13 +2043,34 @@ public class CPPTemplates {
|
|||
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 {
|
||||
ICPPFunction transF1 = transferFunctionTemplate(f1, point);
|
||||
if (transF1 == null)
|
||||
return -1;
|
||||
|
||||
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[] args;
|
||||
switch(mode) {
|
||||
|
@ -2118,8 +2224,6 @@ public class CPPTemplates {
|
|||
final ICPPTemplateParameter[] tpars2 = f2.getTemplateParameters();
|
||||
final ICPPTemplateArgument[] targs1 = f1.getTemplateArguments();
|
||||
final ICPPTemplateArgument[] targs2 = f2.getTemplateArguments();
|
||||
if (targs1.length != targs2.length)
|
||||
return false;
|
||||
|
||||
// Transfer arguments of specialization 1
|
||||
final int tpars1Len = tpars1.length;
|
||||
|
@ -2129,22 +2233,17 @@ public class CPPTemplates {
|
|||
final ICPPTemplateParameter param = tpars1[i];
|
||||
final ICPPTemplateArgument arg = uniqueArg(param);
|
||||
args[i]= arg;
|
||||
transferMap.put(param, arg);
|
||||
if (param.isParameterPack()) {
|
||||
transferMap.put(param, new ICPPTemplateArgument[] { arg });
|
||||
} else {
|
||||
transferMap.put(param, arg);
|
||||
}
|
||||
}
|
||||
final ICPPTemplateArgument[] transferredArgs1 = instantiateArguments(targs1, transferMap, -1, null, point, false);
|
||||
|
||||
// Deduce arguments for specialization 2
|
||||
final CPPTemplateParameterMap deductionMap= new CPPTemplateParameterMap(2);
|
||||
if (!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;
|
||||
return TemplateArgumentDeduction.fromTemplateArguments(tpars2, targs2, transferredArgs1, deductionMap, point);
|
||||
}
|
||||
|
||||
static boolean isValidType(IType t) {
|
||||
|
@ -2226,6 +2325,9 @@ public class CPPTemplates {
|
|||
pType= instantiateType(pType, map, -1, null, point);
|
||||
}
|
||||
|
||||
if (argType instanceof ICPPParameterPackType) {
|
||||
argType = ((ICPPParameterPackType) argType).getType();
|
||||
}
|
||||
if (argType instanceof ICPPUnknownType) {
|
||||
return new CPPTemplateNonTypeArgument(arg.getNonTypeValue(), pType);
|
||||
}
|
||||
|
@ -2378,7 +2480,8 @@ public class CPPTemplates {
|
|||
if (arg.isTypeValue())
|
||||
return isDependentType(arg.getTypeValue());
|
||||
|
||||
return arg.getNonTypeEvaluation().isValueDependent();
|
||||
ICPPEvaluation evaluation = arg.getNonTypeEvaluation();
|
||||
return evaluation.isTypeDependent() || evaluation.isValueDependent();
|
||||
}
|
||||
|
||||
public static boolean containsDependentType(List<IType> ts) {
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -12,6 +12,7 @@
|
|||
* Sergey Prigogin (Google)
|
||||
* Thomas Corbat (IFS)
|
||||
* Nathan Ridge
|
||||
* Marc-Andre Laperle
|
||||
*******************************************************************************/
|
||||
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);
|
||||
if (binding instanceof CPPEnumeration) {
|
||||
CPPEnumeration e= (CPPEnumeration) binding;
|
||||
if (name.equals(e.getDefinition())) {
|
||||
return e;
|
||||
}
|
||||
if (e.isScoped() == specifier.isScoped()) {
|
||||
IType ft2= e.getFixedType();
|
||||
if (fixedType == ft2 || (fixedType != null && fixedType.isSameType(ft2))) {
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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.IVariable;
|
||||
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.ICPPMethod;
|
||||
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.ICPPTemplateArgument;
|
||||
|
@ -241,20 +238,14 @@ public class EvalBinding extends CPPEvaluation {
|
|||
}
|
||||
if (binding instanceof ICPPTemplateNonTypeParameter) {
|
||||
IType type= ((ICPPTemplateNonTypeParameter) binding).getType();
|
||||
if (CPPTemplates.isDependentType(type))
|
||||
return new TypeOfDependentExpression(this);
|
||||
return prvalueType(type);
|
||||
}
|
||||
if (binding instanceof IVariable) {
|
||||
final IType type = ((IVariable) binding).getType();
|
||||
if (CPPTemplates.isDependentType(type))
|
||||
return new TypeOfDependentExpression(this);
|
||||
return SemanticUtil.mapToAST(glvalueType(type), point);
|
||||
}
|
||||
if (binding instanceof IFunction) {
|
||||
final IFunctionType type = ((IFunction) binding).getType();
|
||||
if (CPPTemplates.isDependentType(type))
|
||||
return new TypeOfDependentExpression(this);
|
||||
return SemanticUtil.mapToAST(type, point);
|
||||
}
|
||||
return ProblemType.UNKNOWN_FOR_EXPRESSION;
|
||||
|
@ -325,55 +316,26 @@ public class EvalBinding extends CPPEvaluation {
|
|||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
IBinding binding = getBinding();
|
||||
if (binding instanceof IEnumerator) {
|
||||
IEnumerator enumerator = (IEnumerator) binding;
|
||||
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);
|
||||
IBinding origBinding = getBinding();
|
||||
if (origBinding instanceof ICPPTemplateNonTypeParameter) {
|
||||
ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) origBinding);
|
||||
if (argument != null && argument.isNonTypeValue()) {
|
||||
return argument.getNonTypeEvaluation();
|
||||
}
|
||||
// TODO(sprigogin): Do we need something similar for pack expansion?
|
||||
} else if (binding instanceof ICPPUnknownBinding) {
|
||||
binding = resolveUnknown((ICPPUnknownBinding) binding, tpMap, packOffset, within, point);
|
||||
} else if (binding instanceof ICPPMethod) {
|
||||
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 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));
|
||||
} else if (origBinding instanceof ICPPParameter) {
|
||||
ICPPParameter parameter = (ICPPParameter) origBinding;
|
||||
IType origType = parameter.getType();
|
||||
IType instantiatedType = CPPTemplates.instantiateType(origType, tpMap, packOffset, within, point);
|
||||
if (origType != instantiatedType) {
|
||||
return new EvalFixed(instantiatedType, ValueCategory.LVALUE, Value.create(this));
|
||||
}
|
||||
} else {
|
||||
IBinding instantiatedBinding = instantiateBinding(origBinding, tpMap, packOffset, within, maxdepth, point);
|
||||
if (instantiatedBinding != origBinding)
|
||||
return new EvalBinding(instantiatedBinding, null);
|
||||
}
|
||||
if (binding == fBinding)
|
||||
return this;
|
||||
return new EvalBinding(binding, getFixedType());
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -360,8 +360,13 @@ public class EvalID extends CPPEvaluation {
|
|||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
int r = fFieldOwner != null ? fFieldOwner.determinePackSize(tpMap) : CPPTemplates.PACK_SIZE_NOT_FOUND;
|
||||
for (ICPPTemplateArgument arg : fTemplateArgs) {
|
||||
r = CPPTemplates.combinePackSize(r, CPPTemplates.determinePackSize(arg, tpMap));
|
||||
if (fNameOwner instanceof ICPPUnknownBinding) {
|
||||
r = CPPTemplates.combinePackSize(r, CPPTemplates.determinePackSize((ICPPUnknownBinding) fNameOwner, tpMap));
|
||||
}
|
||||
if (fTemplateArgs != null) {
|
||||
for (ICPPTemplateArgument arg : fTemplateArgs) {
|
||||
r = CPPTemplates.combinePackSize(r, CPPTemplates.determinePackSize(arg, tpMap));
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -11,6 +11,7 @@
|
|||
* Bryan Wilkinson (QNX)
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Sergey Prigogin (Google)
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
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.Kind;
|
||||
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.IPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
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.ICPPClassType;
|
||||
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.ICPPSpecialization;
|
||||
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.parser.Keywords;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
|
@ -663,49 +666,46 @@ public class SemanticUtil {
|
|||
return -1;
|
||||
}
|
||||
|
||||
public static boolean containsUniqueTypeForParameterPack(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);
|
||||
}
|
||||
|
||||
public static boolean isUniqueTypeForParameterPack(IType type) {
|
||||
if (type instanceof UniqueType) {
|
||||
return ((UniqueType) type).isForParameterPack();
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
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.IPointerType;
|
||||
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.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
|
@ -431,7 +431,7 @@ public class TemplateArgumentDeduction {
|
|||
deduct.incPackOffset();
|
||||
} else {
|
||||
if (j >= fnParCount)
|
||||
return result;
|
||||
return -1;
|
||||
|
||||
par= fnPars[j];
|
||||
if (par instanceof ICPPParameterPackType) {
|
||||
|
@ -606,15 +606,37 @@ public class TemplateArgumentDeduction {
|
|||
final ICPPTemplateArgument[] p, final ICPPTemplateArgument[] a, CPPTemplateParameterMap map,
|
||||
IASTNode point) throws DOMException {
|
||||
TemplateArgumentDeduction deduct= new TemplateArgumentDeduction(pars, null, map, 0);
|
||||
final int len= a.length;
|
||||
if (p == null || p.length != len) {
|
||||
if (p == null) {
|
||||
return false;
|
||||
}
|
||||
for (int j= 0; j < len; j++) {
|
||||
if (!deduct.fromTemplateArgument(p[j], a[j], point)) {
|
||||
return false;
|
||||
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)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!containsPackExpansion && p.length < a.length)
|
||||
return false; // Too many arguments.
|
||||
return verifyDeduction(pars, map, false, point);
|
||||
}
|
||||
|
||||
|
@ -636,16 +658,8 @@ public class TemplateArgumentDeduction {
|
|||
deducedArg= tpar.getDefaultValue();
|
||||
if (deducedArg != null) {
|
||||
deducedArg= CPPTemplates.instantiateArgument(deducedArg, tpMap, -1, null, point);
|
||||
if (deducedArg != null) {
|
||||
if (deducedArg instanceof CPPTemplateTypeArgument) {
|
||||
CPPTemplateTypeArgument deducedTypeArg = (CPPTemplateTypeArgument) deducedArg;
|
||||
if (!(deducedTypeArg.getTypeValue() instanceof ISemanticProblem)) {
|
||||
tpMap.put(tpar, deducedArg);
|
||||
}
|
||||
} else {
|
||||
// TODO: Check for problems in non-type or template template parameters?
|
||||
tpMap.put(tpar, deducedArg);
|
||||
}
|
||||
if (CPPTemplates.isValidArgument(deducedArg)) {
|
||||
tpMap.put(tpar, deducedArg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -957,7 +971,7 @@ public class TemplateArgumentDeduction {
|
|||
return false;
|
||||
return fDeducedArgs.putPackElement(parID, fPackOffset, arg, fPackSize);
|
||||
}
|
||||
if (SemanticUtil.containsUniqueTypeForParameterPack(arg.getTypeValue()))
|
||||
if (SemanticUtil.isUniqueTypeForParameterPack(arg.getTypeValue()))
|
||||
return false;
|
||||
fDeducedArgs.put(parID, arg);
|
||||
return true;
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,9 +7,11 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
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.internal.core.dom.parser.ISerializableEvaluation;
|
||||
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
|
||||
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
|
||||
buffer.putByte(ITypeMarshalBuffer.DEPENDENT_EXPRESSION_TYPE);
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -9,6 +9,7 @@
|
|||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Thomas Corbat (IFS)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
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_UNKNOWN_METHOD = IIndexBindingConstants.LAST_CONSTANT + 50;
|
||||
int CPP_TEMPLATE_ALIAS = IIndexBindingConstants.LAST_CONSTANT + 51;
|
||||
int CPP_ENUMERATION_SPECIALIZATION = IIndexBindingConstants.LAST_CONSTANT + 52;
|
||||
int CPP_ENUMERATOR_SPECIALIZATION = IIndexBindingConstants.LAST_CONSTANT + 53;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
*******************************************************************************/
|
||||
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.IEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
@ -25,7 +24,7 @@ class CompositeCEnumeration extends CompositeCBinding implements IEnumeration, I
|
|||
}
|
||||
|
||||
@Override
|
||||
public IEnumerator[] getEnumerators() throws DOMException {
|
||||
public IEnumerator[] getEnumerators() {
|
||||
IEnumerator[] result = ((IEnumeration)rbinding).getEnumerators();
|
||||
for (int i= 0; i < result.length; i++)
|
||||
result[i] = (IEnumerator) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
*******************************************************************************/
|
||||
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.IEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
@ -27,7 +26,7 @@ class CompositeCPPEnumeration extends CompositeCPPBinding implements ICPPEnumera
|
|||
}
|
||||
|
||||
@Override
|
||||
public IEnumerator[] getEnumerators() throws DOMException {
|
||||
public IEnumerator[] getEnumerators() {
|
||||
IEnumerator[] result = ((IEnumeration)rbinding).getEnumerators();
|
||||
for (int i= 0; i < result.length; i++)
|
||||
result[i] = (IEnumerator) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
|
||||
|
|
|
@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.parser;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
|
@ -159,26 +158,15 @@ public class InternalParserUtil extends ParserFactory {
|
|||
IFileStore store = EFS.getStore(file.getLocationURI());
|
||||
IFileInfo fileInfo = store.fetchInfo();
|
||||
input= file.getContents(true);
|
||||
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);
|
||||
if (input instanceof FileInputStream) {
|
||||
try {
|
||||
input = new FileInputStream(fileCache);
|
||||
} catch (FileNotFoundException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
try {
|
||||
return createFileContent(path, file.getCharset(), input,
|
||||
fileInfo.getLastModified(), fileInfo.getLength(), fileReadTime);
|
||||
} finally {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException e) {
|
||||
return createFileContent(path, null, file.getCharset(), input,
|
||||
fileInfo.getLastModified(), fileInfo.getLength(), fileReadTime);
|
||||
} finally {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
|
@ -193,18 +181,19 @@ public class InternalParserUtil extends ParserFactory {
|
|||
CCorePlugin.log(e);
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a code reader for an external location, normalizing path to
|
||||
* canonical path.
|
||||
*/
|
||||
public static InternalFileContent createExternalFileContent(String externalLocation, String encoding) {
|
||||
public static InternalFileContent createExternalFileContent(final String externalLocation, String encoding) {
|
||||
long fileReadTime = System.currentTimeMillis();
|
||||
File includeFile = null;
|
||||
String path = null;
|
||||
String localPath = null;
|
||||
if (!UNCPathConverter.isUNC(externalLocation)) {
|
||||
includeFile = new File(externalLocation);
|
||||
// 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));
|
||||
includeFile = store.toLocalFile(EFS.CACHE, null);
|
||||
path = externalLocation;
|
||||
localPath = includeFile.getAbsolutePath();
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
|
@ -230,7 +220,7 @@ public class InternalParserUtil extends ParserFactory {
|
|||
return null;
|
||||
}
|
||||
try {
|
||||
return createFileContent(path, encoding, in, timestamp, fileSize, fileReadTime);
|
||||
return createFileContent(path, localPath, encoding, in, timestamp, fileSize, fileReadTime);
|
||||
} finally {
|
||||
try {
|
||||
in.close();
|
||||
|
@ -241,10 +231,13 @@ public class InternalParserUtil extends ParserFactory {
|
|||
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) {
|
||||
if (localPath == null) {
|
||||
localPath = path;
|
||||
}
|
||||
try {
|
||||
AbstractCharArray chars= FileCharArray.create(path, charset, in);
|
||||
AbstractCharArray chars= FileCharArray.create(localPath, charset, in);
|
||||
if (chars == null)
|
||||
return null;
|
||||
|
||||
|
|
|
@ -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.parser.IMacroDictionary;
|
||||
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
|
||||
|
@ -49,7 +53,16 @@ public abstract class InternalFileContentProvider extends IncludeFileContentProv
|
|||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ abstract class LocationCtx implements ILocationCtx {
|
|||
* Returns the sequence of file locations spanning the given range.
|
||||
* 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.
|
||||
|
|
|
@ -32,7 +32,7 @@ class LocationCtxContainer extends LocationCtx {
|
|||
private int fChildSequenceLength;
|
||||
|
||||
private ArrayList<LocationCtx> fChildren;
|
||||
private AbstractCharArray fSource;
|
||||
private final AbstractCharArray fSource;
|
||||
private int[] fLineOffsets;
|
||||
|
||||
public LocationCtxContainer(LocationCtxContainer parent, AbstractCharArray source,
|
||||
|
@ -138,47 +138,55 @@ class LocationCtxContainer extends LocationCtx {
|
|||
}
|
||||
|
||||
@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;
|
||||
if (fChildren != null) {
|
||||
int childIdx= Math.max(0, findChildIdxLessOrEqualThan(sequenceNumber, false));
|
||||
for (; childIdx < fChildren.size(); 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) {
|
||||
// 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);
|
||||
// it the child is not affected, we are done.
|
||||
|
||||
// Requested range ends before the child.
|
||||
if (endSequenceNumber <= child.fSequenceNumber) {
|
||||
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);
|
||||
|
||||
sequenceNumber= child.fSequenceNumber;
|
||||
assert sequenceNumber < endSequenceNumber;
|
||||
}
|
||||
|
||||
// let the child create locations
|
||||
// Let the child create locations
|
||||
final int childEndSequenceNumber= child.fSequenceNumber + child.getSequenceLength();
|
||||
if (sequenceNumber < childEndSequenceNumber) {
|
||||
if (child.collectLocations(sequenceNumber, endSequenceNumber - sequenceNumber, locations)) {
|
||||
return true;
|
||||
}
|
||||
if (sequenceNumber < childEndSequenceNumber
|
||||
|| (sequenceNumber == childEndSequenceNumber && !locations.isEmpty())) {
|
||||
child.collectLocations(sequenceNumber, endSequenceNumber - sequenceNumber, locations);
|
||||
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 offset= fSource.getLength() - (myEndNumber - sequenceNumber);
|
||||
if (endSequenceNumber <= myEndNumber) {
|
||||
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) {
|
||||
|
|
|
@ -25,7 +25,7 @@ class LocationCtxMacroExpansion extends LocationCtx {
|
|||
private final LocationMap fLocationMap;
|
||||
private final int fLength;
|
||||
private final ImageLocationInfo[] fLocationInfos;
|
||||
private ASTMacroReferenceName fExpansionName;
|
||||
private final ASTMacroReferenceName fExpansionName;
|
||||
|
||||
public LocationCtxMacroExpansion(LocationMap map, LocationCtxContainer parent, int parentOffset, int parentEndOffset,
|
||||
int sequenceNumber, int length, ImageLocationInfo[] imageLocations, ASTMacroReferenceName expansionName) {
|
||||
|
@ -45,17 +45,15 @@ class LocationCtxMacroExpansion extends LocationCtx {
|
|||
}
|
||||
|
||||
@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;
|
||||
assert offset >= 0 && length >= 0;
|
||||
|
||||
if (offset + length <= fLength) {
|
||||
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() {
|
||||
|
|
|
@ -229,10 +229,11 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
* 137.0 - Fixed serialization of very large types and template arguments, bug 392278.
|
||||
* 138.0 - Constexpr functions, bug 395238.
|
||||
* 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 MAX_SUPPORTED_VERSION= version(139, Short.MAX_VALUE);
|
||||
private static final int DEFAULT_VERSION = version(139, 0);
|
||||
private static final int MIN_SUPPORTED_VERSION= version(140, 0);
|
||||
private static final int MAX_SUPPORTED_VERSION= version(140, Short.MAX_VALUE);
|
||||
private static final int DEFAULT_VERSION = version(140, 0);
|
||||
|
||||
private static int version(int major, int minor) {
|
||||
return (major << 16) + minor;
|
||||
|
|
|
@ -309,7 +309,7 @@ public class PDOMASTAdapter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IEnumerator[] getEnumerators() throws DOMException {
|
||||
public IEnumerator[] getEnumerators() {
|
||||
return fDelegate.getEnumerators();
|
||||
}
|
||||
|
||||
|
@ -507,7 +507,7 @@ public class PDOMASTAdapter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IEnumerator[] getEnumerators() throws DOMException {
|
||||
public IEnumerator[] getEnumerators() {
|
||||
return ((IEnumeration) fDelegate).getEnumerators();
|
||||
}
|
||||
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* IBM Corporation
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* QNX - Initial API and implementation
|
||||
* IBM Corporation
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||
|
||||
|
@ -24,7 +24,6 @@ import org.eclipse.core.runtime.CoreException;
|
|||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public abstract class PDOMNamedNode extends PDOMNode {
|
||||
/**
|
||||
|
@ -104,7 +103,6 @@ public abstract class PDOMNamedNode extends PDOMNode {
|
|||
fName= nameCharArray;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void delete(PDOMLinkage linkage) throws CoreException {
|
||||
final Database db = getDB();
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* 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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
|
@ -23,7 +24,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.IPDOMBinding;
|
|||
*/
|
||||
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();
|
||||
|
||||
|
@ -33,5 +34,5 @@ public interface IPDOMCPPEnumType extends ICPPEnumeration, IPDOMBinding, IIndexT
|
|||
/**
|
||||
* Called by the scope to access the enumerators.
|
||||
*/
|
||||
void loadEnumerators(CharArrayMap<PDOMCPPEnumerator> map);
|
||||
void loadEnumerators(CharArrayMap<IPDOMCPPEnumerator> map);
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
}
|
|
@ -65,7 +65,7 @@ class PDOMCPPEnumScope implements ICPPScope, IIndexScope {
|
|||
@Override
|
||||
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) {
|
||||
try {
|
||||
CharArrayMap<PDOMCPPEnumerator> map= getBindingMap(fBinding);
|
||||
CharArrayMap<IPDOMCPPEnumerator> map= getBindingMap(fBinding);
|
||||
return map.get(name.toCharArray());
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
|
@ -81,7 +81,7 @@ class PDOMCPPEnumScope implements ICPPScope, IIndexScope {
|
|||
@Override
|
||||
public IBinding[] getBindings(ScopeLookupData lookup) {
|
||||
try {
|
||||
CharArrayMap<PDOMCPPEnumerator> map= getBindingMap(fBinding);
|
||||
CharArrayMap<IPDOMCPPEnumerator> map= getBindingMap(fBinding);
|
||||
if (lookup.isPrefixLookup()) {
|
||||
final List<IBinding> result= new ArrayList<IBinding>();
|
||||
final char[] nc= lookup.getLookupKey();
|
||||
|
@ -135,36 +135,36 @@ class PDOMCPPEnumScope implements ICPPScope, IIndexScope {
|
|||
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 PDOM pdom = enumeration.getPDOM();
|
||||
@SuppressWarnings("unchecked")
|
||||
Reference<CharArrayMap<PDOMCPPEnumerator>> cached= (Reference<CharArrayMap<PDOMCPPEnumerator>>) pdom.getCachedResult(key);
|
||||
CharArrayMap<PDOMCPPEnumerator> map= cached == null ? null : cached.get();
|
||||
Reference<CharArrayMap<IPDOMCPPEnumerator>> cached= (Reference<CharArrayMap<IPDOMCPPEnumerator>>) pdom.getCachedResult(key);
|
||||
CharArrayMap<IPDOMCPPEnumerator> map= cached == null ? null : cached.get();
|
||||
|
||||
if (map == null) {
|
||||
// there is no cache, build it:
|
||||
map= new CharArrayMap<PDOMCPPEnumerator>();
|
||||
map= new CharArrayMap<IPDOMCPPEnumerator>();
|
||||
enumeration.loadEnumerators(map);
|
||||
pdom.putCachedResult(key, new SoftReference<CharArrayMap<?>>(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 PDOM pdom = enumType.getPDOM();
|
||||
@SuppressWarnings("unchecked")
|
||||
Reference<CharArrayMap<PDOMCPPEnumerator>> cached= (Reference<CharArrayMap<PDOMCPPEnumerator>>) pdom.getCachedResult(key);
|
||||
CharArrayMap<PDOMCPPEnumerator> map= cached == null ? null : cached.get();
|
||||
Reference<CharArrayMap<IPDOMCPPEnumerator>> cached= (Reference<CharArrayMap<IPDOMCPPEnumerator>>) pdom.getCachedResult(key);
|
||||
CharArrayMap<IPDOMCPPEnumerator> map= cached == null ? null : cached.get();
|
||||
if (map != null) {
|
||||
map.put(enumType.getNameCharArray(), enumItem);
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerator[] getEnumerators(PDOMCPPEnumeration enumType) {
|
||||
public static IEnumerator[] getEnumerators(IPDOMCPPEnumType enumType) {
|
||||
try {
|
||||
CharArrayMap<PDOMCPPEnumerator> map = getBindingMap(enumType);
|
||||
CharArrayMap<IPDOMCPPEnumerator> map = getBindingMap(enumType);
|
||||
List<IEnumerator> result= new ArrayList<IEnumerator>();
|
||||
for (IEnumerator value : map.values()) {
|
||||
if (IndexFilter.ALL_DECLARED.acceptBinding(value)) {
|
||||
|
@ -179,10 +179,10 @@ class PDOMCPPEnumScope implements ICPPScope, IIndexScope {
|
|||
return new IEnumerator[0];
|
||||
}
|
||||
|
||||
public static void acceptViaCache(PDOMCPPEnumeration enumType, IPDOMVisitor visitor) {
|
||||
public static void acceptViaCache(IPDOMCPPEnumType enumType, IPDOMVisitor visitor) {
|
||||
try {
|
||||
CharArrayMap<PDOMCPPEnumerator> map = getBindingMap(enumType);
|
||||
for (PDOMCPPEnumerator enumItem : map.values()) {
|
||||
CharArrayMap<IPDOMCPPEnumerator> map = getBindingMap(enumType);
|
||||
for (IPDOMCPPEnumerator enumItem : map.values()) {
|
||||
visitor.visit(enumItem);
|
||||
visitor.leave(enumItem);
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ class PDOMCPPEnumeration extends PDOMCPPBinding implements IPDOMCPPEnumType, IPD
|
|||
if (node instanceof PDOMCPPEnumerator) {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + OFFSET_ENUMERATOR_LIST);
|
||||
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
|
||||
public void loadEnumerators(final CharArrayMap<PDOMCPPEnumerator> map) {
|
||||
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 PDOMCPPEnumerator) {
|
||||
final PDOMCPPEnumerator item = (PDOMCPPEnumerator) node;
|
||||
if (node instanceof IPDOMCPPEnumerator) {
|
||||
final IPDOMCPPEnumerator item = (IPDOMCPPEnumerator) node;
|
||||
map.put(item.getNameCharArray(), item);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -1,13 +1,14 @@
|
|||
/*******************************************************************************
|
||||
* 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
|
||||
* 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:
|
||||
* Doug Schaefer (QNX) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Doug Schaefer (QNX) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
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.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.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -26,11 +28,11 @@ import org.eclipse.core.runtime.CoreException;
|
|||
/**
|
||||
* 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;
|
||||
|
||||
@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)
|
||||
throws CoreException {
|
||||
|
@ -55,11 +57,10 @@ class PDOMCPPEnumerator extends PDOMCPPBinding implements IEnumerator {
|
|||
private void storeValue(IEnumerator enumerator) throws CoreException {
|
||||
IValue value= enumerator.getValue();
|
||||
if (value != null) {
|
||||
Long val= value.numericalValue();
|
||||
getDB().putInt(record + VALUE, val == null ? -1 : val.intValue());
|
||||
getLinkage().storeValue(record + VALUE, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
|
||||
if (newBinding instanceof IEnumerator)
|
||||
|
@ -77,8 +78,7 @@ class PDOMCPPEnumerator extends PDOMCPPBinding implements IEnumerator {
|
|||
@Override
|
||||
public IValue getValue() {
|
||||
try {
|
||||
int val= getDB().getInt(record + VALUE);
|
||||
return Value.create(val);
|
||||
return getLinkage().loadValue(record + VALUE);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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);
|
||||
} else if (special instanceof ICPPUsingDeclaration) {
|
||||
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;
|
||||
|
@ -893,6 +897,10 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
return new PDOMCPPUsingDeclarationSpecialization(this, record);
|
||||
case CPP_TEMPLATE_ALIAS:
|
||||
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$
|
||||
return null;
|
||||
|
|
|
@ -132,4 +132,5 @@ CProjectStorageType.separatefile.name = Xml Storage (Separate Files)
|
|||
scannerInfoProvider2.name = Scanner Info Provider
|
||||
efsExtensionProvider.name = EFSExtensionProvider
|
||||
refreshExclusionFactory.name = Refresh Exclusion Factory
|
||||
uncPathConverter.name = UNC Path Converter
|
||||
uncPathConverter.name = UNC Path Converter
|
||||
ScannerInfoExtensionLanguageSettingsProvider.name=Contributed ScannerInfo Entries
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<?eclipse version="3.0"?>
|
||||
<plugin>
|
||||
|
||||
|
||||
|
||||
<!-- =================================================================================== -->
|
||||
<!-- Obsolete extension point no longer in use, will be remove. -->
|
||||
<!-- =================================================================================== -->
|
||||
|
@ -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="$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=".*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="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"/>
|
||||
|
@ -806,5 +806,13 @@
|
|||
factoryClass="org.eclipse.cdt.internal.core.resources.ResourceExclusionFactory">
|
||||
</exclusionFactory>
|
||||
</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>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2001, 2012 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2001, 2012 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Contributors:
|
||||
* Rational Software - initial implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2009 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2008, 2009 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.resources;
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -11,24 +11,74 @@
|
|||
package org.eclipse.cdt.internal.core;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
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.WindowsRegistry;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
/**
|
||||
* A collection of cygwin-related utilities.
|
||||
*/
|
||||
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) {
|
||||
return PathUtil.findProgramLocation("cygpath", envPath); //$NON-NLS-1$
|
||||
private static final String CYGPATH = "cygpath"; //$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.
|
||||
* Tells whether cygwin is installed in the path.
|
||||
*
|
||||
* @param envPath - list of directories to search for cygwin utilities separated
|
||||
* 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.
|
||||
*/
|
||||
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.
|
||||
* Tells whether cygwin is installed in the path.
|
||||
*
|
||||
* @return {@code true} if cygwin is available, {@code false} otherwise.
|
||||
*/
|
||||
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.
|
||||
* 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
|
||||
* by path separator (format of environment variable $PATH).
|
||||
* @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)
|
||||
return cygwinPath;
|
||||
|
||||
if (!Platform.getOS().equals(Platform.OS_WIN32)) {
|
||||
// Don't run this on non-windows platforms
|
||||
if (!isWindowsPlatform) {
|
||||
throw new UnsupportedOperationException("Not a Windows system, Cygwin is unavailable."); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
IPath cygpathLocation = findCygpathLocation(envPath);
|
||||
String cygpathLocation = findCygpathLocation(envPath);
|
||||
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$
|
||||
Process cygpathProcess = Runtime.getRuntime().exec(args);
|
||||
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();
|
||||
String windowsPath = runCygpath(new String[] {cygpathLocation, "-w", cygwinPath}); //$NON-NLS-1$
|
||||
return windowsPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @throws UnsupportedOperationException if Cygwin is unavailable.
|
||||
|
@ -99,6 +180,7 @@ public class Cygwin {
|
|||
|
||||
/**
|
||||
* 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 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)
|
||||
return windowsPath;
|
||||
|
||||
if (!Platform.getOS().equals(Platform.OS_WIN32)) {
|
||||
// Don't run this on non-windows platforms
|
||||
if (!isWindowsPlatform) {
|
||||
throw new UnsupportedOperationException("Not a Windows system, Cygwin is unavailable."); //$NON-NLS-1$
|
||||
}
|
||||
IPath cygpathLocation = findCygpathLocation(envPath);
|
||||
|
||||
String cygpathLocation = findCygpathLocation(envPath);
|
||||
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$
|
||||
Process cygpath = Runtime.getRuntime().exec(args);
|
||||
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();
|
||||
String cygwinPath = runCygpath(new String[] {cygpathLocation, "-u", windowsPath}); //$NON-NLS-1$
|
||||
return cygwinPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @return Cygwin style converted path.
|
||||
|
@ -143,4 +219,114 @@ public class Cygwin {
|
|||
public static String windowsToCygwinPath(String windowsPath) throws IOException, UnsupportedOperationException {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2009 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
|
||||
* Copyright (c) 2008, 2009 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
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.utils;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<version>${tycho-version}</version>
|
||||
<configuration>
|
||||
<useUIHarness>true</useUIHarness>
|
||||
<argLine>-Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
|
||||
<argLine>-ea -Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
|
||||
<includes>
|
||||
<include>**/AutomatedSuite.*</include>
|
||||
</includes>
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2004, 2013 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.tests.text.selection;
|
||||
|
||||
|
@ -75,7 +76,6 @@ import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
|
|||
* @author dsteffle
|
||||
*/
|
||||
public class CPPSelectionTestsNoIndexer extends BaseUITestCase {
|
||||
|
||||
private static final String INDEX_FILE_ID = "2946365241"; //$NON-NLS-1$
|
||||
static NullProgressMonitor monitor;
|
||||
static IWorkspace workspace;
|
||||
|
@ -1205,4 +1205,23 @@ public class CPPSelectionTestsNoIndexer extends BaseUITestCase {
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.tests.text.selection;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<filter id="305365105">
|
||||
<message_arguments>
|
||||
<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>
|
||||
</filter>
|
||||
</resource>
|
||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
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-Vendor: %providerName
|
||||
Bundle-Localization: plugin
|
||||
|
|
|
@ -648,4 +648,6 @@ RefreshExclusionContributorExtensionPoint = Refresh Exclusion Contributor
|
|||
newProjectWizard.name = C/C++ Project (prototype)
|
||||
projectTypePages = Project Type Pages
|
||||
|
||||
semanticHighlightingExtensionPoint = Semantic Highlighting Extension Point
|
||||
|
||||
UserSettingEntries.name = CDT User Setting Entries
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
<extension-point id="LanguageSettingsProviderAssociation" name="%LanguageSettingsProviderAssociationExtensionPoint" schema="schema/LanguageSettingsProviderAssociation.exsd"/>
|
||||
<extension-point id="RefreshExclusionContributor" name="%RefreshExclusionContributorExtensionPoint" schema="schema/RefreshExclusionContributor.exsd"/>
|
||||
<extension-point id="projectTypePages" name="%projectTypePages" schema="schema/projectTypePages.exsd"/>
|
||||
<extension-point id="semanticHighlighting" name="%semanticHighlightingExtensionPoint" schema="schema/semanticHighlighting.exsd"/>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.core.runtime.adapters">
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<version>5.5.0-SNAPSHOT</version>
|
||||
<version>5.6.0-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdt.ui</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
||||
|
|
245
core/org.eclipse.cdt.ui/schema/semanticHighlighting.exsd
Normal file
245
core/org.eclipse.cdt.ui/schema/semanticHighlighting.exsd
Normal 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.
|
||||
<p>
|
||||
Extensions specify the priority of the highlighting, which determines the order in which the highlighting is invoked.
|
||||
</p>
|
||||
<p>
|
||||
This extension point supports the <code>enablement</code> tag. Properties to test on are:
|
||||
<dl>
|
||||
<li>projectNatures: type Collection; all project natures of the current project</li>
|
||||
<li>languageId: type String; the result if ILanguage.getId on the token's ITranslationUnit</li>
|
||||
</dl>
|
||||
</p>
|
||||
<p>
|
||||
Contributed highlightings will be visible in the Code tree of the 'C/C++ - Editor - Syntax Colouring' preference page.
|
||||
</p>
|
||||
</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
|
||||
<samp>org.eclipse.cdt.ui.text.ISemanticHighlighter</samp>
|
||||
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'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., "127,0,85". Defaults to "0,0,0" (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:
|
||||
|
||||
<p>
|
||||
<pre>
|
||||
<extension
|
||||
point="org.eclipse.cdt.ui.semanticHighlighting"
|
||||
name="%extensionName"
|
||||
id="com.example.ui.semanticHighlightings">
|
||||
<semanticHighlighting
|
||||
id="com.example.ui.keywordHighlighting"
|
||||
priority="5"
|
||||
class="com.example.internal.ui.ExampleHighlighting"
|
||||
preferenceKey="example-keywords"
|
||||
displayName="%exampleHighlighting.displayName"
|
||||
defaultTextColor="127,0,85"
|
||||
defaultBold="true"
|
||||
defaultEnabled="true">
|
||||
<enablement>
|
||||
<with variable="projectNatures">
|
||||
<iterate operator="or">
|
||||
<equals value="org.eclipse.cdt.core.ccnature"/>
|
||||
</iterate>
|
||||
</with>
|
||||
<with variable="languageId">
|
||||
<or>
|
||||
<equals value="org.eclipse.cdt.core.g++"/>
|
||||
<equals value="org.eclipse.cdt.core.gcc"/>
|
||||
</or>
|
||||
</with>
|
||||
</enablement>
|
||||
</semanticHighlighting>
|
||||
</extension>
|
||||
</pre>
|
||||
</p>
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="apiInfo"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
The contributed class must implement <code>org.eclipse.cdt.ui.text.ISemanticHighlighter</code>
|
||||
</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>
|
|
@ -1,12 +1,12 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.corext;
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2000, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* QNX Software Systems
|
||||
* Sergey Prigogin (Google)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* QNX Software System
|
||||
* Markus Schorn (Wind River Systems)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2001, 2011 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2001, 2011 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Contributors:
|
||||
* Rational Software - initial implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue