1
0
Fork 0
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:
Sergey Prigogin 2013-01-24 20:43:18 -08:00
commit b9396d3a4a
229 changed files with 5416 additions and 1935 deletions

View file

@ -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;

View file

@ -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;
} }

View file

@ -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());
} }

View file

@ -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;
} }
/** /**

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2011 Andrew Gvozdev and others. * Copyright (c) 2009, 2013 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -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));
} }
/** /**

View file

@ -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),
}; };
/** /**

View file

@ -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

View file

@ -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;

View file

@ -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

View file

@ -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
} }

View file

@ -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

View file

@ -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>
@ -19,4 +20,10 @@ 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);

View file

@ -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);
if (console) {
set_noecho(fds); 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 */
if (console) {
dup2(pipe2[1], STDERR_FILENO); /* dup stderr */ 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 */
if (console) {
set_noecho(fdm); set_noecho(fdm);
}
if (channels != NULL) { if (channels != NULL) {
channels[0] = fdm; /* Input Stream. */
channels[1] = fdm; /* Output Stream. */
if (console) {
/* close the write end of pipe1 */ /* close the write end of pipe1 */
if (close(pipe2[1]) == -1) if (close(pipe2[1]) == -1)
perror("close(pipe2[1])"); perror("close(pipe2[1])");
channels[0] = fdm; /* Input Stream. */
channels[1] = fdm; /* Output Stream. */
channels[2] = pipe2[0]; /* stderr Stream. */ channels[2] = pipe2[0]; /* stderr Stream. */
/*channels[2] = fdm; Input Stream. */ } else {
channels[2] = fdm; /* Error Stream. */
}
} }
free(full_path); free(full_path);

View file

@ -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);
} }

View file

@ -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

View file

@ -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

View file

@ -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" );
char * pfind(const char *name) 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 * 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

View file

@ -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
if (console) {
set_noecho(master); 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
}

View file

@ -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;

View file

@ -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>

View file

@ -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,19 +32,19 @@ 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);
} }
@ -69,7 +65,7 @@ public class FileBasePluginTest extends TestCase {
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$
@ -79,8 +75,7 @@ public class FileBasePluginTest extends TestCase {
} }
} }
public FileBasePluginTest(String name, Class className) public FileBasePluginTestCase(String name, Class className) {
{
super(name); super(name);
initialize(className); initialize(className);
} }
@ -94,7 +89,7 @@ public class FileBasePluginTest extends TestCase {
project = null; project = null;
} }
} catch (Throwable e) { } catch (Throwable e) {
/*boo*/ // Ignore
} }
} }
@ -112,29 +107,11 @@ public class FileBasePluginTest extends TestCase {
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);
@ -144,16 +121,18 @@ public class FileBasePluginTest extends TestCase {
return folder; return folder;
} }
public IFile importFile(String fileName, String contents) throws Exception { public IFile importFile(String fileName, String contents) throws Exception {
// Obtain file handle // 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);

View 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,7 +29,7 @@ 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() {
} }
@ -445,11 +446,11 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
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());
} }

View file

@ -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() {
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2012 IBM Corporation and others. * Copyright (c) 2004, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -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() {
} }
@ -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);
} }

View file

@ -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() {
} }

View file

@ -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,19 +35,19 @@ 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);
} }
@ -73,7 +69,7 @@ public class AST2FileBasePluginTest extends TestCase {
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$
@ -83,8 +79,7 @@ public class AST2FileBasePluginTest extends TestCase {
} }
} }
public AST2FileBasePluginTest(String name, Class className) public AST2FileBasePluginTestCase(String name, Class className) {
{
super(name); super(name);
initialize(className); initialize(className);
} }
@ -98,7 +93,7 @@ public class AST2FileBasePluginTest extends TestCase {
project = null; project = null;
} }
} catch (Throwable e) { } catch (Throwable e) {
/*boo*/ // Ignore
} }
} }
@ -116,7 +111,7 @@ public class AST2FileBasePluginTest extends TestCase {
try { try {
members[i].delete(false, monitor); members[i].delete(false, monitor);
} catch (Throwable e) { } catch (Throwable e) {
/*boo*/ // Ignore
} }
} }
} }
@ -130,16 +125,18 @@ public class AST2FileBasePluginTest extends TestCase {
return folder; return folder;
} }
public IFile importFile(String fileName, String contents) throws Exception { public IFile importFile(String fileName, String contents) throws Exception {
// Obtain file handle // 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);
@ -150,5 +147,4 @@ public class AST2FileBasePluginTest extends TestCase {
return TestSourceReader.getContentsForTest( return TestSourceReader.getContentsForTest(
CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), sections); CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), sections);
} }
} }

View file

@ -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() {
} }

View file

@ -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{

View file

@ -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) {

View file

@ -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) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2012 IBM Corporation and others. * Copyright (c) 2005, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -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>
@ -6683,7 +6685,8 @@ public class AST2TemplateTests extends AST2BaseTest {
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());
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2012 IBM Corporation and others. * Copyright (c) 2004, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -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,11 +121,11 @@ 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);
} }
@ -329,9 +329,15 @@ public class AST2BaseTest extends BaseTestCase {
} }
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

View file

@ -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) {

View file

@ -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() {
} }

View file

@ -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() {
} }

View file

@ -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);

View file

@ -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);

View file

@ -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 {

View file

@ -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);
} }

View file

@ -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() {
} }

View file

@ -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);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2010 IBM Corporation and others. * Copyright (c) 2004, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Nathan Ridge
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2; package org.eclipse.cdt.core.parser.tests.ast2;
@ -102,8 +103,12 @@ 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
@ -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)
@ -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);
@ -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 {

View file

@ -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() {
} }

View file

@ -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() {
} }

View file

@ -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 };

View file

@ -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() {
} }

View file

@ -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";

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2010 IBM Corporation and others. * Copyright (c) 2002, 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 Rational Software - Initial API and implementation * IBM Rational Software - 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;
@ -43,7 +44,7 @@ import org.eclipse.core.resources.IFile;
/** /**
* @author dsteffle * @author dsteffle
*/ */
public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
public DOMSelectionParseTest() { public DOMSelectionParseTest() {
} }
@ -56,8 +57,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
super(name, DOMSelectionParseTest.class); super(name, DOMSelectionParseTest.class);
} }
public void testBaseCase_VariableReference() throws Exception public void testBaseCase_VariableReference() throws Exception {
{
String code = "void f() { int x; x=3; }"; //$NON-NLS-1$ String code = "void f() { int x; x=3; }"; //$NON-NLS-1$
int offset1 = code.indexOf( "x=" ); //$NON-NLS-1$ int offset1 = code.indexOf( "x=" ); //$NON-NLS-1$
int offset2 = code.indexOf( '='); int offset2 = code.indexOf( '=');
@ -72,8 +72,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 1); assertEquals( ((ASTNode)decls[0]).getLength(), 1);
} }
public void testBaseCase_FunctionReference() throws Exception public void testBaseCase_FunctionReference() throws Exception {
{
String code = "int x(){x( );}"; //$NON-NLS-1$ String code = "int x(){x( );}"; //$NON-NLS-1$
int offset1 = code.indexOf( "x( " ); //$NON-NLS-1$ int offset1 = code.indexOf( "x( " ); //$NON-NLS-1$
int offset2 = code.indexOf( "( )"); //$NON-NLS-1$ int offset2 = code.indexOf( "( )"); //$NON-NLS-1$
@ -88,16 +87,14 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 1); assertEquals( ((ASTNode)decls[0]).getLength(), 1);
} }
public void testBaseCase_Error() throws Exception public void testBaseCase_Error() throws Exception {
{
String code = "int x() { y( ) }"; //$NON-NLS-1$ String code = "int x() { y( ) }"; //$NON-NLS-1$
int offset1 = code.indexOf( "y( " ); //$NON-NLS-1$ int offset1 = code.indexOf( "y( " ); //$NON-NLS-1$
int offset2 = code.indexOf( "( )"); //$NON-NLS-1$ int offset2 = code.indexOf( "( )"); //$NON-NLS-1$
assertNull( parse( code, offset1, offset2, false )); assertNull( parse( code, offset1, offset2, false ));
} }
public void testBaseCase_FunctionDeclaration() throws Exception public void testBaseCase_FunctionDeclaration() throws Exception {
{
String code = "int x(); void test() {x( );}"; //$NON-NLS-1$ String code = "int x(); void test() {x( );}"; //$NON-NLS-1$
int offset1 = code.indexOf( "x( )" ); //$NON-NLS-1$ int offset1 = code.indexOf( "x( )" ); //$NON-NLS-1$
int offset2 = code.indexOf( "( )"); //$NON-NLS-1$ int offset2 = code.indexOf( "( )"); //$NON-NLS-1$
@ -112,8 +109,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 1); assertEquals( ((ASTNode)decls[0]).getLength(), 1);
} }
public void testBaseCase_FunctionDeclaration2() throws Exception public void testBaseCase_FunctionDeclaration2() throws Exception {
{
String code = "int printf( const char *, ... ); "; //$NON-NLS-1$ String code = "int printf( const char *, ... ); "; //$NON-NLS-1$
int offset1 = code.indexOf( "printf" ); //$NON-NLS-1$ int offset1 = code.indexOf( "printf" ); //$NON-NLS-1$
int offset2 = code.indexOf( "( const"); //$NON-NLS-1$ int offset2 = code.indexOf( "( const"); //$NON-NLS-1$
@ -123,8 +119,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((IASTName)node).toString(), "printf" ); //$NON-NLS-1$ assertEquals( ((IASTName)node).toString(), "printf" ); //$NON-NLS-1$
} }
public void testBaseCase_VariableDeclaration() throws Exception public void testBaseCase_VariableDeclaration() throws Exception {
{
String code = "int x = 3;"; //$NON-NLS-1$ String code = "int x = 3;"; //$NON-NLS-1$
int offset1 = code.indexOf( "x" ); //$NON-NLS-1$ int offset1 = code.indexOf( "x" ); //$NON-NLS-1$
int offset2 = code.indexOf( " ="); //$NON-NLS-1$ int offset2 = code.indexOf( " ="); //$NON-NLS-1$
@ -135,8 +130,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((IASTName)node).toString(), "x" ); //$NON-NLS-1$ assertEquals( ((IASTName)node).toString(), "x" ); //$NON-NLS-1$
} }
public void testBaseCase_Parameter() throws Exception public void testBaseCase_Parameter() throws Exception {
{
String code = "int main( int argc ) { int x = argc; }"; //$NON-NLS-1$ String code = "int main( int argc ) { int x = argc; }"; //$NON-NLS-1$
int offset1 = code.indexOf( "argc;" ); //$NON-NLS-1$ int offset1 = code.indexOf( "argc;" ); //$NON-NLS-1$
int offset2 = code.indexOf( ";" ); //$NON-NLS-1$ int offset2 = code.indexOf( ";" ); //$NON-NLS-1$
@ -152,8 +146,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 4); assertEquals( ((ASTNode)decls[0]).getLength(), 4);
} }
public void testBug57898() throws Exception public void testBug57898() throws Exception {
{
Writer writer = new StringWriter(); Writer writer = new StringWriter();
writer.write( "class Gonzo { public: void playHorn(); };\n" ); //$NON-NLS-1$ writer.write( "class Gonzo { public: void playHorn(); };\n" ); //$NON-NLS-1$
writer.write( "void Gonzo::playHorn() { return; }\n" ); //$NON-NLS-1$ writer.write( "void Gonzo::playHorn() { return; }\n" ); //$NON-NLS-1$
@ -188,8 +181,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
} }
} }
public void testConstructorDestructorDeclaration() throws Exception public void testConstructorDestructorDeclaration() throws Exception {
{
Writer writer = new StringWriter(); Writer writer = new StringWriter();
writer.write( "class Gonzo { Gonzo(); ~Gonzo(); };"); //$NON-NLS-1$ writer.write( "class Gonzo { Gonzo(); ~Gonzo(); };"); //$NON-NLS-1$
String code = writer.toString(); String code = writer.toString();
@ -207,8 +199,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((IASTName)node).toString(), "~Gonzo" ); //$NON-NLS-1$ assertEquals( ((IASTName)node).toString(), "~Gonzo" ); //$NON-NLS-1$
} }
public void testBug60264() throws Exception public void testBug60264() throws Exception {
{
Writer writer = new StringWriter(); Writer writer = new StringWriter();
writer.write( "namespace Muppets { int i; }\n" ); //$NON-NLS-1$ writer.write( "namespace Muppets { int i; }\n" ); //$NON-NLS-1$
writer.write( "int main(int argc, char **argv) { Muppets::i = 1; }\n" ); //$NON-NLS-1$ writer.write( "int main(int argc, char **argv) { Muppets::i = 1; }\n" ); //$NON-NLS-1$
@ -237,8 +228,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 7); assertEquals( ((ASTNode)decls[0]).getLength(), 7);
} }
public void testBug61613() throws Exception public void testBug61613() throws Exception {
{
Writer writer = new StringWriter(); Writer writer = new StringWriter();
writer.write( "class Foo { // ** (A) **\n" ); //$NON-NLS-1$ writer.write( "class Foo { // ** (A) **\n" ); //$NON-NLS-1$
writer.write( " public:\n" ); //$NON-NLS-1$ writer.write( " public:\n" ); //$NON-NLS-1$
@ -261,8 +251,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 3); assertEquals( ((ASTNode)decls[0]).getLength(), 3);
} }
public void testBug60038() throws Exception public void testBug60038() throws Exception {
{
Writer writer = new StringWriter(); Writer writer = new StringWriter();
writer.write( "class Gonzo {\n"); //$NON-NLS-1$ writer.write( "class Gonzo {\n"); //$NON-NLS-1$
writer.write( "public:\n"); //$NON-NLS-1$ writer.write( "public:\n"); //$NON-NLS-1$
@ -296,8 +285,12 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
} }
IASTNode node = parse( code, startOffset, endOffset ); IASTNode node = parse( code, startOffset, endOffset );
assertTrue( node instanceof IASTName ); assertTrue( node instanceof IASTName );
assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPMethod );
IBinding binding = ((IASTName)node).resolveBinding(); IBinding binding = ((IASTName)node).resolveBinding();
if (binding instanceof ICPPClassType) {
node = TestUtil.findImplicitName(node);
binding = ((IASTName)node).resolveBinding();
}
assertTrue( binding instanceof ICPPMethod );
IName[] decls = null; IName[] decls = null;
switch( i ) switch( i )
{ {
@ -333,8 +326,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
} }
} }
public void testMethodReference() throws Exception public void testMethodReference() throws Exception {
{
Writer writer = new StringWriter(); Writer writer = new StringWriter();
writer.write( "class Sample { public:\n"); //$NON-NLS-1$ writer.write( "class Sample { public:\n"); //$NON-NLS-1$
writer.write( " int getAnswer() const;\n"); //$NON-NLS-1$ writer.write( " int getAnswer() const;\n"); //$NON-NLS-1$
@ -356,8 +348,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 9); assertEquals( ((ASTNode)decls[0]).getLength(), 9);
} }
public void testConstructorDefinition() throws Exception public void testConstructorDefinition() throws Exception {
{
String code = "class ABC { public: ABC(); }; ABC::ABC(){}"; //$NON-NLS-1$ String code = "class ABC { public: ABC(); }; ABC::ABC(){}"; //$NON-NLS-1$
int startIndex = code.indexOf( "::ABC") + 2; //$NON-NLS-1$ int startIndex = code.indexOf( "::ABC") + 2; //$NON-NLS-1$
IASTNode node = parse( code, startIndex, startIndex + 3 ); IASTNode node = parse( code, startIndex, startIndex + 3 );
@ -371,8 +362,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 3); assertEquals( ((ASTNode)decls[0]).getLength(), 3);
} }
public void testBug63966() throws Exception public void testBug63966() throws Exception {
{
Writer writer = new StringWriter(); Writer writer = new StringWriter();
writer.write( "void foo(int a) {}\n" ); //$NON-NLS-1$ writer.write( "void foo(int a) {}\n" ); //$NON-NLS-1$
writer.write( "void foo(long a) {}\n" ); //$NON-NLS-1$ writer.write( "void foo(long a) {}\n" ); //$NON-NLS-1$
@ -383,8 +373,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
parse( code, startIndex, startIndex + 3 ); parse( code, startIndex, startIndex + 3 );
} }
public void testBug66744() throws Exception public void testBug66744() throws Exception {
{
Writer writer = new StringWriter(); Writer writer = new StringWriter();
writer.write( "enum EColours { RED, GREEN, BLUE }; \n" ); //$NON-NLS-1$ writer.write( "enum EColours { RED, GREEN, BLUE }; \n" ); //$NON-NLS-1$
writer.write( "void foo() { EColours color = GREEN; } \n" ); //$NON-NLS-1$ writer.write( "void foo() { EColours color = GREEN; } \n" ); //$NON-NLS-1$
@ -396,8 +385,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
public void testBug68527() throws Exception public void testBug68527() throws Exception {
{
Writer writer = new StringWriter(); Writer writer = new StringWriter();
writer.write("struct X;\n"); //$NON-NLS-1$ writer.write("struct X;\n"); //$NON-NLS-1$
writer.write("struct X anA;"); //$NON-NLS-1$ writer.write("struct X anA;"); //$NON-NLS-1$
@ -406,8 +394,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
parse( code, startIndex, startIndex + 1 ); parse( code, startIndex, startIndex + 1 );
} }
public void testBug60407() throws Exception public void testBug60407() throws Exception {
{
Writer writer = new StringWriter(); Writer writer = new StringWriter();
writer.write( "struct ZZZ { int x, y, z; };\n" ); //$NON-NLS-1$ writer.write( "struct ZZZ { int x, y, z; };\n" ); //$NON-NLS-1$
writer.write( "typedef struct ZZZ _FILE;\n" ); //$NON-NLS-1$ writer.write( "typedef struct ZZZ _FILE;\n" ); //$NON-NLS-1$
@ -423,8 +410,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
parse( code, startIndex, startIndex + "static_function".length() ); //$NON-NLS-1$ parse( code, startIndex, startIndex + "static_function".length() ); //$NON-NLS-1$
} }
public void testBug61800() throws Exception public void testBug61800() throws Exception {
{
Writer writer = new StringWriter(); Writer writer = new StringWriter();
writer.write( "class B {};\n"); //$NON-NLS-1$ writer.write( "class B {};\n"); //$NON-NLS-1$
writer.write( "class ABCDEF {\n"); //$NON-NLS-1$ writer.write( "class ABCDEF {\n"); //$NON-NLS-1$
@ -444,8 +430,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 5); assertEquals( ((ASTNode)decls[0]).getLength(), 5);
} }
public void testBug68739() throws Exception public void testBug68739() throws Exception {
{
Writer writer = new StringWriter(); Writer writer = new StringWriter();
writer.write( "int fprintf( int *, const char *, ... ); \n" ); //$NON-NLS-1$ writer.write( "int fprintf( int *, const char *, ... ); \n" ); //$NON-NLS-1$
writer.write( "void boo( int * lcd ) { \n" ); //$NON-NLS-1$ writer.write( "void boo( int * lcd ) { \n" ); //$NON-NLS-1$
@ -462,8 +447,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((IASTName)node).toString(), "fprintf" ); //$NON-NLS-1$ assertEquals( ((IASTName)node).toString(), "fprintf" ); //$NON-NLS-1$
} }
public void testBug72818() throws Exception public void testBug72818() throws Exception {
{
Writer writer = new StringWriter(); Writer writer = new StringWriter();
writer.write( "union Squaw { int x; double u; };\n" ); //$NON-NLS-1$ writer.write( "union Squaw { int x; double u; };\n" ); //$NON-NLS-1$
writer.write( "int main(int argc, char **argv) {\n" ); //$NON-NLS-1$ writer.write( "int main(int argc, char **argv) {\n" ); //$NON-NLS-1$
@ -483,8 +467,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 5); assertEquals( ((ASTNode)decls[0]).getLength(), 5);
} }
public void test72220() throws Exception public void test72220() throws Exception {
{
Writer writer = new StringWriter(); Writer writer = new StringWriter();
writer.write( "const int FOUND_ME = 1;\n" ); //$NON-NLS-1$ writer.write( "const int FOUND_ME = 1;\n" ); //$NON-NLS-1$
writer.write( "class Test{\n" ); //$NON-NLS-1$ writer.write( "class Test{\n" ); //$NON-NLS-1$
@ -599,14 +582,15 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
int startIndex = code.indexOf( "new B" ) + 4; //$NON-NLS-1$ int startIndex = code.indexOf( "new B" ) + 4; //$NON-NLS-1$
IASTNode node = parse( code, startIndex, startIndex + 1 ); IASTNode node = parse( code, startIndex, startIndex + 1 );
node = TestUtil.findImplicitName(node);
assertTrue( node instanceof IASTName ); assertTrue( node instanceof IASTName );
assertTrue( ((IASTName) node).resolveBinding() instanceof ICPPConstructor ); assertTrue( ((IASTName) node).resolveBinding() instanceof ICPPConstructor );
assertEquals( ((IASTName)node).toString(), "B" ); //$NON-NLS-1$ assertEquals( ((IASTName)node).toString(), "B" ); //$NON-NLS-1$
IName[] decls = getDeclarationOffTU((IASTName)node); IName[] decls = getDeclarationOffTU((IASTName)node);
assertEquals(decls.length, 1); assertEquals(decls.length, 1);
assertEquals( decls[0].toString(), "B" ); //$NON-NLS-1$ assertEquals( decls[0].toString(), "B" ); //$NON-NLS-1$
assertEquals( ((ASTNode)decls[0]).getOffset(), 17); assertEquals( 17, ((ASTNode)decls[0]).getOffset() );
assertEquals( ((ASTNode)decls[0]).getLength(), 1); assertEquals( 1, ((ASTNode)decls[0]).getLength() );
} }
public void testBug72712_2() throws Exception{ public void testBug72712_2() throws Exception{
@ -664,8 +648,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
// assertEquals( ((ASTNode)decls[0]).getLength(), 3); // assertEquals( ((ASTNode)decls[0]).getLength(), 3);
} }
public void testBug72710() throws Exception public void testBug72710() throws Exception {
{
Writer writer = new StringWriter(); Writer writer = new StringWriter();
writer.write( "class Card{\n" ); //$NON-NLS-1$ writer.write( "class Card{\n" ); //$NON-NLS-1$
writer.write( " Card( int rank );\n" ); //$NON-NLS-1$ writer.write( " Card( int rank );\n" ); //$NON-NLS-1$
@ -1111,6 +1094,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
int index = code.indexOf("Point(10)"); //$NON-NLS-1$ int index = code.indexOf("Point(10)"); //$NON-NLS-1$
IASTNode node = parse( code, index, index + 5, true ); IASTNode node = parse( code, index, index + 5, true );
node = TestUtil.findImplicitName(node);
assertTrue( node instanceof IASTName ); assertTrue( node instanceof IASTName );
assertTrue( ((IASTName) node).resolveBinding() instanceof ICPPConstructor ); assertTrue( ((IASTName) node).resolveBinding() instanceof ICPPConstructor );
assertEquals( ((IASTName)node).toString(), "Point" ); //$NON-NLS-1$ assertEquals( ((IASTName)node).toString(), "Point" ); //$NON-NLS-1$
@ -1635,8 +1619,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 1); assertEquals( ((ASTNode)decls[0]).getLength(), 1);
} }
public void testBug64181() throws Exception public void testBug64181() throws Exception {
{
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append("namespace Foo { // ** (A) **\n"); //$NON-NLS-1$ buffer.append("namespace Foo { // ** (A) **\n"); //$NON-NLS-1$
buffer.append("int bar;\n"); //$NON-NLS-1$ buffer.append("int bar;\n"); //$NON-NLS-1$
@ -1665,8 +1648,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[1]).getLength(), 3); assertEquals( ((ASTNode)decls[1]).getLength(), 3);
} }
public void testBug80823() throws Exception public void testBug80823() throws Exception {
{
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append("class MyEggImpl {}; // line A\n"); //$NON-NLS-1$ buffer.append("class MyEggImpl {}; // line A\n"); //$NON-NLS-1$
buffer.append("#define MyChicken MyEggImpl\n"); //$NON-NLS-1$ buffer.append("#define MyChicken MyEggImpl\n"); //$NON-NLS-1$
@ -1686,8 +1668,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 9); assertEquals( ((ASTNode)decls[0]).getLength(), 9);
} }
public void testBug86993() throws Exception public void testBug86993() throws Exception {
{
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append("#define _BEGIN_STD_C extern \"C\" {\n"); //$NON-NLS-1$ buffer.append("#define _BEGIN_STD_C extern \"C\" {\n"); //$NON-NLS-1$
buffer.append("#define _END_STD_C }\n"); //$NON-NLS-1$ buffer.append("#define _END_STD_C }\n"); //$NON-NLS-1$
@ -1728,4 +1709,3 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals(length, loc.getNodeLength()); assertEquals(length, loc.getNodeLength());
} }
} }

View file

@ -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);
} }

View file

@ -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);

View file

@ -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() {
} }

View file

@ -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() {
} }

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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); }

View file

@ -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);

View file

@ -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;
}
}

View file

@ -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() {
} }

View file

@ -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;

View file

@ -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 )

View file

@ -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) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* 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
@ -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.core.parser.tests.scanner; package org.eclipse.cdt.core.parser.tests.scanner;
@ -202,6 +203,28 @@ public class LexerTests extends BaseTestCase {
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();

View file

@ -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,16 +92,28 @@ 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) {
if (preferImplicitName) {
return nodeSelector.findImplicitName(offset, len);
} else {
IASTName name= nodeSelector.findName(offset, len); IASTName name= nodeSelector.findName(offset, len);
if (name == null) if (name == null)
name= nodeSelector.findImplicitName(offset, len); name= nodeSelector.findImplicitName(offset, len);
return name; 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
* from the specified code fragment. Fails the test if * from the specified code fragment. Fails the test if
@ -130,8 +143,36 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
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)
@ -147,6 +188,23 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
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.
* @param section the code fragment to search for in the AST. The first occurrence of an identical section is used. * @param section the code fragment to search for in the AST. The first occurrence of an identical section is used.

View file

@ -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;
@ -475,4 +476,16 @@ 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);
}
} }

View file

@ -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);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2012 Symbian Software Systems and others. * Copyright (c) 2007, 2013 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -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)

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2012 Wind River Systems, Inc. and others. * Copyright (c) 2009, 2013 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,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);
} }
} }

View file

@ -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;
@ -34,10 +35,10 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I
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;
} }
} }
} }

View file

@ -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;

View file

@ -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:

View file

@ -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];

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* 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
@ -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;
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2011 IBM Corporation and others. * Copyright (c) 2004, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -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;
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2012 IBM Corporation and others. * Copyright (c) 2004, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -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,11 +3153,11 @@ 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;
@ -3161,19 +3169,6 @@ public class CPPSemantics {
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();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* 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;
@ -582,8 +583,19 @@ final public class Lexer implements ITokenSequence {
} }
break; break;
case ':': case ':':
// 2.5-3
markPhase3();
if (nextCharPhase3() != ':') {
return newDigraphToken(IToken.tLBRACKET, start);
}
switch (nextCharPhase3()) {
case ':': case '>':
restorePhase3();
nextCharPhase3(); nextCharPhase3();
return newDigraphToken(IToken.tLBRACKET, start); return newDigraphToken(IToken.tLBRACKET, start);
}
restorePhase3();
break;
case '%': case '%':
nextCharPhase3(); nextCharPhase3();
return newDigraphToken(IToken.tLBRACE, start); return newDigraphToken(IToken.tLBRACE, start);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2012 QNX Software Systems and others. * Copyright (c) 2005, 2013 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -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,7 +1574,7 @@ 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) {
@ -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));
if (!areSynchronized(trail, index, newResource, newLocation)) { MultiStatus m = areSynchronized(trail, index, newResource, newLocation);
return false; if (m != null) {
m.add(new Status(IStatus.INFO, CCorePlugin.PLUGIN_ID,
"Included by " + file.getLocation().getFullPath())); //$NON-NLS-1$
return m;
} }
} }
} }
} }
} }
}
return true; return null;
} }
public boolean isFileIndexedUnconditionally(IIndexFileLocation ifl) { public boolean isFileIndexedUnconditionally(IIndexFileLocation ifl) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2009 Symbian Software Systems and others. * Copyright (c) 2007, 2013 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -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,12 +46,26 @@ 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);
} }
/** /**
@ -66,15 +83,13 @@ 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);
@ -83,30 +98,40 @@ public class GeneratePDOM {
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
IStatus myStatus = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, Messages.GeneratePDOM_Incomplete);
MultiStatus m = new MultiStatus(CCorePlugin.PLUGIN_ID, 1, new IStatus[] {myStatus, syncStatus},
Messages.GeneratePDOM_Incomplete, null);
// Log the status right away since legacy clients did not return any status details
CCorePlugin.log(m);
return m;
}
}
// Export a .pdom file
CCoreInternals.getPDOMManager().exportProjectPDOM(cproject, targetLocation, converter); CCoreInternals.getPDOMManager().exportProjectPDOM(cproject, targetLocation, converter);
// write properties to exported PDOM // Write properties to exported PDOM
WritablePDOM exportedPDOM= new WritablePDOM(targetLocation, converter, LanguageManager.getInstance().getPDOMLinkageFactoryMappings()); WritablePDOM exportedPDOM= new WritablePDOM(targetLocation, converter,
LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
exportedPDOM.acquireWriteLock(0); exportedPDOM.acquireWriteLock(0);
try { try {
Map<String, String> exportProperties= pm.getExportProperties(); Map<String, String> exportProperties= pm.getExportProperties();
@ -116,12 +141,9 @@ public class GeneratePDOM {
} }
} }
exportedPDOM.close(); exportedPDOM.close();
} } finally {
finally {
exportedPDOM.releaseWriteLock(); exportedPDOM.releaseWriteLock();
} }
}
} catch (InterruptedException ie) { } 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));
@ -131,9 +153,7 @@ public class GeneratePDOM {
} }
} }
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 {

View file

@ -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">

View file

@ -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,14 +78,28 @@ 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++;
} }
@ -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;
} }
} }

View file

@ -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$
} }
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()); fileContents = ProcessHelper.getValueAfterExpandingMacros(fileContents, ProcessHelper.getReplaceKeys(fileContents), template.getValueStore());
contents = new ByteArrayInputStream(fileContents.getBytes()); contents = new ByteArrayInputStream(fileContents.getBytes());
} else { } else {
try { try {

View file

@ -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);
}
}
}

View file

@ -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

View file

@ -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) {

View file

@ -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();

View file

@ -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);
} }

View file

@ -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
@ -26,7 +26,6 @@ import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings;
* @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;
@ -121,7 +120,6 @@ 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),
}; };
@ -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);
} }
} }

View file

@ -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

View file

@ -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

View file

@ -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) {
@ -213,7 +210,6 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
public boolean isIncludesGroupingEnabled() { public boolean isIncludesGroupingEnabled() {
return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_INCLUDES); return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_INCLUDES);
} }
} }
/** /**
@ -247,7 +243,6 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
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;
@ -378,8 +374,8 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
} 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) {
@ -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();
@ -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));
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2012 IBM Corporation and others. * Copyright (c) 2005, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -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.

View file

@ -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)) {

View file

@ -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);

View file

@ -439,11 +439,14 @@ 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)) {
newProvider = getInitialProvider(id);
if(newProvider == null) {
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(checkedProvider); ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(checkedProvider);
if (rawProvider instanceof ILanguageSettingsEditableProvider) { if (rawProvider instanceof ILanguageSettingsEditableProvider) {
newProvider = LanguageSettingsManager.getProviderCopy((ILanguageSettingsEditableProvider) rawProvider, false); newProvider = LanguageSettingsManager.getProviderCopy((ILanguageSettingsEditableProvider) rawProvider, false);
} }
} }
}
} else { } else {
if (!LanguageSettingsManager.isWorkspaceProvider(checkedProvider)) { if (!LanguageSettingsManager.isWorkspaceProvider(checkedProvider)) {
newProvider = LanguageSettingsManager.getWorkspaceProvider(id); newProvider = LanguageSettingsManager.getWorkspaceProvider(id);
@ -479,6 +482,8 @@ 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
newProvider = getInitialProvider(id);
if(newProvider == null) {
try { try {
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider); ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
if (rawProvider instanceof ILanguageSettingsEditableProvider) { if (rawProvider instanceof ILanguageSettingsEditableProvider) {
@ -488,6 +493,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
CUIPlugin.log("Error cloning provider " + id, e); //$NON-NLS-1$ CUIPlugin.log("Error cloning provider " + id, e); //$NON-NLS-1$
} }
} }
}
if (newProvider != null) { if (newProvider != null) {
replaceSelectedProvider(newProvider); replaceSelectedProvider(newProvider);
createOptionsPage(newProvider); createOptionsPage(newProvider);

View file

@ -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

View file

@ -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) },
}; };
} }

View file

@ -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