mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Merge remote-tracking branch 'origin/master' into bug_45203
This commit is contained in:
commit
b9396d3a4a
229 changed files with 5416 additions and 1935 deletions
|
@ -21,7 +21,7 @@ import org.eclipse.core.runtime.IPath;
|
||||||
*/
|
*/
|
||||||
public class AutotoolsProblemMarkerInfo {
|
public class AutotoolsProblemMarkerInfo {
|
||||||
|
|
||||||
public static enum Type{PACKAGE, HEADER, PROG, FILE, GENERIC}
|
public static enum Type{PACKAGE, HEADER, PROG, LIB, FILE, GENERIC}
|
||||||
|
|
||||||
private ProblemMarkerInfo marker;
|
private ProblemMarkerInfo marker;
|
||||||
|
|
||||||
|
|
|
@ -175,6 +175,8 @@ public class ErrorParser extends MarkerGenerator implements IErrorParser {
|
||||||
return AutotoolsProblemMarkerInfo.Type.HEADER;
|
return AutotoolsProblemMarkerInfo.Type.HEADER;
|
||||||
if (typeString.equals("file"))
|
if (typeString.equals("file"))
|
||||||
return AutotoolsProblemMarkerInfo.Type.FILE;
|
return AutotoolsProblemMarkerInfo.Type.FILE;
|
||||||
|
if (typeString.equals("lib"))
|
||||||
|
return AutotoolsProblemMarkerInfo.Type.LIB;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,6 +147,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
detector.processLine("#define \t MACRO_1 VALUE");
|
detector.processLine("#define \t MACRO_1 VALUE");
|
||||||
detector.processLine("#define MACRO_2 \t VALUE");
|
detector.processLine("#define MACRO_2 \t VALUE");
|
||||||
detector.processLine("#define MACRO_3 VALUE \t");
|
detector.processLine("#define MACRO_3 VALUE \t");
|
||||||
|
detector.processLine("#define MACRO_4 VALUE + 1");
|
||||||
detector.shutdownForLanguage();
|
detector.shutdownForLanguage();
|
||||||
detector.shutdown();
|
detector.shutdown();
|
||||||
|
|
||||||
|
@ -155,6 +156,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
assertEquals(new CMacroEntry("MACRO_1", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
|
assertEquals(new CMacroEntry("MACRO_1", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
|
||||||
assertEquals(new CMacroEntry("MACRO_2", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
|
assertEquals(new CMacroEntry("MACRO_2", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
|
||||||
assertEquals(new CMacroEntry("MACRO_3", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
|
assertEquals(new CMacroEntry("MACRO_3", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
|
||||||
|
assertEquals(new CMacroEntry("MACRO_4", "VALUE + 1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
|
||||||
assertEquals(index, entries.size());
|
assertEquals(index, entries.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2522,7 +2522,13 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider
|
||||||
* The function never returns number smaller than 1.
|
* The function never returns number smaller than 1.
|
||||||
*/
|
*/
|
||||||
public int getOptimalParallelJobNum() {
|
public int getOptimalParallelJobNum() {
|
||||||
return Runtime.getRuntime().availableProcessors();
|
// Bug 398426: On my Mac running parallel builds at full tilt hangs the desktop.
|
||||||
|
// Need to pull it back one.
|
||||||
|
int j = Runtime.getRuntime().availableProcessors();
|
||||||
|
if (j > 1 && Platform.getOS().equals(Platform.OS_MACOSX))
|
||||||
|
return j - 1;
|
||||||
|
else
|
||||||
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009, 2011 Andrew Gvozdev and others.
|
* Copyright (c) 2009, 2013 Andrew Gvozdev and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -12,7 +12,9 @@
|
||||||
package org.eclipse.cdt.managedbuilder.internal.language.settings.providers;
|
package org.eclipse.cdt.managedbuilder.internal.language.settings.providers;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.AbstractExecutableExtensionBase;
|
import org.eclipse.cdt.core.AbstractExecutableExtensionBase;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
@ -59,7 +61,7 @@ public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase
|
||||||
languageSettings = getLanguageSettings(rcDescription);
|
languageSettings = getLanguageSettings(rcDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ICLanguageSettingEntry> list = new ArrayList<ICLanguageSettingEntry>();
|
Set<ICLanguageSettingEntry> set = new LinkedHashSet<ICLanguageSettingEntry>();
|
||||||
|
|
||||||
if (languageSettings != null) {
|
if (languageSettings != null) {
|
||||||
for (ICLanguageSetting langSetting : languageSettings) {
|
for (ICLanguageSetting langSetting : languageSettings) {
|
||||||
|
@ -86,8 +88,8 @@ public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase
|
||||||
IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager();
|
IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager();
|
||||||
String projectRootedPath = mngr.generateVariableExpression("workspace_loc", rc.getProject().getName()) + Path.SEPARATOR + pathStr; //$NON-NLS-1$
|
String projectRootedPath = mngr.generateVariableExpression("workspace_loc", rc.getProject().getName()) + Path.SEPARATOR + pathStr; //$NON-NLS-1$
|
||||||
ICLanguageSettingEntry projectRootedEntry = (ICLanguageSettingEntry) CDataUtil.createEntry(kind, projectRootedPath, projectRootedPath, null, entry.getFlags());
|
ICLanguageSettingEntry projectRootedEntry = (ICLanguageSettingEntry) CDataUtil.createEntry(kind, projectRootedPath, projectRootedPath, null, entry.getFlags());
|
||||||
if (! list.contains(projectRootedEntry)) {
|
if (!set.contains(projectRootedEntry)) {
|
||||||
list.add(projectRootedEntry);
|
set.add(projectRootedEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CdtVariableException e) {
|
} catch (CdtVariableException e) {
|
||||||
|
@ -97,8 +99,8 @@ public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (! list.contains(entry)) {
|
if (!set.contains(entry)) {
|
||||||
list.add(entry);
|
set.add(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,7 +109,7 @@ public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return LanguageSettingsStorage.getPooledList(list);
|
return LanguageSettingsStorage.getPooledList(new ArrayList<ICLanguageSettingEntry>(set));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class GCCBuiltinSpecsDetector extends ToolchainBuiltinSpecsDetector imple
|
||||||
new IncludePathOptionParser("#include <(\\S.*)>", "$1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY),
|
new IncludePathOptionParser("#include <(\\S.*)>", "$1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY),
|
||||||
new IncludePathOptionParser("#framework <(\\S.*)>", "$1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.FRAMEWORKS_MAC),
|
new IncludePathOptionParser("#framework <(\\S.*)>", "$1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.FRAMEWORKS_MAC),
|
||||||
new MacroOptionParser("#define\\s+(\\S*\\(.*?\\))\\s*(.*)", "$1", "$2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY),
|
new MacroOptionParser("#define\\s+(\\S*\\(.*?\\))\\s*(.*)", "$1", "$2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY),
|
||||||
new MacroOptionParser("#define\\s+(\\S*)\\s*(\\S*)", "$1", "$2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY),
|
new MacroOptionParser("#define\\s+(\\S*)\\s*(.*)", "$1", "$2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY),
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,7 +32,7 @@ BuilderSettingsTab_8=&Expand Env. Variable Refs in Makefiles
|
||||||
BuilderSettingsTab_9=Build settings
|
BuilderSettingsTab_9=Build settings
|
||||||
BuilderSettingsTab_10=Stop on first build error
|
BuilderSettingsTab_10=Stop on first build error
|
||||||
BuilderSettingsTab_EnableParallelBuild=Enable parallel build
|
BuilderSettingsTab_EnableParallelBuild=Enable parallel build
|
||||||
BuilderSettingsTab_UseOptimalJobs=Use number of processors ({0})
|
BuilderSettingsTab_UseOptimalJobs=Use optimal jobs ({0})
|
||||||
BuilderSettingsTab_UseParallelJobs=Use parallel jobs:
|
BuilderSettingsTab_UseParallelJobs=Use parallel jobs:
|
||||||
BuilderSettingsTab_UseUnlimitedJobs=Use unlimited jobs
|
BuilderSettingsTab_UseUnlimitedJobs=Use unlimited jobs
|
||||||
BuilderSettingsTab_14=Workbench Build Behavior
|
BuilderSettingsTab_14=Workbench Build Behavior
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.eclipse.cdt.core.parser.NullLogService;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.tests.ast2.AST2BaseTest;
|
import org.eclipse.cdt.core.parser.tests.ast2.AST2TestBase;
|
||||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
||||||
|
@ -83,7 +83,7 @@ public abstract class CodanFastCxxAstTestCase extends TestCase {
|
||||||
protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean gcc) {
|
protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean gcc) {
|
||||||
FileContent codeReader = FileContent.create("code.c", code.toCharArray());
|
FileContent codeReader = FileContent.create("code.c", code.toCharArray());
|
||||||
IScannerInfo scannerInfo = new ScannerInfo();
|
IScannerInfo scannerInfo = new ScannerInfo();
|
||||||
IScanner scanner = AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
IScanner scanner = AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||||
ISourceCodeParser parser2 = null;
|
ISourceCodeParser parser2 = null;
|
||||||
if (lang == ParserLanguage.CPP) {
|
if (lang == ParserLanguage.CPP) {
|
||||||
ICPPParserExtensionConfiguration config = null;
|
ICPPParserExtensionConfiguration config = null;
|
||||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %fragmentName.aix
|
Bundle-Name: %fragmentName.aix
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.core.aix; singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.core.aix; singleton:=true
|
||||||
Bundle-Version: 5.1.1.qualifier
|
Bundle-Version: 5.3.0.qualifier
|
||||||
Bundle-Vendor: %providerName
|
Bundle-Vendor: %providerName
|
||||||
Fragment-Host: org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)"
|
Fragment-Host: org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)"
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
|
|
|
@ -7,14 +7,21 @@
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
/* Inaccessible static: hasPTY */
|
|
||||||
/*
|
/*
|
||||||
* Class: org_eclipse_cdt_utils_pty_PTY
|
* Class: org_eclipse_cdt_utils_pty_PTY
|
||||||
* Method: openMaster
|
* Method: openMaster
|
||||||
* Signature: ()Ljava/lang/String;
|
* Signature: (Z)Ljava/lang/String;
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_openMaster
|
JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_openMaster
|
||||||
(JNIEnv *, jobject);
|
(JNIEnv *, jobject, jboolean);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_eclipse_cdt_utils_pty_PTY
|
||||||
|
* Method: change_window_size
|
||||||
|
* Signature: (III)I
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size
|
||||||
|
(JNIEnv *, jobject, jint, jint, jint);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1
|
||||||
* Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[ILjava/lang/String;I)I
|
* Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[ILjava/lang/String;I)I
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2
|
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2
|
||||||
(JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray, jstring, jint);
|
(JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray, jstring, jint, jboolean);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_eclipse_cdt_utils_spawner_Spawner
|
* Class: org_eclipse_cdt_utils_spawner_Spawner
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2003, 2008 IBM Corporation and others.
|
* Copyright (c) 2003, 2013 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
* IBM Corporation - port of 248071
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -16,7 +17,13 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
extern pid_t exec0(const char *path, char *const argv[],
|
extern pid_t exec0(const char *path, char *const argv[],
|
||||||
char *const envp[], const char *dirpath,
|
char *const envp[], const char *dirpath,
|
||||||
int channels[3] );
|
int channels[3]);
|
||||||
|
|
||||||
|
|
||||||
|
extern pid_t exec_pty(const char *path, char *const argv[],
|
||||||
|
char *const envp[], const char *dirpath,
|
||||||
|
int channels[3], const char *pts_name, int fdm,
|
||||||
|
int console);
|
||||||
|
|
||||||
extern int wait0(pid_t pid);
|
extern int wait0(pid_t pid);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004 QNX Software Systems and others.
|
* Copyright (c) 2004, 2013 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - initial API and implementation
|
* QNX Software Systems - initial API and implementation
|
||||||
|
* IBM Corporation - port of 248071
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include "exec0.h"
|
#include "exec0.h"
|
||||||
|
@ -20,11 +21,11 @@
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
|
|
||||||
/* from pfind.c */
|
/* from pfind.c */
|
||||||
extern char *pfind(const char *name);
|
extern char *pfind(const char *name, char * const envp[]);
|
||||||
|
|
||||||
pid_t
|
pid_t
|
||||||
exec_pty(const char *path, char *const argv[], char *const envp[],
|
exec_pty(const char *path, char *const argv[], char *const envp[],
|
||||||
const char *dirpath, int channels[3], const char *pts_name, int fdm)
|
const char *dirpath, int channels[3], const char *pts_name, int fdm, int console)
|
||||||
{
|
{
|
||||||
int pipe2[2];
|
int pipe2[2];
|
||||||
pid_t childpid;
|
pid_t childpid;
|
||||||
|
@ -34,7 +35,7 @@ exec_pty(const char *path, char *const argv[], char *const envp[],
|
||||||
* We use pfind() to check that the program exists and is an executable.
|
* We use pfind() to check that the program exists and is an executable.
|
||||||
* If not pass the error up. Also execve() wants a full path.
|
* If not pass the error up. Also execve() wants a full path.
|
||||||
*/
|
*/
|
||||||
full_path = pfind(path);
|
full_path = pfind(path, envp);
|
||||||
if (full_path == NULL) {
|
if (full_path == NULL) {
|
||||||
fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : "");
|
fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : "");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -43,7 +44,7 @@ exec_pty(const char *path, char *const argv[], char *const envp[],
|
||||||
/*
|
/*
|
||||||
* Make sure we can create our pipes before forking.
|
* Make sure we can create our pipes before forking.
|
||||||
*/
|
*/
|
||||||
if (channels != NULL) {
|
if (channels != NULL && console) {
|
||||||
if (pipe(pipe2) < 0) {
|
if (pipe(pipe2) < 0) {
|
||||||
fprintf(stderr, "%s(%d): returning due to error: %s\n", __FUNCTION__, __LINE__, strerror(errno));
|
fprintf(stderr, "%s(%d): returning due to error: %s\n", __FUNCTION__, __LINE__, strerror(errno));
|
||||||
free(full_path);
|
free(full_path);
|
||||||
|
@ -64,6 +65,11 @@ exec_pty(const char *path, char *const argv[], char *const envp[],
|
||||||
if (channels != NULL) {
|
if (channels != NULL) {
|
||||||
int fds;
|
int fds;
|
||||||
|
|
||||||
|
if (!console && setsid() < 0) {
|
||||||
|
perror("setsid()");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
fds = ptys_open(fdm, pts_name);
|
fds = ptys_open(fdm, pts_name);
|
||||||
if (fds < 0) {
|
if (fds < 0) {
|
||||||
fprintf(stderr, "%s(%d): returning due to error: %s\n", __FUNCTION__, __LINE__, strerror(errno));
|
fprintf(stderr, "%s(%d): returning due to error: %s\n", __FUNCTION__, __LINE__, strerror(errno));
|
||||||
|
@ -71,17 +77,28 @@ exec_pty(const char *path, char *const argv[], char *const envp[],
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the read end of pipe2 */
|
/* Close the read end of pipe2 */
|
||||||
if (close(pipe2[0]) == -1)
|
if (console && close(pipe2[0]) == -1)
|
||||||
perror("close(pipe2[0]))");
|
perror("close(pipe2[0]))");
|
||||||
|
|
||||||
/* close the master, no need in the child */
|
/* close the master, no need in the child */
|
||||||
close(fdm);
|
close(fdm);
|
||||||
|
|
||||||
set_noecho(fds);
|
if (console) {
|
||||||
|
set_noecho(fds);
|
||||||
|
if (setpgid(getpid(), getpid()) < 0) {
|
||||||
|
perror("setpgid()");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* redirections */
|
/* redirections */
|
||||||
dup2(fds, STDIN_FILENO); /* dup stdin */
|
dup2(fds, STDIN_FILENO); /* dup stdin */
|
||||||
dup2(fds, STDOUT_FILENO); /* dup stdout */
|
dup2(fds, STDOUT_FILENO); /* dup stdout */
|
||||||
dup2(pipe2[1], STDERR_FILENO); /* dup stderr */
|
if (console) {
|
||||||
|
dup2(pipe2[1], STDERR_FILENO); /* dup stderr */
|
||||||
|
} else {
|
||||||
|
dup2(fds, STDERR_FILENO); /* dup stderr */
|
||||||
|
}
|
||||||
close(fds); /* done with fds. */
|
close(fds); /* done with fds. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,16 +121,20 @@ exec_pty(const char *path, char *const argv[], char *const envp[],
|
||||||
|
|
||||||
} else if (childpid != 0) { /* parent */
|
} else if (childpid != 0) { /* parent */
|
||||||
|
|
||||||
set_noecho(fdm);
|
if (console) {
|
||||||
|
set_noecho(fdm);
|
||||||
|
}
|
||||||
if (channels != NULL) {
|
if (channels != NULL) {
|
||||||
/* close the write end of pipe1 */
|
|
||||||
if (close(pipe2[1]) == -1)
|
|
||||||
perror("close(pipe2[1])");
|
|
||||||
|
|
||||||
channels[0] = fdm; /* Input Stream. */
|
channels[0] = fdm; /* Input Stream. */
|
||||||
channels[1] = fdm; /* Output Stream. */
|
channels[1] = fdm; /* Output Stream. */
|
||||||
channels[2] = pipe2[0]; /* stderr Stream. */
|
if (console) {
|
||||||
/*channels[2] = fdm; Input Stream. */
|
/* close the write end of pipe1 */
|
||||||
|
if (close(pipe2[1]) == -1)
|
||||||
|
perror("close(pipe2[1])");
|
||||||
|
channels[2] = pipe2[0]; /* stderr Stream. */
|
||||||
|
} else {
|
||||||
|
channels[2] = fdm; /* Error Stream. */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(full_path);
|
free(full_path);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2003, 2008 IBM Corporation and others.
|
* Copyright (c) 2003, 2013 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
* IBM Corporation - port of 248071
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include "exec0.h"
|
#include "exec0.h"
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
/* from pfind.c */
|
/* from pfind.c */
|
||||||
extern char *pfind(const char *name);
|
extern char *pfind(const char *name, char * const envp[]);
|
||||||
|
|
||||||
pid_t
|
pid_t
|
||||||
exec0(const char *path, char *const argv[], char *const envp[],
|
exec0(const char *path, char *const argv[], char *const envp[],
|
||||||
|
@ -33,7 +34,7 @@ exec0(const char *path, char *const argv[], char *const envp[],
|
||||||
* We use pfind() to check that the program exists and is an executable.
|
* We use pfind() to check that the program exists and is an executable.
|
||||||
* If not pass the error up. Also execve() wants a full path.
|
* If not pass the error up. Also execve() wants a full path.
|
||||||
*/
|
*/
|
||||||
full_path = pfind(path);
|
full_path = pfind(path, envp);
|
||||||
if (full_path == NULL) {
|
if (full_path == NULL) {
|
||||||
fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : "");
|
fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : "");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -91,6 +92,8 @@ exec0(const char *path, char *const argv[], char *const envp[],
|
||||||
close(fd++);
|
close(fd++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setpgid(getpid(), getpid());
|
||||||
|
|
||||||
if (envp[0] == NULL) {
|
if (envp[0] == NULL) {
|
||||||
execv(full_path, argv);
|
execv(full_path, argv);
|
||||||
} else {
|
} else {
|
||||||
|
@ -135,9 +138,19 @@ int wait0(pid_t pid)
|
||||||
int status;
|
int status;
|
||||||
int val = -1;
|
int val = -1;
|
||||||
|
|
||||||
if (pid < 0 || waitpid(pid, &status, 0) < 0)
|
if (pid < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
if (waitpid(pid, &status, 0) < 0) {
|
||||||
|
if (errno == EINTR) {
|
||||||
|
// interrupted system call - retry
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (WIFEXITED(status)) {
|
if (WIFEXITED(status)) {
|
||||||
val = WEXITSTATUS(status);
|
val = WEXITSTATUS(status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int ptym_open (char *pts_name);
|
int ptym_open (char *pts_name);
|
||||||
int ptys_open (int fdm, char * pts_name);
|
int ptys_open (int fdm, const char * pts_name);
|
||||||
void set_noecho(int fd);
|
void set_noecho(int fd);
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/******************************************************************************
|
||||||
* Copyright (c) 2003, 2008 IBM Corporation and others.
|
* Copyright (c) 2003, 2013 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,11 +8,12 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* QNX Software Systems
|
* QNX Software Systems
|
||||||
|
* IBM Corporation - port of 248071
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#ifndef _OPENPTY_H
|
#ifndef _OPENPTY_H
|
||||||
#define _OPENPTY_H
|
#define _OPENPTY_H
|
||||||
int ptym_open (char *pts_name);
|
int ptym_open (char *pts_name);
|
||||||
int ptys_open (int fdm, char * pts_name);
|
int ptys_open (int fdm, const char * pts_name);
|
||||||
void set_noecho(int fd);
|
void set_noecho(int fd);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2003, 2008 IBM Corporation and others.
|
* Copyright (c) 2003, 2013 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
* IBM Corporation - port of 248071
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -23,8 +24,25 @@
|
||||||
#define PATH_MAX 1024
|
#define PATH_MAX 1024
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define PATH_DEF "PATH="
|
||||||
|
const int path_def_len = 5; /* strlen(PATH_DEF); */
|
||||||
|
char * path_val(char * const envp[])
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
if (envp == NULL || envp[0] == NULL)
|
||||||
|
return getenv("PATH" );
|
||||||
|
|
||||||
|
for(i = 0; envp[i] != NULL; i++){
|
||||||
|
char* p = envp[i];
|
||||||
|
if(!strncmp(PATH_DEF, p, path_def_len)){
|
||||||
|
return p + path_def_len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
char * pfind(const char *name)
|
char * pfind(const char *name, char * const envp[])
|
||||||
{
|
{
|
||||||
char *tok;
|
char *tok;
|
||||||
char *sp;
|
char *sp;
|
||||||
|
@ -46,7 +64,7 @@ char * pfind(const char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Search in the PATH environment. */
|
/* Search in the PATH environment. */
|
||||||
path = getenv("PATH" );
|
path = path_val( envp );
|
||||||
|
|
||||||
if (path == NULL || strlen(path) <= 0) {
|
if (path == NULL || strlen(path) <= 0) {
|
||||||
fprintf(stderr, "Unable to get $PATH.\n");
|
fprintf(stderr, "Unable to get $PATH.\n");
|
||||||
|
@ -79,7 +97,7 @@ int main(int argc, char **argv)
|
||||||
char *fullpath;
|
char *fullpath;
|
||||||
|
|
||||||
for (i=1; i<argc; i++) {
|
for (i=1; i<argc; i++) {
|
||||||
fullpath = pfind(argv[i]);
|
fullpath = pfind(argv[i], NULL);
|
||||||
if (fullpath == NULL)
|
if (fullpath == NULL)
|
||||||
printf("Unable to find %s in $PATH.\n", argv[i]);
|
printf("Unable to find %s in $PATH.\n", argv[i]);
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2003, 2008 IBM Corporation and others.
|
* Copyright (c) 2003, 2013 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,8 +8,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* QNX Software Systems
|
* QNX Software Systems
|
||||||
|
* IBM Corporation - port of 248071
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
#include <sys/ioctl.h>
|
||||||
#include "PTY.h"
|
#include "PTY.h"
|
||||||
#include "openpty.h"
|
#include "openpty.h"
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
* Signature: ()I
|
* Signature: ()I
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jstring JNICALL
|
JNIEXPORT jstring JNICALL
|
||||||
Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj) {
|
Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj, jboolean console) {
|
||||||
jfieldID fid; /* Store the field ID */
|
jfieldID fid; /* Store the field ID */
|
||||||
jstring jstr = NULL;
|
jstring jstr = NULL;
|
||||||
int master = -1;
|
int master = -1;
|
||||||
|
@ -30,8 +31,10 @@ Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj) {
|
||||||
|
|
||||||
master = ptym_open(line);
|
master = ptym_open(line);
|
||||||
if (master >= 0) {
|
if (master >= 0) {
|
||||||
/* turn off echo */
|
// turn off echo
|
||||||
set_noecho(master);
|
if (console) {
|
||||||
|
set_noecho(master);
|
||||||
|
}
|
||||||
|
|
||||||
/* Get a reference to the obj's class */
|
/* Get a reference to the obj's class */
|
||||||
cls = (*env)->GetObjectClass(env, jobj);
|
cls = (*env)->GetObjectClass(env, jobj);
|
||||||
|
@ -48,3 +51,22 @@ Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj) {
|
||||||
}
|
}
|
||||||
return jstr;
|
return jstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size
|
||||||
|
(JNIEnv *env, jobject jobj, jint fdm, jint width, jint height)
|
||||||
|
{
|
||||||
|
#ifdef TIOCGWINSZ
|
||||||
|
struct winsize win;
|
||||||
|
|
||||||
|
win.ws_col = width;
|
||||||
|
win.ws_row = height;
|
||||||
|
win.ws_xpixel = 0;
|
||||||
|
win.ws_ypixel = 0;
|
||||||
|
|
||||||
|
return ioctl(fdm, TIOCSWINSZ, &win);
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2003, 2008 IBM Corporation and others.
|
* Copyright (c) 2003, 2013 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* QNX Software Systems
|
* QNX Software Systems
|
||||||
|
* IBM Corporation - port of 248071
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -90,13 +91,13 @@ static void free_c_array(char **c_array)
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2
|
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2
|
||||||
(JNIEnv *env, jobject jobj, jobjectArray jcmd, jobjectArray jenv, jstring jdir, jintArray jchannels,
|
(JNIEnv *env, jobject jobj, jobjectArray jcmd, jobjectArray jenv, jstring jdir, jintArray jchannels,
|
||||||
jstring jslaveName, jint masterFD)
|
jstring jslaveName, jint masterFD, jboolean console)
|
||||||
{
|
{
|
||||||
jint *channels = (*env)->GetIntArrayElements(env, jchannels, 0);
|
jint *channels = (*env)->GetIntArrayElements(env, jchannels, 0);
|
||||||
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
|
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
|
||||||
const char *pts_name = (*env)->GetStringUTFChars(env, jslaveName, NULL);
|
const char *pts_name = (*env)->GetStringUTFChars(env, jslaveName, NULL);
|
||||||
char **cmd;
|
char **cmd = NULL;
|
||||||
char **envp;
|
char **envp = NULL;
|
||||||
int fd[3];
|
int fd[3];
|
||||||
pid_t pid = -1;
|
pid_t pid = -1;
|
||||||
|
|
||||||
|
@ -120,7 +121,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2
|
||||||
fprintf(stderr, "pts_name: %s\n", pts_name);
|
fprintf(stderr, "pts_name: %s\n", pts_name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pid = exec_pty(cmd[0], cmd, envp, dirpath, fd, pts_name, masterFD);
|
pid = exec_pty(cmd[0], cmd, envp, dirpath, fd, pts_name, masterFD, console);
|
||||||
if (pid < 0)
|
if (pid < 0)
|
||||||
goto bail_out;
|
goto bail_out;
|
||||||
|
|
||||||
|
@ -147,8 +148,8 @@ Java_org_eclipse_cdt_utils_spawner_Spawner_exec1(JNIEnv * env, jobject jobj,
|
||||||
jstring jdir)
|
jstring jdir)
|
||||||
{
|
{
|
||||||
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
|
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
|
||||||
char **cmd;
|
char **cmd = NULL;
|
||||||
char **envp;
|
char **envp = NULL;
|
||||||
pid_t pid = -1;
|
pid_t pid = -1;
|
||||||
|
|
||||||
cmd = alloc_c_array(env, jcmd);
|
cmd = alloc_c_array(env, jcmd);
|
||||||
|
@ -194,8 +195,8 @@ Java_org_eclipse_cdt_utils_spawner_Spawner_exec0(JNIEnv * env, jobject jobj,
|
||||||
{
|
{
|
||||||
jint *channels = (*env)->GetIntArrayElements(env, jchannels, 0);
|
jint *channels = (*env)->GetIntArrayElements(env, jchannels, 0);
|
||||||
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
|
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
|
||||||
char **cmd;
|
char **cmd = NULL;
|
||||||
char **envp;
|
char **envp = NULL;
|
||||||
int fd[3];
|
int fd[3];
|
||||||
pid_t pid = -1;
|
pid_t pid = -1;
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -11,7 +11,7 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<version>5.1.1-SNAPSHOT</version>
|
<version>5.3.0-SNAPSHOT</version>
|
||||||
<artifactId>org.eclipse.cdt.core.aix</artifactId>
|
<artifactId>org.eclipse.cdt.core.aix</artifactId>
|
||||||
<packaging>eclipse-plugin</packaging>
|
<packaging>eclipse-plugin</packaging>
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*
|
|
||||||
* Created on Sept 28, 2004
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.core.parser.tests;
|
package org.eclipse.cdt.core.parser.tests;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
@ -36,127 +32,110 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
/**
|
/**
|
||||||
* @author dsteffle
|
* @author dsteffle
|
||||||
*/
|
*/
|
||||||
public class FileBasePluginTest extends TestCase {
|
public class FileBasePluginTestCase extends TestCase {
|
||||||
static NullProgressMonitor monitor;
|
static NullProgressMonitor monitor;
|
||||||
static IWorkspace workspace;
|
static IWorkspace workspace;
|
||||||
static IProject project;
|
static IProject project;
|
||||||
static FileManager fileManager;
|
static FileManager fileManager;
|
||||||
static int numProjects = 0;
|
static int numProjects;
|
||||||
static Class className;
|
static Class className;
|
||||||
static ICProject cPrj;
|
static ICProject cPrj;
|
||||||
|
|
||||||
public FileBasePluginTest() {
|
public FileBasePluginTestCase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileBasePluginTest(String name) {
|
public FileBasePluginTestCase(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initialize(Class aClassName){
|
private void initialize(Class aClassName) {
|
||||||
if( CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null){
|
if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null) {
|
||||||
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
|
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
|
|
||||||
workspace = ResourcesPlugin.getWorkspace();
|
workspace = ResourcesPlugin.getWorkspace();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cPrj = CProjectHelper.createCCProject("ParserTestProject", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
|
cPrj = CProjectHelper.createCCProject("ParserTestProject", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
project = cPrj.getProject();
|
project = cPrj.getProject();
|
||||||
|
|
||||||
// ugly
|
// ugly
|
||||||
if (className == null || !className.equals(aClassName)) {
|
if (className == null || !className.equals(aClassName)) {
|
||||||
className = aClassName;
|
className = aClassName;
|
||||||
numProjects++;
|
numProjects++;
|
||||||
}
|
}
|
||||||
} catch ( CoreException e ) {
|
} catch (CoreException e) {
|
||||||
/*boo*/
|
// Ignore
|
||||||
}
|
}
|
||||||
if (project == null)
|
if (project == null)
|
||||||
throw new NullPointerException("Unable to create project"); //$NON-NLS-1$
|
throw new NullPointerException("Unable to create project"); //$NON-NLS-1$
|
||||||
|
|
||||||
//Create file manager
|
//Create file manager
|
||||||
fileManager = new FileManager();
|
fileManager = new FileManager();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileBasePluginTest(String name, Class className)
|
public FileBasePluginTestCase(String name, Class className) {
|
||||||
{
|
|
||||||
super(name);
|
super(name);
|
||||||
initialize(className);
|
initialize(className);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanupProject() throws Exception {
|
public void cleanupProject() throws Exception {
|
||||||
numProjects--;
|
numProjects--;
|
||||||
|
|
||||||
try{
|
try {
|
||||||
if (numProjects == 0) {
|
if (numProjects == 0) {
|
||||||
project.delete( true, false, monitor );
|
project.delete(true, false, monitor);
|
||||||
project = null;
|
project = null;
|
||||||
}
|
}
|
||||||
} catch( Throwable e ){
|
} catch (Throwable e) {
|
||||||
/*boo*/
|
// Ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
if( project == null || !project.exists() )
|
if (project == null || !project.exists())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IResource [] members = project.members();
|
IResource [] members = project.members();
|
||||||
for( int i = 0; i < members.length; i++ ){
|
for (int i = 0; i < members.length; i++) {
|
||||||
if( members[i].getName().equals( ".project" ) || members[i].getName().equals( ".cproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$
|
if (members[i].getName().equals(".project") || members[i].getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
continue;
|
continue;
|
||||||
if (members[i].getName().equals(".settings"))
|
if (members[i].getName().equals(".settings"))
|
||||||
continue;
|
continue;
|
||||||
try{
|
try {
|
||||||
members[i].delete( false, monitor );
|
members[i].delete(false, monitor);
|
||||||
} catch( Throwable e ){
|
} catch (Throwable e) {
|
||||||
/*boo*/
|
// Ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// below can be used to work with large files (too large for memory)
|
|
||||||
// protected IFile importFile(String fileName) throws Exception {
|
|
||||||
// IFile file = cPrj.getProject().getFile(fileName);
|
|
||||||
// if (!file.exists()) {
|
|
||||||
// try{
|
|
||||||
// FileInputStream fileIn = new FileInputStream(
|
|
||||||
// CTestPlugin.getDefault().getFileInPlugin(new Path("resources/parser/" + fileName)));
|
|
||||||
// file.create(fileIn,false, monitor);
|
|
||||||
// } catch (CoreException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// } catch (FileNotFoundException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return file;
|
|
||||||
// }
|
|
||||||
|
|
||||||
protected IFolder importFolder(String folderName) throws Exception {
|
protected IFolder importFolder(String folderName) throws Exception {
|
||||||
IFolder folder = project.getProject().getFolder(folderName);
|
IFolder folder = project.getProject().getFolder(folderName);
|
||||||
|
|
||||||
//Create file input stream
|
// Create file input stream
|
||||||
if( !folder.exists() )
|
if (!folder.exists())
|
||||||
folder.create( false, false, monitor );
|
folder.create(false, false, monitor);
|
||||||
|
|
||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
public IFile importFile(String fileName, String contents ) throws Exception{
|
|
||||||
//Obtain file handle
|
public IFile importFile(String fileName, String contents) throws Exception {
|
||||||
|
// Obtain file handle
|
||||||
IFile file = project.getProject().getFile(fileName);
|
IFile file = project.getProject().getFile(fileName);
|
||||||
|
|
||||||
InputStream stream = new ByteArrayInputStream( contents.getBytes() );
|
InputStream stream = new ByteArrayInputStream(contents.getBytes());
|
||||||
//Create file input stream
|
// Create file input stream
|
||||||
if( file.exists() )
|
if (file.exists()) {
|
||||||
file.setContents( stream, false, false, monitor );
|
file.setContents(stream, false, false, monitor);
|
||||||
else
|
} else {
|
||||||
file.create( stream, false, monitor );
|
file.create(stream, false, monitor);
|
||||||
|
}
|
||||||
|
|
||||||
fileManager.addFile(file);
|
fileManager.addFile(file);
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009, 2010 IBM Corporation and others.
|
* Copyright (c) 2009, 2013 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
* Mike Kucera (IBM)
|
* Mike Kucera (IBM)
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Nathan Ridge
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||||
|
|
||||||
|
@ -28,19 +29,19 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
/**
|
/**
|
||||||
* Tests for classes implementing IASTImplicitNameOwner interface.
|
* Tests for classes implementing IASTImplicitNameOwner interface.
|
||||||
*/
|
*/
|
||||||
public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
public class AST2CPPImplicitNameTests extends AST2TestBase {
|
||||||
|
|
||||||
public AST2CPPImplicitNameTests() {
|
public AST2CPPImplicitNameTests() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public AST2CPPImplicitNameTests(String name) {
|
public AST2CPPImplicitNameTests(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TestSuite suite() {
|
public static TestSuite suite() {
|
||||||
return suite(AST2CPPImplicitNameTests.class);
|
return suite(AST2CPPImplicitNameTests.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTImplicitName[] getImplicitNames(IASTTranslationUnit tu, String contents, String section, int len) {
|
public IASTImplicitName[] getImplicitNames(IASTTranslationUnit tu, String contents, String section, int len) {
|
||||||
final int offset = contents.indexOf(section);
|
final int offset = contents.indexOf(section);
|
||||||
assertTrue(offset >= 0);
|
assertTrue(offset >= 0);
|
||||||
|
@ -75,25 +76,25 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
IASTImplicitName n;
|
IASTImplicitName n;
|
||||||
|
|
||||||
n = ba.assertImplicitName("+= 5", 2, ICPPMethod.class);
|
n = ba.assertImplicitName("+= 5", 2, ICPPMethod.class);
|
||||||
assertSame(n.resolveBinding(), col.getName(14).resolveBinding());
|
assertSame(n.resolveBinding(), col.getName(14).resolveBinding());
|
||||||
|
|
||||||
n = ba.assertImplicitName("+ p", 1, ICPPMethod.class);
|
n = ba.assertImplicitName("+ p", 1, ICPPMethod.class);
|
||||||
assertSame(n.resolveBinding(), col.getName(4).resolveBinding());
|
assertSame(n.resolveBinding(), col.getName(4).resolveBinding());
|
||||||
|
|
||||||
n = ba.assertImplicitName("- p", 1, ICPPMethod.class);
|
n = ba.assertImplicitName("- p", 1, ICPPMethod.class);
|
||||||
assertSame(n.resolveBinding(), col.getName(8).resolveBinding());
|
assertSame(n.resolveBinding(), col.getName(8).resolveBinding());
|
||||||
|
|
||||||
n = ba.assertImplicitName("* p", 1, ICPPFunction.class);
|
n = ba.assertImplicitName("* p", 1, ICPPFunction.class);
|
||||||
assertSame(n.resolveBinding(), col.getName(17).resolveBinding());
|
assertSame(n.resolveBinding(), col.getName(17).resolveBinding());
|
||||||
|
|
||||||
n = ba.assertImplicitName("/ p", 1, ICPPFunction.class);
|
n = ba.assertImplicitName("/ p", 1, ICPPFunction.class);
|
||||||
assertSame(n.resolveBinding(), col.getName(23).resolveBinding());
|
assertSame(n.resolveBinding(), col.getName(23).resolveBinding());
|
||||||
|
|
||||||
n = ba.assertImplicitName("-p;", 1, ICPPMethod.class);
|
n = ba.assertImplicitName("-p;", 1, ICPPMethod.class);
|
||||||
assertSame(n.resolveBinding(), col.getName(12).resolveBinding());
|
assertSame(n.resolveBinding(), col.getName(12).resolveBinding());
|
||||||
|
|
||||||
ba.assertNoImplicitName("<< 6", 2);
|
ba.assertNoImplicitName("<< 6", 2);
|
||||||
ba.assertNoImplicitName("+p;", 1);
|
ba.assertNoImplicitName("+p;", 1);
|
||||||
}
|
}
|
||||||
|
@ -136,9 +137,9 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
||||||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
ba.assertNoImplicitName("&Y::x;", 1);
|
ba.assertNoImplicitName("&Y::x;", 1);
|
||||||
|
|
||||||
IASTImplicitName n = ba.assertImplicitName("&y;", 1, ICPPFunction.class);
|
IASTImplicitName n = ba.assertImplicitName("&y;", 1, ICPPFunction.class);
|
||||||
assertSame(n.resolveBinding(), col.getName(9).resolveBinding());
|
assertSame(n.resolveBinding(), col.getName(9).resolveBinding());
|
||||||
}
|
}
|
||||||
|
@ -165,20 +166,20 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
||||||
// p2->doA();
|
// p2->doA();
|
||||||
// }
|
// }
|
||||||
public void testArrowOperator() throws Exception {
|
public void testArrowOperator() throws Exception {
|
||||||
String contents = getAboveComment();
|
String contents = getAboveComment();
|
||||||
IASTTranslationUnit tu = parse(contents, ParserLanguage.CPP);
|
IASTTranslationUnit tu = parse(contents, ParserLanguage.CPP);
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
IASTImplicitName[] implicits = getImplicitNames(tu, contents, "->doA();", 2);
|
IASTImplicitName[] implicits = getImplicitNames(tu, contents, "->doA();", 2);
|
||||||
|
|
||||||
assertNotNull(implicits);
|
assertNotNull(implicits);
|
||||||
assertEquals(2, implicits.length);
|
assertEquals(2, implicits.length);
|
||||||
|
|
||||||
assertSame(implicits[1].getBinding(), col.getName(4).resolveBinding());
|
assertSame(implicits[1].getBinding(), col.getName(4).resolveBinding());
|
||||||
assertSame(implicits[0].getBinding(), col.getName(12).resolveBinding());
|
assertSame(implicits[0].getBinding(), col.getName(12).resolveBinding());
|
||||||
}
|
}
|
||||||
|
|
||||||
// struct A {
|
// struct A {
|
||||||
// int x;
|
// int x;
|
||||||
// };
|
// };
|
||||||
|
@ -224,15 +225,15 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
||||||
ba.assertNoImplicitName(", b, c, d); // func", 1);
|
ba.assertNoImplicitName(", b, c, d); // func", 1);
|
||||||
ba.assertNoImplicitName(", c, d); // func", 1);
|
ba.assertNoImplicitName(", c, d); // func", 1);
|
||||||
ba.assertNoImplicitName(", d); // func", 1);
|
ba.assertNoImplicitName(", d); // func", 1);
|
||||||
|
|
||||||
IASTImplicitName opAB = ba.assertImplicitName(", b, c, d; // expr", 1, ICPPFunction.class);
|
IASTImplicitName opAB = ba.assertImplicitName(", b, c, d; // expr", 1, ICPPFunction.class);
|
||||||
IASTImplicitName opCC = ba.assertImplicitName(", c, d; // expr", 1, ICPPFunction.class);
|
IASTImplicitName opCC = ba.assertImplicitName(", c, d; // expr", 1, ICPPFunction.class);
|
||||||
ba.assertNoImplicitName(", d; // expr", 1);
|
ba.assertNoImplicitName(", d; // expr", 1);
|
||||||
|
|
||||||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
assertSame(opAB.resolveBinding(), col.getName(5).resolveBinding());
|
assertSame(opAB.resolveBinding(), col.getName(5).resolveBinding());
|
||||||
assertSame(opCC.resolveBinding(), col.getName(11).resolveBinding());
|
assertSame(opCC.resolveBinding(), col.getName(11).resolveBinding());
|
||||||
}
|
}
|
||||||
|
@ -255,20 +256,20 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testCommaOperator2() throws Exception {
|
public void testCommaOperator2() throws Exception {
|
||||||
BindingAssertionHelper ba = new BindingAssertionHelper(getAboveComment(), true);
|
BindingAssertionHelper ba = new BindingAssertionHelper(getAboveComment(), true);
|
||||||
|
|
||||||
IASTImplicitName opAB = ba.assertImplicitName(", b, c, d", 1, ICPPMethod.class);
|
IASTImplicitName opAB = ba.assertImplicitName(", b, c, d", 1, ICPPMethod.class);
|
||||||
IASTImplicitName opCC = ba.assertImplicitName(", c, d", 1, ICPPFunction.class);
|
IASTImplicitName opCC = ba.assertImplicitName(", c, d", 1, ICPPFunction.class);
|
||||||
IASTImplicitName opDD = ba.assertImplicitName(", d", 1, ICPPMethod.class);
|
IASTImplicitName opDD = ba.assertImplicitName(", d", 1, ICPPMethod.class);
|
||||||
|
|
||||||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
// 6, 11, 15
|
// 6, 11, 15
|
||||||
assertSame(opAB.resolveBinding(), col.getName(6).resolveBinding());
|
assertSame(opAB.resolveBinding(), col.getName(6).resolveBinding());
|
||||||
assertSame(opCC.resolveBinding(), col.getName(15).resolveBinding());
|
assertSame(opCC.resolveBinding(), col.getName(15).resolveBinding());
|
||||||
assertSame(opDD.resolveBinding(), col.getName(11).resolveBinding());
|
assertSame(opDD.resolveBinding(), col.getName(11).resolveBinding());
|
||||||
|
|
||||||
ba.assertNonProblem("ee;", 2);
|
ba.assertNonProblem("ee;", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,7 +290,7 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
||||||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
IASTImplicitName n1 = ba.assertImplicitName("(b); // 1", 1, ICPPMethod.class);
|
IASTImplicitName n1 = ba.assertImplicitName("(b); // 1", 1, ICPPMethod.class);
|
||||||
IASTImplicitName n2 = ba.assertImplicitName("); // 1", 1, ICPPMethod.class);
|
IASTImplicitName n2 = ba.assertImplicitName("); // 1", 1, ICPPMethod.class);
|
||||||
assertSame(n1.resolveBinding(), n2.resolveBinding());
|
assertSame(n1.resolveBinding(), n2.resolveBinding());
|
||||||
|
@ -298,14 +299,14 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
||||||
// there should be no overlap
|
// there should be no overlap
|
||||||
ba.assertNoImplicitName("b); // 1", 1);
|
ba.assertNoImplicitName("b); // 1", 1);
|
||||||
assertSame(col.getName(1).resolveBinding(), n1.resolveBinding());
|
assertSame(col.getName(1).resolveBinding(), n1.resolveBinding());
|
||||||
|
|
||||||
n1 = ba.assertImplicitName("(); // 2", 1, ICPPMethod.class);
|
n1 = ba.assertImplicitName("(); // 2", 1, ICPPMethod.class);
|
||||||
n2 = ba.assertImplicitName("); // 2", 1, ICPPMethod.class);
|
n2 = ba.assertImplicitName("); // 2", 1, ICPPMethod.class);
|
||||||
assertSame(n1.resolveBinding(), n2.resolveBinding());
|
assertSame(n1.resolveBinding(), n2.resolveBinding());
|
||||||
assertFalse(n1.isAlternate());
|
assertFalse(n1.isAlternate());
|
||||||
assertTrue(n2.isAlternate());
|
assertTrue(n2.isAlternate());
|
||||||
assertSame(col.getName(3).resolveBinding(), n1.resolveBinding());
|
assertSame(col.getName(3).resolveBinding(), n1.resolveBinding());
|
||||||
|
|
||||||
n1 = ba.assertImplicitName("(1, 2); // 3", 1, ICPPMethod.class);
|
n1 = ba.assertImplicitName("(1, 2); // 3", 1, ICPPMethod.class);
|
||||||
n2 = ba.assertImplicitName("); // 3", 1, ICPPMethod.class);
|
n2 = ba.assertImplicitName("); // 3", 1, ICPPMethod.class);
|
||||||
assertSame(n1.resolveBinding(), n2.resolveBinding());
|
assertSame(n1.resolveBinding(), n2.resolveBinding());
|
||||||
|
@ -348,7 +349,7 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
||||||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
IASTImplicitName n1 = ba.assertImplicitName("[0]); //1", 1, ICPPMethod.class);
|
IASTImplicitName n1 = ba.assertImplicitName("[0]); //1", 1, ICPPMethod.class);
|
||||||
ba.assertNoImplicitName("0]); //1", 1);
|
ba.assertNoImplicitName("0]); //1", 1);
|
||||||
IASTImplicitName n2 = ba.assertImplicitName("]); //1", 1, ICPPMethod.class);
|
IASTImplicitName n2 = ba.assertImplicitName("]); //1", 1, ICPPMethod.class);
|
||||||
|
@ -356,7 +357,7 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
||||||
assertFalse(n1.isAlternate());
|
assertFalse(n1.isAlternate());
|
||||||
assertTrue(n2.isAlternate());
|
assertTrue(n2.isAlternate());
|
||||||
assertSame(col.getName(1).resolveBinding(), n1.resolveBinding());
|
assertSame(col.getName(1).resolveBinding(), n1.resolveBinding());
|
||||||
|
|
||||||
n1 = ba.assertImplicitName("[q]); //2", 1, ICPPMethod.class);
|
n1 = ba.assertImplicitName("[q]); //2", 1, ICPPMethod.class);
|
||||||
ba.assertNoImplicitName("q]); //2", 1);
|
ba.assertNoImplicitName("q]); //2", 1);
|
||||||
n2 = ba.assertImplicitName("]); //2", 1, ICPPMethod.class);
|
n2 = ba.assertImplicitName("]); //2", 1, ICPPMethod.class);
|
||||||
|
@ -384,21 +385,21 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
||||||
assertEquals(2, names.length);
|
assertEquals(2, names.length);
|
||||||
IASTImplicitName destructor = names[0];
|
IASTImplicitName destructor = names[0];
|
||||||
IASTImplicitName delete = names[1];
|
IASTImplicitName delete = names[1];
|
||||||
|
|
||||||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
assertSame(col.getName(1).resolveBinding(), destructor.resolveBinding());
|
assertSame(col.getName(1).resolveBinding(), destructor.resolveBinding());
|
||||||
assertSame(col.getName(2).resolveBinding(), delete.resolveBinding());
|
assertSame(col.getName(2).resolveBinding(), delete.resolveBinding());
|
||||||
|
|
||||||
names = ba.getImplicitNames("delete[] x;", 6);
|
names = ba.getImplicitNames("delete[] x;", 6);
|
||||||
assertEquals(1, names.length);
|
assertEquals(1, names.length);
|
||||||
assertSame(col.getName(4).resolveBinding(), names[0].resolveBinding());
|
assertSame(col.getName(4).resolveBinding(), names[0].resolveBinding());
|
||||||
|
|
||||||
ba.assertNoImplicitName("delete 1;", 6);
|
ba.assertNoImplicitName("delete 1;", 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
// struct A {
|
// struct A {
|
||||||
// void operator delete(void * a);
|
// void operator delete(void * a);
|
||||||
// };
|
// };
|
||||||
|
@ -416,15 +417,15 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
||||||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
||||||
IBinding m= bh.assertNonProblem("operator delete(void * a)", 15);
|
IBinding m= bh.assertNonProblem("operator delete(void * a)", 15);
|
||||||
IBinding f= bh.assertNonProblem("operator delete(void * b)", 15);
|
IBinding f= bh.assertNonProblem("operator delete(void * b)", 15);
|
||||||
|
|
||||||
IASTImplicitName[] names = bh.getImplicitNames("delete a;", 6);
|
IASTImplicitName[] names = bh.getImplicitNames("delete a;", 6);
|
||||||
assertEquals(2, names.length);
|
assertEquals(2, names.length);
|
||||||
assertTrue(((ICPPMethod) names[0].resolveBinding()).isDestructor());
|
assertTrue(((ICPPMethod) names[0].resolveBinding()).isDestructor());
|
||||||
assertSame(m, names[1].resolveBinding());
|
assertSame(m, names[1].resolveBinding());
|
||||||
|
|
||||||
names = bh.getImplicitNames("delete b;", 6);
|
names = bh.getImplicitNames("delete b;", 6);
|
||||||
assertTrue(((ICPPMethod) names[0].resolveBinding()).isDestructor());
|
assertTrue(((ICPPMethod) names[0].resolveBinding()).isDestructor());
|
||||||
assertEquals(2, names.length);
|
assertEquals(2, names.length);
|
||||||
assertSame(f, names[1].resolveBinding());
|
assertSame(f, names[1].resolveBinding());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,13 +444,13 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
||||||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
||||||
IBinding m= bh.assertNonProblem("operator new(size_t a)", 12);
|
IBinding m= bh.assertNonProblem("operator new(size_t a)", 12);
|
||||||
IBinding f= bh.assertNonProblem("operator new(size_t b)", 12);
|
IBinding f= bh.assertNonProblem("operator new(size_t b)", 12);
|
||||||
|
|
||||||
IASTImplicitName[] names = bh.getImplicitNames("new A;", 3);
|
IASTImplicitName[] names = bh.getImplicitNames("new A;", 3);
|
||||||
assertEquals(1, names.length);
|
assertEquals(2, names.length);
|
||||||
assertSame(m, names[0].resolveBinding());
|
assertSame(m, names[0].resolveBinding());
|
||||||
|
|
||||||
names = bh.getImplicitNames("new B;", 3);
|
names = bh.getImplicitNames("new B;", 3);
|
||||||
assertEquals(1, names.length);
|
assertEquals(2, names.length);
|
||||||
assertSame(f, names[0].resolveBinding());
|
assertSame(f, names[0].resolveBinding());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -461,9 +462,9 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
||||||
public void testImplicitNewAndDelete() throws Exception {
|
public void testImplicitNewAndDelete() throws Exception {
|
||||||
BindingAssertionHelper ba = new BindingAssertionHelper(getAboveComment(), true);
|
BindingAssertionHelper ba = new BindingAssertionHelper(getAboveComment(), true);
|
||||||
ba.assertNoImplicitName("new X", 3);
|
ba.assertNoImplicitName("new X", 3);
|
||||||
ba.assertNoImplicitName("delete[]", 6);
|
ba.assertNoImplicitName("delete[]", 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
// typedef long unsigned int size_t
|
// typedef long unsigned int size_t
|
||||||
// struct nothrow_t {};
|
// struct nothrow_t {};
|
||||||
// extern const nothrow_t nothrow;
|
// extern const nothrow_t nothrow;
|
||||||
|
@ -491,7 +492,7 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
||||||
assertSame(col.getName(9).resolveBinding(), n2.resolveBinding());
|
assertSame(col.getName(9).resolveBinding(), n2.resolveBinding());
|
||||||
assertSame(col.getName(14).resolveBinding(), n3.resolveBinding());
|
assertSame(col.getName(14).resolveBinding(), n3.resolveBinding());
|
||||||
}
|
}
|
||||||
|
|
||||||
// int test() {
|
// int test() {
|
||||||
// throw;
|
// throw;
|
||||||
// }
|
// }
|
||||||
|
@ -551,7 +552,7 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
||||||
IASTImplicitName v = ba.assertImplicitName("v(p)", 1, ICPPConstructor.class);
|
IASTImplicitName v = ba.assertImplicitName("v(p)", 1, ICPPConstructor.class);
|
||||||
assertSame(ctor1, v.resolveBinding());
|
assertSame(ctor1, v.resolveBinding());
|
||||||
}
|
}
|
||||||
|
|
||||||
// enum A {aa};
|
// enum A {aa};
|
||||||
// struct B{ operator A();};
|
// struct B{ operator A();};
|
||||||
// bool operator==(A, A); // overrides the built-in operator.
|
// bool operator==(A, A); // overrides the built-in operator.
|
||||||
|
@ -567,5 +568,5 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
||||||
ICPPFunction op = ba.assertNonProblem("operator==", 0);
|
ICPPFunction op = ba.assertNonProblem("operator==", 0);
|
||||||
IASTImplicitName a = ba.assertImplicitName("==b", 2, ICPPFunction.class);
|
IASTImplicitName a = ba.assertImplicitName("==b", 2, ICPPFunction.class);
|
||||||
assertSame(op, a.resolveBinding());
|
assertSame(op, a.resolveBinding());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
/**
|
/**
|
||||||
* Examples taken from the c++-specification.
|
* Examples taken from the c++-specification.
|
||||||
*/
|
*/
|
||||||
public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
public class AST2CPPSpecTest extends AST2SpecTestBase {
|
||||||
|
|
||||||
public AST2CPPSpecTest() {
|
public AST2CPPSpecTest() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
* Copyright (c) 2004, 2013 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -139,7 +139,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
|
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
|
|
||||||
public class AST2CPPTests extends AST2BaseTest {
|
public class AST2CPPTests extends AST2TestBase {
|
||||||
|
|
||||||
public AST2CPPTests() {
|
public AST2CPPTests() {
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
assertEquals(declNames.length, i);
|
assertEquals(declNames.length, i);
|
||||||
assertEquals(defNames.length, j);
|
assertEquals(defNames.length, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void assertSameType(IType first, IType second){
|
protected void assertSameType(IType first, IType second){
|
||||||
assertNotNull(first);
|
assertNotNull(first);
|
||||||
|
@ -1201,10 +1201,10 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testVirtualParentLookup() throws Exception {
|
public void testVirtualParentLookup() throws Exception {
|
||||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
|
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
|
||||||
CPPNameCollector collector = new CPPNameCollector();
|
CPPNameCollector collector = new CPPNameCollector(true);
|
||||||
tu.accept(collector);
|
tu.accept(collector);
|
||||||
|
|
||||||
assertEquals(collector.size(), 15);
|
assertEquals(collector.size(), 16);
|
||||||
|
|
||||||
ICPPClassType D = (ICPPClassType) collector.getName(0).resolveBinding();
|
ICPPClassType D = (ICPPClassType) collector.getName(0).resolveBinding();
|
||||||
ICPPField x = (ICPPField) collector.getName(1).resolveBinding();
|
ICPPField x = (ICPPField) collector.getName(1).resolveBinding();
|
||||||
|
@ -1215,7 +1215,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
assertInstances(collector, D, 3);
|
assertInstances(collector, D, 3);
|
||||||
assertInstances(collector, C, 2);
|
assertInstances(collector, C, 2);
|
||||||
assertInstances(collector, B, 2);
|
assertInstances(collector, B, 2);
|
||||||
assertInstances(collector, A, 2);
|
assertInstances(collector, A, 3);
|
||||||
assertInstances(collector, ctor, 1);
|
assertInstances(collector, ctor, 1);
|
||||||
assertInstances(collector, x, 2);
|
assertInstances(collector, x, 2);
|
||||||
}
|
}
|
||||||
|
@ -1230,10 +1230,10 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testAmbiguousVirtualParentLookup() throws Exception {
|
public void testAmbiguousVirtualParentLookup() throws Exception {
|
||||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
|
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
|
||||||
CPPNameCollector collector = new CPPNameCollector();
|
CPPNameCollector collector = new CPPNameCollector(true);
|
||||||
tu.accept(collector);
|
tu.accept(collector);
|
||||||
|
|
||||||
assertEquals(collector.size(), 15);
|
assertEquals(collector.size(), 16);
|
||||||
|
|
||||||
ICPPClassType D = (ICPPClassType) collector.getName(0).resolveBinding();
|
ICPPClassType D = (ICPPClassType) collector.getName(0).resolveBinding();
|
||||||
ICPPField x1 = (ICPPField) collector.getName(1).resolveBinding();
|
ICPPField x1 = (ICPPField) collector.getName(1).resolveBinding();
|
||||||
|
@ -1241,13 +1241,13 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
ICPPClassType B = (ICPPClassType) collector.getName(4).resolveBinding();
|
ICPPClassType B = (ICPPClassType) collector.getName(4).resolveBinding();
|
||||||
ICPPClassType A = (ICPPClassType) collector.getName(6).resolveBinding();
|
ICPPClassType A = (ICPPClassType) collector.getName(6).resolveBinding();
|
||||||
ICPPConstructor ctor = A.getConstructors()[0];
|
ICPPConstructor ctor = A.getConstructors()[0];
|
||||||
IProblemBinding x2 = (IProblemBinding) collector.getName(14).resolveBinding();
|
IProblemBinding x2 = (IProblemBinding) collector.getName(15).resolveBinding();
|
||||||
assertEquals(x2.getID(), IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP);
|
assertEquals(x2.getID(), IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP);
|
||||||
|
|
||||||
assertInstances(collector, D, 3);
|
assertInstances(collector, D, 3);
|
||||||
assertInstances(collector, C, 2);
|
assertInstances(collector, C, 2);
|
||||||
assertInstances(collector, B, 2);
|
assertInstances(collector, B, 2);
|
||||||
assertInstances(collector, A, 2);
|
assertInstances(collector, A, 3);
|
||||||
assertInstances(collector, ctor, 1);
|
assertInstances(collector, ctor, 1);
|
||||||
assertInstances(collector, x1, 1);
|
assertInstances(collector, x1, 1);
|
||||||
}
|
}
|
||||||
|
@ -1843,7 +1843,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
ICPPMethod dtor = (ICPPMethod) col.getName(13).resolveBinding();
|
ICPPMethod dtor = (ICPPMethod) col.getName(13).resolveBinding();
|
||||||
assertNotNull(dtor);
|
assertNotNull(dtor);
|
||||||
assertEquals(dtor.getName(), "~C"); //$NON-NLS-1$
|
assertEquals(dtor.getName(), "~C"); //$NON-NLS-1$
|
||||||
assertInstances(col, C, 6);
|
assertInstances(col, C, 7);
|
||||||
|
|
||||||
assertInstances(col, op, 3);
|
assertInstances(col, op, 3);
|
||||||
assertInstances(col, other, 4);
|
assertInstances(col, other, 4);
|
||||||
|
@ -1993,7 +1993,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
|
|
||||||
assertInstances(col, pb, 2);
|
assertInstances(col, pb, 2);
|
||||||
assertInstances(col, mutate, 2);
|
assertInstances(col, mutate, 2);
|
||||||
assertInstances(col, B, 2);
|
assertInstances(col, B, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
// struct S { int i; };
|
// struct S { int i; };
|
||||||
|
@ -2511,7 +2511,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testBug86267() throws Exception {
|
public void testBug86267() throws Exception {
|
||||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
|
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector(true);
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
ICPPClassType D1 = (ICPPClassType) col.getName(2).resolveBinding();
|
ICPPClassType D1 = (ICPPClassType) col.getName(2).resolveBinding();
|
||||||
|
@ -2549,7 +2549,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
ICPPMethod op = (ICPPMethod) col.getName(3).resolveBinding();
|
ICPPMethod op = (ICPPMethod) col.getName(3).resolveBinding();
|
||||||
IParameter other = (IParameter) col.getName(5).resolveBinding();
|
IParameter other = (IParameter) col.getName(5).resolveBinding();
|
||||||
|
|
||||||
assertInstances(col, C, 6);
|
assertInstances(col, C, 7);
|
||||||
assertInstances(col, f, 2);
|
assertInstances(col, f, 2);
|
||||||
assertInstances(col, op, 3);
|
assertInstances(col, op, 3);
|
||||||
assertInstances(col, other, 4);
|
assertInstances(col, other, 4);
|
||||||
|
@ -4052,11 +4052,11 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
// X x = new X(y);
|
// X x = new X(y);
|
||||||
public void testBug90654_1() throws Exception {
|
public void testBug90654_1() throws Exception {
|
||||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
|
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector(true);
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
ICPPConstructor ctor1 = (ICPPConstructor) col.getName(1).resolveBinding();
|
ICPPConstructor ctor1 = (ICPPConstructor) col.getName(1).resolveBinding();
|
||||||
ICPPConstructor ctor = (ICPPConstructor) col.getName(11).resolveBinding();
|
ICPPConstructor ctor = (ICPPConstructor) col.getName(12).resolveBinding();
|
||||||
assertSame(ctor, ctor1);
|
assertSame(ctor, ctor1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8382,20 +8382,24 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
// fH({1}); // H(G(1))
|
// fH({1}); // H(G(1))
|
||||||
// }
|
// }
|
||||||
public void testListInitialization_302412f() throws Exception {
|
public void testListInitialization_302412f() throws Exception {
|
||||||
ICPPConstructor ctor;
|
|
||||||
IProblemBinding problem;
|
IProblemBinding problem;
|
||||||
String code= getAboveComment();
|
String code= getAboveComment();
|
||||||
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
|
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
|
||||||
bh.assertProblem("f({1,1})", 1);
|
bh.assertProblem("f({1,1})", 1);
|
||||||
ctor= bh.assertNonProblem("F({1,1})", 1);
|
bh.assertImplicitName("F({1,1})", 1, ICPPConstructor.class);
|
||||||
bh.assertNonProblem("fF({1,1})", 2);
|
bh.assertNonProblem("fF({1,1})", 2);
|
||||||
|
|
||||||
bh.assertNonProblem("fG(1)", 2);
|
bh.assertNonProblem("fG(1)", 2);
|
||||||
bh.assertNonProblem("fG({1})", 2);
|
bh.assertNonProblem("fG({1})", 2);
|
||||||
|
|
||||||
ctor= bh.assertNonProblem("H(1)", 1);
|
bh.assertImplicitName("H(1)", 1, ICPPConstructor.class);
|
||||||
problem= bh.assertProblem("H({1})", 1);
|
bh.assertNoImplicitName("H({1})", 1);
|
||||||
assertEquals(IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, problem.getID());
|
// TODO(nathanridge): Perhaps we should store implicit names even if they
|
||||||
|
// resolve to ProblemBindings. Then we can do the stronger check in the
|
||||||
|
// 3 commented lines below.
|
||||||
|
//IASTImplicitName n= bh.assertImplicitName("H({1})", 1, IProblemBinding.class);
|
||||||
|
//problem= (IProblemBinding) n.resolveBinding();
|
||||||
|
//assertEquals(IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, problem.getID());
|
||||||
bh.assertProblem("fH(1)", 2);
|
bh.assertProblem("fH(1)", 2);
|
||||||
bh.assertNonProblem("fH({1})", 2);
|
bh.assertNonProblem("fH({1})", 2);
|
||||||
}
|
}
|
||||||
|
@ -9823,7 +9827,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// struct Base {
|
// struct Base {
|
||||||
// virtual void mFuncDecl();
|
// virtual void mFuncDecl();
|
||||||
// virtual void mFuncDef(){}
|
// virtual void mFuncDef(){}
|
||||||
// };
|
// };
|
||||||
// struct S : public Base {
|
// struct S : public Base {
|
||||||
|
@ -9851,9 +9855,9 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
assertInstance(declarator, ICPPASTFunctionDeclarator.class);
|
assertInstance(declarator, ICPPASTFunctionDeclarator.class);
|
||||||
assertVirtualSpecifiers((ICPPASTFunctionDeclarator)declarator, true, false);
|
assertVirtualSpecifiers((ICPPASTFunctionDeclarator)declarator, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// struct Base {
|
// struct Base {
|
||||||
// virtual void mFuncDecl();
|
// virtual void mFuncDecl();
|
||||||
// virtual void mFuncDef(){}
|
// virtual void mFuncDef(){}
|
||||||
// };
|
// };
|
||||||
// struct S : public Base {
|
// struct S : public Base {
|
||||||
|
@ -10025,7 +10029,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
// double vdouble;
|
// double vdouble;
|
||||||
// long double vlongdouble;
|
// long double vlongdouble;
|
||||||
// UnscopedEnum vue;
|
// UnscopedEnum vue;
|
||||||
//
|
//
|
||||||
// // Narrowing conversions
|
// // Narrowing conversions
|
||||||
// fint({vdouble});
|
// fint({vdouble});
|
||||||
// ffloat({vlongdouble});
|
// ffloat({vlongdouble});
|
||||||
|
@ -10083,7 +10087,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
helper.assertNonProblemOnFirstIdentifier("fint({vbool");
|
helper.assertNonProblemOnFirstIdentifier("fint({vbool");
|
||||||
helper.assertNonProblemOnFirstIdentifier("fint({vchar");
|
helper.assertNonProblemOnFirstIdentifier("fint({vchar");
|
||||||
}
|
}
|
||||||
|
|
||||||
// namespace std {
|
// namespace std {
|
||||||
// struct string {};
|
// struct string {};
|
||||||
// struct exception {};
|
// struct exception {};
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
/**
|
/**
|
||||||
* @author dsteffle
|
* @author dsteffle
|
||||||
*/
|
*/
|
||||||
public class AST2CSpecTest extends AST2SpecBaseTest {
|
public class AST2CSpecTest extends AST2SpecTestBase {
|
||||||
|
|
||||||
public AST2CSpecTest() {
|
public AST2CSpecTest() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*
|
|
||||||
* Created on Sept 28, 2004
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
@ -39,116 +35,116 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
/**
|
/**
|
||||||
* @author dsteffle
|
* @author dsteffle
|
||||||
*/
|
*/
|
||||||
public class AST2FileBasePluginTest extends TestCase {
|
public class AST2FileBasePluginTestCase extends TestCase {
|
||||||
static NullProgressMonitor monitor;
|
static NullProgressMonitor monitor;
|
||||||
static IWorkspace workspace;
|
static IWorkspace workspace;
|
||||||
static IProject project;
|
static IProject project;
|
||||||
static FileManager fileManager;
|
static FileManager fileManager;
|
||||||
static int numProjects = 0;
|
static int numProjects;
|
||||||
static Class className;
|
static Class className;
|
||||||
static ICProject cPrj;
|
static ICProject cPrj;
|
||||||
|
|
||||||
public AST2FileBasePluginTest() {
|
public AST2FileBasePluginTestCase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public AST2FileBasePluginTest(String name) {
|
public AST2FileBasePluginTestCase(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initialize(Class aClassName){
|
private void initialize(Class aClassName) {
|
||||||
if( CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null){
|
if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null) {
|
||||||
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
|
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
|
|
||||||
workspace = ResourcesPlugin.getWorkspace();
|
workspace = ResourcesPlugin.getWorkspace();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cPrj = CProjectHelper.createCCProject("AST2BasedProjectMofo", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
|
cPrj = CProjectHelper.createCCProject("AST2BasedProjectMofo", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
project = cPrj.getProject();
|
project = cPrj.getProject();
|
||||||
|
|
||||||
// ugly
|
// ugly
|
||||||
if (className == null || !className.equals(aClassName)) {
|
if (className == null || !className.equals(aClassName)) {
|
||||||
className = aClassName;
|
className = aClassName;
|
||||||
numProjects++;
|
numProjects++;
|
||||||
}
|
}
|
||||||
} catch ( CoreException e ) {
|
} catch (CoreException e) {
|
||||||
/*boo*/
|
// Ignore
|
||||||
}
|
}
|
||||||
if (project == null)
|
if (project == null)
|
||||||
throw new NullPointerException("Unable to create project"); //$NON-NLS-1$
|
throw new NullPointerException("Unable to create project"); //$NON-NLS-1$
|
||||||
|
|
||||||
//Create file manager
|
// Create file manager
|
||||||
fileManager = new FileManager();
|
fileManager = new FileManager();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AST2FileBasePluginTest(String name, Class className)
|
public AST2FileBasePluginTestCase(String name, Class className) {
|
||||||
{
|
|
||||||
super(name);
|
super(name);
|
||||||
initialize(className);
|
initialize(className);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanupProject() throws Exception {
|
public void cleanupProject() throws Exception {
|
||||||
numProjects--;
|
numProjects--;
|
||||||
|
|
||||||
try{
|
try {
|
||||||
if (numProjects == 0) {
|
if (numProjects == 0) {
|
||||||
project.delete( true, false, monitor );
|
project.delete(true, false, monitor);
|
||||||
project = null;
|
project = null;
|
||||||
}
|
}
|
||||||
} catch( Throwable e ){
|
} catch (Throwable e) {
|
||||||
/*boo*/
|
// Ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
if( project == null || !project.exists() )
|
if (project == null || !project.exists())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IResource [] members = project.members();
|
IResource[] members = project.members();
|
||||||
for( int i = 0; i < members.length; i++ ){
|
for (int i = 0; i < members.length; i++) {
|
||||||
if( members[i].getName().equals( ".project" ) || members[i].getName().equals( ".cproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$
|
if (members[i].getName().equals(".project") || members[i].getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
continue;
|
continue;
|
||||||
if (members[i].getName().equals(".settings"))
|
if (members[i].getName().equals(".settings"))
|
||||||
continue;
|
continue;
|
||||||
try{
|
try {
|
||||||
members[i].delete( false, monitor );
|
members[i].delete(false, monitor);
|
||||||
} catch( Throwable e ){
|
} catch (Throwable e) {
|
||||||
/*boo*/
|
// Ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IFolder importFolder(String folderName) throws Exception {
|
protected IFolder importFolder(String folderName) throws Exception {
|
||||||
IFolder folder = project.getProject().getFolder(folderName);
|
IFolder folder = project.getProject().getFolder(folderName);
|
||||||
|
|
||||||
//Create file input stream
|
// Create file input stream
|
||||||
if( !folder.exists() )
|
if (!folder.exists())
|
||||||
folder.create( false, false, monitor );
|
folder.create(false, false, monitor);
|
||||||
|
|
||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
public IFile importFile(String fileName, String contents ) throws Exception{
|
|
||||||
//Obtain file handle
|
public IFile importFile(String fileName, String contents) throws Exception {
|
||||||
|
// Obtain file handle
|
||||||
IFile file = project.getProject().getFile(fileName);
|
IFile file = project.getProject().getFile(fileName);
|
||||||
|
|
||||||
InputStream stream = new ByteArrayInputStream( contents.getBytes() );
|
InputStream stream = new ByteArrayInputStream(contents.getBytes());
|
||||||
//Create file input stream
|
// Create file input stream
|
||||||
if( file.exists() )
|
if (file.exists()) {
|
||||||
file.setContents( stream, false, false, monitor );
|
file.setContents(stream, false, false, monitor);
|
||||||
else
|
} else {
|
||||||
file.create( stream, false, monitor );
|
file.create(stream, false, monitor);
|
||||||
|
}
|
||||||
|
|
||||||
fileManager.addFile(file);
|
fileManager.addFile(file);
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected StringBuilder[] getContents(int sections) throws IOException {
|
protected StringBuilder[] getContents(int sections) throws IOException {
|
||||||
return TestSourceReader.getContentsForTest(
|
return TestSourceReader.getContentsForTest(
|
||||||
CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), sections);
|
CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), sections);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -59,7 +59,7 @@ import org.eclipse.cdt.internal.core.dom.parser.c.ICInternalBinding;
|
||||||
/**
|
/**
|
||||||
* @author dsteffle
|
* @author dsteffle
|
||||||
*/
|
*/
|
||||||
public class AST2KnRTests extends AST2BaseTest {
|
public class AST2KnRTests extends AST2TestBase {
|
||||||
|
|
||||||
public AST2KnRTests() {
|
public AST2KnRTests() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
* Copyright (c) 2005, 2013 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
* Nathan Ridge
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||||
|
|
||||||
|
@ -26,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IField;
|
import org.eclipse.cdt.core.dom.ast.IField;
|
||||||
|
@ -46,7 +48,7 @@ import org.eclipse.core.resources.IFile;
|
||||||
/**
|
/**
|
||||||
* @author dsteffle
|
* @author dsteffle
|
||||||
*/
|
*/
|
||||||
public class AST2SelectionParseTest extends AST2SelectionParseBaseTest {
|
public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
|
||||||
|
|
||||||
public AST2SelectionParseTest() {
|
public AST2SelectionParseTest() {
|
||||||
}
|
}
|
||||||
|
@ -352,9 +354,10 @@ public class AST2SelectionParseTest extends AST2SelectionParseBaseTest {
|
||||||
assertTrue(node instanceof IASTTypeId);
|
assertTrue(node instanceof IASTTypeId);
|
||||||
assertEquals(((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName().toString(), "Gonzo"); //$NON-NLS-1$
|
assertEquals(((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName().toString(), "Gonzo"); //$NON-NLS-1$
|
||||||
name = ((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName();
|
name = ((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName();
|
||||||
assertNotNull(name.resolveBinding());
|
name = TestUtil.findImplicitName(name);
|
||||||
assertTrue(name.resolveBinding() instanceof ICPPConstructor);
|
IBinding binding = name.resolveBinding();
|
||||||
assertEquals(((ICPPConstructor)name.resolveBinding()).getName(), "Gonzo"); //$NON-NLS-1$
|
assertTrue(binding instanceof ICPPConstructor);
|
||||||
|
assertEquals(((ICPPConstructor)binding).getName(), "Gonzo"); //$NON-NLS-1$
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assertTrue(node instanceof IASTName);
|
assertTrue(node instanceof IASTName);
|
||||||
|
@ -736,9 +739,10 @@ public class AST2SelectionParseTest extends AST2SelectionParseBaseTest {
|
||||||
assertTrue(node instanceof IASTTypeId);
|
assertTrue(node instanceof IASTTypeId);
|
||||||
assertEquals(((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName().toString(), "B"); //$NON-NLS-1$
|
assertEquals(((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName().toString(), "B"); //$NON-NLS-1$
|
||||||
IASTName name = ((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName();
|
IASTName name = ((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName();
|
||||||
assertNotNull(name.resolveBinding());
|
name = TestUtil.findImplicitName(name);
|
||||||
assertTrue(name.resolveBinding() instanceof ICPPConstructor);
|
IBinding binding = name.resolveBinding();
|
||||||
assertEquals(((ICPPConstructor)name.resolveBinding()).getName(), "B"); //$NON-NLS-1$
|
assertTrue(binding instanceof ICPPConstructor);
|
||||||
|
assertEquals(((ICPPConstructor)binding).getName(), "B"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug72712_2() throws Exception{
|
public void testBug72712_2() throws Exception{
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.eclipse.cdt.core.parser.NullLogService;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.tests.FileBasePluginTest;
|
import org.eclipse.cdt.core.parser.tests.FileBasePluginTestCase;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
||||||
|
@ -40,18 +40,18 @@ import org.eclipse.core.resources.IFile;
|
||||||
/**
|
/**
|
||||||
* @author dsteffle
|
* @author dsteffle
|
||||||
*/
|
*/
|
||||||
public class AST2SelectionParseBaseTest extends FileBasePluginTest {
|
public class AST2SelectionParseTestBase extends FileBasePluginTestCase {
|
||||||
|
|
||||||
public AST2SelectionParseBaseTest() {
|
public AST2SelectionParseTestBase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public AST2SelectionParseBaseTest(String name) {
|
public AST2SelectionParseTestBase(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final IParserLogService NULL_LOG = new NullLogService();
|
private static final IParserLogService NULL_LOG = new NullLogService();
|
||||||
|
|
||||||
public AST2SelectionParseBaseTest(String name, Class className) {
|
public AST2SelectionParseTestBase(String name, Class className) {
|
||||||
super(name, className);
|
super(name, className);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ public class AST2SelectionParseBaseTest extends FileBasePluginTest {
|
||||||
protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems) throws ParserException {
|
protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems) throws ParserException {
|
||||||
FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
|
FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
|
||||||
ScannerInfo scannerInfo = new ScannerInfo();
|
ScannerInfo scannerInfo = new ScannerInfo();
|
||||||
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||||
|
|
||||||
ISourceCodeParser parser2 = null;
|
ISourceCodeParser parser2 = null;
|
||||||
if (lang == ParserLanguage.CPP) {
|
if (lang == ParserLanguage.CPP) {
|
|
@ -41,12 +41,12 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
/**
|
/**
|
||||||
* @author dsteffle
|
* @author dsteffle
|
||||||
*/
|
*/
|
||||||
public class AST2SpecBaseTest extends AST2BaseTest {
|
public class AST2SpecTestBase extends AST2TestBase {
|
||||||
public AST2SpecBaseTest() {
|
public AST2SpecTestBase() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AST2SpecBaseTest(String name) {
|
public AST2SpecTestBase(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ public class AST2SpecBaseTest extends AST2BaseTest {
|
||||||
boolean useGNUExtensions, boolean expectNoProblems, boolean checkBindings,
|
boolean useGNUExtensions, boolean expectNoProblems, boolean checkBindings,
|
||||||
int expectedProblemBindings, String[] problems) throws ParserException {
|
int expectedProblemBindings, String[] problems) throws ParserException {
|
||||||
ScannerInfo scannerInfo = new ScannerInfo();
|
ScannerInfo scannerInfo = new ScannerInfo();
|
||||||
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||||
|
|
||||||
ISourceCodeParser parser2 = null;
|
ISourceCodeParser parser2 = null;
|
||||||
if (lang == ParserLanguage.CPP) {
|
if (lang == ParserLanguage.CPP) {
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
* Copyright (c) 2005, 2013 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -44,6 +44,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IField;
|
import org.eclipse.cdt.core.dom.ast.IField;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||||
|
@ -55,6 +56,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
||||||
|
@ -101,7 +103,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
|
|
||||||
public class AST2TemplateTests extends AST2BaseTest {
|
public class AST2TemplateTests extends AST2TestBase {
|
||||||
|
|
||||||
public AST2TemplateTests() {
|
public AST2TemplateTests() {
|
||||||
}
|
}
|
||||||
|
@ -2371,11 +2373,11 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
public void testCPPConstructorTemplateSpecialization() throws Exception {
|
public void testCPPConstructorTemplateSpecialization() throws Exception {
|
||||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||||
|
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector(true);
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
ICPPASTTemplateId tid= (ICPPASTTemplateId) col.getName(20);
|
IASTImplicitName tid= (IASTImplicitName) col.getName(20);
|
||||||
IASTName cn= col.getName(21);
|
IASTName cn= col.getName(22);
|
||||||
assertInstance(cn.resolveBinding(), ICPPClassTemplate.class); // *D*<int>(5, 6)
|
assertInstance(cn.resolveBinding(), ICPPClassTemplate.class); // *D*<int>(5, 6)
|
||||||
assertInstance(cn.resolveBinding(), ICPPClassType.class); // *D*<int>(5, 6)
|
assertInstance(cn.resolveBinding(), ICPPClassType.class); // *D*<int>(5, 6)
|
||||||
assertInstance(tid.resolveBinding(), ICPPTemplateInstance.class); // *D<int>*(5, 6)
|
assertInstance(tid.resolveBinding(), ICPPTemplateInstance.class); // *D<int>*(5, 6)
|
||||||
|
@ -3840,7 +3842,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// };
|
// };
|
||||||
public void testNestedTemplates_259872_1() throws Exception {
|
public void testNestedTemplates_259872_1() throws Exception {
|
||||||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), CPP);
|
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), CPP);
|
||||||
bh.assertNonProblem("A<B, int>", 9, ICPPConstructor.class);
|
bh.assertNonProblem("A<B, int>", 9, ICPPClassType.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// template <typename CL, typename T>
|
// template <typename CL, typename T>
|
||||||
|
@ -3865,7 +3867,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// };
|
// };
|
||||||
public void testNestedTemplates_259872_2() throws Exception {
|
public void testNestedTemplates_259872_2() throws Exception {
|
||||||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), CPP);
|
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), CPP);
|
||||||
bh.assertNonProblem("A<B, int>", 9, ICPPConstructor.class);
|
bh.assertNonProblem("A<B, int>", 9, ICPPClassType.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// template <class T>
|
// template <class T>
|
||||||
|
@ -6219,24 +6221,24 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testSimpleAliasDeclaration() throws Exception {
|
public void testSimpleAliasDeclaration() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
|
|
||||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||||
|
|
||||||
ICPPClassType S = assertionHelper.assertNonProblem("struct S {", "S", ICPPClassType.class);
|
ICPPClassType S = assertionHelper.assertNonProblem("struct S {", "S", ICPPClassType.class);
|
||||||
ICPPField x = assertionHelper.assertNonProblem("int x", "x", ICPPField.class);
|
ICPPField x = assertionHelper.assertNonProblem("int x", "x", ICPPField.class);
|
||||||
ITypedef Alias = assertionHelper.assertNonProblem("using Alias = S", "Alias", ITypedef.class);
|
ITypedef Alias = assertionHelper.assertNonProblem("using Alias = S", "Alias", ITypedef.class);
|
||||||
IFunction foo = assertionHelper.assertNonProblem("void foo() {", "foo", IFunction.class);
|
IFunction foo = assertionHelper.assertNonProblem("void foo() {", "foo", IFunction.class);
|
||||||
IVariable myA = assertionHelper.assertNonProblem("Alias myA", "myA", IVariable.class);
|
IVariable myA = assertionHelper.assertNonProblem("Alias myA", "myA", IVariable.class);
|
||||||
|
|
||||||
|
|
||||||
assertInstances(collector, S, 2);
|
assertInstances(collector, S, 2);
|
||||||
assertInstances(collector, x, 2);
|
assertInstances(collector, x, 2);
|
||||||
assertInstances(collector, Alias, 2);
|
assertInstances(collector, Alias, 2);
|
||||||
assertInstances(collector, foo, 1);
|
assertInstances(collector, foo, 1);
|
||||||
assertInstances(collector, myA, 2);
|
assertInstances(collector, myA, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// template<typename T>
|
// template<typename T>
|
||||||
// struct S {
|
// struct S {
|
||||||
// T x;
|
// T x;
|
||||||
|
@ -6248,7 +6250,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testSpecifiedTemplateAliasDeclaration() throws Exception {
|
public void testSpecifiedTemplateAliasDeclaration() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
|
|
||||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||||
|
|
||||||
|
@ -6257,7 +6259,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
ITypedef Alias = assertionHelper.assertNonProblem("using Alias = S<int>;", "Alias", ITypedef.class);
|
ITypedef Alias = assertionHelper.assertNonProblem("using Alias = S<int>;", "Alias", ITypedef.class);
|
||||||
IVariable myA = assertionHelper.assertNonProblem("Alias myA;", "myA", IVariable.class);
|
IVariable myA = assertionHelper.assertNonProblem("Alias myA;", "myA", IVariable.class);
|
||||||
ICPPSpecialization xRef = assertionHelper.assertNonProblem("myA.x = 42;", "x", ICPPSpecialization.class);
|
ICPPSpecialization xRef = assertionHelper.assertNonProblem("myA.x = 42;", "x", ICPPSpecialization.class);
|
||||||
|
|
||||||
|
|
||||||
assertInstances(collector, S, 2);
|
assertInstances(collector, S, 2);
|
||||||
assertInstances(collector, Alias, 2);
|
assertInstances(collector, Alias, 2);
|
||||||
|
@ -6273,13 +6275,13 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testTemplatedAliasBasicType() throws Exception {
|
public void testTemplatedAliasBasicType() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
|
|
||||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||||
|
|
||||||
ICPPAliasTemplate Alias = assertionHelper.assertNonProblem("using Alias = int;", "Alias", ICPPAliasTemplate.class);
|
ICPPAliasTemplate Alias = assertionHelper.assertNonProblem("using Alias = int;", "Alias", ICPPAliasTemplate.class);
|
||||||
ICPPAliasTemplateInstance aliasFloatInstance = assertionHelper.assertNonProblem("Alias<float> myA;", "Alias<float>", ICPPAliasTemplateInstance.class);
|
ICPPAliasTemplateInstance aliasFloatInstance = assertionHelper.assertNonProblem("Alias<float> myA;", "Alias<float>", ICPPAliasTemplateInstance.class);
|
||||||
|
|
||||||
assertInstances(collector, Alias, 2);
|
assertInstances(collector, Alias, 2);
|
||||||
assertSameType(aliasFloatInstance, new CPPBasicType(IBasicType.Kind.eInt, 0));
|
assertSameType(aliasFloatInstance, new CPPBasicType(IBasicType.Kind.eInt, 0));
|
||||||
}
|
}
|
||||||
|
@ -6296,7 +6298,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testTemplatedAliasDeclaration() throws Exception {
|
public void testTemplatedAliasDeclaration() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
|
|
||||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||||
|
|
||||||
|
@ -6334,9 +6336,9 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testTemplatedAliasDeclarationMultipleParameters() throws Exception {
|
public void testTemplatedAliasDeclarationMultipleParameters() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
|
|
||||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||||
|
|
||||||
ICPPField t1 = assertionHelper.assertNonProblem("T1 t1;", "t1", ICPPField.class);
|
ICPPField t1 = assertionHelper.assertNonProblem("T1 t1;", "t1", ICPPField.class);
|
||||||
ICPPField t2 = assertionHelper.assertNonProblem("T2 t2;", "t2", ICPPField.class);
|
ICPPField t2 = assertionHelper.assertNonProblem("T2 t2;", "t2", ICPPField.class);
|
||||||
ICPPField t3 = assertionHelper.assertNonProblem("T3 t3;", "t3", ICPPField.class);
|
ICPPField t3 = assertionHelper.assertNonProblem("T3 t3;", "t3", ICPPField.class);
|
||||||
|
@ -6377,9 +6379,9 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testTemplatedAliasDeclarationTemplateArgument() throws Exception {
|
public void testTemplatedAliasDeclarationTemplateArgument() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
|
|
||||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||||
|
|
||||||
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
||||||
ICPPAliasTemplateInstance TAliasSInt = assertionHelper.assertNonProblem("TAlias<S<int>> myA;", "TAlias<S<int>>", ICPPAliasTemplateInstance.class);
|
ICPPAliasTemplateInstance TAliasSInt = assertionHelper.assertNonProblem("TAlias<S<int>> myA;", "TAlias<S<int>>", ICPPAliasTemplateInstance.class);
|
||||||
ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = S<int>()", "t", ICPPSpecialization.class);
|
ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = S<int>()", "t", ICPPSpecialization.class);
|
||||||
|
@ -6400,9 +6402,9 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testTemplatedAliasAsTemplateArgument() throws Exception {
|
public void testTemplatedAliasAsTemplateArgument() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
|
|
||||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||||
|
|
||||||
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
||||||
ICPPTemplateInstance STAliasInt = assertionHelper.assertNonProblem("S<TAlias<int>> myA;", "S<TAlias<int>>", ICPPTemplateInstance.class);
|
ICPPTemplateInstance STAliasInt = assertionHelper.assertNonProblem("S<TAlias<int>> myA;", "S<TAlias<int>>", ICPPTemplateInstance.class);
|
||||||
ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = S<int>();", "t", ICPPSpecialization.class);
|
ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = S<int>();", "t", ICPPSpecialization.class);
|
||||||
|
@ -6423,9 +6425,9 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testTemplatedAliasDeclarationValueArgument() throws Exception {
|
public void testTemplatedAliasDeclarationValueArgument() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
|
|
||||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||||
|
|
||||||
ICPPField buff = assertionHelper.assertNonProblem("int buff [Size];", "buff", ICPPField.class);
|
ICPPField buff = assertionHelper.assertNonProblem("int buff [Size];", "buff", ICPPField.class);
|
||||||
ICPPSpecialization buffRef = assertionHelper.assertNonProblem("myA.buff[0] = 1;", "buff", ICPPSpecialization.class);
|
ICPPSpecialization buffRef = assertionHelper.assertNonProblem("myA.buff[0] = 1;", "buff", ICPPSpecialization.class);
|
||||||
|
|
||||||
|
@ -6446,9 +6448,9 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testTemplatedAliasDefaultArguments() throws Exception {
|
public void testTemplatedAliasDefaultArguments() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
|
|
||||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||||
|
|
||||||
ICPPField buff = assertionHelper.assertNonProblem("T buff [Size];", "buff", ICPPField.class);
|
ICPPField buff = assertionHelper.assertNonProblem("T buff [Size];", "buff", ICPPField.class);
|
||||||
ICPPAliasTemplateInstance myA = assertionHelper.assertNonProblem("TAlias<> myA;", "TAlias<>", ICPPAliasTemplateInstance.class);
|
ICPPAliasTemplateInstance myA = assertionHelper.assertNonProblem("TAlias<> myA;", "TAlias<>", ICPPAliasTemplateInstance.class);
|
||||||
ICPPSpecialization buffRef = assertionHelper.assertNonProblem("myA.buff[0] = 1;", "buff", ICPPSpecialization.class);
|
ICPPSpecialization buffRef = assertionHelper.assertNonProblem("myA.buff[0] = 1;", "buff", ICPPSpecialization.class);
|
||||||
|
@ -6470,9 +6472,9 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testTemplatedAliasTemplateArgument() throws Exception {
|
public void testTemplatedAliasTemplateArgument() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
|
|
||||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||||
|
|
||||||
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
||||||
ICPPSpecialization tRef = assertionHelper.assertNonProblem(" myA.t = S<int>();", "t", ICPPSpecialization.class);
|
ICPPSpecialization tRef = assertionHelper.assertNonProblem(" myA.t = S<int>();", "t", ICPPSpecialization.class);
|
||||||
ICPPClassSpecialization Sint = assertionHelper.assertNonProblem("myA.t = S<int>();", "S<int>", ICPPClassSpecialization.class);
|
ICPPClassSpecialization Sint = assertionHelper.assertNonProblem("myA.t = S<int>();", "S<int>", ICPPClassSpecialization.class);
|
||||||
|
@ -6497,9 +6499,9 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testTemplatedAliasAsFunctionParameter() throws Exception {
|
public void testTemplatedAliasAsFunctionParameter() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
|
|
||||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||||
|
|
||||||
ICPPFunction bar = assertionHelper.assertNonProblem("void bar(TAlias<int> arg){", "bar", ICPPFunction.class);
|
ICPPFunction bar = assertionHelper.assertNonProblem("void bar(TAlias<int> arg){", "bar", ICPPFunction.class);
|
||||||
ICPPFunction barRefAlias = assertionHelper.assertNonProblem("bar(myA);", "bar", ICPPFunction.class);
|
ICPPFunction barRefAlias = assertionHelper.assertNonProblem("bar(myA);", "bar", ICPPFunction.class);
|
||||||
ICPPFunction barRefSInt = assertionHelper.assertNonProblem("bar(myS);", "bar", ICPPFunction.class);
|
ICPPFunction barRefSInt = assertionHelper.assertNonProblem("bar(myS);", "bar", ICPPFunction.class);
|
||||||
|
@ -6522,7 +6524,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testTemplatedAliasAsFunctionArgument() throws Exception {
|
public void testTemplatedAliasAsFunctionArgument() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
|
|
||||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||||
|
|
||||||
ICPPFunction bar = assertionHelper.assertNonProblem("void bar(S<int> arg){", "bar", ICPPFunction.class);
|
ICPPFunction bar = assertionHelper.assertNonProblem("void bar(S<int> arg){", "bar", ICPPFunction.class);
|
||||||
|
@ -6571,7 +6573,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testSimpleFunctionAliasDeclaration() throws Exception {
|
public void testSimpleFunctionAliasDeclaration() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
|
|
||||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||||
|
|
||||||
|
@ -6596,7 +6598,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testTemplatedAliasForTemplateReference() throws Exception {
|
public void testTemplatedAliasForTemplateReference() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
|
|
||||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||||
|
|
||||||
ICPPClassSpecialization SInt = assertionHelper.assertNonProblem("S<int> myS;", "S<int>", ICPPClassSpecialization.class);
|
ICPPClassSpecialization SInt = assertionHelper.assertNonProblem("S<int> myS;", "S<int>", ICPPClassSpecialization.class);
|
||||||
|
@ -6612,7 +6614,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testSimpleFunctionTemplateAliasDeclaration() throws Exception {
|
public void testSimpleFunctionTemplateAliasDeclaration() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
|
|
||||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||||
|
|
||||||
|
@ -6632,7 +6634,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testSimpleFunctionReferenceTemplateAliasDeclaration() throws Exception {
|
public void testSimpleFunctionReferenceTemplateAliasDeclaration() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
|
|
||||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||||
|
|
||||||
|
@ -6657,7 +6659,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testTemplatedAliasTemplateParameter() throws Exception {
|
public void testTemplatedAliasTemplateParameter() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
|
|
||||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||||
|
|
||||||
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
||||||
|
@ -6680,10 +6682,11 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// Alias<int> intAlias;
|
// Alias<int> intAlias;
|
||||||
public void testAliasDeclarationContext() throws Exception {
|
public void testAliasDeclarationContext() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
|
|
||||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||||
|
|
||||||
ICPPAliasTemplateInstance AliasInt = assertionHelper.assertNonProblem("Alias<int> intAlias;", "Alias<int>", ICPPAliasTemplateInstance.class);
|
ICPPAliasTemplateInstance AliasInt =
|
||||||
|
assertionHelper.assertNonProblem("Alias<int> intAlias;", "Alias<int>", ICPPAliasTemplateInstance.class);
|
||||||
assertEquals("Alias<int>", AliasInt.getName());
|
assertEquals("Alias<int>", AliasInt.getName());
|
||||||
assertEquals("NS", AliasInt.getQualifiedName()[0]);
|
assertEquals("NS", AliasInt.getQualifiedName()[0]);
|
||||||
assertEquals("Alias<int>", AliasInt.getQualifiedName()[1]);
|
assertEquals("Alias<int>", AliasInt.getQualifiedName()[1]);
|
||||||
|
@ -7004,4 +7007,26 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
public void testDependentExpressions_395243d() throws Exception {
|
public void testDependentExpressions_395243d() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 {
|
||||||
|
BindingAssertionHelper ah = getAssertionHelper();
|
||||||
|
IEnumerator binding = ah.assertNonProblem("C<bool>::id", "id");
|
||||||
|
IValue value = binding.getValue();
|
||||||
|
Long num = value.numericalValue();
|
||||||
|
assertNotNull(num);
|
||||||
|
assertEquals(1, num.longValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
* Copyright (c) 2004, 2013 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -95,7 +95,7 @@ import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class AST2BaseTest extends BaseTestCase {
|
public class AST2TestBase extends BaseTestCase {
|
||||||
public final static String TEST_CODE = "<testcode>";
|
public final static String TEST_CODE = "<testcode>";
|
||||||
protected static final IParserLogService NULL_LOG = new NullLogService();
|
protected static final IParserLogService NULL_LOG = new NullLogService();
|
||||||
protected static boolean sValidateCopy;
|
protected static boolean sValidateCopy;
|
||||||
|
@ -121,14 +121,14 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AST2BaseTest() {
|
public AST2TestBase() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AST2BaseTest(String name) {
|
public AST2TestBase(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
sValidateCopy= true;
|
sValidateCopy= true;
|
||||||
|
@ -138,7 +138,7 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
protected IASTTranslationUnit parse(String code, ParserLanguage lang) throws ParserException {
|
protected IASTTranslationUnit parse(String code, ParserLanguage lang) throws ParserException {
|
||||||
return parse(code, lang, false, true);
|
return parse(code, lang, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions) throws ParserException {
|
protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions) throws ParserException {
|
||||||
return parse(code, lang, useGNUExtensions, true);
|
return parse(code, lang, useGNUExtensions, true);
|
||||||
}
|
}
|
||||||
|
@ -147,10 +147,10 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
boolean expectNoProblems) throws ParserException {
|
boolean expectNoProblems) throws ParserException {
|
||||||
return parse(code, lang, useGNUExtensions, expectNoProblems, false);
|
return parse(code, lang, useGNUExtensions, expectNoProblems, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions,
|
protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions,
|
||||||
boolean expectNoProblems, boolean skipTrivialInitializers) throws ParserException {
|
boolean expectNoProblems, boolean skipTrivialInitializers) throws ParserException {
|
||||||
IScanner scanner = createScanner(FileContent.create(TEST_CODE, code.toCharArray()), lang, ParserMode.COMPLETE_PARSE,
|
IScanner scanner = createScanner(FileContent.create(TEST_CODE, code.toCharArray()), lang, ParserMode.COMPLETE_PARSE,
|
||||||
createScannerInfo(useGNUExtensions));
|
createScannerInfo(useGNUExtensions));
|
||||||
configureScanner(scanner);
|
configureScanner(scanner);
|
||||||
AbstractGNUSourceCodeParser parser = null;
|
AbstractGNUSourceCodeParser parser = null;
|
||||||
|
@ -170,12 +170,12 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
} else {
|
} else {
|
||||||
config = new ANSICParserExtensionConfiguration();
|
config = new ANSICParserExtensionConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
parser = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null);
|
parser = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null);
|
||||||
}
|
}
|
||||||
if (skipTrivialInitializers)
|
if (skipTrivialInitializers)
|
||||||
parser.setSkipTrivialExpressionsInAggregateInitializers(true);
|
parser.setSkipTrivialExpressionsInAggregateInitializers(true);
|
||||||
|
|
||||||
IASTTranslationUnit tu = parser.parse();
|
IASTTranslationUnit tu = parser.parse();
|
||||||
assertTrue(tu.isFrozen());
|
assertTrue(tu.isFrozen());
|
||||||
if (sValidateCopy)
|
if (sValidateCopy)
|
||||||
|
@ -183,7 +183,7 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
|
|
||||||
if (parser.encounteredError() && expectNoProblems)
|
if (parser.encounteredError() && expectNoProblems)
|
||||||
throw new ParserException("FAILURE"); //$NON-NLS-1$
|
throw new ParserException("FAILURE"); //$NON-NLS-1$
|
||||||
|
|
||||||
if (lang == ParserLanguage.C && expectNoProblems) {
|
if (lang == ParserLanguage.C && expectNoProblems) {
|
||||||
assertEquals(CVisitor.getProblems(tu).length, 0);
|
assertEquals(CVisitor.getProblems(tu).length, 0);
|
||||||
assertEquals(tu.getPreprocessorProblems().length, 0);
|
assertEquals(tu.getPreprocessorProblems().length, 0);
|
||||||
|
@ -193,7 +193,7 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
if (expectNoProblems)
|
if (expectNoProblems)
|
||||||
assertEquals(0, tu.getPreprocessorProblems().length);
|
assertEquals(0, tu.getPreprocessorProblems().length);
|
||||||
|
|
||||||
return tu;
|
return tu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
configuration= GPPScannerExtensionConfiguration.getInstance(scannerInfo);
|
configuration= GPPScannerExtensionConfiguration.getInstance(scannerInfo);
|
||||||
}
|
}
|
||||||
IScanner scanner;
|
IScanner scanner;
|
||||||
scanner= new CPreprocessor(codeReader, scannerInfo, lang, NULL_LOG, configuration,
|
scanner= new CPreprocessor(codeReader, scannerInfo, lang, NULL_LOG, configuration,
|
||||||
IncludeFileContentProvider.getSavedFilesProvider());
|
IncludeFileContentProvider.getSavedFilesProvider());
|
||||||
return scanner;
|
return scanner;
|
||||||
}
|
}
|
||||||
|
@ -263,7 +263,7 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void validateSimpleBinaryExpressionC(String code, int operand) throws ParserException {
|
protected void validateSimpleBinaryExpressionC(String code, int operand) throws ParserException {
|
||||||
IASTBinaryExpression e = (IASTBinaryExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
|
IASTBinaryExpression e = (IASTBinaryExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
|
||||||
assertNotNull(e);
|
assertNotNull(e);
|
||||||
assertEquals(e.getOperator(), operand);
|
assertEquals(e.getOperator(), operand);
|
||||||
IASTIdExpression x = (IASTIdExpression) e.getOperand1();
|
IASTIdExpression x = (IASTIdExpression) e.getOperand1();
|
||||||
|
@ -290,8 +290,8 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
ASTComparer.assertCopy(tu, copy);
|
ASTComparer.assertCopy(tu, copy);
|
||||||
return (T) copy;
|
return (T) copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static protected class CNameCollector extends ASTVisitor {
|
static protected class CNameCollector extends ASTVisitor {
|
||||||
{
|
{
|
||||||
shouldVisitNames = true;
|
shouldVisitNames = true;
|
||||||
|
@ -309,29 +309,35 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
return null;
|
return null;
|
||||||
return nameList.get(idx);
|
return nameList.get(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int size() {
|
public int size() {
|
||||||
return nameList.size();
|
return nameList.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertInstances(CNameCollector collector, IBinding binding, int num) throws Exception {
|
protected void assertInstances(CNameCollector collector, IBinding binding, int num) throws Exception {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
assertNotNull(binding);
|
assertNotNull(binding);
|
||||||
|
|
||||||
for (int i = 0; i < collector.size(); i++) {
|
for (int i = 0; i < collector.size(); i++) {
|
||||||
if (collector.getName(i).resolveBinding() == binding)
|
if (collector.getName(i).resolveBinding() == binding)
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(count, num);
|
assertEquals(count, num);
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected class CPPNameCollector extends ASTVisitor {
|
static protected class CPPNameCollector extends ASTVisitor {
|
||||||
{
|
public CPPNameCollector() {
|
||||||
shouldVisitNames = true;
|
this(false); // don't visit implicit names by default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CPPNameCollector(boolean shouldVisitImplicitNames) {
|
||||||
|
this.shouldVisitNames = true;
|
||||||
|
this.shouldVisitImplicitNames = shouldVisitImplicitNames;
|
||||||
|
}
|
||||||
|
|
||||||
public List<IASTName> nameList = new ArrayList<IASTName>();
|
public List<IASTName> nameList = new ArrayList<IASTName>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -349,7 +355,7 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
public int size() {
|
public int size() {
|
||||||
return nameList.size();
|
return nameList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dump() {
|
public void dump() {
|
||||||
for (int i= 0; i < size(); i++) {
|
for (int i= 0; i < size(); i++) {
|
||||||
IASTName name= getName(i);
|
IASTName name= getName(i);
|
||||||
|
@ -365,7 +371,7 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
if (collector.getName(i).resolveBinding() == binding)
|
if (collector.getName(i).resolveBinding() == binding)
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(num, count);
|
assertEquals(num, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,42 +392,42 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
String expressionString = ASTStringUtil.getExpressionString(exp);
|
String expressionString = ASTStringUtil.getExpressionString(exp);
|
||||||
assertEquals(str, expressionString);
|
assertEquals(str, expressionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void isParameterSignatureEqual(IASTDeclarator decltor, String str) {
|
protected void isParameterSignatureEqual(IASTDeclarator decltor, String str) {
|
||||||
assertTrue(decltor instanceof IASTFunctionDeclarator);
|
assertTrue(decltor instanceof IASTFunctionDeclarator);
|
||||||
final String[] sigArray = ASTStringUtil.getParameterSignatureArray((IASTFunctionDeclarator) decltor);
|
final String[] sigArray = ASTStringUtil.getParameterSignatureArray((IASTFunctionDeclarator) decltor);
|
||||||
assertEquals(str, "(" + ASTStringUtil.join(sigArray, ", ") + ")");
|
assertEquals(str, "(" + ASTStringUtil.join(sigArray, ", ") + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void isSignatureEqual(IASTDeclarator declarator, String expected) {
|
protected void isSignatureEqual(IASTDeclarator declarator, String expected) {
|
||||||
String signature= ASTStringUtil.getSignatureString(declarator);
|
String signature= ASTStringUtil.getSignatureString(declarator);
|
||||||
assertEquals(expected, signature);
|
assertEquals(expected, signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void isSignatureEqual(IASTDeclSpecifier declSpec, String str) {
|
protected void isSignatureEqual(IASTDeclSpecifier declSpec, String str) {
|
||||||
assertEquals(str, ASTStringUtil.getSignatureString(declSpec, null));
|
assertEquals(str, ASTStringUtil.getSignatureString(declSpec, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void isSignatureEqual(IASTTypeId typeId, String str) {
|
protected void isSignatureEqual(IASTTypeId typeId, String str) {
|
||||||
assertEquals(str, ASTStringUtil.getSignatureString(typeId.getDeclSpecifier(), typeId.getAbstractDeclarator()));
|
assertEquals(str, ASTStringUtil.getSignatureString(typeId.getDeclSpecifier(), typeId.getAbstractDeclarator()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void isTypeEqual(IASTDeclarator decltor, String str) {
|
protected void isTypeEqual(IASTDeclarator decltor, String str) {
|
||||||
assertEquals(str, ASTTypeUtil.getType(decltor));
|
assertEquals(str, ASTTypeUtil.getType(decltor));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void isTypeEqual(IASTTypeId typeId, String str) {
|
protected void isTypeEqual(IASTTypeId typeId, String str) {
|
||||||
assertEquals(str, ASTTypeUtil.getType(typeId));
|
assertEquals(str, ASTTypeUtil.getType(typeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void isTypeEqual(IType type, String str) {
|
protected void isTypeEqual(IType type, String str) {
|
||||||
assertEquals(str, ASTTypeUtil.getType(type));
|
assertEquals(str, ASTTypeUtil.getType(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void isParameterTypeEqual(IFunctionType fType, String str) {
|
protected void isParameterTypeEqual(IFunctionType fType, String str) {
|
||||||
assertEquals(str, ASTTypeUtil.getParameterTypeString(fType));
|
assertEquals(str, ASTTypeUtil.getParameterTypeString(fType));
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected class CNameResolver extends ASTVisitor {
|
static protected class CNameResolver extends ASTVisitor {
|
||||||
{
|
{
|
||||||
shouldVisitNames = true;
|
shouldVisitNames = true;
|
||||||
|
@ -449,9 +455,9 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
|
|
||||||
public int size() {
|
public int size() {
|
||||||
return nameList.size();
|
return nameList.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected class CPPNameResolver extends ASTVisitor {
|
static protected class CPPNameResolver extends ASTVisitor {
|
||||||
{
|
{
|
||||||
shouldVisitNames = true;
|
shouldVisitNames = true;
|
||||||
|
@ -479,13 +485,13 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
|
|
||||||
public int size() {
|
public int size() {
|
||||||
return nameList.size();
|
return nameList.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getAboveComment() throws IOException {
|
protected String getAboveComment() throws IOException {
|
||||||
return getContents(1)[0].toString();
|
return getContents(1)[0].toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CharSequence[] getContents(int sections) throws IOException {
|
protected CharSequence[] getContents(int sections) throws IOException {
|
||||||
CTestPlugin plugin = CTestPlugin.getDefault();
|
CTestPlugin plugin = CTestPlugin.getDefault();
|
||||||
if (plugin == null)
|
if (plugin == null)
|
||||||
|
@ -502,14 +508,14 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
return clazz.cast(o);
|
return clazz.cast(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void assertField(IBinding binding, String fieldName, String ownerName) {
|
protected static void assertField(IBinding binding, String fieldName, String ownerName) {
|
||||||
assertInstance(binding, IField.class);
|
assertInstance(binding, IField.class);
|
||||||
assertEquals(fieldName, binding.getName());
|
assertEquals(fieldName, binding.getName());
|
||||||
ICompositeType struct = ((IField) binding).getCompositeTypeOwner();
|
ICompositeType struct = ((IField) binding).getCompositeTypeOwner();
|
||||||
assertEquals(ownerName, struct.getName());
|
assertEquals(ownerName, struct.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class BindingAssertionHelper {
|
protected class BindingAssertionHelper {
|
||||||
protected IASTTranslationUnit tu;
|
protected IASTTranslationUnit tu;
|
||||||
protected String contents;
|
protected String contents;
|
||||||
|
@ -562,7 +568,7 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
IBinding binding= binding(section, len);
|
IBinding binding= binding(section, len);
|
||||||
if (binding instanceof IProblemBinding) {
|
if (binding instanceof IProblemBinding) {
|
||||||
IProblemBinding problem= (IProblemBinding) binding;
|
IProblemBinding problem= (IProblemBinding) binding;
|
||||||
fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID()) + ")");
|
fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID()) + ")");
|
||||||
}
|
}
|
||||||
if (binding == null) {
|
if (binding == null) {
|
||||||
fail("Null binding resolved for name: " + section.substring(0, len));
|
fail("Null binding resolved for name: " + section.substring(0, len));
|
||||||
|
@ -611,12 +617,12 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
IASTName name = findImplicitName(section, len);
|
IASTName name = findImplicitName(section, len);
|
||||||
final String selection = section.substring(0, len);
|
final String selection = section.substring(0, len);
|
||||||
assertNotNull("did not find \"" + selection + "\"", name);
|
assertNotNull("did not find \"" + selection + "\"", name);
|
||||||
|
|
||||||
assertInstance(name, IASTImplicitName.class);
|
assertInstance(name, IASTImplicitName.class);
|
||||||
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
||||||
IASTImplicitName[] implicits = owner.getImplicitNames();
|
IASTImplicitName[] implicits = owner.getImplicitNames();
|
||||||
assertNotNull(implicits);
|
assertNotNull(implicits);
|
||||||
|
|
||||||
if (implicits.length > 1) {
|
if (implicits.length > 1) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (IASTImplicitName n : implicits) {
|
for (IASTImplicitName n : implicits) {
|
||||||
|
@ -627,34 +633,34 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
assertTrue(found);
|
assertTrue(found);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(selection, name.getRawSignature());
|
assertEquals(selection, name.getRawSignature());
|
||||||
IBinding binding = name.resolveBinding();
|
IBinding binding = name.resolveBinding();
|
||||||
assertNotNull(binding);
|
assertNotNull(binding);
|
||||||
assertInstance(binding, bindingClass);
|
assertInstance(binding, bindingClass);
|
||||||
return (IASTImplicitName) name;
|
return (IASTImplicitName) name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assertNoImplicitName(String section, int len) {
|
public void assertNoImplicitName(String section, int len) {
|
||||||
IASTName name = findImplicitName(section, len);
|
IASTName name = findImplicitName(section, len);
|
||||||
final String selection = section.substring(0, len);
|
final String selection = section.substring(0, len);
|
||||||
assertNull("found name \"" + selection + "\"", name);
|
assertNull("found name \"" + selection + "\"", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTImplicitName[] getImplicitNames(String section, int len) {
|
public IASTImplicitName[] getImplicitNames(String section, int len) {
|
||||||
IASTName name = findImplicitName(section, len);
|
IASTName name = findImplicitName(section, len);
|
||||||
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
||||||
IASTImplicitName[] implicits = owner.getImplicitNames();
|
IASTImplicitName[] implicits = owner.getImplicitNames();
|
||||||
return implicits;
|
return implicits;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTName findName(String section, int len) {
|
public IASTName findName(String section, int len) {
|
||||||
final int offset = contents.indexOf(section);
|
final int offset = contents.indexOf(section);
|
||||||
assertTrue("Section \"" + section + "\" not found", offset >= 0);
|
assertTrue("Section \"" + section + "\" not found", offset >= 0);
|
||||||
IASTNodeSelector selector = tu.getNodeSelector(null);
|
IASTNodeSelector selector = tu.getNodeSelector(null);
|
||||||
return selector.findName(offset, len);
|
return selector.findName(offset, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTName findName(String context, String name) {
|
public IASTName findName(String context, String name) {
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
context = contents;
|
context = contents;
|
||||||
|
@ -712,7 +718,7 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
return "Unknown problem ID";
|
return "Unknown problem ID";
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends IBinding> T assertNonProblem(String section, int len, Class... cs) {
|
public <T extends IBinding> T assertNonProblem(String section, int len, Class... cs) {
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
len += section.length();
|
len += section.length();
|
||||||
|
@ -744,10 +750,10 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
final String selection = section.substring(0, len);
|
final String selection = section.substring(0, len);
|
||||||
assertNotNull("No AST name for \"" + selection + "\"", astName);
|
assertNotNull("No AST name for \"" + selection + "\"", astName);
|
||||||
assertEquals(selection, astName.getRawSignature());
|
assertEquals(selection, astName.getRawSignature());
|
||||||
|
|
||||||
IBinding binding = astName.resolveBinding();
|
IBinding binding = astName.resolveBinding();
|
||||||
assertNotNull("No binding for " + astName.getRawSignature(), binding);
|
assertNotNull("No binding for " + astName.getRawSignature(), binding);
|
||||||
|
|
||||||
return astName.resolveBinding();
|
return astName.resolveBinding();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -755,10 +761,10 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
IASTName astName = findName(context, name);
|
IASTName astName = findName(context, name);
|
||||||
assertNotNull("No AST name for \"" + name + "\"", astName);
|
assertNotNull("No AST name for \"" + name + "\"", astName);
|
||||||
assertEquals(name, astName.getRawSignature());
|
assertEquals(name, astName.getRawSignature());
|
||||||
|
|
||||||
IBinding binding = astName.resolveBinding();
|
IBinding binding = astName.resolveBinding();
|
||||||
assertNotNull("No binding for " + astName.getRawSignature(), binding);
|
assertNotNull("No binding for " + astName.getRawSignature(), binding);
|
||||||
|
|
||||||
return astName.resolveBinding();
|
return astName.resolveBinding();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -770,10 +776,10 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang, boolean useGnuExtensions) throws Exception {
|
final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang, boolean useGnuExtensions) throws Exception {
|
||||||
return parseAndCheckBindings(code, lang, useGnuExtensions, false);
|
return parseAndCheckBindings(code, lang, useGnuExtensions, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang, boolean useGnuExtensions,
|
final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang, boolean useGnuExtensions,
|
||||||
boolean skipTrivialInitializers) throws Exception {
|
boolean skipTrivialInitializers) throws Exception {
|
||||||
IASTTranslationUnit tu = parse(code, lang, useGnuExtensions, true, skipTrivialInitializers);
|
IASTTranslationUnit tu = parse(code, lang, useGnuExtensions, true, skipTrivialInitializers);
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
assertNoProblemBindings(col);
|
assertNoProblemBindings(col);
|
File diff suppressed because it is too large
Load diff
|
@ -17,7 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
|
|
||||||
public class AST2UtilOldTests extends AST2BaseTest {
|
public class AST2UtilOldTests extends AST2TestBase {
|
||||||
public AST2UtilOldTests() {
|
public AST2UtilOldTests() {
|
||||||
}
|
}
|
||||||
public AST2UtilOldTests(String name) {
|
public AST2UtilOldTests(String name) {
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator;
|
||||||
/**
|
/**
|
||||||
* @author dsteffle
|
* @author dsteffle
|
||||||
*/
|
*/
|
||||||
public class AST2UtilTests extends AST2BaseTest {
|
public class AST2UtilTests extends AST2TestBase {
|
||||||
public AST2UtilTests() {
|
public AST2UtilTests() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
|
|
||||||
public class ASTCPPSpecDefectTests extends AST2BaseTest {
|
public class ASTCPPSpecDefectTests extends AST2TestBase {
|
||||||
|
|
||||||
public ASTCPPSpecDefectTests() {
|
public ASTCPPSpecDefectTests() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
/**
|
/**
|
||||||
* Testcases for inactive code in ast.
|
* Testcases for inactive code in ast.
|
||||||
*/
|
*/
|
||||||
public class ASTInactiveCodeTests extends AST2BaseTest {
|
public class ASTInactiveCodeTests extends AST2TestBase {
|
||||||
|
|
||||||
public static TestSuite suite() {
|
public static TestSuite suite() {
|
||||||
return suite(ASTInactiveCodeTests.class);
|
return suite(ASTInactiveCodeTests.class);
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
||||||
|
|
||||||
public class ASTNodeSelectorTest extends AST2BaseTest {
|
public class ASTNodeSelectorTest extends AST2TestBase {
|
||||||
|
|
||||||
static public TestSuite suite() {
|
static public TestSuite suite() {
|
||||||
return suite(ASTNodeSelectorTest.class);
|
return suite(ASTNodeSelectorTest.class);
|
||||||
|
@ -55,7 +55,7 @@ public class ASTNodeSelectorTest extends AST2BaseTest {
|
||||||
fCode= getContents(1)[0].toString();
|
fCode= getContents(1)[0].toString();
|
||||||
FileContent codeReader = FileContent.create("<test-code>", fCode.toCharArray());
|
FileContent codeReader = FileContent.create("<test-code>", fCode.toCharArray());
|
||||||
ScannerInfo scannerInfo = new ScannerInfo();
|
ScannerInfo scannerInfo = new ScannerInfo();
|
||||||
IScanner scanner= AST2BaseTest.createScanner(codeReader, ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, scannerInfo);
|
IScanner scanner= AST2TestBase.createScanner(codeReader, ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||||
GNUCPPSourceParser parser= new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, new NullLogService(), new GPPParserExtensionConfiguration());
|
GNUCPPSourceParser parser= new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, new NullLogService(), new GPPParserExtensionConfiguration());
|
||||||
fTu= parser.parse();
|
fTu= parser.parse();
|
||||||
fSelector= fTu.getNodeSelector(null);
|
fSelector= fTu.getNodeSelector(null);
|
||||||
|
|
|
@ -18,7 +18,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.AccessContext;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.AccessContext;
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
|
|
||||||
public class AccessControlTests extends AST2BaseTest {
|
public class AccessControlTests extends AST2TestBase {
|
||||||
|
|
||||||
protected class AccessAssertionHelper extends BindingAssertionHelper {
|
protected class AccessAssertionHelper extends BindingAssertionHelper {
|
||||||
AccessAssertionHelper(String contents) throws ParserException {
|
AccessAssertionHelper(String contents) throws ParserException {
|
||||||
|
|
|
@ -13,22 +13,22 @@ package org.eclipse.cdt.core.parser.tests.ast2;
|
||||||
import org.eclipse.cdt.core.dom.CDOM;
|
import org.eclipse.cdt.core.dom.CDOM;
|
||||||
import org.eclipse.cdt.core.dom.IASTServiceProvider.UnsupportedDialectException;
|
import org.eclipse.cdt.core.dom.IASTServiceProvider.UnsupportedDialectException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.parser.tests.FileBasePluginTest;
|
import org.eclipse.cdt.core.parser.tests.FileBasePluginTestCase;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author dsteffle
|
* @author dsteffle
|
||||||
*/
|
*/
|
||||||
public class CDOMBaseTest extends FileBasePluginTest {
|
public class CDOMTestBase extends FileBasePluginTestCase {
|
||||||
|
|
||||||
public CDOMBaseTest() {
|
public CDOMTestBase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CDOMBaseTest(String name) {
|
public CDOMTestBase(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CDOMBaseTest(String name, Class className) {
|
public CDOMTestBase(String name, Class className) {
|
||||||
super(name, className);
|
super(name, className);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.eclipse.core.runtime.jobs.Job;
|
||||||
/**
|
/**
|
||||||
* @author dsteffle
|
* @author dsteffle
|
||||||
*/
|
*/
|
||||||
public class CodeReaderCacheTest extends CDOMBaseTest {
|
public class CodeReaderCacheTest extends CDOMTestBase {
|
||||||
|
|
||||||
public CodeReaderCacheTest() {
|
public CodeReaderCacheTest() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
* @author Guido Zgraggen
|
* @author Guido Zgraggen
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CommentTests extends AST2BaseTest {
|
public class CommentTests extends AST2TestBase {
|
||||||
|
|
||||||
public static TestSuite suite() {
|
public static TestSuite suite() {
|
||||||
return suite(CommentTests.class);
|
return suite(CommentTests.class);
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
* Copyright (c) 2004, 2013 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Nathan Ridge
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||||
|
|
||||||
|
@ -102,9 +103,13 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
static private class CPPNameCollector extends ASTVisitor {
|
static private class CPPNameCollector extends ASTVisitor {
|
||||||
{
|
public CPPNameCollector() {
|
||||||
shouldVisitNames = true;
|
this(false); // don't visit implicit names by default
|
||||||
}
|
}
|
||||||
|
public CPPNameCollector(boolean shouldVisitImplicitNames) {
|
||||||
|
this.shouldVisitNames = true;
|
||||||
|
this.shouldVisitImplicitNames = shouldVisitImplicitNames;
|
||||||
|
}
|
||||||
public List nameList = new ArrayList();
|
public List nameList = new ArrayList();
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTName name){
|
public int visit(IASTName name){
|
||||||
|
@ -141,7 +146,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
if (nameCollector.getName(i).resolveBinding() == binding)
|
if (nameCollector.getName(i).resolveBinding() == binding)
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
assertEquals(count, num);
|
assertEquals(num, count);
|
||||||
}
|
}
|
||||||
protected void assertInstances(CNameCollector nameCollector, IBinding binding, int num) throws Exception {
|
protected void assertInstances(CNameCollector nameCollector, IBinding binding, int num) throws Exception {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -149,7 +154,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
if (nameCollector.getName(i).resolveBinding() == binding)
|
if (nameCollector.getName(i).resolveBinding() == binding)
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
assertEquals(count, num);
|
assertEquals(num, count);
|
||||||
}
|
}
|
||||||
protected IASTTranslationUnit parse(String code, boolean expectedToPass,
|
protected IASTTranslationUnit parse(String code, boolean expectedToPass,
|
||||||
ParserLanguage lang) throws Exception {
|
ParserLanguage lang) throws Exception {
|
||||||
|
@ -172,7 +177,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
|
FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
|
||||||
ScannerInfo scannerInfo = new ScannerInfo();
|
ScannerInfo scannerInfo = new ScannerInfo();
|
||||||
ISourceCodeParser parser2 = null;
|
ISourceCodeParser parser2 = null;
|
||||||
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||||
if (lang == ParserLanguage.CPP) {
|
if (lang == ParserLanguage.CPP) {
|
||||||
ICPPParserExtensionConfiguration config = null;
|
ICPPParserExtensionConfiguration config = null;
|
||||||
if (gcc)
|
if (gcc)
|
||||||
|
@ -750,7 +755,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConstructorChain() throws Exception {
|
public void testConstructorChain() throws Exception {
|
||||||
IASTTranslationUnit tu = parse("int x = 5;\n class A \n{ public : \n int a; \n A() : a(x) { } };");
|
IASTTranslationUnit tu = parse("int x = 5;\n class A \n{ public : \n int a; \n A() : a(x) { } };");
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
|
@ -1053,7 +1058,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScoping() throws Exception {
|
public void testScoping() throws Exception {
|
||||||
IASTTranslationUnit tu = parse("void foo() { int x = 3; if (x == 1) { int x = 4; } else int x = 2; }");
|
IASTTranslationUnit tu = parse("void foo() { int x = 3; if (x == 1) { int x = 4; } else int x = 2; }");
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
|
@ -1098,7 +1103,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug42872() throws Exception {
|
public void testBug42872() throws Exception {
|
||||||
IASTTranslationUnit tu = parse("struct B {}; struct D : B {}; void foo(D* dp) { B* bp = dynamic_cast<B*>(dp); }");
|
IASTTranslationUnit tu = parse("struct B {}; struct D : B {}; void foo(D* dp) { B* bp = dynamic_cast<B*>(dp); }");
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
|
@ -1112,14 +1117,14 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
|
|
||||||
public void testBug43503A() throws Exception {
|
public void testBug43503A() throws Exception {
|
||||||
IASTTranslationUnit tu = parse("class SD_01 { void f_SD_01() {}}; int main(){ SD_01 * a = new SD_01(); a->f_SD_01(); } ");
|
IASTTranslationUnit tu = parse("class SD_01 { void f_SD_01() {}}; int main(){ SD_01 * a = new SD_01(); a->f_SD_01(); } ");
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector(true);
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
assertEquals(col.size(), 8);
|
assertEquals(col.size(), 9);
|
||||||
ICPPClassType SD_01 = (ICPPClassType) col.getName(0).resolveBinding();
|
ICPPClassType SD_01 = (ICPPClassType) col.getName(0).resolveBinding();
|
||||||
ICPPMethod f_SD_01 = (ICPPMethod) col.getName(1).resolveBinding();
|
ICPPMethod f_SD_01 = (ICPPMethod) col.getName(1).resolveBinding();
|
||||||
ICPPConstructor ctor = SD_01.getConstructors()[0];
|
ICPPConstructor ctor = SD_01.getConstructors()[0];
|
||||||
assertInstances(col, SD_01, 2);
|
assertInstances(col, SD_01, 3);
|
||||||
assertInstances(col, ctor, 1);
|
assertInstances(col, ctor, 1);
|
||||||
assertInstances(col, f_SD_01, 2);
|
assertInstances(col, f_SD_01, 2);
|
||||||
}
|
}
|
||||||
|
@ -1204,10 +1209,10 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
buff.append("} \n");
|
buff.append("} \n");
|
||||||
IASTTranslationUnit tu = parse(buff.toString());
|
IASTTranslationUnit tu = parse(buff.toString());
|
||||||
|
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector(true);
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
assertEquals(col.size(), 17);
|
assertEquals(col.size(), 18);
|
||||||
ICompositeType SD_02 = (ICompositeType) col.getName(0).resolveBinding();
|
ICompositeType SD_02 = (ICompositeType) col.getName(0).resolveBinding();
|
||||||
ICPPMethod f_SD_02 = (ICPPMethod) col.getName(1).resolveBinding();
|
ICPPMethod f_SD_02 = (ICPPMethod) col.getName(1).resolveBinding();
|
||||||
ICPPClassType SD_01 = (ICPPClassType) col.getName(2).resolveBinding();
|
ICPPClassType SD_01 = (ICPPClassType) col.getName(2).resolveBinding();
|
||||||
|
@ -1217,7 +1222,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
|
|
||||||
assertInstances(col, SD_02, 2);
|
assertInstances(col, SD_02, 2);
|
||||||
assertInstances(col, f_SD_02, 2);
|
assertInstances(col, f_SD_02, 2);
|
||||||
assertInstances(col, SD_01, 3);
|
assertInstances(col, SD_01, 4);
|
||||||
assertInstances(col, ctor, 1);
|
assertInstances(col, ctor, 1);
|
||||||
assertInstances(col, next, 2);
|
assertInstances(col, next, 2);
|
||||||
assertInstances(col, f_SD_01, 4);
|
assertInstances(col, f_SD_01, 4);
|
||||||
|
@ -1268,10 +1273,10 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
|
|
||||||
public void testBug44342() throws Exception {
|
public void testBug44342() throws Exception {
|
||||||
IASTTranslationUnit tu = parse("class A { void f(){} void f(int){} }; int main(){ A * a = new A(); a->f();} ");
|
IASTTranslationUnit tu = parse("class A { void f(){} void f(int){} }; int main(){ A * a = new A(); a->f();} ");
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector(true);
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
assertEquals(col.size(), 10);
|
assertEquals(col.size(), 11);
|
||||||
ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
|
ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
|
||||||
ICPPMethod f1 = (ICPPMethod) col.getName(1).resolveBinding();
|
ICPPMethod f1 = (ICPPMethod) col.getName(1).resolveBinding();
|
||||||
ICPPMethod f2 = (ICPPMethod) col.getName(2).resolveBinding();
|
ICPPMethod f2 = (ICPPMethod) col.getName(2).resolveBinding();
|
||||||
|
@ -1279,7 +1284,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
ICPPConstructor ctor = A.getConstructors()[0];
|
ICPPConstructor ctor = A.getConstructors()[0];
|
||||||
IVariable a = (IVariable) col.getName(6).resolveBinding();
|
IVariable a = (IVariable) col.getName(6).resolveBinding();
|
||||||
|
|
||||||
assertInstances(col, A, 2);
|
assertInstances(col, A, 3);
|
||||||
assertInstances(col, f1, 2);
|
assertInstances(col, f1, 2);
|
||||||
assertInstances(col, f2, 1);
|
assertInstances(col, f2, 1);
|
||||||
assertInstances(col, ctor, 1);
|
assertInstances(col, ctor, 1);
|
||||||
|
@ -1288,7 +1293,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
|
|
||||||
public void testCDesignatedInitializers() throws Exception {
|
public void testCDesignatedInitializers() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append("struct Inner { int a,b,c; };");
|
buffer.append("struct Inner { int a,b,c; };");
|
||||||
buffer.append("struct A { int x; int y[]; struct Inner innerArray[]; int z[]; };");
|
buffer.append("struct A { int x; int y[]; struct Inner innerArray[]; int z[]; };");
|
||||||
buffer.append("struct A myA = { .x = 4, .y[3] = 4, .y[4] = 3, .innerArray[0].a = 3, .innerArray[1].b = 5, .innerArray[2].c=6, .z = { 1,4,5} };");
|
buffer.append("struct A myA = { .x = 4, .y[3] = 4, .y[4] = 3, .innerArray[0].a = 3, .innerArray[1].b = 5, .innerArray[2].c=6, .z = { 1,4,5} };");
|
||||||
parse(buffer.toString(), true, ParserLanguage.C);
|
parse(buffer.toString(), true, ParserLanguage.C);
|
||||||
|
@ -1314,7 +1319,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
" _Bool b; " +
|
" _Bool b; " +
|
||||||
" f(b);" +
|
" f(b);" +
|
||||||
" f(g((_Bool) 1) );" +
|
" f(g((_Bool) 1) );" +
|
||||||
"}",
|
"}",
|
||||||
true, ParserLanguage.C);
|
true, ParserLanguage.C);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1337,7 +1342,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
|
|
||||||
public void testBug44925() throws Exception {
|
public void testBug44925() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append("class MyClass { };");
|
buffer.append("class MyClass { };");
|
||||||
buffer.append("class MyClass myObj1;");
|
buffer.append("class MyClass myObj1;");
|
||||||
buffer.append("enum MyEnum { Item1 };");
|
buffer.append("enum MyEnum { Item1 };");
|
||||||
buffer.append("enum MyEnum myObj2;");
|
buffer.append("enum MyEnum myObj2;");
|
||||||
|
@ -1420,23 +1425,23 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
buffer.append("void main() { N::A * a = new N::A(); a->f(); } ");
|
buffer.append("void main() { N::A * a = new N::A(); a->f(); } ");
|
||||||
IASTTranslationUnit tu = parse(buffer.toString());
|
IASTTranslationUnit tu = parse(buffer.toString());
|
||||||
|
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector(true);
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
assertEquals(col.size(), 13);
|
assertEquals(col.size(), 14);
|
||||||
ICPPNamespace N = (ICPPNamespace) col.getName(0).resolveBinding();
|
ICPPNamespace N = (ICPPNamespace) col.getName(0).resolveBinding();
|
||||||
IFunction f = (IFunction) col.getName(1).resolveBinding();
|
IFunction f = (IFunction) col.getName(1).resolveBinding();
|
||||||
ICPPClassType A = (ICPPClassType) col.getName(2).resolveBinding();
|
ICPPClassType A = (ICPPClassType) col.getName(2).resolveBinding();
|
||||||
|
|
||||||
ICPPConstructor ctor = A.getConstructors()[0];
|
ICPPConstructor ctor = A.getConstructors()[0];
|
||||||
|
|
||||||
IProblemBinding fp = (IProblemBinding) col.getName(12).resolveBinding();
|
IProblemBinding fp = (IProblemBinding) col.getName(13).resolveBinding();
|
||||||
assertEquals(fp.getID(), IProblemBinding.SEMANTIC_NAME_NOT_FOUND);
|
assertEquals(fp.getID(), IProblemBinding.SEMANTIC_NAME_NOT_FOUND);
|
||||||
|
|
||||||
assertInstances(col, N, 3);
|
assertInstances(col, N, 3);
|
||||||
assertInstances(col, f, 1);
|
assertInstances(col, f, 1);
|
||||||
assertInstances(col, A, 3);
|
assertInstances(col, A, 5);
|
||||||
assertInstances(col, ctor, 2);
|
assertInstances(col, ctor, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug43110() throws Exception {
|
public void testBug43110() throws Exception {
|
||||||
|
@ -1994,7 +1999,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
writer.write("int main(int argc, char **argv) {\n");
|
writer.write("int main(int argc, char **argv) {\n");
|
||||||
writer.write("FILE * file = 0;\n");
|
writer.write("FILE * file = 0;\n");
|
||||||
writer.write("static_function(file);\n");
|
writer.write("static_function(file);\n");
|
||||||
writer.write("return 0;\n");
|
writer.write("return 0;\n");
|
||||||
writer.write("}\n");
|
writer.write("}\n");
|
||||||
parse(writer.toString());
|
parse(writer.toString());
|
||||||
}
|
}
|
||||||
|
@ -2046,8 +2051,8 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
writer.write("};\n");
|
writer.write("};\n");
|
||||||
writer.write("\n");
|
writer.write("\n");
|
||||||
writer.write("template<typename T>\n");
|
writer.write("template<typename T>\n");
|
||||||
writer.write("inline T526026< T >\n");
|
writer.write("inline T526026< T >\n");
|
||||||
writer.write("operator+(typename T526026<T>::diff d, const T526026<T> & x)\n");
|
writer.write("operator+(typename T526026<T>::diff d, const T526026<T> & x)\n");
|
||||||
writer.write("{ return T526026< T >(); }\n");
|
writer.write("{ return T526026< T >(); }\n");
|
||||||
writer.write("}\n");
|
writer.write("}\n");
|
||||||
parse(writer.toString(), false);
|
parse(writer.toString(), false);
|
||||||
|
@ -2055,7 +2060,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
|
|
||||||
public void testBug71094() throws Exception {
|
public void testBug71094() throws Exception {
|
||||||
Writer writer = new StringWriter();
|
Writer writer = new StringWriter();
|
||||||
writer.write("using namespace DOESNOTEXIST;\n");
|
writer.write("using namespace DOESNOTEXIST;\n");
|
||||||
writer.write("class A { int x; };\n");
|
writer.write("class A { int x; };\n");
|
||||||
parse(writer.toString(), false);
|
parse(writer.toString(), false);
|
||||||
}
|
}
|
||||||
|
@ -2223,7 +2228,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
|
|
||||||
public void testBug74328() throws Exception {
|
public void testBug74328() throws Exception {
|
||||||
Writer writer = new StringWriter();
|
Writer writer = new StringWriter();
|
||||||
writer.write("int\n");
|
writer.write("int\n");
|
||||||
writer.write("main(int argc, char **argv) {\n");
|
writer.write("main(int argc, char **argv) {\n");
|
||||||
writer.write(" char *sign;\n");
|
writer.write(" char *sign;\n");
|
||||||
writer.write("sign = \"\"; // IProblem generated here, syntax error\n");
|
writer.write("sign = \"\"; // IProblem generated here, syntax error\n");
|
||||||
|
|
|
@ -19,7 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DOMGCCSelectionParseExtensionsTest extends DOMSelectionParseBaseTest {
|
public class DOMGCCSelectionParseExtensionsTest extends DOMSelectionParseTestBase {
|
||||||
|
|
||||||
public DOMGCCSelectionParseExtensionsTest() {
|
public DOMGCCSelectionParseExtensionsTest() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ import org.eclipse.core.runtime.content.IContentType;
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class DOMLocationInclusionTests extends AST2FileBasePluginTest {
|
public class DOMLocationInclusionTests extends AST2FileBasePluginTestCase {
|
||||||
|
|
||||||
public DOMLocationInclusionTests() {
|
public DOMLocationInclusionTests() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
|
|
||||||
public class DOMLocationMacroTests extends AST2BaseTest {
|
public class DOMLocationMacroTests extends AST2TestBase {
|
||||||
|
|
||||||
final ParserLanguage[] languages = new ParserLanguage[] { ParserLanguage.C, ParserLanguage.CPP };
|
final ParserLanguage[] languages = new ParserLanguage[] { ParserLanguage.C, ParserLanguage.CPP };
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class DOMLocationTests extends AST2BaseTest {
|
public class DOMLocationTests extends AST2TestBase {
|
||||||
|
|
||||||
public DOMLocationTests() {
|
public DOMLocationTests() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
* @author Emanuel Graf
|
* @author Emanuel Graf
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DOMPreprocessorInformationTest extends AST2BaseTest {
|
public class DOMPreprocessorInformationTest extends AST2TestBase {
|
||||||
|
|
||||||
public void testPragma() throws Exception {
|
public void testPragma() throws Exception {
|
||||||
String msg = "GCC poison printf sprintf fprintf";
|
String msg = "GCC poison printf sprintf fprintf";
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -23,16 +23,16 @@ import org.eclipse.core.resources.IFile;
|
||||||
* @author johnc
|
* @author johnc
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DOMSelectionParseBaseTest extends DOMFileBasePluginTest {
|
public class DOMSelectionParseTestBase extends DOMFileBasePluginTest {
|
||||||
|
|
||||||
public DOMSelectionParseBaseTest() {
|
public DOMSelectionParseTestBase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DOMSelectionParseBaseTest(String name) {
|
public DOMSelectionParseTestBase(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DOMSelectionParseBaseTest(String name, Class className) {
|
public DOMSelectionParseTestBase(String name, Class className) {
|
||||||
super(name, className);
|
super(name, className);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
/**
|
/**
|
||||||
* Testcases related to recovery from invalid syntax.
|
* Testcases related to recovery from invalid syntax.
|
||||||
*/
|
*/
|
||||||
public class FaultToleranceTests extends AST2BaseTest {
|
public class FaultToleranceTests extends AST2TestBase {
|
||||||
|
|
||||||
public static TestSuite suite() {
|
public static TestSuite suite() {
|
||||||
return suite(FaultToleranceTests.class);
|
return suite(FaultToleranceTests.class);
|
||||||
|
|
|
@ -31,7 +31,7 @@ import org.eclipse.cdt.internal.core.dom.parser.c.CFunction;
|
||||||
import org.eclipse.cdt.internal.core.model.ASTStringUtil;
|
import org.eclipse.cdt.internal.core.model.ASTStringUtil;
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
|
|
||||||
public class GCCCompleteParseExtensionsTest extends AST2BaseTest {
|
public class GCCCompleteParseExtensionsTest extends AST2TestBase {
|
||||||
|
|
||||||
public GCCCompleteParseExtensionsTest() {
|
public GCCCompleteParseExtensionsTest() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class GCCTests extends AST2BaseTest {
|
public class GCCTests extends AST2TestBase {
|
||||||
|
|
||||||
public GCCTests() {
|
public GCCTests() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class ImageLocationTests extends AST2BaseTest {
|
public class ImageLocationTests extends AST2TestBase {
|
||||||
|
|
||||||
private static final int CODE = IASTImageLocation.REGULAR_CODE;
|
private static final int CODE = IASTImageLocation.REGULAR_CODE;
|
||||||
private static final int MACRO = IASTImageLocation.MACRO_DEFINITION;
|
private static final int MACRO = IASTImageLocation.MACRO_DEFINITION;
|
||||||
|
|
|
@ -44,7 +44,7 @@ import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
|
||||||
/**
|
/**
|
||||||
* Testcases for non-gnu language extensions.
|
* Testcases for non-gnu language extensions.
|
||||||
*/
|
*/
|
||||||
public class LanguageExtensionsTest extends AST2BaseTest {
|
public class LanguageExtensionsTest extends AST2TestBase {
|
||||||
|
|
||||||
protected static final int SIZEOF_EXTENSION = 0x1;
|
protected static final int SIZEOF_EXTENSION = 0x1;
|
||||||
protected static final int FUNCTION_STYLE_ASM = 0x2;
|
protected static final int FUNCTION_STYLE_ASM = 0x2;
|
||||||
|
|
|
@ -1335,7 +1335,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
ParserLanguage lang, boolean gcc) throws Exception {
|
ParserLanguage lang, boolean gcc) throws Exception {
|
||||||
FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
|
FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
|
||||||
IScannerInfo scannerInfo = new ScannerInfo();
|
IScannerInfo scannerInfo = new ScannerInfo();
|
||||||
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||||
ISourceCodeParser parser2 = null;
|
ISourceCodeParser parser2 = null;
|
||||||
if (lang == ParserLanguage.CPP) {
|
if (lang == ParserLanguage.CPP) {
|
||||||
ICPPParserExtensionConfiguration config = null;
|
ICPPParserExtensionConfiguration config = null;
|
||||||
|
|
|
@ -20,7 +20,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||||
/**
|
/**
|
||||||
* Directly tests parts of the semantics package
|
* Directly tests parts of the semantics package
|
||||||
*/
|
*/
|
||||||
public class SemanticsTests extends AST2BaseTest {
|
public class SemanticsTests extends AST2TestBase {
|
||||||
|
|
||||||
public SemanticsTests() {}
|
public SemanticsTests() {}
|
||||||
public SemanticsTests(String name) { super(name); }
|
public SemanticsTests(String name) { super(name); }
|
||||||
|
|
|
@ -18,7 +18,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.TodoTaskParser;
|
import org.eclipse.cdt.internal.core.pdom.indexer.TodoTaskParser;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.TodoTaskParser.Task;
|
import org.eclipse.cdt.internal.core.pdom.indexer.TodoTaskParser.Task;
|
||||||
|
|
||||||
public class TaskParserTest extends AST2BaseTest {
|
public class TaskParserTest extends AST2TestBase {
|
||||||
|
|
||||||
public static TestSuite suite() {
|
public static TestSuite suite() {
|
||||||
return suite(TaskParserTest.class);
|
return suite(TaskParserTest.class);
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.parser.tests.ast2;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
|
||||||
|
public class TestUtil {
|
||||||
|
/**
|
||||||
|
* Searches the AST upward from the given starting node to find the
|
||||||
|
* nearest IASTImplicitNameOwner and returns its first implicit name,
|
||||||
|
* or null if it has no implicit names.
|
||||||
|
*/
|
||||||
|
public static IASTName findImplicitName(IASTNode node) {
|
||||||
|
while (node != null) {
|
||||||
|
if (node instanceof IASTImplicitNameOwner) {
|
||||||
|
IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) node).getImplicitNames();
|
||||||
|
if (implicitNames != null && implicitNames.length > 0) {
|
||||||
|
return implicitNames[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
node = node.getParent();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,7 +21,7 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
/**
|
/**
|
||||||
* Tests for ClassTypeHelper class.
|
* Tests for ClassTypeHelper class.
|
||||||
*/
|
*/
|
||||||
public class TypeTraitsTests extends AST2BaseTest {
|
public class TypeTraitsTests extends AST2TestBase {
|
||||||
|
|
||||||
public TypeTraitsTests() {
|
public TypeTraitsTests() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||||
/**
|
/**
|
||||||
* Unit tests for CPPVariableReadWriteFlags and CVariableReadWriteFlags classes.
|
* Unit tests for CPPVariableReadWriteFlags and CVariableReadWriteFlags classes.
|
||||||
*/
|
*/
|
||||||
public class VariableReadWriteFlagsTest extends AST2BaseTest {
|
public class VariableReadWriteFlagsTest extends AST2TestBase {
|
||||||
private static final int READ = PDOMName.READ_ACCESS;
|
private static final int READ = PDOMName.READ_ACCESS;
|
||||||
private static final int WRITE = PDOMName.WRITE_ACCESS;
|
private static final int WRITE = PDOMName.WRITE_ACCESS;
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ import org.eclipse.cdt.core.parser.NullLogService;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.tests.ast2.AST2BaseTest;
|
import org.eclipse.cdt.core.parser.tests.ast2.AST2TestBase;
|
||||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||||
|
@ -53,7 +53,7 @@ public class CompletionTestBase extends BaseTestCase {
|
||||||
protected IASTCompletionNode getCompletionNode(String code, ParserLanguage lang, boolean useGNUExtensions) throws ParserException {
|
protected IASTCompletionNode getCompletionNode(String code, ParserLanguage lang, boolean useGNUExtensions) throws ParserException {
|
||||||
FileContent codeReader = FileContent.create("<test-code>", code.trim().toCharArray());
|
FileContent codeReader = FileContent.create("<test-code>", code.trim().toCharArray());
|
||||||
ScannerInfo scannerInfo = new ScannerInfo();
|
ScannerInfo scannerInfo = new ScannerInfo();
|
||||||
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||||
|
|
||||||
ISourceCodeParser parser = null;
|
ISourceCodeParser parser = null;
|
||||||
if( lang == ParserLanguage.CPP )
|
if( lang == ParserLanguage.CPP )
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.eclipse.cdt.core.parser.NullLogService;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.tests.ast2.AST2BaseTest;
|
import org.eclipse.cdt.core.parser.tests.ast2.AST2TestBase;
|
||||||
import org.eclipse.cdt.core.parser.tests.rewrite.RewriteBaseTest;
|
import org.eclipse.cdt.core.parser.tests.rewrite.RewriteBaseTest;
|
||||||
import org.eclipse.cdt.core.parser.tests.rewrite.TestHelper;
|
import org.eclipse.cdt.core.parser.tests.rewrite.TestHelper;
|
||||||
import org.eclipse.cdt.core.parser.tests.rewrite.TestSourceFile;
|
import org.eclipse.cdt.core.parser.tests.rewrite.TestSourceFile;
|
||||||
|
@ -95,7 +95,7 @@ public class ASTWriterTest extends RewriteBaseTest {
|
||||||
ParserLanguage language = getLanguage(testFile);
|
ParserLanguage language = getLanguage(testFile);
|
||||||
boolean useGNUExtensions = getGNUExtension(testFile);
|
boolean useGNUExtensions = getGNUExtension(testFile);
|
||||||
|
|
||||||
IScanner scanner = AST2BaseTest.createScanner(codeReader, language, ParserMode.COMPLETE_PARSE, scannerInfo);
|
IScanner scanner = AST2TestBase.createScanner(codeReader, language, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||||
|
|
||||||
ISourceCodeParser parser = null;
|
ISourceCodeParser parser = null;
|
||||||
if (language == ParserLanguage.CPP) {
|
if (language == ParserLanguage.CPP) {
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.tests.scanner;
|
package org.eclipse.cdt.core.parser.tests.scanner;
|
||||||
|
|
||||||
|
@ -201,7 +202,29 @@ public class LexerTests extends BaseTestCase {
|
||||||
id("ab");
|
id("ab");
|
||||||
eof();
|
eof();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testLessColonColon() throws Exception {
|
||||||
|
// 2.5-3
|
||||||
|
// <: is treated as digraph [
|
||||||
|
init("<::>");
|
||||||
|
token(IToken.tLBRACKET);
|
||||||
|
token(IToken.tRBRACKET);
|
||||||
|
eof();
|
||||||
|
|
||||||
|
// <: is treated as digraph [
|
||||||
|
init("<:::");
|
||||||
|
token(IToken.tLBRACKET);
|
||||||
|
token(IToken.tCOLONCOLON);
|
||||||
|
eof();
|
||||||
|
|
||||||
|
// <:: is treated as < and ::
|
||||||
|
init("<::A");
|
||||||
|
token(IToken.tLT);
|
||||||
|
token(IToken.tCOLONCOLON);
|
||||||
|
token(IToken.tIDENTIFIER);
|
||||||
|
eof();
|
||||||
|
}
|
||||||
|
|
||||||
public void testWindowsLineEnding() throws Exception {
|
public void testWindowsLineEnding() throws Exception {
|
||||||
init("\n\n");
|
init("\n\n");
|
||||||
nl(); nl(); eof();
|
nl(); nl(); eof();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2012 Symbian Software Systems and others.
|
* Copyright (c) 2006, 2013 Symbian Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -10,6 +10,7 @@
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
|
* Nathan Ridge
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.index.tests;
|
package org.eclipse.cdt.internal.index.tests;
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTName findName(String section, int len) {
|
protected IASTName findName(String section, int len, boolean preferImplicitName) {
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
len= section.length();
|
len= section.length();
|
||||||
for (int i = 0; i < strategy.getAstCount(); i++) {
|
for (int i = 0; i < strategy.getAstCount(); i++) {
|
||||||
|
@ -91,15 +92,27 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
||||||
final IASTNodeSelector nodeSelector = ast.getNodeSelector(null);
|
final IASTNodeSelector nodeSelector = ast.getNodeSelector(null);
|
||||||
final int offset = strategy.getAstSource(i).indexOf(section);
|
final int offset = strategy.getAstSource(i).indexOf(section);
|
||||||
if (offset >= 0) {
|
if (offset >= 0) {
|
||||||
IASTName name= nodeSelector.findName(offset, len);
|
if (preferImplicitName) {
|
||||||
if (name == null)
|
return nodeSelector.findImplicitName(offset, len);
|
||||||
name= nodeSelector.findImplicitName(offset, len);
|
} else {
|
||||||
return name;
|
IASTName name= nodeSelector.findName(offset, len);
|
||||||
|
if (name == null)
|
||||||
|
name= nodeSelector.findImplicitName(offset, len);
|
||||||
|
return name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IASTName findName(String section, int len) {
|
||||||
|
return findName(section, len, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IASTName findImplicitName(String section, int len) {
|
||||||
|
return findName(section, len, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to get an IBinding from the initial specified number of characters
|
* Attempts to get an IBinding from the initial specified number of characters
|
||||||
|
@ -129,9 +142,37 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
||||||
assertInstance(binding, clazz, cs);
|
assertInstance(binding, clazz, cs);
|
||||||
return clazz.cast(binding);
|
return clazz.cast(binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to get an IBinding attached to an implicit name from the initial specified
|
||||||
|
* number of characters from the specified code fragment. Fails the test if
|
||||||
|
* <ul>
|
||||||
|
* <li> There is not a unique implicit name with the specified criteria
|
||||||
|
* <li> The binding associated with the implicit name is null or a problem binding
|
||||||
|
* <li> The binding is not an instance of the specified class
|
||||||
|
* </ul>
|
||||||
|
* @param section the code fragment to search for in the AST. The first occurrence of an identical section is used.
|
||||||
|
* @param len the length of the specified section to use as a name
|
||||||
|
* @param clazz an expected class type or interface that the binding should extend/implement
|
||||||
|
* @return the associated implicit name's binding
|
||||||
|
*/
|
||||||
|
protected <T> T getBindingFromImplicitASTName(String section, int len, Class<T> clazz, Class ... cs) {
|
||||||
|
if (len < 1) {
|
||||||
|
len= section.length()+len;
|
||||||
|
}
|
||||||
|
IASTName name= findImplicitName(section, len);
|
||||||
|
assertNotNull("Name not found for \"" + section + "\"", name);
|
||||||
|
assertEquals(section.substring(0, len), name.getRawSignature());
|
||||||
|
|
||||||
|
IBinding binding = name.resolveBinding();
|
||||||
|
assertNotNull("No binding for " + name.getRawSignature(), binding);
|
||||||
|
assertFalse("Binding is a ProblemBinding for name \"" + name.getRawSignature() + "\"", IProblemBinding.class.isAssignableFrom(name.resolveBinding().getClass()));
|
||||||
|
assertInstance(binding, clazz, cs);
|
||||||
|
return clazz.cast(binding);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see IndexBindingResolutionTestBase#getBindingFromASTName(Class, String, int)
|
* @see IndexBindingResolutionTestBase#getBindingFromASTName(String, int, Class<T>, Class ...)
|
||||||
*/
|
*/
|
||||||
protected <T extends IBinding> T getBindingFromASTName(String section, int len) {
|
protected <T extends IBinding> T getBindingFromASTName(String section, int len) {
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
|
@ -146,6 +187,23 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
||||||
assertFalse("Binding is a ProblemBinding for name \"" + name.getRawSignature() + "\"", IProblemBinding.class.isAssignableFrom(name.resolveBinding().getClass()));
|
assertFalse("Binding is a ProblemBinding for name \"" + name.getRawSignature() + "\"", IProblemBinding.class.isAssignableFrom(name.resolveBinding().getClass()));
|
||||||
return (T) binding;
|
return (T) binding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see IndexBindingResolutionTestBase#getBindingFromImplicitASTName(String, int, Class<T>, Class ...)
|
||||||
|
*/
|
||||||
|
protected <T extends IBinding> T getBindingFromImplicitASTName(String section, int len) {
|
||||||
|
if (len <= 0)
|
||||||
|
len += section.length();
|
||||||
|
|
||||||
|
IASTName name= findImplicitName(section, len);
|
||||||
|
assertNotNull("Name not found for \"" + section + "\"", name);
|
||||||
|
assertEquals(section.substring(0, len), name.getRawSignature());
|
||||||
|
|
||||||
|
IBinding binding = name.resolveBinding();
|
||||||
|
assertNotNull("No binding for " + name.getRawSignature(), binding);
|
||||||
|
assertFalse("Binding is a ProblemBinding for name \"" + name.getRawSignature() + "\"", IProblemBinding.class.isAssignableFrom(name.resolveBinding().getClass()));
|
||||||
|
return (T) binding;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to verify that the resolved binding for a name is a problem binding.
|
* Attempts to verify that the resolved binding for a name is a problem binding.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2013 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.index.tests;
|
package org.eclipse.cdt.internal.index.tests;
|
||||||
|
|
||||||
|
@ -42,20 +43,20 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
||||||
public ProjectWithDepProj() { setStrategy(new ReferencedProject(false)); }
|
public ProjectWithDepProj() { setStrategy(new ReferencedProject(false)); }
|
||||||
public static TestSuite suite() { return suite(ProjectWithDepProj.class); }
|
public static TestSuite suite() { return suite(ProjectWithDepProj.class); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addTests(TestSuite suite) {
|
public static void addTests(TestSuite suite) {
|
||||||
suite.addTest(SingleProject.suite());
|
suite.addTest(SingleProject.suite());
|
||||||
suite.addTest(ProjectWithDepProj.suite());
|
suite.addTest(ProjectWithDepProj.suite());
|
||||||
}
|
}
|
||||||
|
|
||||||
// #include <stdio.h>
|
// #include <stdio.h>
|
||||||
// void func1(void) {
|
// void func1(void) {
|
||||||
// int i = 0;
|
// int i = 0;
|
||||||
// for (i=0; i<10;i++) {
|
// for (i=0; i<10;i++) {
|
||||||
// printf("%i", i);
|
// printf("%i", i);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
//
|
//
|
||||||
// int main(void) {
|
// int main(void) {
|
||||||
|
@ -77,7 +78,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
||||||
}
|
}
|
||||||
|
|
||||||
// void func1(void);
|
// void func1(void);
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
//
|
//
|
||||||
// int main(void) {
|
// int main(void) {
|
||||||
|
@ -87,7 +88,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
||||||
IBinding b0 = getBindingFromASTName("func1;", 5);
|
IBinding b0 = getBindingFromASTName("func1;", 5);
|
||||||
assertTrue(b0 instanceof IFunction);
|
assertTrue(b0 instanceof IFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
// typedef struct {
|
// typedef struct {
|
||||||
// int utm;
|
// int utm;
|
||||||
// } usertype;
|
// } usertype;
|
||||||
|
@ -132,7 +133,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
||||||
assertInstance(type, IEnumeration.class);
|
assertInstance(type, IEnumeration.class);
|
||||||
assertTrue(type instanceof IEnumeration);
|
assertTrue(type instanceof IEnumeration);
|
||||||
}
|
}
|
||||||
|
|
||||||
// int globalVar;
|
// int globalVar;
|
||||||
|
|
||||||
// // don't include header
|
// // don't include header
|
||||||
|
@ -268,10 +269,10 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
||||||
e= (IEnumeration) b1;
|
e= (IEnumeration) b1;
|
||||||
ei= e.getEnumerators();
|
ei= e.getEnumerators();
|
||||||
assertEquals(1, ei.length);
|
assertEquals(1, ei.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
// // no header needed
|
// // no header needed
|
||||||
|
|
||||||
// typedef struct {
|
// typedef struct {
|
||||||
// int member;
|
// int member;
|
||||||
// } t_struct;
|
// } t_struct;
|
||||||
|
@ -289,7 +290,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
||||||
assertTrue(tdIndex instanceof IIndexBinding);
|
assertTrue(tdIndex instanceof IIndexBinding);
|
||||||
assertTrue(tdAST instanceof ITypedef);
|
assertTrue(tdAST instanceof ITypedef);
|
||||||
assertTrue(tdIndex instanceof ITypedef);
|
assertTrue(tdIndex instanceof ITypedef);
|
||||||
|
|
||||||
IType tAST= ((ITypedef) tdAST).getType();
|
IType tAST= ((ITypedef) tdAST).getType();
|
||||||
IType tIndex= ((ITypedef) tdIndex).getType();
|
IType tIndex= ((ITypedef) tdIndex).getType();
|
||||||
assertTrue(tAST instanceof ICompositeType);
|
assertTrue(tAST instanceof ICompositeType);
|
||||||
|
@ -304,7 +305,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
||||||
assertTrue(tdIndex instanceof IIndexBinding);
|
assertTrue(tdIndex instanceof IIndexBinding);
|
||||||
assertTrue(tdAST instanceof ITypedef);
|
assertTrue(tdAST instanceof ITypedef);
|
||||||
assertTrue(tdIndex instanceof ITypedef);
|
assertTrue(tdIndex instanceof ITypedef);
|
||||||
|
|
||||||
tAST= ((ITypedef) tdAST).getType();
|
tAST= ((ITypedef) tdAST).getType();
|
||||||
tIndex= ((ITypedef) tdIndex).getType();
|
tIndex= ((ITypedef) tdIndex).getType();
|
||||||
assertTrue(tAST instanceof ICompositeType);
|
assertTrue(tAST instanceof ICompositeType);
|
||||||
|
@ -319,7 +320,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
||||||
assertTrue(tdIndex instanceof IIndexBinding);
|
assertTrue(tdIndex instanceof IIndexBinding);
|
||||||
assertTrue(tdAST instanceof ITypedef);
|
assertTrue(tdAST instanceof ITypedef);
|
||||||
assertTrue(tdIndex instanceof ITypedef);
|
assertTrue(tdIndex instanceof ITypedef);
|
||||||
|
|
||||||
tAST= ((ITypedef) tdAST).getType();
|
tAST= ((ITypedef) tdAST).getType();
|
||||||
tIndex= ((ITypedef) tdIndex).getType();
|
tIndex= ((ITypedef) tdIndex).getType();
|
||||||
assertTrue(tAST instanceof IEnumeration);
|
assertTrue(tAST instanceof IEnumeration);
|
||||||
|
@ -327,13 +328,13 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
||||||
assertTrue(tAST.isSameType(tIndex));
|
assertTrue(tAST.isSameType(tIndex));
|
||||||
assertTrue(tIndex.isSameType(tAST));
|
assertTrue(tIndex.isSameType(tAST));
|
||||||
}
|
}
|
||||||
|
|
||||||
// struct outer {
|
// struct outer {
|
||||||
// union {
|
// union {
|
||||||
// int var1;
|
// int var1;
|
||||||
// };
|
// };
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// void test() {
|
// void test() {
|
||||||
// struct outer x;
|
// struct outer x;
|
||||||
|
@ -354,7 +355,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
||||||
// int var1;
|
// int var1;
|
||||||
// };
|
// };
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// void test() {
|
// void test() {
|
||||||
// union outer x;
|
// union outer x;
|
||||||
|
@ -369,14 +370,14 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
||||||
assertTrue(outer instanceof ICCompositeTypeScope);
|
assertTrue(outer instanceof ICCompositeTypeScope);
|
||||||
assertEquals("outer", outer.getScopeName().toString());
|
assertEquals("outer", outer.getScopeName().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// int myFunc();
|
// int myFunc();
|
||||||
|
|
||||||
// int myFunc(var)
|
// int myFunc(var)
|
||||||
// int var;
|
// int var;
|
||||||
// {
|
// {
|
||||||
// return var;
|
// return var;
|
||||||
// }
|
// }
|
||||||
// int main(void) {
|
// int main(void) {
|
||||||
// return myFunc(0);
|
// return myFunc(0);
|
||||||
// }
|
// }
|
||||||
|
@ -390,7 +391,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
||||||
assertTrue(params[0].getType() instanceof IBasicType);
|
assertTrue(params[0].getType() instanceof IBasicType);
|
||||||
assertEquals(IBasicType.Kind.eInt, ((IBasicType) params[0].getType()).getKind());
|
assertEquals(IBasicType.Kind.eInt, ((IBasicType) params[0].getType()).getKind());
|
||||||
}
|
}
|
||||||
|
|
||||||
// typedef struct S S;
|
// typedef struct S S;
|
||||||
// void setValue(S *pSelf, int value);
|
// void setValue(S *pSelf, int value);
|
||||||
|
|
||||||
|
@ -404,7 +405,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
||||||
IBinding b = getBindingFromASTName("value =", 5);
|
IBinding b = getBindingFromASTName("value =", 5);
|
||||||
assertTrue(b instanceof IField);
|
assertTrue(b instanceof IField);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void f255(
|
// void f255(
|
||||||
// int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int,
|
// int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int,
|
||||||
// int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int,
|
// int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int,
|
||||||
|
@ -439,8 +440,8 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
||||||
// int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int,
|
// int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int,
|
||||||
// int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int,
|
// int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int,
|
||||||
// int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int);
|
// int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int);
|
||||||
|
|
||||||
// void test() {
|
// void test() {
|
||||||
// f255(
|
// f255(
|
||||||
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
@ -463,8 +464,8 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
||||||
public void testFunctionsWithManyParameters_Bug319186() throws Exception {
|
public void testFunctionsWithManyParameters_Bug319186() throws Exception {
|
||||||
getBindingFromASTName("f255", 0);
|
getBindingFromASTName("f255", 0);
|
||||||
getBindingFromASTName("f256", 0);
|
getBindingFromASTName("f256", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// struct B {
|
// struct B {
|
||||||
// float f;
|
// float f;
|
||||||
// };
|
// };
|
||||||
|
@ -474,5 +475,17 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
||||||
// };
|
// };
|
||||||
public void testDesignatedInitializer_Bug210019() throws Exception {
|
public void testDesignatedInitializer_Bug210019() throws Exception {
|
||||||
IField f= getBindingFromASTName("f", 0);
|
IField f= getBindingFromASTName("f", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// struct S {
|
||||||
|
// int data;
|
||||||
|
// };
|
||||||
|
|
||||||
|
// void test(void (*f)(void*)) {
|
||||||
|
// struct S *i;
|
||||||
|
// f(&i->data);
|
||||||
|
// }
|
||||||
|
public void testBug394151() throws Exception {
|
||||||
|
IParameter f= getBindingFromASTName("f(", 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2010 Symbian Software Systems and others.
|
* Copyright (c) 2007, 2013 Symbian Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
|
* Nathan Ridge
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.index.tests;
|
package org.eclipse.cdt.internal.index.tests;
|
||||||
|
|
||||||
|
@ -1490,9 +1491,7 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
||||||
assertFalse(b0 instanceof IIndexBinding);
|
assertFalse(b0 instanceof IIndexBinding);
|
||||||
ICPPConstructor b1 = getBindingFromASTName("B(int x)", 1, ICPPConstructor.class);
|
ICPPConstructor b1 = getBindingFromASTName("B(int x)", 1, ICPPConstructor.class);
|
||||||
assertFalse(b1 instanceof IIndexBinding);
|
assertFalse(b1 instanceof IIndexBinding);
|
||||||
ICPPConstructor b2 = getBindingFromASTName("B(0)", 1, ICPPConstructor.class);
|
ICPPClassType b2 = getBindingFromASTName("B(0)", 1, ICPPClassType.class);
|
||||||
assertFalse(b2 instanceof IIndexBinding);
|
|
||||||
assertEquals(b1, b2);
|
|
||||||
ICPPMethod b3 = getBindingFromASTName("m(0)", 1, ICPPMethod.class);
|
ICPPMethod b3 = getBindingFromASTName("m(0)", 1, ICPPMethod.class);
|
||||||
assertFalse(b3 instanceof IIndexBinding);
|
assertFalse(b3 instanceof IIndexBinding);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2012 Symbian Software Systems and others.
|
* Copyright (c) 2007, 2013 Symbian Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -300,7 +300,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
||||||
// X<A> xa= new X<A>();
|
// X<A> xa= new X<A>();
|
||||||
// }
|
// }
|
||||||
public void testUnindexedConstructorInstance() {
|
public void testUnindexedConstructorInstance() {
|
||||||
IBinding b0= getBindingFromASTName("X<A>()", 4);
|
IBinding b0= getBindingFromImplicitASTName("X<A>()", 4);
|
||||||
assertInstance(b0, ICPPConstructor.class);
|
assertInstance(b0, ICPPConstructor.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,7 +409,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
||||||
// assertEquals(3, _ctcs.length); // two implicit plus the constructor template
|
// assertEquals(3, _ctcs.length); // two implicit plus the constructor template
|
||||||
|
|
||||||
IBinding b2= getBindingFromASTName("D<int>(", 1);
|
IBinding b2= getBindingFromASTName("D<int>(", 1);
|
||||||
IBinding b3= getBindingFromASTName("D<int>(", 6);
|
IBinding b3= getBindingFromImplicitASTName("D<int>(", 6);
|
||||||
|
|
||||||
assertInstance(b2, ICPPClassTemplate.class); // *D*<int>(5, 6)
|
assertInstance(b2, ICPPClassTemplate.class); // *D*<int>(5, 6)
|
||||||
assertInstance(b2, ICPPClassType.class); // *D*<int>(5, 6)
|
assertInstance(b2, ICPPClassType.class); // *D*<int>(5, 6)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009, 2012 Wind River Systems, Inc. and others.
|
* Copyright (c) 2009, 2013 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,9 +8,12 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
|
* Chris Recoskie (IBM Corporation)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser;
|
package org.eclipse.cdt.core.parser;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
@ -133,6 +136,11 @@ public abstract class FileContent {
|
||||||
public static FileContent adapt(CodeReader reader) {
|
public static FileContent adapt(CodeReader reader) {
|
||||||
if (reader == null)
|
if (reader == null)
|
||||||
return null;
|
return null;
|
||||||
return create(reader.getPath(), reader.buffer);
|
|
||||||
|
long fileReadTime = System.currentTimeMillis();
|
||||||
|
CharArray chars = new CharArray(reader.buffer);
|
||||||
|
String filePath = reader.getPath();
|
||||||
|
File file = new File(filePath);
|
||||||
|
return new InternalFileContent(filePath, chars, file.lastModified(), file.length(), fileReadTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2011 Wind River Systems, Inc. and others.
|
* Copyright (c) 2008, 2013 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser;
|
package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
|
|
||||||
|
@ -33,11 +34,11 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I
|
||||||
setName(name);
|
setName(name);
|
||||||
setValue(value);
|
setValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void copyAbstractEnumerator(ASTEnumerator copy, CopyStyle style) {
|
protected <T extends ASTEnumerator> T copy(T copy, CopyStyle style) {
|
||||||
copy.setName(name == null ? null : name.copy(style));
|
copy.setName(name == null ? null : name.copy(style));
|
||||||
copy.setValue(value == null ? null : value.copy(style));
|
copy.setValue(value == null ? null : value.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return super.copy(copy, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -125,23 +126,26 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createEnumValues(IASTEnumerationSpecifier parent) {
|
private void createEnumValues(IASTEnumerationSpecifier parent) {
|
||||||
|
IValue previousExplicitValue = null;
|
||||||
|
int delta = 0;
|
||||||
IASTEnumerator[] etors= parent.getEnumerators();
|
IASTEnumerator[] etors= parent.getEnumerators();
|
||||||
long cv= -1;
|
|
||||||
boolean isknown= true;
|
|
||||||
for (IASTEnumerator etor : etors) {
|
for (IASTEnumerator etor : etors) {
|
||||||
cv++;
|
IValue val;
|
||||||
IASTExpression expr= etor.getValue();
|
IASTExpression expr= etor.getValue();
|
||||||
if (expr != null) {
|
if (expr != null) {
|
||||||
IValue val= Value.create(expr, Value.MAX_RECURSION_DEPTH);
|
val= Value.create(expr, Value.MAX_RECURSION_DEPTH);
|
||||||
Long nv= val.numericalValue();
|
previousExplicitValue = val;
|
||||||
isknown= false;
|
delta = 1;
|
||||||
if (nv != null) {
|
} else {
|
||||||
isknown= true;
|
if (previousExplicitValue != null) {
|
||||||
cv= nv.longValue();
|
val = Value.incrementedValue(previousExplicitValue, delta);
|
||||||
|
} else {
|
||||||
|
val = Value.create(delta);
|
||||||
}
|
}
|
||||||
|
delta++;
|
||||||
}
|
}
|
||||||
if (etor instanceof ASTEnumerator) {
|
if (etor instanceof ASTEnumerator) {
|
||||||
((ASTEnumerator) etor).integralValue= isknown ? Value.create(cv) : Value.UNKNOWN;
|
((ASTEnumerator) etor).integralValue= val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,11 @@ public class SizeofCalculator {
|
||||||
sizeof_long_long = getSize(sizeofMacros, "__SIZEOF_LONG_LONG__", maxAlignment); //$NON-NLS-1$
|
sizeof_long_long = getSize(sizeofMacros, "__SIZEOF_LONG_LONG__", maxAlignment); //$NON-NLS-1$
|
||||||
sizeof_int128 = getSize(sizeofMacros, "__SIZEOF_INT128__", maxAlignment); //$NON-NLS-1$
|
sizeof_int128 = getSize(sizeofMacros, "__SIZEOF_INT128__", maxAlignment); //$NON-NLS-1$
|
||||||
sizeof_short = getSize(sizeofMacros, "__SIZEOF_SHORT__", maxAlignment); //$NON-NLS-1$
|
sizeof_short = getSize(sizeofMacros, "__SIZEOF_SHORT__", maxAlignment); //$NON-NLS-1$
|
||||||
sizeof_bool = getSize(sizeofMacros, "__SIZEOF_BOOL__", maxAlignment); //$NON-NLS-1$
|
SizeAndAlignment size = getSize(sizeofMacros, "__SIZEOF_BOOL__", maxAlignment); //$NON-NLS-1$
|
||||||
|
// __SIZEOF_BOOL__ is not defined by GCC but sizeof(bool) is needed for template resolution.
|
||||||
|
if (size == null)
|
||||||
|
size = SIZE_1;
|
||||||
|
sizeof_bool = size;
|
||||||
sizeof_wchar_t = getSize(sizeofMacros, "__SIZEOF_WCHAR_T__", maxAlignment); //$NON-NLS-1$
|
sizeof_wchar_t = getSize(sizeofMacros, "__SIZEOF_WCHAR_T__", maxAlignment); //$NON-NLS-1$
|
||||||
sizeof_float = getSize(sizeofMacros, "__SIZEOF_FLOAT__", maxAlignment); //$NON-NLS-1$
|
sizeof_float = getSize(sizeofMacros, "__SIZEOF_FLOAT__", maxAlignment); //$NON-NLS-1$
|
||||||
sizeof_complex_float = getSizeOfPair(sizeof_float);
|
sizeof_complex_float = getSizeOfPair(sizeof_float);
|
||||||
|
@ -152,7 +156,7 @@ public class SizeofCalculator {
|
||||||
sizeof_long_long = null;
|
sizeof_long_long = null;
|
||||||
sizeof_int128 = size_16;
|
sizeof_int128 = size_16;
|
||||||
sizeof_short = null;
|
sizeof_short = null;
|
||||||
sizeof_bool = null;
|
sizeof_bool = SIZE_1;
|
||||||
sizeof_wchar_t = null;
|
sizeof_wchar_t = null;
|
||||||
sizeof_float = null;
|
sizeof_float = null;
|
||||||
sizeof_complex_float = null;
|
sizeof_complex_float = null;
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.eclipse.cdt.core.dom.ast.IASTBinaryTypeIdExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
|
||||||
|
@ -53,16 +54,20 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment;
|
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinary;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.TypeTraits;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.TypeTraits;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator;
|
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator.EvalException;
|
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator.EvalException;
|
||||||
|
@ -77,6 +82,7 @@ public class Value implements IValue {
|
||||||
public static final int MAX_RECURSION_DEPTH = 25;
|
public static final int MAX_RECURSION_DEPTH = 25;
|
||||||
public static final Value UNKNOWN= new Value("<unknown>".toCharArray(), null); //$NON-NLS-1$
|
public static final Value UNKNOWN= new Value("<unknown>".toCharArray(), null); //$NON-NLS-1$
|
||||||
public static final Value NOT_INITIALIZED= new Value("<__>".toCharArray(), null); //$NON-NLS-1$
|
public static final Value NOT_INITIALIZED= new Value("<__>".toCharArray(), null); //$NON-NLS-1$
|
||||||
|
private static final IType INT_TYPE= new CPPBasicType(ICPPBasicType.Kind.eInt, 0);
|
||||||
|
|
||||||
private static final Number VALUE_CANNOT_BE_DETERMINED = new Number() {
|
private static final Number VALUE_CANNOT_BE_DETERMINED = new Number() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -271,6 +277,16 @@ public class Value implements IValue {
|
||||||
return UNKNOWN;
|
return UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IValue incrementedValue(IValue value, int increment) {
|
||||||
|
Long val = value.numericalValue();
|
||||||
|
if (val != null) {
|
||||||
|
return create(val.longValue() + increment);
|
||||||
|
}
|
||||||
|
ICPPEvaluation arg1 = value.getEvaluation();
|
||||||
|
EvalFixed arg2 = new EvalFixed(INT_TYPE, ValueCategory.PRVALUE, create(increment));
|
||||||
|
return create(new EvalBinary(IASTBinaryExpression.op_plus, arg1, arg2));
|
||||||
|
}
|
||||||
|
|
||||||
private static Number applyUnaryTypeIdOperator(int operator, IType type, IASTNode point) {
|
private static Number applyUnaryTypeIdOperator(int operator, IType type, IASTNode point) {
|
||||||
switch (operator) {
|
switch (operator) {
|
||||||
case op_sizeof:
|
case op_sizeof:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser;
|
package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
|
|
||||||
|
@ -191,7 +192,7 @@ public abstract class VariableReadWriteFlags {
|
||||||
final IType type= functionNameExpression.getExpressionType();
|
final IType type= functionNameExpression.getExpressionType();
|
||||||
if (type instanceof IFunctionType) {
|
if (type instanceof IFunctionType) {
|
||||||
return rwArgumentForFunctionCall((IFunctionType) type, i, indirection);
|
return rwArgumentForFunctionCall((IFunctionType) type, i, indirection);
|
||||||
} else {
|
} else if (funcCall instanceof IASTImplicitNameOwner) {
|
||||||
IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) funcCall).getImplicitNames();
|
IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) funcCall).getImplicitNames();
|
||||||
if (implicitNames.length == 1) {
|
if (implicitNames.length == 1) {
|
||||||
IASTImplicitName name = implicitNames[0];
|
IASTImplicitName name = implicitNames[0];
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
* Copyright (c) 2005, 2013 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -34,11 +34,6 @@ public class CASTEnumerator extends ASTEnumerator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CASTEnumerator copy(CopyStyle style) {
|
public CASTEnumerator copy(CopyStyle style) {
|
||||||
CASTEnumerator copy = new CASTEnumerator();
|
return copy(new CASTEnumerator(), style);
|
||||||
copyAbstractEnumerator(copy, style);
|
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2013 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM) - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -35,11 +35,6 @@ public class CPPASTEnumerator extends ASTEnumerator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CPPASTEnumerator copy(CopyStyle style) {
|
public CPPASTEnumerator copy(CopyStyle style) {
|
||||||
CPPASTEnumerator copy = new CPPASTEnumerator();
|
return copy(new CPPASTEnumerator(), style);
|
||||||
copyAbstractEnumerator(copy, style);
|
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
* Copyright (c) 2004, 2013 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -550,14 +550,6 @@ public class CPPSemantics {
|
||||||
if (parent instanceof ICPPASTConstructorChainInitializer) {
|
if (parent instanceof ICPPASTConstructorChainInitializer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (parent instanceof ICPPASTNamedTypeSpecifier) {
|
|
||||||
parent= parent.getParent();
|
|
||||||
if (parent instanceof IASTTypeId && parent.getParent() instanceof ICPPASTNewExpression) {
|
|
||||||
IASTDeclarator dtor = ((IASTTypeId) parent).getAbstractDeclarator();
|
|
||||||
if (dtor != null && dtor.getPointerOperators().length == 0)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3103,27 +3095,43 @@ public class CPPSemantics {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
IType type = ((ICPPVariable) binding).getType();
|
IType type = ((ICPPVariable) binding).getType();
|
||||||
try {
|
type = SemanticUtil.getNestedType(type, TDEF | CVTYPE);
|
||||||
type = SemanticUtil.getNestedType(type, TDEF | CVTYPE);
|
if (!(type instanceof ICPPClassType))
|
||||||
if (!(type instanceof ICPPClassType))
|
return null;
|
||||||
return null;
|
if (type instanceof ICPPClassTemplate || type instanceof ICPPUnknownType || type instanceof ISemanticProblem)
|
||||||
if (type instanceof ICPPClassTemplate || type instanceof ICPPUnknownType || type instanceof ISemanticProblem)
|
return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
final ICPPClassType classType = (ICPPClassType) type;
|
return findImplicitlyCalledConstructor((ICPPClassType) type, initializer, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ICPPConstructor findImplicitlyCalledConstructor(ICPPASTNewExpression expr) {
|
||||||
|
IType type = getNestedType(expr.getExpressionType(), TDEF | REF | CVTYPE);
|
||||||
|
if (!(type instanceof IPointerType))
|
||||||
|
return null;
|
||||||
|
type = ((IPointerType) type).getType();
|
||||||
|
if (type instanceof ICPPClassType) {
|
||||||
|
return findImplicitlyCalledConstructor((ICPPClassType) type,
|
||||||
|
expr.getInitializer(), expr.getTypeId());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ICPPConstructor findImplicitlyCalledConstructor(ICPPClassType type, IASTInitializer initializer,
|
||||||
|
IASTNode typeId) {
|
||||||
|
try {
|
||||||
if (initializer instanceof IASTEqualsInitializer) {
|
if (initializer instanceof IASTEqualsInitializer) {
|
||||||
// Copy initialization.
|
// Copy initialization.
|
||||||
IASTEqualsInitializer eqInit= (IASTEqualsInitializer) initializer;
|
IASTEqualsInitializer eqInit= (IASTEqualsInitializer) initializer;
|
||||||
ICPPASTInitializerClause initClause = (ICPPASTInitializerClause) eqInit.getInitializerClause();
|
ICPPASTInitializerClause initClause = (ICPPASTInitializerClause) eqInit.getInitializerClause();
|
||||||
final ICPPEvaluation evaluation = initClause.getEvaluation();
|
final ICPPEvaluation evaluation = initClause.getEvaluation();
|
||||||
IType sourceType= evaluation.getTypeOrFunctionSet(name);
|
IType sourceType= evaluation.getTypeOrFunctionSet(typeId);
|
||||||
ValueCategory isLValue= evaluation.getValueCategory(name);
|
ValueCategory isLValue= evaluation.getValueCategory(typeId);
|
||||||
if (sourceType != null) {
|
if (sourceType != null) {
|
||||||
Cost c;
|
Cost c;
|
||||||
if (calculateInheritanceDepth(sourceType, classType, name) >= 0) {
|
if (calculateInheritanceDepth(sourceType, type, typeId) >= 0) {
|
||||||
c = Conversions.copyInitializationOfClass(isLValue, sourceType, classType, false, name);
|
c = Conversions.copyInitializationOfClass(isLValue, sourceType, type, false, typeId);
|
||||||
} else {
|
} else {
|
||||||
c = Conversions.checkImplicitConversionSequence(type, sourceType, isLValue, UDCMode.ALLOWED, Context.ORDINARY, name);
|
c = Conversions.checkImplicitConversionSequence(type, sourceType, isLValue, UDCMode.ALLOWED, Context.ORDINARY, typeId);
|
||||||
}
|
}
|
||||||
if (c.converts()) {
|
if (c.converts()) {
|
||||||
ICPPFunction f = c.getUserDefinedConversion();
|
ICPPFunction f = c.getUserDefinedConversion();
|
||||||
|
@ -3136,7 +3144,7 @@ public class CPPSemantics {
|
||||||
// List initialization.
|
// List initialization.
|
||||||
ICPPEvaluation eval= ((ICPPASTInitializerList) initializer).getEvaluation();
|
ICPPEvaluation eval= ((ICPPASTInitializerList) initializer).getEvaluation();
|
||||||
if (eval instanceof EvalInitList) {
|
if (eval instanceof EvalInitList) {
|
||||||
Cost c= Conversions.listInitializationSequence((EvalInitList) eval, type, UDCMode.ALLOWED, true, name);
|
Cost c= Conversions.listInitializationSequence((EvalInitList) eval, type, UDCMode.ALLOWED, true, typeId);
|
||||||
if (c.converts()) {
|
if (c.converts()) {
|
||||||
ICPPFunction f = c.getUserDefinedConversion();
|
ICPPFunction f = c.getUserDefinedConversion();
|
||||||
if (f instanceof ICPPConstructor)
|
if (f instanceof ICPPConstructor)
|
||||||
|
@ -3145,35 +3153,22 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
} else if (initializer instanceof ICPPASTConstructorInitializer) {
|
} else if (initializer instanceof ICPPASTConstructorInitializer) {
|
||||||
// Direct initialization.
|
// Direct initialization.
|
||||||
return findImplicitlyCalledConstructor(classType,
|
return findImplicitlyCalledConstructor(type,
|
||||||
(ICPPASTConstructorInitializer) initializer, name);
|
(ICPPASTConstructorInitializer) initializer, typeId);
|
||||||
} else if (initializer == null) {
|
} else if (initializer == null) {
|
||||||
// Default initialization.
|
// Default initialization.
|
||||||
ICPPConstructor[] ctors = ClassTypeHelper.getConstructors(classType, name);
|
ICPPConstructor[] ctors = ClassTypeHelper.getConstructors(type, typeId);
|
||||||
for (ICPPConstructor ctor : ctors) {
|
for (ICPPConstructor ctor : ctors) {
|
||||||
if (ctor.getRequiredArgumentCount() == 0)
|
if (ctor.getRequiredArgumentCount() == 0)
|
||||||
return ctor;
|
return ctor;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ICPPConstructor findImplicitlyCalledConstructor(ICPPASTNewExpression expr) {
|
|
||||||
IType type = getNestedType(expr.getExpressionType(), TDEF | REF | CVTYPE);
|
|
||||||
if (!(type instanceof IPointerType))
|
|
||||||
return null;
|
|
||||||
type = ((IPointerType) type).getType();
|
|
||||||
IASTInitializer initializer = expr.getInitializer();
|
|
||||||
if (type instanceof ICPPClassType && initializer instanceof ICPPASTConstructorInitializer) {
|
|
||||||
return findImplicitlyCalledConstructor((ICPPClassType) type,
|
|
||||||
(ICPPASTConstructorInitializer) initializer, expr.getTypeId());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ICPPConstructor findImplicitlyCalledConstructor(ICPPClassType classType,
|
private static ICPPConstructor findImplicitlyCalledConstructor(ICPPClassType classType,
|
||||||
ICPPASTConstructorInitializer initializer, IASTNode typeId) {
|
ICPPASTConstructorInitializer initializer, IASTNode typeId) {
|
||||||
final IASTInitializerClause[] arguments = initializer.getArguments();
|
final IASTInitializerClause[] arguments = initializer.getArguments();
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* Mike Kucera (IBM) - UTF string literals
|
* Mike Kucera (IBM) - UTF string literals
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||||
|
|
||||||
|
@ -195,7 +196,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
Token t= fToken;
|
Token t= fToken;
|
||||||
Token lt= null;
|
Token lt= null;
|
||||||
while (true) {
|
while (true) {
|
||||||
switch(t.getType()) {
|
switch (t.getType()) {
|
||||||
case IToken.tCOMPLETION:
|
case IToken.tCOMPLETION:
|
||||||
if (lt != null) {
|
if (lt != null) {
|
||||||
fLastToken= lt;
|
fLastToken= lt;
|
||||||
|
@ -228,7 +229,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
public Token nextDirective() throws OffsetLimitReachedException {
|
public Token nextDirective() throws OffsetLimitReachedException {
|
||||||
Token t0;
|
Token t0;
|
||||||
Token t1= fToken;
|
Token t1= fToken;
|
||||||
for(;;) {
|
for (;;) {
|
||||||
t0= t1;
|
t0= t1;
|
||||||
t1= fetchToken();
|
t1= fetchToken();
|
||||||
final int tt1 = t1.getType();
|
final int tt1 = t1.getType();
|
||||||
|
@ -252,7 +253,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
final int start= fOffset;
|
final int start= fOffset;
|
||||||
final int c= fCharPhase3;
|
final int c= fCharPhase3;
|
||||||
final int d= nextCharPhase3();
|
final int d= nextCharPhase3();
|
||||||
switch(c) {
|
switch (c) {
|
||||||
case END_OF_INPUT:
|
case END_OF_INPUT:
|
||||||
return newToken(IToken.tEND_OF_INPUT, start);
|
return newToken(IToken.tEND_OF_INPUT, start);
|
||||||
case '\n':
|
case '\n':
|
||||||
|
@ -266,7 +267,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'L':
|
case 'L':
|
||||||
switch(d) {
|
switch (d) {
|
||||||
case 'R':
|
case 'R':
|
||||||
if (fOptions.fSupportRawStringLiterals) {
|
if (fOptions.fSupportRawStringLiterals) {
|
||||||
markPhase3();
|
markPhase3();
|
||||||
|
@ -289,7 +290,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
case 'u':
|
case 'u':
|
||||||
case 'U':
|
case 'U':
|
||||||
if (fOptions.fSupportUTFLiterals) {
|
if (fOptions.fSupportUTFLiterals) {
|
||||||
switch(d) {
|
switch (d) {
|
||||||
case 'R':
|
case 'R':
|
||||||
if (fOptions.fSupportRawStringLiterals) {
|
if (fOptions.fSupportRawStringLiterals) {
|
||||||
markPhase3();
|
markPhase3();
|
||||||
|
@ -364,7 +365,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\\':
|
case '\\':
|
||||||
switch(d) {
|
switch (d) {
|
||||||
case 'u': case 'U':
|
case 'u': case 'U':
|
||||||
nextCharPhase3();
|
nextCharPhase3();
|
||||||
return identifier(start, 2);
|
return identifier(start, 2);
|
||||||
|
@ -376,7 +377,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
return number(start, 1, false);
|
return number(start, 1, false);
|
||||||
|
|
||||||
case '.':
|
case '.':
|
||||||
switch(d) {
|
switch (d) {
|
||||||
case '0': case '1': case '2': case '3': case '4':
|
case '0': case '1': case '2': case '3': case '4':
|
||||||
case '5': case '6': case '7': case '8': case '9':
|
case '5': case '6': case '7': case '8': case '9':
|
||||||
nextCharPhase3();
|
nextCharPhase3();
|
||||||
|
@ -420,7 +421,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
return newToken(IToken.tSEMI, start);
|
return newToken(IToken.tSEMI, start);
|
||||||
|
|
||||||
case ':':
|
case ':':
|
||||||
switch(d) {
|
switch (d) {
|
||||||
case ':':
|
case ':':
|
||||||
nextCharPhase3();
|
nextCharPhase3();
|
||||||
return newToken(IToken.tCOLONCOLON, start);
|
return newToken(IToken.tCOLONCOLON, start);
|
||||||
|
@ -564,7 +565,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
return headerName(start, false);
|
return headerName(start, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(d) {
|
switch (d) {
|
||||||
case '=':
|
case '=':
|
||||||
nextCharPhase3();
|
nextCharPhase3();
|
||||||
return newToken(IToken.tLTEQUAL, start);
|
return newToken(IToken.tLTEQUAL, start);
|
||||||
|
@ -582,8 +583,19 @@ final public class Lexer implements ITokenSequence {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ':':
|
case ':':
|
||||||
nextCharPhase3();
|
// 2.5-3
|
||||||
return newDigraphToken(IToken.tLBRACKET, start);
|
markPhase3();
|
||||||
|
if (nextCharPhase3() != ':') {
|
||||||
|
return newDigraphToken(IToken.tLBRACKET, start);
|
||||||
|
}
|
||||||
|
switch (nextCharPhase3()) {
|
||||||
|
case ':': case '>':
|
||||||
|
restorePhase3();
|
||||||
|
nextCharPhase3();
|
||||||
|
return newDigraphToken(IToken.tLBRACKET, start);
|
||||||
|
}
|
||||||
|
restorePhase3();
|
||||||
|
break;
|
||||||
case '%':
|
case '%':
|
||||||
nextCharPhase3();
|
nextCharPhase3();
|
||||||
return newDigraphToken(IToken.tLBRACE, start);
|
return newDigraphToken(IToken.tLBRACE, start);
|
||||||
|
@ -591,7 +603,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
return newToken(IToken.tLT, start);
|
return newToken(IToken.tLT, start);
|
||||||
|
|
||||||
case '>':
|
case '>':
|
||||||
switch(d) {
|
switch (d) {
|
||||||
case '=':
|
case '=':
|
||||||
nextCharPhase3();
|
nextCharPhase3();
|
||||||
return newToken(IToken.tGTEQUAL, start);
|
return newToken(IToken.tGTEQUAL, start);
|
||||||
|
@ -636,7 +648,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
|
|
||||||
private Token newToken(final int kind, final int offset, final int imageLength) {
|
private Token newToken(final int kind, final int offset, final int imageLength) {
|
||||||
final int endOffset= fOffset;
|
final int endOffset= fOffset;
|
||||||
final int sourceLen= endOffset-offset;
|
final int sourceLen= endOffset - offset;
|
||||||
char[] image;
|
char[] image;
|
||||||
if (sourceLen != imageLength) {
|
if (sourceLen != imageLength) {
|
||||||
image= getCharImage(offset, endOffset, imageLength);
|
image= getCharImage(offset, endOffset, imageLength);
|
||||||
|
@ -719,7 +731,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
int c= fCharPhase3;
|
int c= fCharPhase3;
|
||||||
|
|
||||||
loop: while (!done) {
|
loop: while (!done) {
|
||||||
switch(c) {
|
switch (c) {
|
||||||
case END_OF_INPUT:
|
case END_OF_INPUT:
|
||||||
if (fSupportContentAssist) {
|
if (fSupportContentAssist) {
|
||||||
throw new OffsetLimitReachedException(ORIGIN_LEXER, newToken(tokenType, start, length));
|
throw new OffsetLimitReachedException(ORIGIN_LEXER, newToken(tokenType, start, length));
|
||||||
|
@ -752,19 +764,19 @@ final public class Lexer implements ITokenSequence {
|
||||||
final int delimOffset= fOffset;
|
final int delimOffset= fOffset;
|
||||||
int delimEndOffset = delimOffset;
|
int delimEndOffset = delimOffset;
|
||||||
int offset;
|
int offset;
|
||||||
for(;; delimEndOffset++) {
|
for (;; delimEndOffset++) {
|
||||||
if (!fInput.isValidOffset(delimEndOffset)) {
|
if (!fInput.isValidOffset(delimEndOffset)) {
|
||||||
offset= delimEndOffset;
|
offset= delimEndOffset;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (fInput.get(delimEndOffset) == '(') {
|
if (fInput.get(delimEndOffset) == '(') {
|
||||||
offset= delimEndOffset+1;
|
offset= delimEndOffset + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final int delimLength= delimEndOffset-delimOffset;
|
final int delimLength= delimEndOffset - delimOffset;
|
||||||
for(;; offset++) {
|
for (;; offset++) {
|
||||||
if (!fInput.isValidOffset(offset)) {
|
if (!fInput.isValidOffset(offset)) {
|
||||||
handleProblem(IProblem.SCANNER_UNBOUNDED_STRING, getInputChars(start, offset), start);
|
handleProblem(IProblem.SCANNER_UNBOUNDED_STRING, getInputChars(start, offset), start);
|
||||||
break;
|
break;
|
||||||
|
@ -772,27 +784,27 @@ final public class Lexer implements ITokenSequence {
|
||||||
|
|
||||||
final char c= fInput.get(offset);
|
final char c= fInput.get(offset);
|
||||||
if (c == ')') {
|
if (c == ')') {
|
||||||
final int endingDoubleQuoteOffset= offset+delimLength+1;
|
final int endingDoubleQuoteOffset= offset + delimLength + 1;
|
||||||
if (fInput.isValidOffset(endingDoubleQuoteOffset) && fInput.get(endingDoubleQuoteOffset) == '"') {
|
if (fInput.isValidOffset(endingDoubleQuoteOffset) && fInput.get(endingDoubleQuoteOffset) == '"') {
|
||||||
boolean prefixMatches= true;
|
boolean prefixMatches= true;
|
||||||
for (int i = 0; i < delimLength; i++) {
|
for (int i = 0; i < delimLength; i++) {
|
||||||
if (fInput.get(offset + i + 1) != fInput.get(delimOffset+i)) {
|
if (fInput.get(offset + i + 1) != fInput.get(delimOffset + i)) {
|
||||||
prefixMatches= false;
|
prefixMatches= false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (prefixMatches) {
|
if (prefixMatches) {
|
||||||
offset= endingDoubleQuoteOffset+1;
|
offset= endingDoubleQuoteOffset + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fOffset= offset-1;
|
fOffset= offset - 1;
|
||||||
fEndOffset= offset;
|
fEndOffset= offset;
|
||||||
fCharPhase3= 0;
|
fCharPhase3= 0;
|
||||||
nextCharPhase3();
|
nextCharPhase3();
|
||||||
return newToken(tokenType, start, offset-start);
|
return newToken(tokenType, start, offset - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Token charLiteral(final int start, final int tokenType) throws OffsetLimitReachedException {
|
private Token charLiteral(final int start, final int tokenType) throws OffsetLimitReachedException {
|
||||||
|
@ -802,7 +814,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
int c= fCharPhase3;
|
int c= fCharPhase3;
|
||||||
|
|
||||||
loop: while (!done) {
|
loop: while (!done) {
|
||||||
switch(c) {
|
switch (c) {
|
||||||
case END_OF_INPUT:
|
case END_OF_INPUT:
|
||||||
if (fSupportContentAssist) {
|
if (fSupportContentAssist) {
|
||||||
throw new OffsetLimitReachedException(ORIGIN_LEXER, newToken(tokenType, start, length));
|
throw new OffsetLimitReachedException(ORIGIN_LEXER, newToken(tokenType, start, length));
|
||||||
|
@ -835,7 +847,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
boolean isPartOfIdentifier= true;
|
boolean isPartOfIdentifier= true;
|
||||||
int c= fCharPhase3;
|
int c= fCharPhase3;
|
||||||
while (true) {
|
while (true) {
|
||||||
switch(c) {
|
switch (c) {
|
||||||
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i':
|
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i':
|
||||||
case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
|
case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
|
||||||
case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
|
case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
|
||||||
|
@ -849,7 +861,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
|
|
||||||
case '\\': // universal character name
|
case '\\': // universal character name
|
||||||
markPhase3();
|
markPhase3();
|
||||||
switch(nextCharPhase3()) {
|
switch (nextCharPhase3()) {
|
||||||
case 'u': case 'U':
|
case 'u': case 'U':
|
||||||
length++;
|
length++;
|
||||||
break;
|
break;
|
||||||
|
@ -904,7 +916,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
boolean isHex= false;
|
boolean isHex= false;
|
||||||
int c= fCharPhase3;
|
int c= fCharPhase3;
|
||||||
while (true) {
|
while (true) {
|
||||||
switch(c) {
|
switch (c) {
|
||||||
// non-digit
|
// non-digit
|
||||||
case 'a': case 'b': case 'c': case 'd': case 'f': case 'g': case 'h': case 'i':
|
case 'a': case 'b': case 'c': case 'd': case 'f': case 'g': case 'h': case 'i':
|
||||||
case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'q': case 'r':
|
case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'q': case 'r':
|
||||||
|
@ -952,7 +964,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
// universal character name (non-digit)
|
// universal character name (non-digit)
|
||||||
case '\\':
|
case '\\':
|
||||||
markPhase3();
|
markPhase3();
|
||||||
switch(nextCharPhase3()) {
|
switch (nextCharPhase3()) {
|
||||||
case 'u': case 'U':
|
case 'u': case 'U':
|
||||||
length++;
|
length++;
|
||||||
break;
|
break;
|
||||||
|
@ -1013,7 +1025,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
private int nextCharPhase3() {
|
private int nextCharPhase3() {
|
||||||
int pos= fEndOffset;
|
int pos= fEndOffset;
|
||||||
do {
|
do {
|
||||||
if (!isValidOffset(pos+1)) {
|
if (!isValidOffset(pos + 1)) {
|
||||||
if (!isValidOffset(pos)) {
|
if (!isValidOffset(pos)) {
|
||||||
fOffset= pos;
|
fOffset= pos;
|
||||||
fEndOffset= pos;
|
fEndOffset= pos;
|
||||||
|
@ -1021,7 +1033,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
return END_OF_INPUT;
|
return END_OF_INPUT;
|
||||||
}
|
}
|
||||||
fOffset= pos;
|
fOffset= pos;
|
||||||
fEndOffset= pos+1;
|
fEndOffset= pos + 1;
|
||||||
fCharPhase3= fInput.get(pos);
|
fCharPhase3= fInput.get(pos);
|
||||||
return fCharPhase3;
|
return fCharPhase3;
|
||||||
}
|
}
|
||||||
|
@ -1030,7 +1042,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
fOffset= pos;
|
fOffset= pos;
|
||||||
fEndOffset= ++pos;
|
fEndOffset= ++pos;
|
||||||
fCharPhase3= c;
|
fCharPhase3= c;
|
||||||
switch(c) {
|
switch (c) {
|
||||||
// windows line-ending
|
// windows line-ending
|
||||||
case '\r':
|
case '\r':
|
||||||
if (fInput.get(pos) == '\n') {
|
if (fInput.get(pos) == '\n') {
|
||||||
|
@ -1080,7 +1092,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
* @return the character encoded or 0.
|
* @return the character encoded or 0.
|
||||||
*/
|
*/
|
||||||
private char checkTrigraph(char c) {
|
private char checkTrigraph(char c) {
|
||||||
switch(c) {
|
switch (c) {
|
||||||
case '=': return '#';
|
case '=': return '#';
|
||||||
case '\'':return '^';
|
case '\'':return '^';
|
||||||
case '(': return '[';
|
case '(': return '[';
|
||||||
|
@ -1101,7 +1113,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
boolean haveBackslash= true;
|
boolean haveBackslash= true;
|
||||||
int result= -1;
|
int result= -1;
|
||||||
loop: while (isValidOffset(pos)) {
|
loop: while (isValidOffset(pos)) {
|
||||||
switch(fInput.get(pos++)) {
|
switch (fInput.get(pos++)) {
|
||||||
case '\n':
|
case '\n':
|
||||||
if (haveBackslash) {
|
if (haveBackslash) {
|
||||||
result= pos;
|
result= pos;
|
||||||
|
@ -1140,7 +1152,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
* Returns the image from the input without any modification.
|
* Returns the image from the input without any modification.
|
||||||
*/
|
*/
|
||||||
public char[] getInputChars(int offset, int endOffset) {
|
public char[] getInputChars(int offset, int endOffset) {
|
||||||
final int length= endOffset-offset;
|
final int length= endOffset - offset;
|
||||||
if (length <= 0) {
|
if (length <= 0) {
|
||||||
return CharArrayUtils.EMPTY;
|
return CharArrayUtils.EMPTY;
|
||||||
}
|
}
|
||||||
|
@ -1160,7 +1172,7 @@ final public class Lexer implements ITokenSequence {
|
||||||
final char[] result= new char[imageLength];
|
final char[] result= new char[imageLength];
|
||||||
markPhase3();
|
markPhase3();
|
||||||
fEndOffset= offset;
|
fEndOffset= offset;
|
||||||
for (int idx=0; idx<imageLength; idx++) {
|
for (int idx= 0; idx < imageLength; idx++) {
|
||||||
result[idx]= (char) nextCharPhase3();
|
result[idx]= (char) nextCharPhase3();
|
||||||
}
|
}
|
||||||
restorePhase3();
|
restorePhase3();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2012 QNX Software Systems and others.
|
* Copyright (c) 2005, 2013 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -13,6 +13,7 @@
|
||||||
* Tim Kelly (Nokia)
|
* Tim Kelly (Nokia)
|
||||||
* Anna Dushistova (MontaVista)
|
* Anna Dushistova (MontaVista)
|
||||||
* Marc-Andre Laperle
|
* Marc-Andre Laperle
|
||||||
|
* Martin Oberhuber (Wind River) - [397652] fix up-to-date check for PDOM
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom;
|
package org.eclipse.cdt.internal.core.pdom;
|
||||||
|
|
||||||
|
@ -23,6 +24,7 @@ import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -93,6 +95,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.ISafeRunnable;
|
import org.eclipse.core.runtime.ISafeRunnable;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.ListenerList;
|
import org.eclipse.core.runtime.ListenerList;
|
||||||
|
import org.eclipse.core.runtime.MultiStatus;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.OperationCanceledException;
|
import org.eclipse.core.runtime.OperationCanceledException;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
@ -109,6 +112,7 @@ import org.eclipse.core.runtime.preferences.IPreferencesService;
|
||||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||||
|
|
||||||
import com.ibm.icu.text.MessageFormat;
|
import com.ibm.icu.text.MessageFormat;
|
||||||
|
import com.ibm.icu.text.SimpleDateFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages PDOM updates and events associated with them. Provides methods for index access.
|
* Manages PDOM updates and events associated with them. Provides methods for index access.
|
||||||
|
@ -1529,11 +1533,25 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
public boolean isProjectContentSynced(ICProject cproject) throws CoreException {
|
public boolean isProjectContentSynced(ICProject cproject) throws CoreException {
|
||||||
|
IStatus s = getProjectContentSyncState(cproject);
|
||||||
|
return s == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the index is in sync with the file system.
|
||||||
|
* @param cproject the project to check
|
||||||
|
* @return <code>null</code> when the content in the project fragment of the specified project's index
|
||||||
|
* is complete (contains all sources) and up to date; or an @link{IStatus} indicating the first
|
||||||
|
* occurrence of an index file found not up-to-date, along with its include trail.
|
||||||
|
* @throws CoreException in case of a file access or other internal error
|
||||||
|
*/
|
||||||
|
public IStatus getProjectContentSyncState(ICProject cproject) throws CoreException {
|
||||||
if (!"true".equals(IndexerPreferences.get(cproject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, null))) //$NON-NLS-1$
|
if (!"true".equals(IndexerPreferences.get(cproject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, null))) //$NON-NLS-1$
|
||||||
return true; // no check performed in this case
|
return null; // No check is performed in this case
|
||||||
|
|
||||||
Set<ITranslationUnit> sources= new HashSet<ITranslationUnit>();
|
Set<ITranslationUnit> sources= new HashSet<ITranslationUnit>();
|
||||||
cproject.accept(new TranslationUnitCollector(sources, null, new NullProgressMonitor()));
|
cproject.accept(new TranslationUnitCollector(sources, null, new NullProgressMonitor()));
|
||||||
|
IStatus syncStatus = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IIndex index= getIndex(cproject);
|
IIndex index= getIndex(cproject);
|
||||||
|
@ -1543,8 +1561,9 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
||||||
IResource resource= tu.getResource();
|
IResource resource= tu.getResource();
|
||||||
if (resource instanceof IFile && isSubjectToIndexing(tu.getLanguage())) {
|
if (resource instanceof IFile && isSubjectToIndexing(tu.getLanguage())) {
|
||||||
IIndexFileLocation location= IndexLocationFactory.getWorkspaceIFL((IFile) resource);
|
IIndexFileLocation location= IndexLocationFactory.getWorkspaceIFL((IFile) resource);
|
||||||
if (!areSynchronized(new HashSet<IIndexFileLocation>(), index, resource, location)) {
|
syncStatus = areSynchronized(new HashSet<IIndexFileLocation>(), index, resource, location);
|
||||||
return false;
|
if (syncStatus != null) {
|
||||||
|
return syncStatus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1555,11 +1574,11 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSubjectToIndexing(ILanguage language) {
|
private boolean isSubjectToIndexing(ILanguage language) {
|
||||||
final int linkageID=language.getLinkageID();
|
final int linkageID = language.getLinkageID();
|
||||||
for (int id : IDS_FOR_LINKAGES_TO_INDEX) {
|
for (int id : IDS_FOR_LINKAGES_TO_INDEX) {
|
||||||
if (linkageID == id)
|
if (linkageID == id)
|
||||||
return true;
|
return true;
|
||||||
|
@ -1568,45 +1587,57 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursively checks that the specified file, and its include are up-to-date.
|
* Recursively checks that the specified file, and its includes are up-to-date.
|
||||||
* @param trail a set of previously checked include file locations
|
* @param trail a set of previously checked include file locations
|
||||||
* @param index the index to check against
|
* @param index the index to check against
|
||||||
* @param resource the resource to check from the workspace
|
* @param resource the resource to check from the workspace
|
||||||
* @param location the location to check from the index
|
* @param location the location to check from the index
|
||||||
* @return whether the specified file, and its includes are up-to-date.
|
* @return <code>null</code> when whether the specified file, and its includes are up-to-date,
|
||||||
|
* or a MultiStatus indicating the file found to be not in sync along with it include trail.
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
private static boolean areSynchronized(Set<IIndexFileLocation> trail, IIndex index, IResource resource, IIndexFileLocation location) throws CoreException {
|
private static MultiStatus areSynchronized(Set<IIndexFileLocation> trail, IIndex index,
|
||||||
|
IResource resource, IIndexFileLocation location) throws CoreException {
|
||||||
if (!trail.contains(location)) {
|
if (!trail.contains(location)) {
|
||||||
trail.add(location);
|
trail.add(location);
|
||||||
|
|
||||||
IIndexFile[] file= index.getFiles(location);
|
IIndexFile[] files= index.getFiles(location);
|
||||||
|
|
||||||
// pre-includes may be listed twice (191989)
|
if (files.length <= 0)
|
||||||
if (file.length < 1 || file.length > 2)
|
return new MultiStatus(CCorePlugin.PLUGIN_ID, IStatus.OK, "No index file found for: " + location, null); //$NON-NLS-1$
|
||||||
return false;
|
|
||||||
|
|
||||||
if (resource.getLocalTimeStamp() != file[0].getTimestamp())
|
for (IIndexFile file : files) {
|
||||||
return false;
|
long diff = resource.getLocalTimeStamp() - file.getTimestamp();
|
||||||
|
if (diff != 0) {
|
||||||
|
return new MultiStatus(CCorePlugin.PLUGIN_ID, IStatus.OK,
|
||||||
|
"Index timestamp for '" //$NON-NLS-1$
|
||||||
|
+ file.getLocation().getFullPath()
|
||||||
|
+ "' is " + diff + " msec older than " //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
+ location
|
||||||
|
+ "(" + SimpleDateFormat.getDateTimeInstance().format(new Date(resource.getLocalTimeStamp())) //$NON-NLS-1$
|
||||||
|
+ ")", null); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
// if it is up-to-date, the includes have not changed and may
|
// If it is up-to-date, the includes have not changed and may be read from the index.
|
||||||
// be read from the index.
|
IIndexInclude[] includes= index.findIncludes(file);
|
||||||
IIndexInclude[] includes= index.findIncludes(file[0]);
|
for (IIndexInclude inc : includes) {
|
||||||
for (IIndexInclude inc : includes) {
|
IIndexFileLocation newLocation= inc.getIncludesLocation();
|
||||||
IIndexFileLocation newLocation= inc.getIncludesLocation();
|
if (newLocation != null) {
|
||||||
if (newLocation != null) {
|
String path= newLocation.getFullPath();
|
||||||
String path= newLocation.getFullPath();
|
if (path != null) {
|
||||||
if (path != null) {
|
IResource newResource= ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path));
|
||||||
IResource newResource= ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path));
|
MultiStatus m = areSynchronized(trail, index, newResource, newLocation);
|
||||||
if (!areSynchronized(trail, index, newResource, newLocation)) {
|
if (m != null) {
|
||||||
return false;
|
m.add(new Status(IStatus.INFO, CCorePlugin.PLUGIN_ID,
|
||||||
|
"Included by " + file.getLocation().getFullPath())); //$NON-NLS-1$
|
||||||
|
return m;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFileIndexedUnconditionally(IIndexFileLocation ifl) {
|
public boolean isFileIndexedUnconditionally(IIndexFileLocation ifl) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2009 Symbian Software Systems and others.
|
* Copyright (c) 2007, 2013 Symbian Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,11 +8,11 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Martin Oberhuber (Wind River) - [397652] fix up-to-date check for PDOM
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.export;
|
package org.eclipse.cdt.internal.core.pdom.export;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import com.ibm.icu.text.MessageFormat;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
@ -26,9 +26,12 @@ import org.eclipse.cdt.internal.core.pdom.WritablePDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.MultiStatus;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
|
||||||
|
import com.ibm.icu.text.MessageFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An ISafeRunnable which
|
* An ISafeRunnable which
|
||||||
* <ul>
|
* <ul>
|
||||||
|
@ -43,14 +46,28 @@ public class GeneratePDOM {
|
||||||
protected File targetLocation;
|
protected File targetLocation;
|
||||||
protected String indexerID;
|
protected String indexerID;
|
||||||
protected boolean deleteOnExit;
|
protected boolean deleteOnExit;
|
||||||
|
protected boolean checkIndexStatus;
|
||||||
public GeneratePDOM(IExportProjectProvider pm, String[] applicationArguments, File targetLocation, String indexerID) {
|
|
||||||
|
/**
|
||||||
|
* Runnable to export a PDOM.
|
||||||
|
* @param checkIndexStatus <code>true</code> to check index completeness before exporting, or
|
||||||
|
* <code>false</code> to export the index without checking anything
|
||||||
|
* @since 5.5
|
||||||
|
*/
|
||||||
|
public GeneratePDOM(IExportProjectProvider pm, String[] applicationArguments, File targetLocation,
|
||||||
|
String indexerID, boolean checkIndexStatus) {
|
||||||
this.pm= pm;
|
this.pm= pm;
|
||||||
this.applicationArguments= applicationArguments;
|
this.applicationArguments= applicationArguments;
|
||||||
this.targetLocation= targetLocation;
|
this.targetLocation= targetLocation;
|
||||||
this.indexerID= indexerID;
|
this.indexerID= indexerID;
|
||||||
|
this.checkIndexStatus= checkIndexStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GeneratePDOM(IExportProjectProvider pm, String[] applicationArguments, File targetLocation,
|
||||||
|
String indexerID) {
|
||||||
|
this(pm, applicationArguments, targetLocation, indexerID, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When set, the project created by the associated {@link IExportProjectProvider} will
|
* When set, the project created by the associated {@link IExportProjectProvider} will
|
||||||
* be deleted after {@link #run()} completes. By default this is not set.
|
* be deleted after {@link #run()} completes. By default this is not set.
|
||||||
|
@ -66,74 +83,77 @@ public class GeneratePDOM {
|
||||||
* @throws CoreException if an internal or invalid configuration error occurs
|
* @throws CoreException if an internal or invalid configuration error occurs
|
||||||
*/
|
*/
|
||||||
public final IStatus run() throws CoreException {
|
public final IStatus run() throws CoreException {
|
||||||
boolean isContentSynced= false;
|
// Create the project
|
||||||
|
|
||||||
// create the project
|
|
||||||
pm.setApplicationArguments(applicationArguments);
|
pm.setApplicationArguments(applicationArguments);
|
||||||
final ICProject cproject = pm.createProject();
|
final ICProject cproject = pm.createProject();
|
||||||
if(cproject==null) {
|
if (cproject == null) {
|
||||||
fail(MessageFormat.format(Messages.GeneratePDOM_ProjectProviderReturnedNullCProject,
|
fail(MessageFormat.format(Messages.GeneratePDOM_ProjectProviderReturnedNullCProject,
|
||||||
new Object [] {pm.getClass().getName()}));
|
new Object[] { pm.getClass().getName() }));
|
||||||
return null; // cannot be reached, inform the compiler
|
return null; // Cannot be reached, inform the compiler
|
||||||
}
|
}
|
||||||
|
|
||||||
IIndexLocationConverter converter= pm.getLocationConverter(cproject);
|
IIndexLocationConverter converter= pm.getLocationConverter(cproject);
|
||||||
if(converter==null) {
|
if (converter == null) {
|
||||||
fail(MessageFormat.format(Messages.GeneratePDOM_NullLocationConverter,
|
fail(MessageFormat.format(Messages.GeneratePDOM_NullLocationConverter,
|
||||||
new Object [] {pm.getClass().getName()}));
|
new Object[] { pm.getClass().getName() }));
|
||||||
}
|
}
|
||||||
|
|
||||||
// index the project
|
// Index the project
|
||||||
IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEXER_ID, indexerID);
|
IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEXER_ID, indexerID);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final IIndexManager im = CCorePlugin.getIndexManager();
|
final IIndexManager manager = CCorePlugin.getIndexManager();
|
||||||
for (int i = 0; i < 20; i++) {
|
for (int i = 0; i < 20; i++) {
|
||||||
if(CCoreInternals.getPDOMManager().isProjectRegistered(cproject)) {
|
if (CCoreInternals.getPDOMManager().isProjectRegistered(cproject)) {
|
||||||
im.joinIndexer(Integer.MAX_VALUE, new NullProgressMonitor());
|
manager.joinIndexer(Integer.MAX_VALUE, new NullProgressMonitor());
|
||||||
if (!im.isIndexerSetupPostponed(cproject)) {
|
if (!manager.isIndexerSetupPostponed(cproject)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check status
|
if (checkIndexStatus) {
|
||||||
isContentSynced= CCoreInternals.getPDOMManager().isProjectContentSynced(cproject);
|
// Check status
|
||||||
|
IStatus syncStatus = CCoreInternals.getPDOMManager().getProjectContentSyncState(cproject);
|
||||||
if(isContentSynced) {
|
if (syncStatus != null) {
|
||||||
// export a .pdom file
|
// Add message and error severity
|
||||||
CCoreInternals.getPDOMManager().exportProjectPDOM(cproject, targetLocation, converter);
|
IStatus myStatus = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, Messages.GeneratePDOM_Incomplete);
|
||||||
|
MultiStatus m = new MultiStatus(CCorePlugin.PLUGIN_ID, 1, new IStatus[] {myStatus, syncStatus},
|
||||||
// write properties to exported PDOM
|
Messages.GeneratePDOM_Incomplete, null);
|
||||||
WritablePDOM exportedPDOM= new WritablePDOM(targetLocation, converter, LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
|
// Log the status right away since legacy clients did not return any status details
|
||||||
exportedPDOM.acquireWriteLock(0);
|
CCorePlugin.log(m);
|
||||||
try {
|
return m;
|
||||||
Map<String,String> exportProperties= pm.getExportProperties();
|
|
||||||
if(exportProperties!=null) {
|
|
||||||
for(Map.Entry<String,String> entry : exportProperties.entrySet()) {
|
|
||||||
exportedPDOM.setProperty(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exportedPDOM.close();
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
exportedPDOM.releaseWriteLock();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Export a .pdom file
|
||||||
} catch(InterruptedException ie) {
|
CCoreInternals.getPDOMManager().exportProjectPDOM(cproject, targetLocation, converter);
|
||||||
|
|
||||||
|
// Write properties to exported PDOM
|
||||||
|
WritablePDOM exportedPDOM= new WritablePDOM(targetLocation, converter,
|
||||||
|
LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
|
||||||
|
exportedPDOM.acquireWriteLock(0);
|
||||||
|
try {
|
||||||
|
Map<String, String> exportProperties= pm.getExportProperties();
|
||||||
|
if (exportProperties != null) {
|
||||||
|
for(Map.Entry<String, String> entry : exportProperties.entrySet()) {
|
||||||
|
exportedPDOM.setProperty(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exportedPDOM.close();
|
||||||
|
} finally {
|
||||||
|
exportedPDOM.releaseWriteLock();
|
||||||
|
}
|
||||||
|
} catch (InterruptedException ie) {
|
||||||
String msg= MessageFormat.format(Messages.GeneratePDOM_GenericGenerationFailed, new Object[] {ie.getMessage()});
|
String msg= MessageFormat.format(Messages.GeneratePDOM_GenericGenerationFailed, new Object[] {ie.getMessage()});
|
||||||
throw new CoreException(CCorePlugin.createStatus(msg, ie));
|
throw new CoreException(CCorePlugin.createStatus(msg, ie));
|
||||||
} finally {
|
} finally {
|
||||||
if(deleteOnExit) {
|
if (deleteOnExit) {
|
||||||
cproject.getProject().delete(true, new NullProgressMonitor());
|
cproject.getProject().delete(true, new NullProgressMonitor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return isContentSynced ?
|
return new Status(IStatus.OK, CCorePlugin.PLUGIN_ID, Messages.GeneratePDOM_Success);
|
||||||
new Status(IStatus.OK, CCorePlugin.PLUGIN_ID, Messages.GeneratePDOM_Success)
|
|
||||||
: new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, Messages.GeneratePDOM_Incomplete);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fail(String message) throws CoreException {
|
private void fail(String message) throws CoreException {
|
||||||
|
|
|
@ -757,6 +757,30 @@
|
||||||
<simple name="valueName"/>
|
<simple name="valueName"/>
|
||||||
<simple name="appName"/>
|
<simple name="appName"/>
|
||||||
</processType>
|
</processType>
|
||||||
|
<processType
|
||||||
|
name="AddFiles2"
|
||||||
|
processRunner="org.eclipse.cdt.core.templateengine.process.processes.AddFiles">
|
||||||
|
<simple name="projectName"/>
|
||||||
|
<simple name="startPattern"/>
|
||||||
|
<simple name="endPattern"/>
|
||||||
|
<complexArray name="files">
|
||||||
|
<baseType>
|
||||||
|
<simple name="source"/>
|
||||||
|
<simple name="target"/>
|
||||||
|
<simple name="replaceable"/>
|
||||||
|
</baseType>
|
||||||
|
</complexArray>
|
||||||
|
</processType>
|
||||||
|
<processType
|
||||||
|
name="AddNature"
|
||||||
|
processRunner="org.eclipse.cdt.core.templateengine.process.processes.AddNature">
|
||||||
|
<simple
|
||||||
|
name="projectName">
|
||||||
|
</simple>
|
||||||
|
<simple
|
||||||
|
name="natureId">
|
||||||
|
</simple>
|
||||||
|
</processType>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.cdt.core.CProjectDescriptionStorage">
|
point="org.eclipse.cdt.core.CProjectDescriptionStorage">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2008 Symbian Software Limited and others.
|
* Copyright (c) 2007, 2013 Symbian Software Limited and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
* Bala Torati (Symbian) - Initial API and implementation
|
* Bala Torati (Symbian) - Initial API and implementation
|
||||||
* Mark Espiritu (VastSystems) - bug 215283
|
* Mark Espiritu (VastSystems) - bug 215283
|
||||||
* Raphael Zulliger (Indel AG) - [367482] fixed resource leak
|
* Raphael Zulliger (Indel AG) - [367482] fixed resource leak
|
||||||
|
* Doug Schaefer (QNX) - added different start and end patterns for macros
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.templateengine.process;
|
package org.eclipse.cdt.core.templateengine.process;
|
||||||
|
|
||||||
|
@ -77,21 +78,35 @@ public class ProcessHelper {
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public static Set<String> getReplaceKeys(String str) {
|
public static Set<String> getReplaceKeys(String str) {
|
||||||
|
return getReplaceKeys(str, START_PATTERN, END_PATTERN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns a vector of all replace marker strings. (e.g.,
|
||||||
|
* $(item), vector contains 'item' as one item) is the end pattern.
|
||||||
|
*
|
||||||
|
* @param str A given string possibly containing markers.
|
||||||
|
* @param startPattern token to start macro replacement
|
||||||
|
* @param endPattern token to end macro replacement
|
||||||
|
* @return the set of names occurring within markers
|
||||||
|
* @since 5.5
|
||||||
|
*/
|
||||||
|
public static Set<String> getReplaceKeys(String str, String startPattern, String endPattern) {
|
||||||
Set<String> replaceStrings = new HashSet<String>();
|
Set<String> replaceStrings = new HashSet<String>();
|
||||||
int start= 0;
|
int start= 0;
|
||||||
int end= 0;
|
int end= 0;
|
||||||
while ((start = str.indexOf(START_PATTERN, start)) >= 0) {
|
while ((start = str.indexOf(startPattern, start)) >= 0) {
|
||||||
end = str.indexOf(END_PATTERN, start);
|
end = str.indexOf(endPattern, start);
|
||||||
if (end != -1) {
|
if (end != -1) {
|
||||||
replaceStrings.add(str.substring(start + START_PATTERN.length(), end));
|
replaceStrings.add(str.substring(start + startPattern.length(), end));
|
||||||
start = end + END_PATTERN.length();
|
start = end + endPattern.length();
|
||||||
} else {
|
} else {
|
||||||
start++;
|
start++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return replaceStrings;
|
return replaceStrings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method takes a URL as parameter to read the contents, and to add
|
* This method takes a URL as parameter to read the contents, and to add
|
||||||
* into a string buffer.
|
* into a string buffer.
|
||||||
|
@ -183,12 +198,24 @@ public class ProcessHelper {
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public static String getValueAfterExpandingMacros(String string, Set<String> macros,
|
public static String getValueAfterExpandingMacros(String string, Set<String> macros, Map<String, String> valueStore) {
|
||||||
Map<String, String> valueStore) {
|
return getValueAfterExpandingMacros(string, macros, valueStore, START_PATTERN, END_PATTERN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @param macros
|
||||||
|
* @param valueStore
|
||||||
|
* @return the macro value after expanding the macros.
|
||||||
|
*
|
||||||
|
* @since 5.5
|
||||||
|
*/
|
||||||
|
public static String getValueAfterExpandingMacros(String string, Set<String> macros, Map<String, String> valueStore,
|
||||||
|
String startPattern, String endPattern) {
|
||||||
for (String key : macros) {
|
for (String key : macros) {
|
||||||
String value = valueStore.get(key);
|
String value = valueStore.get(key);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
string = string.replace(START_PATTERN + key + END_PATTERN, value);
|
string = string.replace(startPattern + key + endPattern, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return string;
|
return string;
|
||||||
|
@ -203,4 +230,5 @@ public class ProcessHelper {
|
||||||
public static String getReplaceMarker(String macro) {
|
public static String getReplaceMarker(String macro) {
|
||||||
return START_PATTERN + macro + END_PATTERN;
|
return START_PATTERN + macro + END_PATTERN;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2008 Symbian Software Limited and others.
|
* Copyright (c) 2007, 2013 Symbian Software Limited and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Bala Torati (Symbian) - Initial API and implementation
|
* Bala Torati (Symbian) - Initial API and implementation
|
||||||
|
* Doug Schaefer (QNX) - Added overridable start and end patterns
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.templateengine.process.processes;
|
package org.eclipse.cdt.core.templateengine.process.processes;
|
||||||
|
|
||||||
|
@ -29,7 +30,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds Files to the Project
|
* Adds Files to the Project
|
||||||
*/
|
*/
|
||||||
|
@ -40,9 +40,30 @@ public class AddFiles extends ProcessRunner {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {
|
public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {
|
||||||
String projectName = args[0].getSimpleValue();
|
IProject projectHandle = null;
|
||||||
IProject projectHandle = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
|
ProcessArgument[][] files = null;
|
||||||
ProcessArgument[][] files = args[1].getComplexArrayValue();
|
String startPattern = null;
|
||||||
|
String endPattern = null;
|
||||||
|
|
||||||
|
for (ProcessArgument arg : args) {
|
||||||
|
String argName = arg.getName();
|
||||||
|
if (argName.equals("projectName")) { //$NON-NLS-1$
|
||||||
|
projectHandle = ResourcesPlugin.getWorkspace().getRoot().getProject(arg.getSimpleValue());
|
||||||
|
} else if (argName.equals("files")) { //$NON-NLS-1$
|
||||||
|
files = arg.getComplexArrayValue();
|
||||||
|
} else if (argName.equals("startPattern")) { //$NON-NLS-1$
|
||||||
|
startPattern = arg.getSimpleValue();
|
||||||
|
} else if (argName.equals("endPattern")) { //$NON-NLS-1$
|
||||||
|
endPattern = arg.getSimpleValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (projectHandle == null)
|
||||||
|
throw new ProcessFailureException(getProcessMessage(processId, IStatus.ERROR, Messages.getString("AddFiles.8"))); //$NON-NLS-1$
|
||||||
|
|
||||||
|
if (files == null)
|
||||||
|
throw new ProcessFailureException(getProcessMessage(processId, IStatus.ERROR, Messages.getString("AddFiles.9"))); //$NON-NLS-1$
|
||||||
|
|
||||||
for(int i=0; i<files.length; i++) {
|
for(int i=0; i<files.length; i++) {
|
||||||
ProcessArgument[] file = files[i];
|
ProcessArgument[] file = files[i];
|
||||||
String fileSourcePath = file[0].getSimpleValue();
|
String fileSourcePath = file[0].getSimpleValue();
|
||||||
|
@ -67,7 +88,12 @@ public class AddFiles extends ProcessRunner {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ProcessFailureException(Messages.getString("AddFiles.3") + fileSourcePath); //$NON-NLS-1$
|
throw new ProcessFailureException(Messages.getString("AddFiles.3") + fileSourcePath); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
fileContents = ProcessHelper.getValueAfterExpandingMacros(fileContents, ProcessHelper.getReplaceKeys(fileContents), template.getValueStore());
|
if (startPattern != null && endPattern != null)
|
||||||
|
fileContents = ProcessHelper.getValueAfterExpandingMacros(fileContents, ProcessHelper.getReplaceKeys(fileContents, startPattern, endPattern), template.getValueStore(),
|
||||||
|
startPattern, endPattern);
|
||||||
|
else
|
||||||
|
fileContents = ProcessHelper.getValueAfterExpandingMacros(fileContents, ProcessHelper.getReplaceKeys(fileContents), template.getValueStore());
|
||||||
|
|
||||||
contents = new ByteArrayInputStream(fileContents.getBytes());
|
contents = new ByteArrayInputStream(fileContents.getBytes());
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Doug Schaefer (QNX) - Initial implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.core.templateengine.process.processes;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CProjectNature;
|
||||||
|
import org.eclipse.cdt.core.templateengine.TemplateCore;
|
||||||
|
import org.eclipse.cdt.core.templateengine.process.ProcessArgument;
|
||||||
|
import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
|
||||||
|
import org.eclipse.cdt.core.templateengine.process.ProcessRunner;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dschaefer
|
||||||
|
* @since 5.5
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class AddNature extends ProcessRunner {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {
|
||||||
|
IProject project = null;
|
||||||
|
String natureId = null;
|
||||||
|
|
||||||
|
for (ProcessArgument arg : args) {
|
||||||
|
String argName = arg.getName();
|
||||||
|
if (argName.equals("projectName")) //$NON-NLS-1$
|
||||||
|
project = ResourcesPlugin.getWorkspace().getRoot().getProject(arg.getSimpleValue());
|
||||||
|
else if (argName.equals("natureId")) //$NON-NLS-1$
|
||||||
|
natureId = arg.getSimpleValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (project == null)
|
||||||
|
throw new ProcessFailureException(getProcessMessage(processId, IStatus.ERROR, Messages.getString("AddNature.noProject"))); //$NON-NLS-1$
|
||||||
|
|
||||||
|
if (natureId == null)
|
||||||
|
throw new ProcessFailureException(getProcessMessage(processId, IStatus.ERROR, Messages.getString("AddNature.noNature"))); //$NON-NLS-1$
|
||||||
|
|
||||||
|
try {
|
||||||
|
CProjectNature.addNature(project, natureId, monitor);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
throw new ProcessFailureException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -9,13 +9,15 @@
|
||||||
# Bala Torati (Symbian) - Initial API and implementation
|
# Bala Torati (Symbian) - Initial API and implementation
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
AddFiles.1=Add File failure: template source not found:
|
AddFiles.1=Add Files failure: template source not found:
|
||||||
AddFiles.2=Add Files failure: template source not found:
|
AddFiles.2=Add Files failure: template source not found:
|
||||||
AddFiles.3=Add Files failure: cannot read template source:
|
AddFiles.3=Add Files failure: cannot read template source:
|
||||||
AddFiles.4=Add File failure: cannot read template source:
|
AddFiles.4=Add Files failure: cannot read template source:
|
||||||
AddFiles.5=Add Files failure: File already exists.
|
AddFiles.5=Add Files failure: File already exists.
|
||||||
AddFiles.6=Add Files failure:
|
AddFiles.6=Add Files failure:
|
||||||
AddFiles.7=Add Files failure:
|
AddFiles.7=Add Files failure:
|
||||||
|
AddFiles.8=Add Files failure: projectName not specified
|
||||||
|
AddFiles.9=Add Files failure: No files
|
||||||
AddFile.0=Add File failure: template source not found:
|
AddFile.0=Add File failure: template source not found:
|
||||||
AddFile.1=Add File failure: template source not found:
|
AddFile.1=Add File failure: template source not found:
|
||||||
AddFile.2=Add File failure: cannot read template source:
|
AddFile.2=Add File failure: cannot read template source:
|
||||||
|
@ -53,3 +55,5 @@ Append.0=Add File failure: template source not found:
|
||||||
Append.1=Copy failure: template source not found:
|
Append.1=Copy failure: template source not found:
|
||||||
Append.3=Copy failure: cannot read template source:
|
Append.3=Copy failure: cannot read template source:
|
||||||
Append.4=Append failure: failed while trying to append contents.
|
Append.4=Append failure: failed while trying to append contents.
|
||||||
|
AddNature.noProject=Add nature failure: projectName not specified
|
||||||
|
AddNature.noNature=Add nature failure: nature not specified
|
||||||
|
|
|
@ -20,7 +20,7 @@ import junit.framework.TestSuite;
|
||||||
import org.eclipse.jface.text.IRegion;
|
import org.eclipse.jface.text.IRegion;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.parser.tests.ast2.AST2BaseTest;
|
import org.eclipse.cdt.core.parser.tests.ast2.AST2TestBase;
|
||||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||||
import org.eclipse.cdt.ui.testplugin.CTestPlugin;
|
import org.eclipse.cdt.ui.testplugin.CTestPlugin;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ import org.eclipse.cdt.internal.ui.search.LinkedNamesFinder;
|
||||||
/**
|
/**
|
||||||
* Tests for LinkedNamesFinder class.
|
* Tests for LinkedNamesFinder class.
|
||||||
*/
|
*/
|
||||||
public class LinkedNamesFinderTest extends AST2BaseTest {
|
public class LinkedNamesFinderTest extends AST2TestBase {
|
||||||
private static class RegionComparator implements Comparator<IRegion> {
|
private static class RegionComparator implements Comparator<IRegion> {
|
||||||
@Override
|
@Override
|
||||||
public int compare(IRegion r1, IRegion r2) {
|
public int compare(IRegion r1, IRegion r2) {
|
||||||
|
|
|
@ -432,7 +432,7 @@ public class CIndenterTest extends BaseUITestCase {
|
||||||
//class MyClass {
|
//class MyClass {
|
||||||
//typedef int MyType;
|
//typedef int MyType;
|
||||||
//public:
|
//public:
|
||||||
//int getA() {
|
//virtual int getA() {
|
||||||
//return a;
|
//return a;
|
||||||
//}
|
//}
|
||||||
//MyClass();
|
//MyClass();
|
||||||
|
@ -444,7 +444,7 @@ public class CIndenterTest extends BaseUITestCase {
|
||||||
//class MyClass {
|
//class MyClass {
|
||||||
// typedef int MyType;
|
// typedef int MyType;
|
||||||
// public:
|
// public:
|
||||||
// int getA() {
|
// virtual int getA() {
|
||||||
// return a;
|
// return a;
|
||||||
// }
|
// }
|
||||||
// MyClass();
|
// MyClass();
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2011 IBM Corporation and others.
|
* Copyright (c) 2000, 2011 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
|
@ -28,26 +28,21 @@ import org.eclipse.cdt.ui.text.ICPartitions;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.text.CTextTools;
|
import org.eclipse.cdt.internal.ui.text.CTextTools;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests to verify the C partitioning.
|
* Tests to verify the C partitioning.
|
||||||
* Derived from JavaPartitionerTest.
|
* Derived from JavaPartitionerTest.
|
||||||
*/
|
*/
|
||||||
public class CPartitionerTest extends TestCase {
|
public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
private CTextTools fTextTools;
|
private CTextTools fTextTools;
|
||||||
private Document fDocument;
|
private Document fDocument;
|
||||||
protected boolean fDocumentPartitioningChanged;
|
protected boolean fDocumentPartitioningChanged;
|
||||||
|
|
||||||
|
|
||||||
public CPartitionerTest(String name) {
|
public CPartitionerTest(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() {
|
protected void setUp() {
|
||||||
|
|
||||||
fTextTools= new CTextTools();
|
fTextTools= new CTextTools();
|
||||||
|
|
||||||
fDocument= new Document();
|
fDocument= new Document();
|
||||||
|
@ -84,7 +79,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkPartitioning(ITypedRegion[] expectation, ITypedRegion[] result) {
|
protected void checkPartitioning(ITypedRegion[] expectation, ITypedRegion[] result) {
|
||||||
|
|
||||||
assertEquals("invalid number of partitions", expectation.length, result.length);
|
assertEquals("invalid number of partitions", expectation.length, result.length);
|
||||||
|
|
||||||
for (int i= 0; i < expectation.length; i++) {
|
for (int i= 0; i < expectation.length; i++) {
|
||||||
|
@ -92,12 +86,10 @@ public class CPartitionerTest extends TestCase {
|
||||||
ITypedRegion r= result[i];
|
ITypedRegion r= result[i];
|
||||||
assertTrue(print(r) + " != " + print(e), r.equals(e));
|
assertTrue(print(r) + " != " + print(e), r.equals(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInitialPartitioning() {
|
public void testInitialPartitioning() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***/\nxxx"
|
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***/\nxxx"
|
||||||
|
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
|
@ -121,7 +113,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testIntraPartitionChange() {
|
public void testIntraPartitionChange() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(34, 3, "y");
|
fDocument.replace(34, 3, "y");
|
||||||
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\ny\n/***/\nxxx");
|
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\ny\n/***/\nxxx");
|
||||||
|
|
||||||
|
@ -148,7 +139,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testIntraPartitionChange2() {
|
public void testIntraPartitionChange2() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(41, 0, "yyy");
|
fDocument.replace(41, 0, "yyy");
|
||||||
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/**yyy*/\nxxx");
|
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/**yyy*/\nxxx");
|
||||||
|
|
||||||
|
@ -172,9 +162,9 @@ public class CPartitionerTest extends TestCase {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInsertNewPartition() {
|
public void testInsertNewPartition() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(35, 1, "/***/");
|
fDocument.replace(35, 1, "/***/");
|
||||||
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nx/***/x\n/***/\nxxx");
|
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nx/***/x\n/***/\nxxx");
|
||||||
|
|
||||||
|
@ -200,9 +190,9 @@ public class CPartitionerTest extends TestCase {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInsertStringPartition() {
|
public void testInsertStringPartition() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(35, 1, "\"yyy\"");
|
fDocument.replace(35, 1, "\"yyy\"");
|
||||||
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nx\"yyy\"x\n/***/\nxxx");
|
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nx\"yyy\"x\n/***/\nxxx");
|
||||||
|
|
||||||
|
@ -228,9 +218,9 @@ public class CPartitionerTest extends TestCase {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInsertCharacterPartition() {
|
public void testInsertCharacterPartition() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(35, 1, "'y'");
|
fDocument.replace(35, 1, "'y'");
|
||||||
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nx\"yyy\"x\n/***/\nxxx");
|
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nx\"yyy\"x\n/***/\nxxx");
|
||||||
|
|
||||||
|
@ -256,9 +246,9 @@ public class CPartitionerTest extends TestCase {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInsertPreprocessorPartition() {
|
public void testInsertPreprocessorPartition() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(4, 0, " # include <x.h>\n");
|
fDocument.replace(4, 0, " # include <x.h>\n");
|
||||||
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nx\"yyy\"x\n/***/\nxxx");
|
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nx\"yyy\"x\n/***/\nxxx");
|
||||||
// "xxx\n # include <x.h>\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nx\"yyy\"x\n/***/\nxxx");
|
// "xxx\n # include <x.h>\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nx\"yyy\"x\n/***/\nxxx");
|
||||||
|
@ -287,13 +277,11 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testRemovePartition1() {
|
public void testRemovePartition1() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(13, 16, null);
|
fDocument.replace(13, 16, null);
|
||||||
// "xxx\n/*xxx*/\nx/**/\nxxx\n/***/\nxxx");
|
// "xxx\n/*xxx*/\nx/**/\nxxx\n/***/\nxxx");
|
||||||
|
|
||||||
assertTrue(fDocumentPartitioningChanged);
|
assertTrue(fDocumentPartitioningChanged);
|
||||||
|
|
||||||
|
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
TypedRegion[] expectation= {
|
TypedRegion[] expectation= {
|
||||||
new TypedRegion(0, 4, IDocument.DEFAULT_CONTENT_TYPE),
|
new TypedRegion(0, 4, IDocument.DEFAULT_CONTENT_TYPE),
|
||||||
|
@ -312,12 +300,10 @@ public class CPartitionerTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRemovePartition2() {
|
public void testRemovePartition2() {
|
||||||
|
|
||||||
testJoinPartition3();
|
testJoinPartition3();
|
||||||
fDocumentPartitioningChanged= false;
|
fDocumentPartitioningChanged= false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(5, 2, null);
|
fDocument.replace(5, 2, null);
|
||||||
// "xxx\nxxx\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***/\nxxx"
|
// "xxx\nxxx\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***/\nxxx"
|
||||||
|
|
||||||
|
@ -340,10 +326,8 @@ public class CPartitionerTest extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testJoinPartitions1() {
|
public void testJoinPartitions1() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(31, 1, null);
|
fDocument.replace(31, 1, null);
|
||||||
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/*/\nxxx\n/***/\nxxx"
|
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/*/\nxxx\n/***/\nxxx"
|
||||||
|
|
||||||
|
@ -368,7 +352,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testJoinPartitions2() {
|
public void testJoinPartitions2() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(32, 1, null);
|
fDocument.replace(32, 1, null);
|
||||||
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**\nxxx\n/***/\nxxx"
|
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**\nxxx\n/***/\nxxx"
|
||||||
|
|
||||||
|
@ -393,7 +376,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testJoinPartition3() {
|
public void testJoinPartition3() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(9, 2, null);
|
fDocument.replace(9, 2, null);
|
||||||
// "xxx\n/*xxx\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***/\nxxx"
|
// "xxx\n/*xxx\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***/\nxxx"
|
||||||
|
|
||||||
|
@ -416,22 +398,16 @@ public class CPartitionerTest extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testSplitPartition1() {
|
public void testSplitPartition1() {
|
||||||
|
|
||||||
testJoinPartitions1();
|
testJoinPartitions1();
|
||||||
fDocumentPartitioningChanged= false;
|
fDocumentPartitioningChanged= false;
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/*/\nxxx\n/***/\nxxx"
|
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/*/\nxxx\n/***/\nxxx"
|
||||||
fDocument.replace(31, 0, "*");
|
fDocument.replace(31, 0, "*");
|
||||||
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***/\nxxx"
|
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***/\nxxx"
|
||||||
|
|
||||||
assertTrue(fDocumentPartitioningChanged);
|
assertTrue(fDocumentPartitioningChanged);
|
||||||
|
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -440,18 +416,15 @@ public class CPartitionerTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSplitPartition2() {
|
public void testSplitPartition2() {
|
||||||
|
|
||||||
testJoinPartitions2();
|
testJoinPartitions2();
|
||||||
fDocumentPartitioningChanged= false;
|
fDocumentPartitioningChanged= false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**\nxxx\n/***/\nxxx"
|
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**\nxxx\n/***/\nxxx"
|
||||||
fDocument.replace(32, 0, "/");
|
fDocument.replace(32, 0, "/");
|
||||||
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***/\nxxx"
|
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***/\nxxx"
|
||||||
|
|
||||||
assertTrue(fDocumentPartitioningChanged);
|
assertTrue(fDocumentPartitioningChanged);
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -460,11 +433,9 @@ public class CPartitionerTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSplitPartition3() {
|
public void testSplitPartition3() {
|
||||||
|
|
||||||
fDocumentPartitioningChanged= false;
|
fDocumentPartitioningChanged= false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***/\nxxx"
|
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***/\nxxx"
|
||||||
fDocument.replace(12, 9, "");
|
fDocument.replace(12, 9, "");
|
||||||
// "xxx\n/*xxx*/\nx*/\nxxx\n/**/\nxxx\n/***/\nxxx"
|
// "xxx\n/*xxx*/\nx*/\nxxx\n/**/\nxxx\n/***/\nxxx"
|
||||||
|
@ -490,7 +461,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testCorruptPartitioning1() {
|
public void testCorruptPartitioning1() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(0, fDocument.getLength(), "/***/\n/***/");
|
fDocument.replace(0, fDocument.getLength(), "/***/\n/***/");
|
||||||
|
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
|
@ -513,7 +483,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
new TypedRegion(14, 1, IDocument.DEFAULT_CONTENT_TYPE),
|
new TypedRegion(14, 1, IDocument.DEFAULT_CONTENT_TYPE),
|
||||||
new TypedRegion(15, 7, ICPartitions.C_MULTI_LINE_COMMENT)
|
new TypedRegion(15, 7, ICPartitions.C_MULTI_LINE_COMMENT)
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -521,7 +490,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testCorruptPartitioning2() {
|
public void testCorruptPartitioning2() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(0, fDocument.getLength(), "/***/\n/***/\n/***/");
|
fDocument.replace(0, fDocument.getLength(), "/***/\n/***/\n/***/");
|
||||||
|
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
|
@ -548,7 +516,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
new TypedRegion(22, 1, IDocument.DEFAULT_CONTENT_TYPE),
|
new TypedRegion(22, 1, IDocument.DEFAULT_CONTENT_TYPE),
|
||||||
new TypedRegion(23, 5, ICPartitions.C_MULTI_LINE_COMMENT)
|
new TypedRegion(23, 5, ICPartitions.C_MULTI_LINE_COMMENT)
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -556,7 +523,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testCorruptPartitioning3() {
|
public void testCorruptPartitioning3() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(0, fDocument.getLength(), "/***/\n/**/");
|
fDocument.replace(0, fDocument.getLength(), "/***/\n/**/");
|
||||||
|
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
|
@ -581,7 +547,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
new TypedRegion(17, 1, IDocument.DEFAULT_CONTENT_TYPE),
|
new TypedRegion(17, 1, IDocument.DEFAULT_CONTENT_TYPE),
|
||||||
new TypedRegion(18, 5, ICPartitions.C_MULTI_LINE_COMMENT)
|
new TypedRegion(18, 5, ICPartitions.C_MULTI_LINE_COMMENT)
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -589,7 +554,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testOpenPartition1() {
|
public void testOpenPartition1() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(42, 1, null);
|
fDocument.replace(42, 1, null);
|
||||||
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***\nxxx"
|
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***\nxxx"
|
||||||
|
|
||||||
|
@ -616,7 +580,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testOpenPartition2() {
|
public void testOpenPartition2() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(47, 0, "/*");
|
fDocument.replace(47, 0, "/*");
|
||||||
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***/\nxxx/*"
|
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***/\nxxx/*"
|
||||||
|
|
||||||
|
@ -646,7 +609,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testPartitionFinder() {
|
public void testPartitionFinder() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
ITypedRegion[] partitioning= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] partitioning= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
|
|
||||||
for (int i= 0; i < partitioning.length; i++) {
|
for (int i= 0; i < partitioning.length; i++) {
|
||||||
|
@ -656,7 +618,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
assertTrue(expected.equals(result));
|
assertTrue(expected.equals(result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -664,7 +625,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testExtendPartition() {
|
public void testExtendPartition() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(0, fDocument.getLength(), "/*");
|
fDocument.replace(0, fDocument.getLength(), "/*");
|
||||||
|
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
|
@ -681,7 +641,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
};
|
};
|
||||||
|
|
||||||
checkPartitioning(expectation, result);
|
checkPartitioning(expectation, result);
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -689,7 +648,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testTogglePartition() {
|
public void testTogglePartition() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(0, fDocument.getLength(), "\t/*\n\tx\n\t/*/\n\ty\n//\t*/");
|
fDocument.replace(0, fDocument.getLength(), "\t/*\n\tx\n\t/*/\n\ty\n//\t*/");
|
||||||
|
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
|
@ -712,7 +670,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
new TypedRegion(10, 12, ICPartitions.C_MULTI_LINE_COMMENT)
|
new TypedRegion(10, 12, ICPartitions.C_MULTI_LINE_COMMENT)
|
||||||
};
|
};
|
||||||
checkPartitioning(expectation2, result);
|
checkPartitioning(expectation2, result);
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -720,7 +677,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testEditing1() {
|
public void testEditing1() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(0, fDocument.getLength(), "");
|
fDocument.replace(0, fDocument.getLength(), "");
|
||||||
|
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
|
@ -749,7 +705,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
};
|
};
|
||||||
checkPartitioning(expectation, result);
|
checkPartitioning(expectation, result);
|
||||||
|
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -757,7 +712,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testEditing2() {
|
public void testEditing2() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(0, fDocument.getLength(), "");
|
fDocument.replace(0, fDocument.getLength(), "");
|
||||||
|
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
|
@ -794,7 +748,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
new TypedRegion(0, fDocument.getLength(), ICPartitions.C_MULTI_LINE_COMMENT)
|
new TypedRegion(0, fDocument.getLength(), ICPartitions.C_MULTI_LINE_COMMENT)
|
||||||
};
|
};
|
||||||
checkPartitioning(expectation, result);
|
checkPartitioning(expectation, result);
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -802,7 +755,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testEditing3() {
|
public void testEditing3() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(0, fDocument.getLength(), "");
|
fDocument.replace(0, fDocument.getLength(), "");
|
||||||
|
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
|
@ -831,7 +783,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
new TypedRegion(8, 1, IDocument.DEFAULT_CONTENT_TYPE)
|
new TypedRegion(8, 1, IDocument.DEFAULT_CONTENT_TYPE)
|
||||||
};
|
};
|
||||||
checkPartitioning(expectation, result);
|
checkPartitioning(expectation, result);
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -839,7 +790,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testEditingString() {
|
public void testEditingString() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(0, fDocument.getLength(), "");
|
fDocument.replace(0, fDocument.getLength(), "");
|
||||||
|
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
|
@ -904,7 +854,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
new TypedRegion(5, 2, ICPartitions.C_STRING)
|
new TypedRegion(5, 2, ICPartitions.C_STRING)
|
||||||
};
|
};
|
||||||
checkPartitioning(expectation, result);
|
checkPartitioning(expectation, result);
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -912,7 +861,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testEditingCharacter() {
|
public void testEditingCharacter() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(0, fDocument.getLength(), "");
|
fDocument.replace(0, fDocument.getLength(), "");
|
||||||
|
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
|
@ -977,7 +925,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
new TypedRegion(5, 2, ICPartitions.C_CHARACTER)
|
new TypedRegion(5, 2, ICPartitions.C_CHARACTER)
|
||||||
};
|
};
|
||||||
checkPartitioning(expectation, result);
|
checkPartitioning(expectation, result);
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -985,7 +932,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testEditingPreprocessor() {
|
public void testEditingPreprocessor() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(0, fDocument.getLength(), "");
|
fDocument.replace(0, fDocument.getLength(), "");
|
||||||
|
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
|
@ -1096,7 +1042,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
new TypedRegion(33, 1, IDocument.DEFAULT_CONTENT_TYPE)
|
new TypedRegion(33, 1, IDocument.DEFAULT_CONTENT_TYPE)
|
||||||
};
|
};
|
||||||
checkPartitioning(expectation, result);
|
checkPartitioning(expectation, result);
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -1104,7 +1049,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testLineSplicing_Bug124113() {
|
public void testLineSplicing_Bug124113() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(0, fDocument.getLength(), "// comment... \\\\\ncontinued");
|
fDocument.replace(0, fDocument.getLength(), "// comment... \\\\\ncontinued");
|
||||||
|
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
|
@ -1136,7 +1080,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
new TypedRegion(0, fDocument.getLength(), ICPartitions.C_CHARACTER)
|
new TypedRegion(0, fDocument.getLength(), ICPartitions.C_CHARACTER)
|
||||||
};
|
};
|
||||||
checkPartitioning(expectation, result);
|
checkPartitioning(expectation, result);
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -1144,7 +1087,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testCommentInPreprocessorString() {
|
public void testCommentInPreprocessorString() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(0, fDocument.getLength(), "#define S \"http://www.foo.bar\"");
|
fDocument.replace(0, fDocument.getLength(), "#define S \"http://www.foo.bar\"");
|
||||||
|
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
|
@ -1160,7 +1102,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
new TypedRegion(0, fDocument.getLength(), ICPartitions.C_PREPROCESSOR)
|
new TypedRegion(0, fDocument.getLength(), ICPartitions.C_PREPROCESSOR)
|
||||||
};
|
};
|
||||||
checkPartitioning(expectation, result);
|
checkPartitioning(expectation, result);
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -1168,7 +1109,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testString1() {
|
public void testString1() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(0, fDocument.getLength(), "\"[string]\"");
|
fDocument.replace(0, fDocument.getLength(), "\"[string]\"");
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
TypedRegion[] expectation= {
|
TypedRegion[] expectation= {
|
||||||
|
@ -1184,7 +1124,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
new TypedRegion(10, 9, ICPartitions.C_STRING)
|
new TypedRegion(10, 9, ICPartitions.C_STRING)
|
||||||
};
|
};
|
||||||
checkPartitioning(expectation, result);
|
checkPartitioning(expectation, result);
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -1192,7 +1131,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testString2() {
|
public void testString2() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(0, fDocument.getLength(), "\"string\"RRRRRRRR\"string\"nostring");
|
fDocument.replace(0, fDocument.getLength(), "\"string\"RRRRRRRR\"string\"nostring");
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
TypedRegion[] expectation= {
|
TypedRegion[] expectation= {
|
||||||
|
@ -1202,7 +1140,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
new TypedRegion(24, 8, IDocument.DEFAULT_CONTENT_TYPE)
|
new TypedRegion(24, 8, IDocument.DEFAULT_CONTENT_TYPE)
|
||||||
};
|
};
|
||||||
checkPartitioning(expectation, result);
|
checkPartitioning(expectation, result);
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -1210,7 +1147,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testRawString1() {
|
public void testRawString1() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(0, fDocument.getLength(), "R\"(line 1\n/*line 2*/\nline 3\n)\"");
|
fDocument.replace(0, fDocument.getLength(), "R\"(line 1\n/*line 2*/\nline 3\n)\"");
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
TypedRegion[] expectation= {
|
TypedRegion[] expectation= {
|
||||||
|
@ -1235,7 +1171,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
new TypedRegion(1, fDocument.getLength() - 1, ICPartitions.C_STRING)
|
new TypedRegion(1, fDocument.getLength() - 1, ICPartitions.C_STRING)
|
||||||
};
|
};
|
||||||
checkPartitioning(expectation, result);
|
checkPartitioning(expectation, result);
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -1243,7 +1178,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testRawString2() {
|
public void testRawString2() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(0, fDocument.getLength(), "/***/R\"(line 1\nline 2\nline 3\n)\"");
|
fDocument.replace(0, fDocument.getLength(), "/***/R\"(line 1\nline 2\nline 3\n)\"");
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
TypedRegion[] expectation= {
|
TypedRegion[] expectation= {
|
||||||
|
@ -1261,7 +1195,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
new TypedRegion(13, fDocument.getLength() - 13, ICPartitions.C_STRING)
|
new TypedRegion(13, fDocument.getLength() - 13, ICPartitions.C_STRING)
|
||||||
};
|
};
|
||||||
checkPartitioning(expectation, result);
|
checkPartitioning(expectation, result);
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -1269,7 +1202,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testRawString3() {
|
public void testRawString3() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(0, fDocument.getLength(), "/***/R\"(line 1\nline 2\nline 3\n)\" \"str\"");
|
fDocument.replace(0, fDocument.getLength(), "/***/R\"(line 1\nline 2\nline 3\n)\" \"str\"");
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
TypedRegion[] expectation= {
|
TypedRegion[] expectation= {
|
||||||
|
@ -1291,7 +1223,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
new TypedRegion(fDocument.getLength() - 5, 5, ICPartitions.C_STRING),
|
new TypedRegion(fDocument.getLength() - 5, 5, ICPartitions.C_STRING),
|
||||||
};
|
};
|
||||||
checkPartitioning(expectation, result);
|
checkPartitioning(expectation, result);
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -1299,7 +1230,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testRawString_Bug352544() {
|
public void testRawString_Bug352544() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(0, fDocument.getLength(), "BAR\"(\";");
|
fDocument.replace(0, fDocument.getLength(), "BAR\"(\";");
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
TypedRegion[] expectation= {
|
TypedRegion[] expectation= {
|
||||||
|
@ -1308,7 +1238,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
new TypedRegion(6, 1, IDocument.DEFAULT_CONTENT_TYPE),
|
new TypedRegion(6, 1, IDocument.DEFAULT_CONTENT_TYPE),
|
||||||
};
|
};
|
||||||
checkPartitioning(expectation, result);
|
checkPartitioning(expectation, result);
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -1316,7 +1245,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testEditingRawString1() {
|
public void testEditingRawString1() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(0, fDocument.getLength(), "/***/R\"(line 1\nline 2\nline 3\n)\" \"str\"");
|
fDocument.replace(0, fDocument.getLength(), "/***/R\"(line 1\nline 2\nline 3\n)\" \"str\"");
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
TypedRegion[] expectation= {
|
TypedRegion[] expectation= {
|
||||||
|
@ -1351,7 +1279,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
new TypedRegion(fDocument.getLength() - 5, 5, ICPartitions.C_STRING),
|
new TypedRegion(fDocument.getLength() - 5, 5, ICPartitions.C_STRING),
|
||||||
};
|
};
|
||||||
checkPartitioning(expectation, result);
|
checkPartitioning(expectation, result);
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -1359,7 +1286,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testEditingRawString2() {
|
public void testEditingRawString2() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fDocument.replace(0, fDocument.getLength(), "/***/R\"(line 1\nline 2\nline 3\n)\" \"str\"");
|
fDocument.replace(0, fDocument.getLength(), "/***/R\"(line 1\nline 2\nline 3\n)\" \"str\"");
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
TypedRegion[] expectation= {
|
TypedRegion[] expectation= {
|
||||||
|
@ -1402,7 +1328,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
new TypedRegion(6, fDocument.getLength() - 6, ICPartitions.C_STRING),
|
new TypedRegion(6, fDocument.getLength() - 6, ICPartitions.C_STRING),
|
||||||
};
|
};
|
||||||
checkPartitioning(expectation, result);
|
checkPartitioning(expectation, result);
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -1410,8 +1335,7 @@ public class CPartitionerTest extends TestCase {
|
||||||
|
|
||||||
public void testEditingRawString3() {
|
public void testEditingRawString3() {
|
||||||
try {
|
try {
|
||||||
|
fDocument.replace(0, fDocument.getLength(), "/***/R\"\"(line 1\nline 2\nline 3\n)\"\" \"str\"");
|
||||||
fDocument.replace(0, fDocument.getLength(), "/***/R\"(line 1\nline 2\nline 3\n)\" \"str\"");
|
|
||||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||||
TypedRegion[] expectation= {
|
TypedRegion[] expectation= {
|
||||||
new TypedRegion(0, 5, ICPartitions.C_MULTI_LINE_COMMENT),
|
new TypedRegion(0, 5, ICPartitions.C_MULTI_LINE_COMMENT),
|
||||||
|
@ -1433,7 +1357,6 @@ public class CPartitionerTest extends TestCase {
|
||||||
new TypedRegion(fDocument.getLength() - 5, 5, ICPartitions.C_STRING),
|
new TypedRegion(fDocument.getLength() - 5, 5, ICPartitions.C_STRING),
|
||||||
};
|
};
|
||||||
checkPartitioning(expectation, result);
|
checkPartitioning(expectation, result);
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2011 IBM Corporation and others.
|
* Copyright (c) 2000, 2013 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
|
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
@ -20,13 +20,12 @@ import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Semantic highlighting tests.
|
* Semantic highlighting tests.
|
||||||
*
|
*
|
||||||
* <p>Derived from JDT.<p>
|
* <p>Derived from JDT.<p>
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
|
|
||||||
private static final boolean PRINT_POSITIONS= false;
|
private static final boolean PRINT_POSITIONS= false;
|
||||||
|
|
||||||
private static final Class<?> THIS= SemanticHighlightingTest.class;
|
private static final Class<?> THIS= SemanticHighlightingTest.class;
|
||||||
|
@ -101,7 +100,7 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
createPosition(108, 4, 26),
|
createPosition(108, 4, 26),
|
||||||
createPosition(112, 4, 25),
|
createPosition(112, 4, 25),
|
||||||
createPosition(117, 4, 32),
|
createPosition(117, 4, 32),
|
||||||
};
|
};
|
||||||
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
@ -121,10 +120,9 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
createPosition(108, 4, 26),
|
createPosition(108, 4, 26),
|
||||||
createPosition(112, 4, 25),
|
createPosition(112, 4, 25),
|
||||||
createPosition(117, 4, 32),
|
createPosition(117, 4, 32),
|
||||||
createPosition(118, 23, 9),
|
|
||||||
createPosition(122, 4, 15),
|
createPosition(122, 4, 15),
|
||||||
createPosition(130, 13, 9),
|
createPosition(130, 13, 9),
|
||||||
};
|
};
|
||||||
Position[] actual= getSemanticHighlightingPositions();
|
Position[] actual= getSemanticHighlightingPositions();
|
||||||
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
|
@ -134,7 +132,7 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
setUpSemanticHighlighting(SemanticHighlightings.STATIC_METHOD_INVOCATION);
|
setUpSemanticHighlighting(SemanticHighlightings.STATIC_METHOD_INVOCATION);
|
||||||
Position[] expected= new Position[] {
|
Position[] expected= new Position[] {
|
||||||
createPosition(122, 4, 15),
|
createPosition(122, 4, 15),
|
||||||
};
|
};
|
||||||
Position[] actual= getSemanticHighlightingPositions();
|
Position[] actual= getSemanticHighlightingPositions();
|
||||||
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
|
@ -256,6 +254,7 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
createPosition(112, 4, 14),
|
createPosition(112, 4, 14),
|
||||||
createPosition(117, 4, 14),
|
createPosition(117, 4, 14),
|
||||||
createPosition(118, 4, 9),
|
createPosition(118, 4, 9),
|
||||||
|
createPosition(118, 23, 9),
|
||||||
createPosition(120, 4, 8),
|
createPosition(120, 4, 8),
|
||||||
createPosition(129, 4, 8),
|
createPosition(129, 4, 8),
|
||||||
createPosition(147, 42, 7),
|
createPosition(147, 42, 7),
|
||||||
|
@ -297,7 +296,6 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testGlobalVariableHighlighting() throws Exception {
|
public void testGlobalVariableHighlighting() throws Exception {
|
||||||
setUpSemanticHighlighting(SemanticHighlightings.GLOBAL_VARIABLE);
|
setUpSemanticHighlighting(SemanticHighlightings.GLOBAL_VARIABLE);
|
||||||
Position[] actual= getSemanticHighlightingPositions();
|
Position[] actual= getSemanticHighlightingPositions();
|
||||||
|
@ -421,5 +419,4 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -608,6 +608,8 @@ excludedFile.name = C/C++ Files and Folders Excluded from Build
|
||||||
excludedFile.description = Decorates source files and folders excluded from C/C++ build.
|
excludedFile.description = Decorates source files and folders excluded from C/C++ build.
|
||||||
includeFolderDecorator.name = C/C++ Missing Include Folders
|
includeFolderDecorator.name = C/C++ Missing Include Folders
|
||||||
includeFolderDecorator.description = Decorates missing include folders with error/warning indicator.
|
includeFolderDecorator.description = Decorates missing include folders with error/warning indicator.
|
||||||
|
CustomBuildSettingsDecorator.name= C/C++ Files and Folders with Customized Build Settings
|
||||||
|
CustomBuildSettingsDecorator.description= Decorates files and folders when build settings are different from parent resource.
|
||||||
|
|
||||||
templatesViewName= Templates
|
templatesViewName= Templates
|
||||||
|
|
||||||
|
@ -629,9 +631,11 @@ LanguageSettingsProviderAssociationExtensionPoint=Language Settings Provider UI
|
||||||
overrideAnnotation.label = C/C++ Override indicators
|
overrideAnnotation.label = C/C++ Override indicators
|
||||||
|
|
||||||
transfer.EditorAppearance.name = C/C++ Editor Appearance
|
transfer.EditorAppearance.name = C/C++ Editor Appearance
|
||||||
transfer.EditorAppearance.description = Preference related to how the editor presents the edited code to the user (including colors, fonts, hovers, foldings, etc...)
|
transfer.EditorAppearance.description = Preferences related to how the editor presents the edited code to the user (including colors, fonts, hovers, foldings, etc...)
|
||||||
transfer.EditorBehavior.name = C/C++ Editor Behavior
|
transfer.EditorBehavior.name = C/C++ Editor Behavior
|
||||||
transfer.EditorBehavior.description = Preference related to how the editor process the edited code (typing, save action, etc...)
|
transfer.EditorBehavior.description = Preferences related to how the editor deals with the edited code (typing, save action, etc...)
|
||||||
|
transfer.CodeStyle.name = C/C++ Code Style
|
||||||
|
transfer.CodeStyle.description = C/C++ > Code Style preferences
|
||||||
|
|
||||||
# Refresh Exclusion Contributors
|
# Refresh Exclusion Contributors
|
||||||
RefreshExclusionContributor.name = Resources
|
RefreshExclusionContributor.name = Resources
|
||||||
|
|
|
@ -4167,6 +4167,22 @@
|
||||||
</or>
|
</or>
|
||||||
</enablement>
|
</enablement>
|
||||||
</decorator>
|
</decorator>
|
||||||
|
<decorator
|
||||||
|
adaptable="true"
|
||||||
|
class="org.eclipse.cdt.internal.ui.viewsupport.CustomBuildSettingsDecorator"
|
||||||
|
id="org.eclipse.cdt.internal.ui.CustomBuildSettingsDecorator"
|
||||||
|
label="%CustomBuildSettingsDecorator.name"
|
||||||
|
lightweight="true"
|
||||||
|
location="TOP_RIGHT"
|
||||||
|
state="true">
|
||||||
|
<description>%CustomBuildSettingsDecorator.description</description>
|
||||||
|
<enablement>
|
||||||
|
<or>
|
||||||
|
<objectClass name="org.eclipse.core.resources.IFile" />
|
||||||
|
<objectClass name="org.eclipse.core.resources.IFolder" />
|
||||||
|
</or>
|
||||||
|
</enablement>
|
||||||
|
</decorator>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
<!-- Hyperlinking support -->
|
<!-- Hyperlinking support -->
|
||||||
|
@ -4492,6 +4508,7 @@
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.ui.preferenceTransfer">
|
point="org.eclipse.ui.preferenceTransfer">
|
||||||
<transfer
|
<transfer
|
||||||
|
icon="icons/view16/c_pers.gif"
|
||||||
id="org.eclipse.cdt.ui.transfer.editor.appearance"
|
id="org.eclipse.cdt.ui.transfer.editor.appearance"
|
||||||
name="%transfer.EditorAppearance.name">
|
name="%transfer.EditorAppearance.name">
|
||||||
<mapping scope="instance">
|
<mapping scope="instance">
|
||||||
|
@ -4550,6 +4567,7 @@
|
||||||
</description>
|
</description>
|
||||||
</transfer>
|
</transfer>
|
||||||
<transfer
|
<transfer
|
||||||
|
icon="icons/view16/c_pers.gif"
|
||||||
id="org.eclipse.cdt.ui.transfer.editor.behavior"
|
id="org.eclipse.cdt.ui.transfer.editor.behavior"
|
||||||
name="%transfer.EditorBehavior.name">
|
name="%transfer.EditorBehavior.name">
|
||||||
<mapping scope="instance">
|
<mapping scope="instance">
|
||||||
|
@ -4583,15 +4601,31 @@
|
||||||
<key name="stickyOccurrences"/>
|
<key name="stickyOccurrences"/>
|
||||||
<key name="markOverloadedOperatorsOccurrences"/>
|
<key name="markOverloadedOperatorsOccurrences"/>
|
||||||
<key name="scalability." match="prefix"/>
|
<key name="scalability." match="prefix"/>
|
||||||
<key
|
<key name="content_assist_proposals_timeout"/>
|
||||||
name="content_assist_proposals_timeout">
|
|
||||||
</key>
|
|
||||||
</entry>
|
</entry>
|
||||||
</mapping>
|
</mapping>
|
||||||
<description>
|
<description>
|
||||||
%transfer.EditorBehavior.description
|
%transfer.EditorBehavior.description
|
||||||
</description>
|
</description>
|
||||||
</transfer>
|
</transfer>
|
||||||
|
<transfer
|
||||||
|
icon="icons/view16/c_pers.gif"
|
||||||
|
id="org.eclipse.cdt.ui.transfer.code_style"
|
||||||
|
name="%transfer.CodeStyle.name">
|
||||||
|
<mapping scope="instance">
|
||||||
|
<entry node="org.eclipse.cdt.ui">
|
||||||
|
<key name="codetemplates." match="prefix"/>
|
||||||
|
<key name="nameStyle." match="prefix"/>
|
||||||
|
<key name="formatter_profile"/>
|
||||||
|
<key name="class_member_ascending_visibility_order"/>
|
||||||
|
<key name="function_output_parameters_before_input"/>
|
||||||
|
<key name="function_pass_output_parameters_by_pointer"/>
|
||||||
|
</entry>
|
||||||
|
</mapping>
|
||||||
|
<description>
|
||||||
|
%transfer.CodeStyle.description
|
||||||
|
</description>
|
||||||
|
</transfer>
|
||||||
|
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
|
|
|
@ -93,13 +93,12 @@ import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider;
|
||||||
*
|
*
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractCModelOutlinePage extends Page implements IContentOutlinePage, ISelectionChangedListener, IAdaptable {
|
public abstract class AbstractCModelOutlinePage extends Page
|
||||||
|
implements IContentOutlinePage, ISelectionChangedListener, IAdaptable {
|
||||||
/**
|
/**
|
||||||
* The default label provider for the outline.
|
* The default label provider for the outline.
|
||||||
*/
|
*/
|
||||||
public static class COutlineLabelProvider extends AppearanceAwareLabelProvider {
|
public static class COutlineLabelProvider extends AppearanceAwareLabelProvider {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag whether to show member definitions with qualified or simple names.
|
* Flag whether to show member definitions with qualified or simple names.
|
||||||
*/
|
*/
|
||||||
|
@ -148,9 +147,7 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
|
||||||
public OutlineTreeViewer(Composite parent, int flags) {
|
public OutlineTreeViewer(Composite parent, int flags) {
|
||||||
super(parent, flags);
|
super(parent, flags);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* @see TreeViewer#internalExpandToLevel
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void internalExpandToLevel(Widget node, int level) {
|
protected void internalExpandToLevel(Widget node, int level) {
|
||||||
if (node instanceof Item) {
|
if (node instanceof Item) {
|
||||||
|
@ -210,10 +207,9 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
|
||||||
PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.OUTLINE_GROUP_INCLUDES, isChecked());
|
PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.OUTLINE_GROUP_INCLUDES, isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIncludesGroupingEnabled () {
|
public boolean isIncludesGroupingEnabled() {
|
||||||
return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_INCLUDES);
|
return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_INCLUDES);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -244,10 +240,9 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
|
||||||
PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.OUTLINE_GROUP_MACROS, isChecked());
|
PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.OUTLINE_GROUP_MACROS, isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMacroGroupingEnabled () {
|
public boolean isMacroGroupingEnabled() {
|
||||||
return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_MACROS);
|
return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_MACROS);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -257,7 +252,6 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public class ToggleLinkingAction extends AbstractToggleLinkingAction {
|
public class ToggleLinkingAction extends AbstractToggleLinkingAction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new action.
|
* Constructs a new action.
|
||||||
*/
|
*/
|
||||||
|
@ -277,7 +271,9 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final long TEXT_FLAGS = AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | CElementLabels.F_APP_TYPE_SIGNATURE | CElementLabels.M_APP_RETURNTYPE;
|
private static final long TEXT_FLAGS =
|
||||||
|
AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | CElementLabels.F_APP_TYPE_SIGNATURE |
|
||||||
|
CElementLabels.M_APP_RETURNTYPE;
|
||||||
private static final int IMAGE_FLAGS = AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS;
|
private static final int IMAGE_FLAGS = AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS;
|
||||||
protected ITextEditor fEditor;
|
protected ITextEditor fEditor;
|
||||||
protected ITranslationUnit fInput;
|
protected ITranslationUnit fInput;
|
||||||
|
@ -374,12 +370,12 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
|
||||||
int offset= tsel.getOffset();
|
int offset= tsel.getOffset();
|
||||||
ICElement element= null;
|
ICElement element= null;
|
||||||
if (fEditor instanceof CEditor) {
|
if (fEditor instanceof CEditor) {
|
||||||
element= ((CEditor)fEditor).getElementAt(offset, false);
|
element= ((CEditor) fEditor).getElementAt(offset, false);
|
||||||
} else if (fInput != null) {
|
} else if (fInput != null) {
|
||||||
try {
|
try {
|
||||||
element= fInput.getElementAtOffset(offset);
|
element= fInput.getElementAtOffset(offset);
|
||||||
} catch (CModelException exc) {
|
} catch (CModelException e) {
|
||||||
CUIPlugin.log(exc);
|
CUIPlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (element != null) {
|
if (element != null) {
|
||||||
|
@ -407,11 +403,11 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
|
||||||
* Sets the selected element to the one at the current cursor position in the editor.
|
* Sets the selected element to the one at the current cursor position in the editor.
|
||||||
*/
|
*/
|
||||||
public void synchronizeSelectionWithEditor() {
|
public void synchronizeSelectionWithEditor() {
|
||||||
if(fInput == null || fEditor == null || fTreeViewer == null)
|
if (fInput == null || fEditor == null || fTreeViewer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ITextSelection editorSelection = (ITextSelection) fEditor.getSelectionProvider().getSelection();
|
ITextSelection editorSelection = (ITextSelection) fEditor.getSelectionProvider().getSelection();
|
||||||
if(editorSelection == null)
|
if (editorSelection == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int offset = editorSelection.getOffset();
|
int offset = editorSelection.getOffset();
|
||||||
|
@ -513,7 +509,8 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
|
||||||
site.setSelectionProvider(fTreeViewer);
|
site.setSelectionProvider(fTreeViewer);
|
||||||
|
|
||||||
IActionBars bars= site.getActionBars();
|
IActionBars bars= site.getActionBars();
|
||||||
bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY, fTogglePresentation);
|
bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY,
|
||||||
|
fTogglePresentation);
|
||||||
|
|
||||||
fSelectionSearchGroup = createSearchActionGroup();
|
fSelectionSearchGroup = createSearchActionGroup();
|
||||||
fOpenViewActionGroup = createOpenViewActionGroup();
|
fOpenViewActionGroup = createOpenViewActionGroup();
|
||||||
|
@ -529,7 +526,7 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
|
||||||
fTreeViewer.setInput(fInput);
|
fTreeViewer.setInput(fInput);
|
||||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(control, ICHelpContextIds.COUTLINE_VIEW);
|
PlatformUI.getWorkbench().getHelpSystem().setHelp(control, ICHelpContextIds.COUTLINE_VIEW);
|
||||||
|
|
||||||
IHandlerService handlerService= (IHandlerService)site.getService(IHandlerService.class);
|
IHandlerService handlerService= (IHandlerService) site.getService(IHandlerService.class);
|
||||||
handlerService.activateHandler(CollapseAllHandler.COMMAND_ID, new ActionHandler(fCollapseAllAction));
|
handlerService.activateHandler(CollapseAllHandler.COMMAND_ID, new ActionHandler(fCollapseAllAction));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -764,7 +761,7 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
|
||||||
public void setInput(ITranslationUnit unit) {
|
public void setInput(ITranslationUnit unit) {
|
||||||
fInput = unit;
|
fInput = unit;
|
||||||
if (fTreeViewer != null) {
|
if (fTreeViewer != null) {
|
||||||
fTreeViewer.setInput (fInput);
|
fTreeViewer.setInput(fInput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -786,5 +783,4 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
|
||||||
};
|
};
|
||||||
fTreeViewer.addDragSupport(ops, transfers, new CDTViewerDragAdapter(fTreeViewer, dragListeners));
|
fTreeViewer.addDragSupport(ops, transfers, new CDTViewerDragAdapter(fTreeViewer, dragListeners));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
* Copyright (c) 2005, 2013 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -1637,7 +1637,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
|
||||||
fOutlinePage = new CContentOutlinePage(this);
|
fOutlinePage = new CContentOutlinePage(this);
|
||||||
fOutlinePage.addSelectionChangedListener(this);
|
fOutlinePage.addSelectionChangedListener(this);
|
||||||
}
|
}
|
||||||
setOutlinePageInput(fOutlinePage, getEditorInput());
|
setOutlinePageInputIfNotSame(fOutlinePage, getEditorInput());
|
||||||
return fOutlinePage;
|
return fOutlinePage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2567,6 +2567,16 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void setOutlinePageInputIfNotSame(CContentOutlinePage page, IEditorInput input) {
|
||||||
|
if (page != null) {
|
||||||
|
IWorkingCopyManager manager = CUIPlugin.getDefault().getWorkingCopyManager();
|
||||||
|
IWorkingCopy workingCopy = manager.getWorkingCopy(input);
|
||||||
|
if (workingCopy != page.getRoot()) {
|
||||||
|
page.setInput(workingCopy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if folding is enabled.
|
* Determines if folding is enabled.
|
||||||
* @return <code>true</code> if folding is enabled, <code>false</code> otherwise.
|
* @return <code>true</code> if folding is enabled, <code>false</code> otherwise.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2011 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2013 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
|
* Martin Oberhuber (Wind River) - bug 398195: consider external API in IB
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.includebrowser;
|
package org.eclipse.cdt.internal.ui.includebrowser;
|
||||||
|
|
||||||
|
@ -81,6 +82,7 @@ import org.eclipse.ui.part.ViewPart;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexManager;
|
||||||
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
@ -214,7 +216,8 @@ public class IBViewPart extends ViewPart implements IShowInSource, IShowInTarget
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
try {
|
try {
|
||||||
final ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects();
|
final ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects();
|
||||||
IIndex index= CCorePlugin.getIndexManager().getIndex(projects);
|
IIndex index= CCorePlugin.getIndexManager().getIndex(projects,
|
||||||
|
IIndexManager.ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
if (!IndexUI.isIndexed(index, input)) {
|
if (!IndexUI.isIndexed(index, input)) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Martin Oberhuber (Wind River) - bug 398195: consider external API in IB
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.includebrowser;
|
package org.eclipse.cdt.internal.ui.includebrowser;
|
||||||
|
@ -21,6 +22,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IIndexInclude;
|
import org.eclipse.cdt.core.index.IIndexInclude;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexManager;
|
||||||
import org.eclipse.cdt.core.model.CoreModelUtil;
|
import org.eclipse.cdt.core.model.CoreModelUtil;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
@ -70,7 +72,8 @@ public class IncludeBrowserUI {
|
||||||
private static ITranslationUnit findTargetTranslationUnit(IInclude input) throws CoreException, InterruptedException {
|
private static ITranslationUnit findTargetTranslationUnit(IInclude input) throws CoreException, InterruptedException {
|
||||||
ICProject project= input.getCProject();
|
ICProject project= input.getCProject();
|
||||||
if (project != null) {
|
if (project != null) {
|
||||||
IIndex index= CCorePlugin.getIndexManager().getIndex(project);
|
IIndex index= CCorePlugin.getIndexManager().getIndex(project,
|
||||||
|
IIndexManager.ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexInclude include= IndexUI.elementToInclude(index, input);
|
IIndexInclude include= IndexUI.elementToInclude(index, input);
|
||||||
|
|
|
@ -439,9 +439,12 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
|
||||||
|
|
||||||
if (event.getChecked()) {
|
if (event.getChecked()) {
|
||||||
if (LanguageSettingsManager.isWorkspaceProvider(checkedProvider) && !LanguageSettingsManager.isPreferShared(id)) {
|
if (LanguageSettingsManager.isWorkspaceProvider(checkedProvider) && !LanguageSettingsManager.isPreferShared(id)) {
|
||||||
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(checkedProvider);
|
newProvider = getInitialProvider(id);
|
||||||
if (rawProvider instanceof ILanguageSettingsEditableProvider) {
|
if(newProvider == null) {
|
||||||
newProvider = LanguageSettingsManager.getProviderCopy((ILanguageSettingsEditableProvider) rawProvider, false);
|
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(checkedProvider);
|
||||||
|
if (rawProvider instanceof ILanguageSettingsEditableProvider) {
|
||||||
|
newProvider = LanguageSettingsManager.getProviderCopy((ILanguageSettingsEditableProvider) rawProvider, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -479,13 +482,16 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
|
||||||
newProvider = LanguageSettingsManager.getWorkspaceProvider(id);
|
newProvider = LanguageSettingsManager.getWorkspaceProvider(id);
|
||||||
} else {
|
} else {
|
||||||
// Toggle to configuration-owned provider
|
// Toggle to configuration-owned provider
|
||||||
try {
|
newProvider = getInitialProvider(id);
|
||||||
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
|
if(newProvider == null) {
|
||||||
if (rawProvider instanceof ILanguageSettingsEditableProvider) {
|
try {
|
||||||
newProvider = ((ILanguageSettingsEditableProvider) rawProvider).cloneShallow();
|
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
|
||||||
|
if (rawProvider instanceof ILanguageSettingsEditableProvider) {
|
||||||
|
newProvider = ((ILanguageSettingsEditableProvider) rawProvider).cloneShallow();
|
||||||
|
}
|
||||||
|
} catch (CloneNotSupportedException e) {
|
||||||
|
CUIPlugin.log("Error cloning provider " + id, e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
} catch (CloneNotSupportedException e) {
|
|
||||||
CUIPlugin.log("Error cloning provider " + id, e); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newProvider != null) {
|
if (newProvider != null) {
|
||||||
|
|
|
@ -202,7 +202,7 @@ LanguageSettingsProviderTab_Reset=Reset
|
||||||
LanguageSettingsProviderTab_ProviderOptions=Language Settings Provider Options
|
LanguageSettingsProviderTab_ProviderOptions=Language Settings Provider Options
|
||||||
LanguageSettingsProviderTab_SettingEntries=Setting Entries
|
LanguageSettingsProviderTab_SettingEntries=Setting Entries
|
||||||
LanguageSettingsProviderTab_SettingEntriesTooltip=Setting Entries
|
LanguageSettingsProviderTab_SettingEntriesTooltip=Setting Entries
|
||||||
LanguageSettingsProviderTab_ShareProviders=Share setting entries between projects (global provider)
|
LanguageSettingsProviderTab_ShareProviders=Use global provider shared between projects
|
||||||
LanguageSettingsProviderTab_StoreEntriesInsideProject=Store entries in project settings folder (easing project migration)
|
LanguageSettingsProviderTab_StoreEntriesInsideProject=Store entries in project settings folder (easing project migration)
|
||||||
LanguageSettingsProviderTab_TitleResetProviders=Reset Language Settings Providers
|
LanguageSettingsProviderTab_TitleResetProviders=Reset Language Settings Providers
|
||||||
LanguageSettingsProviderTab_WorkspaceSettings=Workspace Settings
|
LanguageSettingsProviderTab_WorkspaceSettings=Workspace Settings
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2011 IBM Corporation and others.
|
* Copyright (c) 2000, 2013 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -10,7 +10,6 @@
|
||||||
* Anton Leherbauer (Wind River Systems
|
* Anton Leherbauer (Wind River Systems
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.preferences;
|
package org.eclipse.cdt.internal.ui.preferences;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
@ -81,7 +80,6 @@ import org.eclipse.cdt.internal.ui.text.util.CColorManager;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
|
class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Item in the highlighting color list.
|
* Item in the highlighting color list.
|
||||||
*/
|
*/
|
||||||
|
@ -161,7 +159,6 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SemanticHighlightingColorListItem extends HighlightingColorListItem {
|
private static class SemanticHighlightingColorListItem extends HighlightingColorListItem {
|
||||||
|
|
||||||
/** Enablement preference key */
|
/** Enablement preference key */
|
||||||
private final String fEnableKey;
|
private final String fEnableKey;
|
||||||
|
|
||||||
|
@ -175,7 +172,8 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
|
||||||
* @param underlineKey the underlineKey preference key
|
* @param underlineKey the underlineKey preference key
|
||||||
* @param enableKey the enable preference key
|
* @param enableKey the enable preference key
|
||||||
*/
|
*/
|
||||||
public SemanticHighlightingColorListItem(String displayName, String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey, String enableKey) {
|
public SemanticHighlightingColorListItem(String displayName, String colorKey, String boldKey,
|
||||||
|
String italicKey, String strikethroughKey, String underlineKey, String enableKey) {
|
||||||
super(displayName, colorKey, boldKey, italicKey, strikethroughKey, underlineKey);
|
super(displayName, colorKey, boldKey, italicKey, strikethroughKey, underlineKey);
|
||||||
fEnableKey= enableKey;
|
fEnableKey= enableKey;
|
||||||
}
|
}
|
||||||
|
@ -192,9 +190,6 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
|
||||||
* Color list label provider.
|
* Color list label provider.
|
||||||
*/
|
*/
|
||||||
private class ColorListLabelProvider extends LabelProvider implements IColorProvider {
|
private class ColorListLabelProvider extends LabelProvider implements IColorProvider {
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getText(Object element) {
|
public String getText(Object element) {
|
||||||
if (element instanceof String)
|
if (element instanceof String)
|
||||||
|
@ -202,17 +197,11 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
|
||||||
return ((HighlightingColorListItem)element).getDisplayName();
|
return ((HighlightingColorListItem)element).getDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Color getBackground(Object element) {
|
public Color getBackground(Object element) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Color getForeground(Object element) {
|
public Color getForeground(Object element) {
|
||||||
if (element instanceof SemanticHighlightingColorListItem) {
|
if (element instanceof SemanticHighlightingColorListItem) {
|
||||||
|
@ -228,25 +217,15 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
|
||||||
* Color list content provider.
|
* Color list content provider.
|
||||||
*/
|
*/
|
||||||
private class ColorListContentProvider implements ITreeContentProvider {
|
private class ColorListContentProvider implements ITreeContentProvider {
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Object[] getElements(Object inputElement) {
|
public Object[] getElements(Object inputElement) {
|
||||||
return new String[] {fCodeCategory, fAssemblyCategory, fCommentsCategory, fPreprocessorCategory, fDoxygenCategory};
|
return new String[] {fCodeCategory, fAssemblyCategory, fCommentsCategory, fPreprocessorCategory, fDoxygenCategory};
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||||
}
|
}
|
||||||
|
@ -564,7 +543,6 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Control createSyntaxPage(final Composite parent) {
|
private Control createSyntaxPage(final Composite parent) {
|
||||||
|
|
||||||
Composite colorComposite= new Composite(parent, SWT.NONE);
|
Composite colorComposite= new Composite(parent, SWT.NONE);
|
||||||
GridLayout layout= new GridLayout();
|
GridLayout layout= new GridLayout();
|
||||||
layout.marginHeight= 0;
|
layout.marginHeight= 0;
|
||||||
|
@ -912,11 +890,11 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
|
||||||
{ createHighlightedRange(13, 16, 4, SemanticHighlightings.ENUMERATOR) },
|
{ createHighlightedRange(13, 16, 4, SemanticHighlightings.ENUMERATOR) },
|
||||||
{ createHighlightedRange(13, 22, 3, SemanticHighlightings.ENUMERATOR) },
|
{ createHighlightedRange(13, 22, 3, SemanticHighlightings.ENUMERATOR) },
|
||||||
{ createHighlightedRange(13, 27, 3, SemanticHighlightings.ENUMERATOR) },
|
{ createHighlightedRange(13, 27, 3, SemanticHighlightings.ENUMERATOR) },
|
||||||
{ createHighlightedRange(14, 14, 11, SemanticHighlightings.STATIC_FIELD), createHighlightedRange(13, 14, 11, SemanticHighlightings.FIELD) },
|
{ createHighlightedRange(14, 14, 11, SemanticHighlightings.STATIC_FIELD), createHighlightedRange(14, 14, 11, SemanticHighlightings.FIELD) },
|
||||||
{ createHighlightedRange(15, 6, 5, SemanticHighlightings.FIELD) },
|
{ createHighlightedRange(15, 6, 5, SemanticHighlightings.FIELD) },
|
||||||
{ createHighlightedRange(16, 10, 6, SemanticHighlightings.ENUM) },
|
{ createHighlightedRange(16, 10, 6, SemanticHighlightings.ENUM) },
|
||||||
{ createHighlightedRange(16, 17, 7, SemanticHighlightings.METHOD_DECLARATION), createHighlightedRange(15, 17, 7, SemanticHighlightings.METHOD) },
|
{ createHighlightedRange(16, 17, 7, SemanticHighlightings.METHOD_DECLARATION), createHighlightedRange(16, 17, 7, SemanticHighlightings.METHOD) },
|
||||||
{ createHighlightedRange(17, 7, 6, SemanticHighlightings.METHOD_DECLARATION), createHighlightedRange(16, 7, 6, SemanticHighlightings.METHOD) },
|
{ createHighlightedRange(17, 7, 6, SemanticHighlightings.METHOD_DECLARATION), createHighlightedRange(17, 7, 6, SemanticHighlightings.METHOD) },
|
||||||
{ createHighlightedRange(17, 14, 6, SemanticHighlightings.ENUM) },
|
{ createHighlightedRange(17, 14, 6, SemanticHighlightings.ENUM) },
|
||||||
{ createHighlightedRange(17, 21, 1, SemanticHighlightings.PARAMETER_VARIABLE) },
|
{ createHighlightedRange(17, 21, 1, SemanticHighlightings.PARAMETER_VARIABLE) },
|
||||||
{ createHighlightedRange(18, 8, 5, SemanticHighlightings.LOCAL_VARIABLE_DECLARATION) },
|
{ createHighlightedRange(18, 8, 5, SemanticHighlightings.LOCAL_VARIABLE_DECLARATION) },
|
||||||
|
@ -925,9 +903,9 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
|
||||||
{ createHighlightedRange(19, 7, 6, SemanticHighlightings.FUNCTION) },
|
{ createHighlightedRange(19, 7, 6, SemanticHighlightings.FUNCTION) },
|
||||||
{ createHighlightedRange(19, 14, 5, SemanticHighlightings.LOCAL_VARIABLE) },
|
{ createHighlightedRange(19, 14, 5, SemanticHighlightings.LOCAL_VARIABLE) },
|
||||||
{ createHighlightedRange(20, 4, 7, SemanticHighlightings.METHOD) },
|
{ createHighlightedRange(20, 4, 7, SemanticHighlightings.METHOD) },
|
||||||
{ createHighlightedRange(21, 4, 12, SemanticHighlightings.STATIC_METHOD_INVOCATION), createHighlightedRange(20, 4, 12, SemanticHighlightings.METHOD) },
|
{ createHighlightedRange(21, 4, 12, SemanticHighlightings.STATIC_METHOD_INVOCATION), createHighlightedRange(21, 4, 12, SemanticHighlightings.METHOD) },
|
||||||
{ createHighlightedRange(22, 4, 7, SemanticHighlightings.PROBLEM) },
|
{ createHighlightedRange(22, 4, 7, SemanticHighlightings.PROBLEM) },
|
||||||
{ createHighlightedRange(24, 14, 12, SemanticHighlightings.METHOD_DECLARATION), createHighlightedRange(23, 14, 12, SemanticHighlightings.METHOD) },
|
{ createHighlightedRange(24, 14, 12, SemanticHighlightings.METHOD_DECLARATION), createHighlightedRange(24, 14, 12, SemanticHighlightings.METHOD) },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.preferences;
|
package org.eclipse.cdt.internal.ui.preferences;
|
||||||
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
@ -19,8 +18,6 @@ import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Code coloring preference page.
|
* Code coloring preference page.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -30,41 +27,27 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public class CEditorColoringPreferencePage extends AbstractConfigurationBlockPreferencePage {
|
public class CEditorColoringPreferencePage extends AbstractConfigurationBlockPreferencePage {
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected String getHelpId() {
|
protected String getHelpId() {
|
||||||
return ICHelpContextIds.C_EDITOR_COLORS_PREF_PAGE;
|
return ICHelpContextIds.C_EDITOR_COLORS_PREF_PAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void setDescription() {
|
protected void setDescription() {
|
||||||
String description= PreferencesMessages.CEditorPreferencePage_colors;
|
String description= PreferencesMessages.CEditorPreferencePage_colors;
|
||||||
setDescription(description);
|
setDescription(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Label createDescriptionLabel(Composite parent) {
|
protected Label createDescriptionLabel(Composite parent) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void setPreferenceStore() {
|
protected void setPreferenceStore() {
|
||||||
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
|
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) {
|
protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) {
|
||||||
return new CEditorColoringConfigurationBlock(overlayPreferenceStore);
|
return new CEditorColoringConfigurationBlock(overlayPreferenceStore);
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue